mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Remove mark/restore support in GIN and GiST indexes.
Per Tom's comment. Also revome useless GISTScanOpaque->flags field.
This commit is contained in:
@ -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.76 2008/10/17 17:02:21 teodor Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.77 2008/10/20 13:39:44 teodor Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -494,16 +494,6 @@ gistfindnext(IndexScanDesc scan, OffsetNumber n, ScanDirection dir)
|
||||
*/
|
||||
oldcxt = MemoryContextSwitchTo(so->tempCxt);
|
||||
|
||||
/*
|
||||
* If we modified the index during the scan, we may have a pointer to a
|
||||
* ghost tuple, before the scan. If this is the case, back up one.
|
||||
*/
|
||||
if (so->flags & GS_CURBEFORE)
|
||||
{
|
||||
so->flags &= ~GS_CURBEFORE;
|
||||
n = OffsetNumberPrev(n);
|
||||
}
|
||||
|
||||
while (n >= FirstOffsetNumber && n <= maxoff)
|
||||
{
|
||||
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
|
||||
|
@ -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.72 2008/10/17 17:02:21 teodor Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.73 2008/10/20 13:39:44 teodor Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -49,30 +49,21 @@ gistrescan(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* rescan an existing indexscan --- reset state */
|
||||
gistfreestack(so->stack);
|
||||
gistfreestack(so->markstk);
|
||||
so->stack = so->markstk = NULL;
|
||||
so->flags = 0x0;
|
||||
so->stack = NULL;
|
||||
/* drop pins on buffers -- no locks held */
|
||||
if (BufferIsValid(so->curbuf))
|
||||
{
|
||||
ReleaseBuffer(so->curbuf);
|
||||
so->curbuf = InvalidBuffer;
|
||||
}
|
||||
if (BufferIsValid(so->markbuf))
|
||||
{
|
||||
ReleaseBuffer(so->markbuf);
|
||||
so->markbuf = InvalidBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* initialize opaque data */
|
||||
so = (GISTScanOpaque) palloc(sizeof(GISTScanOpaqueData));
|
||||
so->stack = so->markstk = NULL;
|
||||
so->flags = 0x0;
|
||||
so->stack = NULL;
|
||||
so->tempCxt = createTempGistContext();
|
||||
so->curbuf = so->markbuf = InvalidBuffer;
|
||||
so->curbuf = InvalidBuffer;
|
||||
so->giststate = (GISTSTATE *) palloc(sizeof(GISTSTATE));
|
||||
initGISTstate(so->giststate, scan->indexRelation);
|
||||
|
||||
@ -83,7 +74,6 @@ gistrescan(PG_FUNCTION_ARGS)
|
||||
* Clear all the pointers.
|
||||
*/
|
||||
ItemPointerSetInvalid(&so->curpos);
|
||||
ItemPointerSetInvalid(&so->markpos);
|
||||
so->nPageData = so->curPageData = 0;
|
||||
|
||||
/* Update scan key, if a new one is given */
|
||||
@ -119,108 +109,14 @@ gistrescan(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
gistmarkpos(PG_FUNCTION_ARGS)
|
||||
{
|
||||
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
|
||||
GISTScanOpaque so;
|
||||
GISTSearchStack *o,
|
||||
*n,
|
||||
*tmp;
|
||||
|
||||
so = (GISTScanOpaque) scan->opaque;
|
||||
so->markpos = so->curpos;
|
||||
if (so->flags & GS_CURBEFORE)
|
||||
so->flags |= GS_MRKBEFORE;
|
||||
else
|
||||
so->flags &= ~GS_MRKBEFORE;
|
||||
|
||||
o = NULL;
|
||||
n = so->stack;
|
||||
|
||||
/* copy the parent stack from the current item data */
|
||||
while (n != NULL)
|
||||
{
|
||||
tmp = (GISTSearchStack *) palloc(sizeof(GISTSearchStack));
|
||||
tmp->lsn = n->lsn;
|
||||
tmp->parentlsn = n->parentlsn;
|
||||
tmp->block = n->block;
|
||||
tmp->next = o;
|
||||
o = tmp;
|
||||
n = n->next;
|
||||
}
|
||||
|
||||
gistfreestack(so->markstk);
|
||||
so->markstk = o;
|
||||
|
||||
/* Update markbuf: make sure to bump ref count on curbuf */
|
||||
if (BufferIsValid(so->markbuf))
|
||||
{
|
||||
ReleaseBuffer(so->markbuf);
|
||||
so->markbuf = InvalidBuffer;
|
||||
}
|
||||
if (BufferIsValid(so->curbuf))
|
||||
{
|
||||
IncrBufferRefCount(so->curbuf);
|
||||
so->markbuf = so->curbuf;
|
||||
}
|
||||
|
||||
so->markNPageData = so->nPageData;
|
||||
so->markCurPageData = so->curPageData;
|
||||
if ( so->markNPageData > 0 )
|
||||
memcpy( so->markPageData, so->pageData, sizeof(ItemResult) * so->markNPageData );
|
||||
|
||||
elog(ERROR, "GiST does not support mark/restore");
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
gistrestrpos(PG_FUNCTION_ARGS)
|
||||
{
|
||||
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
|
||||
GISTScanOpaque so;
|
||||
GISTSearchStack *o,
|
||||
*n,
|
||||
*tmp;
|
||||
|
||||
so = (GISTScanOpaque) scan->opaque;
|
||||
so->curpos = so->markpos;
|
||||
if (so->flags & GS_MRKBEFORE)
|
||||
so->flags |= GS_CURBEFORE;
|
||||
else
|
||||
so->flags &= ~GS_CURBEFORE;
|
||||
|
||||
o = NULL;
|
||||
n = so->markstk;
|
||||
|
||||
/* copy the parent stack from the current item data */
|
||||
while (n != NULL)
|
||||
{
|
||||
tmp = (GISTSearchStack *) palloc(sizeof(GISTSearchStack));
|
||||
tmp->lsn = n->lsn;
|
||||
tmp->parentlsn = n->parentlsn;
|
||||
tmp->block = n->block;
|
||||
tmp->next = o;
|
||||
o = tmp;
|
||||
n = n->next;
|
||||
}
|
||||
|
||||
gistfreestack(so->stack);
|
||||
so->stack = o;
|
||||
|
||||
/* Update curbuf: be sure to bump ref count on markbuf */
|
||||
if (BufferIsValid(so->curbuf))
|
||||
{
|
||||
ReleaseBuffer(so->curbuf);
|
||||
so->curbuf = InvalidBuffer;
|
||||
}
|
||||
if (BufferIsValid(so->markbuf))
|
||||
{
|
||||
IncrBufferRefCount(so->markbuf);
|
||||
so->curbuf = so->markbuf;
|
||||
}
|
||||
|
||||
so->nPageData = so->markNPageData;
|
||||
so->curPageData = so->markNPageData;
|
||||
if ( so->markNPageData > 0 )
|
||||
memcpy( so->pageData, so->markPageData, sizeof(ItemResult) * so->markNPageData );
|
||||
|
||||
elog(ERROR, "GiST does not support mark/restore");
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@ -235,14 +131,11 @@ gistendscan(PG_FUNCTION_ARGS)
|
||||
if (so != NULL)
|
||||
{
|
||||
gistfreestack(so->stack);
|
||||
gistfreestack(so->markstk);
|
||||
if (so->giststate != NULL)
|
||||
freeGISTstate(so->giststate);
|
||||
/* drop pins on buffers -- we aren't holding any locks */
|
||||
if (BufferIsValid(so->curbuf))
|
||||
ReleaseBuffer(so->curbuf);
|
||||
if (BufferIsValid(so->markbuf))
|
||||
ReleaseBuffer(so->markbuf);
|
||||
MemoryContextDelete(so->tempCxt);
|
||||
pfree(scan->opaque);
|
||||
}
|
||||
|
Reference in New Issue
Block a user