]> granicus.if.org Git - postgresql/commitdiff
Fix bug in lossy-page handling in GIN
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sat, 10 May 2014 20:24:23 +0000 (23:24 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sat, 10 May 2014 20:28:26 +0000 (23:28 +0300)
When returning rows from a bitmap, as done with partial match queries, we
would get stuck in an infinite loop if the bitmap contained a lossy page
reference.

This bug is new in master, it was introduced by the patch to allow skipping
items refuted by other entries in GIN scans.

Report and fix by Alexander Korotkov

src/backend/access/gin/ginget.c

index 271f09901b9fcc5e665ec5f72378aaa28362d5e1..144ed504dc28e40bb54ac0ac5691824c0e49a55c 100644 (file)
@@ -741,7 +741,9 @@ entryGetItem(GinState *ginstate, GinScanEntry entry,
                        while (entry->matchResult == NULL ||
                                   (entry->matchResult->ntuples >= 0 &&
                                        entry->offset >= entry->matchResult->ntuples) ||
-                                  entry->matchResult->blockno < advancePastBlk)
+                                  entry->matchResult->blockno < advancePastBlk ||
+                                  (ItemPointerIsLossyPage(&advancePast) &&
+                                       entry->matchResult->blockno == advancePastBlk))
                        {
                                entry->matchResult = tbm_iterate(entry->matchIterator);