1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

Make ALTER TABLE revalidate uniqueness and exclusion constraints.

Failure to do so can lead to constraint violations.  This was broken by
commit 1ddc2703a9 on 2010-02-07, so
back-patch to 9.0.

Noah Misch.  Regression test by me.
This commit is contained in:
Robert Haas
2011-01-20 22:44:10 -05:00
parent ba3afc88d2
commit 39b5e5f337
8 changed files with 48 additions and 27 deletions

View File

@ -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
{