Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4e7d10c

Browse files
committed
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.
1 parent 0a20207 commit 4e7d10c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/backend/catalog/index.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.263 2006/03/05 15:58:22 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.264 2006/03/24 23:02:17 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1473,7 +1473,9 @@ IndexBuildHeapScan(Relation heapRelation,
14731473

14741474
/*
14751475
* If tuple is recently deleted then we must index it
1476-
* anyway to keep VACUUM from complaining.
1476+
* anyway to preserve MVCC semantics. (Pre-existing
1477+
* transactions could try to use the index after we
1478+
* finish building it, and may need to see such tuples.)
14771479
*/
14781480
indexIt = true;
14791481
tupleIsAlive = false;
@@ -1541,13 +1543,10 @@ IndexBuildHeapScan(Relation heapRelation,
15411543

15421544
/*
15431545
* In a partial index, discard tuples that don't satisfy the
1544-
* predicate. We can also discard recently-dead tuples, since VACUUM
1545-
* doesn't complain about tuple count mismatch for partial indexes.
1546+
* predicate.
15461547
*/
15471548
if (predicate != NIL)
15481549
{
1549-
if (!tupleIsAlive)
1550-
continue;
15511550
if (!ExecQual(predicate, econtext, false))
15521551
continue;
15531552
}

0 commit comments

Comments
 (0)