diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-02-28 04:10:28 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-02-28 04:10:28 +0000 |
commit | 2c0ef9777cce8f97dd01073d962e6aa31722b5ad (patch) | |
tree | bcfa428f69e6013002a79ab29e053bd6c6cbcfa7 /src/backend/executor/execMain.c | |
parent | 7f4f42fa100872507ca10d8e0f7d923acc266ee8 (diff) | |
download | postgresql-2c0ef9777cce8f97dd01073d962e6aa31722b5ad.tar.gz postgresql-2c0ef9777cce8f97dd01073d962e6aa31722b5ad.zip |
Extend the ExecInitNode API so that plan nodes receive a set of flag
bits indicating which optional capabilities can actually be exercised
at runtime. This will allow Sort and Material nodes, and perhaps later
other nodes, to avoid unnecessary overhead in common cases.
This commit just adds the infrastructure and arranges to pass the correct
flag values down to plan nodes; none of the actual optimizations are here
yet. I'm committing this separately in case anyone wants to measure the
added overhead. (It should be negligible.)
Simon Riggs and Tom Lane
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 57570a5cc0c..48449e39551 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.267 2006/02/21 23:01:54 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.268 2006/02/28 04:10:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ typedef struct evalPlanQual } evalPlanQual; /* decls for local routines only used within this module */ -static void InitPlan(QueryDesc *queryDesc, bool explainOnly); +static void InitPlan(QueryDesc *queryDesc, int eflags); static void initResultRelInfo(ResultRelInfo *resultRelInfo, Index resultRelationIndex, List *rangeTable, @@ -105,15 +105,14 @@ static void EvalPlanQualStop(evalPlanQual *epq); * field of the QueryDesc is filled in to describe the tuples that will be * returned, and the internal fields (estate and planstate) are set up. * - * If explainOnly is true, we are not actually intending to run the plan, - * only to set up for EXPLAIN; so skip unwanted side-effects. + * eflags contains flag bits as described in executor.h. * * NB: the CurrentMemoryContext when this is called will become the parent * of the per-query context used for this Executor invocation. * ---------------------------------------------------------------- */ void -ExecutorStart(QueryDesc *queryDesc, bool explainOnly) +ExecutorStart(QueryDesc *queryDesc, int eflags) { EState *estate; MemoryContext oldcontext; @@ -124,9 +123,9 @@ ExecutorStart(QueryDesc *queryDesc, bool explainOnly) /* * If the transaction is read-only, we need to check if any writes are - * planned to non-temporary tables. + * planned to non-temporary tables. EXPLAIN is considered read-only. */ - if (XactReadOnly && !explainOnly) + if (XactReadOnly && !(eflags & EXEC_FLAG_EXPLAIN_ONLY)) ExecCheckXactReadOnly(queryDesc->parsetree); /* @@ -156,7 +155,7 @@ ExecutorStart(QueryDesc *queryDesc, bool explainOnly) /* * Initialize the plan state tree */ - InitPlan(queryDesc, explainOnly); + InitPlan(queryDesc, eflags); MemoryContextSwitchTo(oldcontext); } @@ -442,7 +441,7 @@ fail: * ---------------------------------------------------------------- */ static void -InitPlan(QueryDesc *queryDesc, bool explainOnly) +InitPlan(QueryDesc *queryDesc, int eflags) { CmdType operation = queryDesc->operation; Query *parseTree = queryDesc->parsetree; @@ -608,7 +607,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) * tree. This opens files, allocates storage and leaves us ready to start * processing tuples. */ - planstate = ExecInitNode(plan, estate); + planstate = ExecInitNode(plan, estate, eflags); /* * Get the tuple descriptor describing the type of tuples to return. (this @@ -727,7 +726,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) */ intoRelationDesc = NULL; - if (do_select_into && !explainOnly) + if (do_select_into && !(eflags & EXEC_FLAG_EXPLAIN_ONLY)) { char *intoName; Oid namespaceId; @@ -2283,7 +2282,7 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq) epqstate->es_tupleTable = ExecCreateTupleTable(estate->es_tupleTable->size); - epq->planstate = ExecInitNode(estate->es_topPlan, epqstate); + epq->planstate = ExecInitNode(estate->es_topPlan, epqstate, 0); MemoryContextSwitchTo(oldcontext); } |