aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-24 23:02:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-24 23:02:23 +0000
commitdf7b5f57346f263a735cddd0716445cfee83e5d1 (patch)
tree9301e905902d4ca37759e25aa0125dd1bd4ac167 /src
parentdb61437b274a5d9134467346bf7bf996877cc5f6 (diff)
downloadpostgresql-df7b5f57346f263a735cddd0716445cfee83e5d1.tar.gz
postgresql-df7b5f57346f263a735cddd0716445cfee83e5d1.zip
Comments in IndexBuildHeapScan describe the indexing of recently-dead
tuples as needed "to keep VACUUM from complaining", but actually there is a more compelling reason to do it: failure to do so violates MVCC semantics. This is because a pre-existing serializable transaction might try to use the index after we finish (re)building it, and it might fail to find tuples it should be able to see. We got this mostly right, but not in the case of partial indexes: the code mistakenly discarded recently-dead tuples for partial indexes. Fix that, and adjust the comments.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/index.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index ca082ecfac6..11323bc36a8 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.261.2.1 2005/11/22 18:23:06 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.261.2.2 2006/03/24 23:02:23 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -1473,7 +1473,9 @@ IndexBuildHeapScan(Relation heapRelation,
/*
* If tuple is recently deleted then we must index it
- * anyway to keep VACUUM from complaining.
+ * anyway to preserve MVCC semantics. (Pre-existing
+ * transactions could try to use the index after we
+ * finish building it, and may need to see such tuples.)
*/
indexIt = true;
tupleIsAlive = false;
@@ -1541,13 +1543,10 @@ IndexBuildHeapScan(Relation heapRelation,
/*
* In a partial index, discard tuples that don't satisfy the
- * predicate. We can also discard recently-dead tuples, since VACUUM
- * doesn't complain about tuple count mismatch for partial indexes.
+ * predicate.
*/
if (predicate != NIL)
{
- if (!tupleIsAlive)
- continue;
if (!ExecQual(predicate, econtext, false))
continue;
}