diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index e2c9b5f069c..5eacd6e47a1 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -425,7 +425,10 @@ gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, * killed tuple as not passing the qual. */ if (scan->ignore_killed_tuples && ItemIdIsDead(iid)) + { + Assert(GistPageIsLeaf(page)); continue; + } it = (IndexTuple) PageGetItem(page, iid); @@ -722,6 +725,7 @@ gistgettuple(IndexScanDesc scan, ScanDirection dir) CHECK_FOR_INTERRUPTS(); /* save current item BlockNumber for next gistkillitems() call */ + Assert(so->numKilled == 0); so->curBlkno = item->blkno; /* diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 00400583c0b..bde0e656f48 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -133,7 +133,12 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys, int i; MemoryContext oldCxt; + /* invalidate any killed items still pending */ + so->numKilled = 0; + /* rescan an existing indexscan --- reset state */ + so->curBlkno = InvalidBlockNumber; + so->curPageLSN = InvalidXLogRecPtr; /* * The first time through, we create the search queue in the scanCxt. @@ -350,6 +355,9 @@ gistendscan(IndexScanDesc scan) { GISTScanOpaque so = (GISTScanOpaque) scan->opaque; + /* invalidate any killed items still pending */ + so->numKilled = 0; + /* * freeGISTstate is enough to clean up everything made by gistbeginscan, * as well as the queueCxt if there is a separate context for it.