]> granicus.if.org Git - postgresql/commitdiff
Grab predicate locks on matching tuples in a lossy bitmap heap scan.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 29 Jun 2011 18:40:27 +0000 (21:40 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 29 Jun 2011 18:50:42 +0000 (21:50 +0300)
Non-lossy case was already handled correctly.

Kevin Grittner

src/backend/executor/nodeBitmapHeapscan.c

index 40ad77575879191e4c8b97321cfb9900cd68feee..568035a481beafae49dabafa1f79d7b5d2192d31 100644 (file)
@@ -42,6 +42,7 @@
 #include "executor/nodeBitmapHeapscan.h"
 #include "pgstat.h"
 #include "storage/bufmgr.h"
+#include "storage/predicate.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
 #include "utils/tqual.h"
@@ -371,14 +372,23 @@ bitgetpage(HeapScanDesc scan, TBMIterateResult *tbmres)
                {
                        ItemId          lp;
                        HeapTupleData loctup;
+                       bool            valid;
 
                        lp = PageGetItemId(dp, offnum);
                        if (!ItemIdIsNormal(lp))
                                continue;
                        loctup.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
                        loctup.t_len = ItemIdGetLength(lp);
-                       if (HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer))
+                       loctup.t_tableOid = scan->rs_rd->rd_id;
+                       ItemPointerSet(&loctup.t_self, page, offnum);
+                       valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer);
+                       if (valid)
+                       {
                                scan->rs_vistuples[ntup++] = offnum;
+                               PredicateLockTuple(scan->rs_rd, &loctup, snapshot);
+                       }
+                       CheckForSerializableConflictOut(valid, scan->rs_rd, &loctup,
+                                                                                       buffer, snapshot);
                }
        }