aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2013-07-04 03:24:09 +0900
committerFujii Masao <fujii@postgresql.org>2013-07-04 03:24:09 +0900
commit2ef085d0e6960f5087c97266a7211d37ddaa9f68 (patch)
tree7edac95cbc3bbe0aea721e95e8d4804486a7d0ea /src/backend/commands/tablecmds.c
parentf71939cd1ac765ba618115f40de4d9c47955a9ef (diff)
downloadpostgresql-2ef085d0e6960f5087c97266a7211d37ddaa9f68.tar.gz
postgresql-2ef085d0e6960f5087c97266a7211d37ddaa9f68.zip
Get rid of pg_class.reltoastidxid.
Treat TOAST index just the same as normal one and get the OID of TOAST index from pg_index but not pg_class.reltoastidxid. This change allows us to handle multiple TOAST indexes, and which is required infrastructure for upcoming REINDEX CONCURRENTLY feature. Patch by Michael Paquier, reviewed by Andres Freund and me.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 6a7aa44ccc6..6708725d696 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8878,7 +8878,6 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
Relation rel;
Oid oldTableSpace;
Oid reltoastrelid;
- Oid reltoastidxid;
Oid newrelfilenode;
RelFileNode newrnode;
SMgrRelation dstrel;
@@ -8886,6 +8885,8 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
HeapTuple tuple;
Form_pg_class rd_rel;
ForkNumber forkNum;
+ List *reltoastidxids = NIL;
+ ListCell *lc;
/*
* Need lock here in case we are recursing to toast table or index
@@ -8932,7 +8933,13 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
errmsg("cannot move temporary tables of other sessions")));
reltoastrelid = rel->rd_rel->reltoastrelid;
- reltoastidxid = rel->rd_rel->reltoastidxid;
+ /* Fetch the list of indexes on toast relation if necessary */
+ if (OidIsValid(reltoastrelid))
+ {
+ Relation toastRel = relation_open(reltoastrelid, lockmode);
+ reltoastidxids = RelationGetIndexList(toastRel);
+ relation_close(toastRel, lockmode);
+ }
/* Get a modifiable copy of the relation's pg_class row */
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
@@ -9010,11 +9017,14 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
/* Make sure the reltablespace change is visible */
CommandCounterIncrement();
- /* Move associated toast relation and/or index, too */
+ /* Move associated toast relation and/or indexes, too */
if (OidIsValid(reltoastrelid))
ATExecSetTableSpace(reltoastrelid, newTableSpace, lockmode);
- if (OidIsValid(reltoastidxid))
- ATExecSetTableSpace(reltoastidxid, newTableSpace, lockmode);
+ foreach(lc, reltoastidxids)
+ ATExecSetTableSpace(lfirst_oid(lc), newTableSpace, lockmode);
+
+ /* Clean up */
+ list_free(reltoastidxids);
}
/*