1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Refactor the index AM API slightly: move currentItemData and

currentMarkData from IndexScanDesc to the opaque structs for the
AMs that need this information (currently gist and hash).

Patch from Heikki Linnakangas, fixes by Neil Conway.
This commit is contained in:
Neil Conway
2007-01-20 18:43:35 +00:00
parent 978fff7942
commit 2b7334d487
9 changed files with 57 additions and 59 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.63 2007/01/05 22:19:22 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.64 2007/01/20 18:43:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -106,8 +106,8 @@ gistgettuple(PG_FUNCTION_ARGS)
* If we have produced an index tuple in the past and the executor has
* informed us we need to mark it as "killed", do so now.
*/
if (scan->kill_prior_tuple && ItemPointerIsValid(&(scan->currentItemData)))
killtuple(scan->indexRelation, so, &(scan->currentItemData));
if (scan->kill_prior_tuple && ItemPointerIsValid(&(so->curpos)))
killtuple(scan->indexRelation, so, &(so->curpos));
/*
* Get the next tuple that matches the search key. If asked to skip killed
@ -138,7 +138,8 @@ gistgetmulti(PG_FUNCTION_ARGS)
* tuples. Returns true iff a matching tuple was found.
*/
static int
gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, bool ignore_killed_tuples)
gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids,
int maxtids, bool ignore_killed_tuples)
{
Page p;
OffsetNumber n;
@ -151,7 +152,7 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
so = (GISTScanOpaque) scan->opaque;
if (ItemPointerIsValid(&scan->currentItemData) == false)
if (ItemPointerIsValid(&so->curpos) == false)
{
/* Being asked to fetch the first entry, so start at the root */
Assert(so->curbuf == InvalidBuffer);
@ -226,7 +227,7 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
}
if (!GistPageIsLeaf(p) || resetoffset ||
!ItemPointerIsValid(&scan->currentItemData))
!ItemPointerIsValid(&so->curpos))
{
if (ScanDirectionIsBackward(dir))
n = PageGetMaxOffsetNumber(p);
@ -235,7 +236,7 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
}
else
{
n = ItemPointerGetOffsetNumber(&(scan->currentItemData));
n = ItemPointerGetOffsetNumber(&(so->curpos));
if (ScanDirectionIsBackward(dir))
n = OffsetNumberPrev(n);
@ -285,7 +286,7 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
* we can efficiently resume the index scan later.
*/
ItemPointerSet(&(scan->currentItemData),
ItemPointerSet(&(so->curpos),
BufferGetBlockNumber(so->curbuf), n);
if (!(ignore_killed_tuples && ItemIdDeleted(PageGetItemId(p, n))))

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.66 2007/01/05 22:19:22 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.67 2007/01/20 18:43:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -42,12 +42,6 @@ gistrescan(PG_FUNCTION_ARGS)
GISTScanOpaque so;
int i;
/*
* Clear all the pointers.
*/
ItemPointerSetInvalid(&scan->currentItemData);
ItemPointerSetInvalid(&scan->currentMarkData);
so = (GISTScanOpaque) scan->opaque;
if (so != NULL)
{
@ -82,6 +76,12 @@ gistrescan(PG_FUNCTION_ARGS)
scan->opaque = so;
}
/*
* Clear all the pointers.
*/
ItemPointerSetInvalid(&so->curpos);
ItemPointerSetInvalid(&so->markpos);
/* Update scan key, if a new one is given */
if (key && scan->numberOfKeys > 0)
{
@ -111,8 +111,8 @@ gistmarkpos(PG_FUNCTION_ARGS)
*n,
*tmp;
scan->currentMarkData = scan->currentItemData;
so = (GISTScanOpaque) scan->opaque;
so->markpos = so->curpos;
if (so->flags & GS_CURBEFORE)
so->flags |= GS_MRKBEFORE;
else
@ -160,8 +160,8 @@ gistrestrpos(PG_FUNCTION_ARGS)
*n,
*tmp;
scan->currentItemData = scan->currentMarkData;
so = (GISTScanOpaque) scan->opaque;
so->curpos = so->markpos;
if (so->flags & GS_MRKBEFORE)
so->flags |= GS_CURBEFORE;
else