diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 56 |
1 files changed, 2 insertions, 54 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 714a9f1ee78..093224f4e64 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -393,7 +393,6 @@ static void ATExecClusterOn(Relation rel, const char *indexName, LOCKMODE lockmode); static void ATExecDropCluster(Relation rel, LOCKMODE lockmode); static bool ATPrepChangePersistence(Relation rel, bool toLogged); -static void ATChangeIndexesPersistence(Oid relid, char relpersistence); static void ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename, LOCKMODE lockmode); static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode); @@ -3735,16 +3734,6 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode) ATRewriteTable(tab, OIDNewHeap, lockmode); /* - * Change the persistence marking of indexes, if necessary. This - * is so that the new copies are built with the right persistence - * in the reindex step below. Note we cannot do this earlier, - * because the rewrite step might read the indexes, and that would - * cause buffers for them to have the wrong setting. - */ - if (tab->chgPersistence) - ATChangeIndexesPersistence(tab->relid, tab->newrelpersistence); - - /* * Swap the physical files of the old and new heaps, then rebuild * indexes and discard the old heap. We can use RecentXmin for * the table's new relfrozenxid because we rewrote all the tuples @@ -3756,7 +3745,8 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode) false, false, true, !OidIsValid(tab->newTableSpace), RecentXmin, - ReadNextMultiXactId()); + ReadNextMultiXactId(), + persistence); } else { @@ -10880,48 +10870,6 @@ ATPrepChangePersistence(Relation rel, bool toLogged) } /* - * Update the pg_class entry of each index for the given relation to the - * given persistence. - */ -static void -ATChangeIndexesPersistence(Oid relid, char relpersistence) -{ - Relation rel; - Relation pg_class; - List *indexes; - ListCell *cell; - - pg_class = heap_open(RelationRelationId, RowExclusiveLock); - - /* We already have a lock on the table */ - rel = relation_open(relid, NoLock); - indexes = RelationGetIndexList(rel); - foreach(cell, indexes) - { - Oid indexid = lfirst_oid(cell); - HeapTuple tuple; - Form_pg_class pg_class_form; - - tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(indexid)); - if (!HeapTupleIsValid(tuple)) - elog(ERROR, "cache lookup failed for relation %u", - indexid); - - pg_class_form = (Form_pg_class) GETSTRUCT(tuple); - pg_class_form->relpersistence = relpersistence; - simple_heap_update(pg_class, &tuple->t_self, tuple); - - /* keep catalog indexes current */ - CatalogUpdateIndexes(pg_class, tuple); - - heap_freetuple(tuple); - } - - heap_close(pg_class, RowExclusiveLock); - heap_close(rel, NoLock); -} - -/* * Execute ALTER TABLE SET SCHEMA */ Oid |