mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03:00
Restore REINDEX constraint validation.
Refactoring as part of commit 8ceb245680
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.
This commit is contained in:
@ -1768,7 +1768,9 @@ ReindexTable(RangeVar *relation)
|
||||
heapOid = RangeVarGetRelidExtended(relation, ShareLock, false, false,
|
||||
RangeVarCallbackOwnsTable, NULL);
|
||||
|
||||
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)));
|
||||
@ -1884,7 +1886,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)),
|
||||
|
Reference in New Issue
Block a user