mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
Fix missing rows in query
update a=.. where a... with GiST index on column 'a'
This commit is contained in:
parent
846ed05de6
commit
13ff51baf2
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.112 2004/12/31 21:59:10 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.112.4.1 2005/08/30 07:57:48 teodor Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -503,7 +503,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
|
|||||||
* changed beginning from 'child' offset
|
* changed beginning from 'child' offset
|
||||||
*/
|
*/
|
||||||
if (ret & SPLITED)
|
if (ret & SPLITED)
|
||||||
gistadjscans(r, GISTOP_SPLIT, blkno, child);
|
gistadjscans(r, GISTOP_SPLIT, nblkno, FirstOffsetNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = INSERTED;
|
ret = INSERTED;
|
||||||
@ -1420,6 +1420,9 @@ gistnewroot(Relation r, IndexTuple *itup, int len)
|
|||||||
Page p;
|
Page p;
|
||||||
|
|
||||||
b = ReadBuffer(r, GISTP_ROOT);
|
b = ReadBuffer(r, GISTP_ROOT);
|
||||||
|
|
||||||
|
gistadjscans(r, GISTOP_SPLIT, GISTP_ROOT, FirstOffsetNumber);
|
||||||
|
|
||||||
GISTInitBuffer(b, 0);
|
GISTInitBuffer(b, 0);
|
||||||
p = BufferGetPage(b);
|
p = BufferGetPage(b);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.43 2004/12/31 21:59:10 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.43.4.1 2005/08/30 07:57:48 teodor Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -167,10 +167,18 @@ gistnext(IndexScanDesc s, ScanDirection dir)
|
|||||||
maxoff = PageGetMaxOffsetNumber(p);
|
maxoff = PageGetMaxOffsetNumber(p);
|
||||||
po = (GISTPageOpaque) PageGetSpecialPointer(p);
|
po = (GISTPageOpaque) PageGetSpecialPointer(p);
|
||||||
|
|
||||||
if (ScanDirectionIsBackward(dir))
|
if ( stk->gs_child == InvalidOffsetNumber ) {
|
||||||
n = OffsetNumberPrev(stk->gs_child);
|
/* rescan page */
|
||||||
else
|
if (ScanDirectionIsBackward(dir))
|
||||||
n = OffsetNumberNext(stk->gs_child);
|
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;
|
so->s_stack = stk->gs_parent;
|
||||||
pfree(stk);
|
pfree(stk);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.56 2004/12/31 21:59:10 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.56.4.1 2005/08/30 07:57:48 teodor Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -25,7 +25,7 @@ static void gistregscan(IndexScanDesc s);
|
|||||||
static void gistdropscan(IndexScanDesc s);
|
static void gistdropscan(IndexScanDesc s);
|
||||||
static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
||||||
OffsetNumber offnum);
|
OffsetNumber offnum);
|
||||||
static void adjuststack(GISTSTACK *stk, BlockNumber blkno);
|
static void adjuststack(GISTSTACK *stk, int op,BlockNumber blkno, OffsetNumber offnum);
|
||||||
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
||||||
int op, BlockNumber blkno, OffsetNumber offnum);
|
int op, BlockNumber blkno, OffsetNumber offnum);
|
||||||
|
|
||||||
@ -325,11 +325,8 @@ gistadjone(IndexScanDesc s,
|
|||||||
|
|
||||||
so = (GISTScanOpaque) s->opaque;
|
so = (GISTScanOpaque) s->opaque;
|
||||||
|
|
||||||
if (op == GISTOP_SPLIT)
|
adjuststack(so->s_stack, op, blkno, offnum);
|
||||||
{
|
adjuststack(so->s_markstk, op, blkno, offnum);
|
||||||
adjuststack(so->s_stack, blkno);
|
|
||||||
adjuststack(so->s_markstk, blkno);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -411,14 +408,31 @@ adjustiptr(IndexScanDesc s,
|
|||||||
* access method update code for heaps; if we've modified the tuple we
|
* access method update code for heaps; if we've modified the tuple we
|
||||||
* are looking at already in this transaction, we ignore the update
|
* are looking at already in this transaction, we ignore the update
|
||||||
* request.
|
* request.
|
||||||
|
* If index tuple on our parent stack has been deleted, we need
|
||||||
|
* to make step back to avoid miss.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
adjuststack(GISTSTACK *stk, BlockNumber blkno)
|
adjuststack(GISTSTACK *stk, int op, BlockNumber blkno, OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
while (stk != NULL)
|
while (stk != NULL)
|
||||||
{
|
{
|
||||||
if (stk->gs_blk == blkno)
|
if (stk->gs_blk == blkno) {
|
||||||
stk->gs_child = FirstOffsetNumber;
|
switch (op) {
|
||||||
|
case GISTOP_DEL:
|
||||||
|
if ( stk->gs_child >= offnum ) {
|
||||||
|
if ( stk->gs_child > FirstOffsetNumber )
|
||||||
|
stk->gs_child = OffsetNumberPrev( stk->gs_child );
|
||||||
|
else
|
||||||
|
stk->gs_child = InvalidOffsetNumber;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GISTOP_SPLIT:
|
||||||
|
stk->gs_child = InvalidOffsetNumber;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elog(ERROR, "Bad operation in GiST scan adjust: %d", op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stk = stk->gs_parent;
|
stk = stk->gs_parent;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user