aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistget.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-12-04 13:47:08 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2010-12-04 13:47:08 -0500
commitd1f5a92e18dcfc750e9d338597e66af920aad99e (patch)
tree23d3ef58b6a5f7b1e6eda3fff9dce65814fe83c4 /src/backend/access/gist/gistget.c
parent387e468b82952776121a8d4bd409d72757edbc16 (diff)
downloadpostgresql-d1f5a92e18dcfc750e9d338597e66af920aad99e.tar.gz
postgresql-d1f5a92e18dcfc750e9d338597e66af920aad99e.zip
Fix two small bugs in new gistget.c logic.
1. Complain, rather than silently doing nothing, if an "invalid" tuple is found on a leaf page. Per off-list discussion with Heikki. 2. Fix oversight in code that removes a GISTSearchItem from the search queue: we have to reset lastHeap if this was the last heap item in the parent GISTSearchTreeItem. Otherwise subsequent additions will do the wrong thing. This was probably masked in early testing because in typical cases the parent item would now be completely empty and would be deleted on next call. You'd need a queued non-leaf page at exactly the same distance as a heap tuple to expose the bug.
Diffstat (limited to 'src/backend/access/gist/gistget.c')
-rw-r--r--src/backend/access/gist/gistget.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index afff55c7881..56921cfee01 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -70,9 +70,10 @@ gistindex_keytest(IndexScanDesc scan,
{
int i;
+ if (GistPageIsLeaf(page)) /* shouldn't happen */
+ elog(ERROR, "invalid GIST tuple found on leaf page");
for (i = 0; i < scan->numberOfOrderBys; i++)
so->distances[i] = -get_float8_infinity();
- *recheck_p = true; /* probably unnecessary */
return true;
}
@@ -403,6 +404,8 @@ getNextGISTSearchItem(GISTScanOpaque so)
{
/* Delink item from chain */
so->curTreeItem->head = item->next;
+ if (item == so->curTreeItem->lastHeap)
+ so->curTreeItem->lastHeap = NULL;
/* Return item; caller is responsible to pfree it */
return item;
}