From ba5f900b3d22ca0dfab923abaab4b331595c96b3 Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Tue, 30 Aug 2005 08:48:16 +0000 Subject: Fix missing rows in query update a=.. where a... with GiST index on column 'a' Backpatch from 8.0 branch --- src/backend/access/gist/gistget.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/backend/access/gist/gistget.c') diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 2f5801fe781..b10228f18e5 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.35 2002/09/04 20:31:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.35.2.1 2005/08/30 08:48:16 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -167,10 +167,18 @@ gistnext(IndexScanDesc s, ScanDirection dir) maxoff = PageGetMaxOffsetNumber(p); po = (GISTPageOpaque) PageGetSpecialPointer(p); - if (ScanDirectionIsBackward(dir)) - n = OffsetNumberPrev(stk->gs_child); - else - n = OffsetNumberNext(stk->gs_child); + if ( stk->gs_child == InvalidOffsetNumber ) { + /* rescan page */ + if (ScanDirectionIsBackward(dir)) + n = PageGetMaxOffsetNumber(p); + else + n = FirstOffsetNumber; + } else { + if (ScanDirectionIsBackward(dir)) + n = OffsetNumberPrev(stk->gs_child); + else + n = OffsetNumberNext(stk->gs_child); + } so->s_stack = stk->gs_parent; pfree(stk); -- cgit v1.2.3