diff options
Diffstat (limited to 'src/backend/commands')
| -rw-r--r-- | src/backend/commands/cluster.c | 9 | ||||
| -rw-r--r-- | src/backend/commands/indexcmds.c | 4 | ||||
| -rw-r--r-- | src/backend/commands/tablecmds.c | 7 |
3 files changed, 13 insertions, 7 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 7a1b8e885be..61020dcbe74 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -607,7 +607,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, * rebuild the target's indexes and throw away the transient table. */ finish_heap_swap(tableOid, OIDNewHeap, is_system_catalog, - swap_toast_by_content, frozenXid); + swap_toast_by_content, false, frozenXid); } @@ -1326,10 +1326,12 @@ void finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, bool is_system_catalog, bool swap_toast_by_content, + bool check_constraints, TransactionId frozenXid) { ObjectAddress object; Oid mapped_tables[4]; + int reindex_flags; int i; /* Zero out possible results from swapped_relation_files */ @@ -1359,7 +1361,10 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, * so no chance to reclaim disk space before commit. We do not need a * final CommandCounterIncrement() because reindex_relation does it. */ - reindex_relation(OIDOldHeap, false, true); + reindex_flags = REINDEX_SUPPRESS_INDEX_USE; + if (check_constraints) + reindex_flags |= REINDEX_CHECK_CONSTRAINTS; + reindex_relation(OIDOldHeap, false, reindex_flags); /* Destroy new heap with old filenode */ object.classId = RelationRelationId; diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 780dbc23ede..a129511128b 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1634,7 +1634,7 @@ ReindexTable(RangeVar *relation) ReleaseSysCache(tuple); - if (!reindex_relation(heapOid, true, false)) + if (!reindex_relation(heapOid, true, 0)) ereport(NOTICE, (errmsg("table \"%s\" has no indexes", relation->relname))); @@ -1747,7 +1747,7 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user) StartTransactionCommand(); /* functions in indexes may want a snapshot set */ PushActiveSnapshot(GetTransactionSnapshot()); - if (reindex_relation(relid, true, false)) + if (reindex_relation(relid, true, 0)) ereport(NOTICE, (errmsg("table \"%s.%s\" was reindexed", get_namespace_name(get_rel_namespace(relid)), diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index ab9c6a5191d..6a1804b6fec 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1032,7 +1032,7 @@ ExecuteTruncate(TruncateStmt *stmt) /* * Reconstruct the indexes to match, and we're done. */ - reindex_relation(heap_relid, true, false); + reindex_relation(heap_relid, true, 0); } } @@ -2941,13 +2941,14 @@ ATRewriteTables(List **wqueue) /* * Swap the physical files of the old and new heaps, then rebuild - * indexes and discard the new heap. We can use RecentXmin for + * indexes and discard the old heap. We can use RecentXmin for * the table's new relfrozenxid because we rewrote all the tuples * in ATRewriteTable, so no older Xid remains in the table. Also, * we never try to swap toast tables by content, since we have no * interest in letting this code work on system catalogs. */ - finish_heap_swap(tab->relid, OIDNewHeap, false, false, RecentXmin); + finish_heap_swap(tab->relid, OIDNewHeap, + false, false, true, RecentXmin); } else { |
