diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-12-26 21:37:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-12-26 21:37:20 +0000 |
commit | 0cbc5b1ed49ed744e856687b1d5e36d312327a34 (patch) | |
tree | 6a56142c89f023731a991141114ef070c5a3f470 /src/backend/executor/execMain.c | |
parent | 68996463d405a0e3e35f81371ffebbbaff7c1f63 (diff) | |
download | postgresql-0cbc5b1ed49ed744e856687b1d5e36d312327a34.tar.gz postgresql-0cbc5b1ed49ed744e856687b1d5e36d312327a34.zip |
Fix failure due to accessing an already-freed tuple descriptor in a plan
involving HashAggregate over SubqueryScan (this is the known case, there
may well be more). The bug is only latent in releases before 8.2 since they
didn't try to access tupletable slots' descriptors during ExecDropTupleTable.
The least bogus fix seems to be to make subqueries share the parent query's
memory context, so that tupdescs they create will have the same lifespan as
those of the parent query. There are comments in the code envisioning going
even further by not having a separate child EState at all, but that will
require rethinking executor access to range tables, which I don't want to
tackle right now. Per bug report from Jean-Pierre Pelletier.
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 6db354cd4f9..ec7959a9f5f 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.281 2006/12/04 02:06:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.282 2006/12/26 21:37:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2247,6 +2247,10 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq) rtsize = list_length(estate->es_range_table); + /* + * It's tempting to think about using CreateSubExecutorState here, but + * at present we can't because of memory leakage concerns ... + */ epq->estate = epqstate = CreateExecutorState(); oldcontext = MemoryContextSwitchTo(epqstate->es_query_cxt); |