]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix nasty bug in nodeIndexscan.c's detection of duplicate tuples during
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 May 2006 16:30:50 +0000 (16:30 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 May 2006 16:30:50 +0000 (16:30 +0000)
a multiple (OR'ed) indexscan.  It was checking for duplicate
tuple->t_data->t_ctid, when what it should be checking is tuple->t_self.
The trouble situation occurs when a live tuple has t_ctid not pointing to
itself, which can happen if an attempted UPDATE was rolled back.  After a
VACUUM, an unrelated tuple could be installed where the failed update tuple
was, leading to one live tuple's t_ctid pointing to an unrelated tuple.
If one of these tuples is fetched by an earlier OR'ed indexscan and the other
by a later indexscan, nodeIndexscan.c would incorrectly ignore the second
tuple.  The bug exists in all 7.4.* and 8.0.* versions, but not in earlier
or later branches because this code was only used in those releases.  Per
trouble report from Rafael Martinez Guerrero.

src/backend/executor/nodeIndexscan.c

index a7c91093adb272c70f8ac6fc2f479a3abb066100..afe3a8effa39e5b4e6125ac8abf352806747e17a 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.99 2004/12/31 21:59:45 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.99.4.1 2006/05/19 16:30:50 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -249,7 +249,7 @@ IndexNext(IndexScanState *node)
 
                                        entry = (DupHashTabEntry *)
                                                hash_search(node->iss_DupHash,
-                                                                       &tuple->t_data->t_ctid,
+                                                                       &tuple->t_self,
                                                                        HASH_ENTER,
                                                                        &found);
                                        if (entry == NULL ||