diff options
Diffstat (limited to 'src/backend/access/gist/gistscan.c')
-rw-r--r-- | src/backend/access/gist/gistscan.c | 119 |
1 files changed, 6 insertions, 113 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 6dba277b18f..4e529b61992 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -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); } |