1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Get rid of the separate EState for subplans, and just let them share the

parent query's EState.  Now that there's a single flat rangetable for both
the main plan and subplans, there's no need anymore for a separate EState,
and removing it allows cleaning up some crufty code in nodeSubplan.c and
nodeSubqueryscan.c.  Should be a tad faster too, although any difference
will probably be hard to measure.  This is the last bit of subsidiary
mop-up work from changing to a flat rangetable.
This commit is contained in:
Tom Lane
2007-02-27 01:11:26 +00:00
parent 4756ff3dca
commit c7ff7663e4
15 changed files with 258 additions and 358 deletions

View File

@ -8,14 +8,13 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.146 2007/02/22 22:00:22 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.147 2007/02/27 01:11:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* INTERFACE ROUTINES
* CreateExecutorState Create/delete executor working state
* CreateSubExecutorState
* FreeExecutorState
* CreateExprContext
* CreateStandaloneExprContext
@ -66,8 +65,6 @@ int NIndexTupleInserted;
int NIndexTupleProcessed;
static EState *InternalCreateExecutorState(MemoryContext qcontext,
bool is_subquery);
static void ShutdownExprContext(ExprContext *econtext);
@ -152,7 +149,9 @@ DisplayTupleCount(FILE *statfp)
EState *
CreateExecutorState(void)
{
EState *estate;
MemoryContext qcontext;
MemoryContext oldcontext;
/*
* Create the per-query context for this Executor run.
@ -163,37 +162,6 @@ CreateExecutorState(void)
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
return InternalCreateExecutorState(qcontext, false);
}
/* ----------------
* CreateSubExecutorState
*
* Create and initialize an EState node for a sub-query.
*
* Ideally, sub-queries probably shouldn't have their own EState at all,
* but right now this is necessary because they have their own rangetables
* and we access the rangetable via the EState. It is critical that a
* sub-query share the parent's es_query_cxt, else structures allocated by
* the sub-query (especially its result tuple descriptor) may disappear
* too soon during executor shutdown.
* ----------------
*/
EState *
CreateSubExecutorState(EState *parent_estate)
{
return InternalCreateExecutorState(parent_estate->es_query_cxt, true);
}
/*
* Guts of CreateExecutorState/CreateSubExecutorState
*/
static EState *
InternalCreateExecutorState(MemoryContext qcontext, bool is_subquery)
{
EState *estate;
MemoryContext oldcontext;
/*
* Make the EState node within the per-query context. This way, we don't
* need a separate pfree() operation for it at shutdown.
@ -232,14 +200,14 @@ InternalCreateExecutorState(MemoryContext qcontext, bool is_subquery)
estate->es_lastoid = InvalidOid;
estate->es_rowMarks = NIL;
estate->es_is_subquery = is_subquery;
estate->es_instrument = false;
estate->es_select_into = false;
estate->es_into_oids = false;
estate->es_exprcontexts = NIL;
estate->es_subplanstates = NIL;
estate->es_per_tuple_exprcontext = NULL;
estate->es_plannedstmt = NULL;
@ -292,12 +260,9 @@ FreeExecutorState(EState *estate)
/*
* Free the per-query memory context, thereby releasing all working
* memory, including the EState node itself. In a subquery, we don't
* do this, leaving the memory cleanup to happen when the topmost query
* is closed down.
* memory, including the EState node itself.
*/
if (!estate->es_is_subquery)
MemoryContextDelete(estate->es_query_cxt);
MemoryContextDelete(estate->es_query_cxt);
}
/* ----------------