diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-02-04 17:40:25 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-02-04 17:40:25 +0200 |
commit | d88976cfa1302e8dccdcbfe55e9e29faee8c0cdf (patch) | |
tree | c1fb1f00b9c7d350b723d1eafabaf764dc8d30f3 /src/backend/access/gin/ginget.c | |
parent | 57fe246890ad51e166fb6a8da937e41c35d7a279 (diff) |
Use a separate memory context for GIN scan keys.
It was getting tedious to track and release all the different things that
form a scan key. We were leaking at least the queryCategories array, and
possibly more, on a rescan. That was visible if a GIN index was used in a
nested loop join. This also protects from leaks in extractQuery method.
No backpatching, given the lack of complaints from the field. Maybe later,
after this has received more field testing.
Diffstat (limited to 'src/backend/access/gin/ginget.c')
-rw-r--r-- | src/backend/access/gin/ginget.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index 9d73142ee93..3e2b8b5fedf 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -497,7 +497,7 @@ startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key) } /* i is now the last required entry. */ - MemoryContextSwitchTo(oldCtx); + MemoryContextSwitchTo(so->keyCtx); key->nrequired = i + 1; key->nadditional = key->nentries - key->nrequired; @@ -515,11 +515,14 @@ startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key) } else { + MemoryContextSwitchTo(so->keyCtx); + key->nrequired = 1; key->nadditional = 0; key->requiredEntries = palloc(1 * sizeof(GinScanEntry)); key->requiredEntries[0] = key->scanEntry[0]; } + MemoryContextSwitchTo(oldCtx); } static void |