From ed33ad39a2f353acc3d38591a749f324de3b6c23 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Tue, 30 Jul 2013 18:36:52 -0400 Subject: Restore REINDEX constraint validation. Refactoring as part of commit 8ceb24568054232696dddc1166a8563bc78c900a had the unintended effect of making REINDEX TABLE and REINDEX DATABASE no longer validate constraints enforced by the indexes in question; REINDEX INDEX still did so. Indexes marked invalid remained so, and constraint violations arising from data corruption went undetected. Back-patch to 9.0, like the causative commit. --- src/backend/commands/indexcmds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/backend/commands/indexcmds.c') diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 34153f5eb9a..ab73567ad2a 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1553,7 +1553,9 @@ ReindexTable(RangeVar *relation) ReleaseSysCache(tuple); - if (!reindex_relation(heapOid, REINDEX_REL_PROCESS_TOAST)) + if (!reindex_relation(heapOid, + REINDEX_REL_PROCESS_TOAST | + REINDEX_REL_CHECK_CONSTRAINTS)) ereport(NOTICE, (errmsg("table \"%s\" has no indexes", relation->relname))); @@ -1666,7 +1668,9 @@ 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, REINDEX_REL_PROCESS_TOAST)) + if (reindex_relation(relid, + REINDEX_REL_PROCESS_TOAST | + REINDEX_REL_CHECK_CONSTRAINTS)) ereport(NOTICE, (errmsg("table \"%s.%s\" was reindexed", get_namespace_name(get_rel_namespace(relid)), -- cgit v1.2.3