summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistget.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-09-30 19:48:57 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-09-30 19:48:57 -0400
commitd22a09dc70f9830fa78c1cd1a3a453e4e473d354 (patch)
tree0867ec67a9643663d27f90ef8df2d58cb6cd9c3a /src/backend/access/gist/gistget.c
parent79edb2b1dc33166b576f51a8255a7614f748d9c9 (diff)
downloadpostgresql-d22a09dc70f9830fa78c1cd1a3a453e4e473d354.tar.gz
Support GiST index support functions that want to cache data across calls.
pg_trgm was already doing this unofficially, but the implementation hadn't been thought through very well and leaked memory. Restructure the core GiST code so that it actually works, and document it. Ordinarily this would have required an extra memory context creation/destruction for each GiST index search, but I was able to avoid that in the normal case of a non-rescanned search by finessing the handling of the RBTree. It used to have its own context always, but now shares a context with the scan-lifespan data structures, unless there is more than one rescan call. This should make the added overhead unnoticeable in typical cases.
Diffstat (limited to 'src/backend/access/gist/gistget.c')
-rw-r--r--src/backend/access/gist/gistget.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index 60116dfd46..b565d09b38 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -307,12 +307,12 @@ gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, double *myDistances,
* Must call gistindex_keytest in tempCxt, and clean up any leftover
* junk afterward.
*/
- oldcxt = MemoryContextSwitchTo(so->tempCxt);
+ oldcxt = MemoryContextSwitchTo(so->giststate->tempCxt);
match = gistindex_keytest(scan, it, page, i, &recheck);
MemoryContextSwitchTo(oldcxt);
- MemoryContextReset(so->tempCxt);
+ MemoryContextReset(so->giststate->tempCxt);
/* Ignore tuple if it doesn't match */
if (!match)