diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-06 20:26:28 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-06 20:26:28 +0000 |
commit | 79913910d4b518a42c893b6dd459656798ffa591 (patch) | |
tree | f0cd5c25dff8d026b9d8d4736717a4d38c278134 /src/backend/executor/execMain.c | |
parent | 299fbb4b379003557f79d2732a85ece168d04ec4 (diff) | |
download | postgresql-79913910d4b518a42c893b6dd459656798ffa591.tar.gz postgresql-79913910d4b518a42c893b6dd459656798ffa591.zip |
Restructure command destination handling so that we pass around
DestReceiver pointers instead of just CommandDest values. The DestReceiver
is made at the point where the destination is selected, rather than
deep inside the executor. This cleans up the original kluge implementation
of tstoreReceiver.c, and makes it easy to support retrieving results
from utility statements inside portals. Thus, you can now do fun things
like Bind and Execute a FETCH or EXPLAIN command, and it'll all work
as expected (e.g., you can Describe the portal, or use Execute's count
parameter to suspend the output partway through). Implementation involves
stuffing the utility command's output into a Tuplestore, which would be
kind of annoying for huge output sets, but should be quite acceptable
for typical uses of utility commands.
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 719c9456562..3d1b950e210 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.207 2003/05/06 00:20:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.208 2003/05/06 20:26:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -72,9 +72,9 @@ static TupleTableSlot *ExecutePlan(EState *estate, PlanState *planstate, CmdType operation, long numberTuples, ScanDirection direction, - DestReceiver *destfunc); + DestReceiver *dest); static void ExecSelect(TupleTableSlot *slot, - DestReceiver *destfunc, + DestReceiver *dest, EState *estate); static void ExecInsert(TupleTableSlot *slot, ItemPointer tupleid, EState *estate); @@ -188,8 +188,7 @@ ExecutorRun(QueryDesc *queryDesc, { EState *estate; CmdType operation; - CommandDest dest; - DestReceiver *destfunc; + DestReceiver *dest; TupleTableSlot *result; MemoryContext oldcontext; @@ -218,11 +217,10 @@ ExecutorRun(QueryDesc *queryDesc, estate->es_processed = 0; estate->es_lastoid = InvalidOid; - destfunc = DestToFunction(dest); - (*destfunc->setup) (destfunc, operation, - queryDesc->portalName, - queryDesc->tupDesc, - queryDesc->planstate->plan->targetlist); + (*dest->startup) (dest, operation, + queryDesc->portalName, + queryDesc->tupDesc, + queryDesc->planstate->plan->targetlist); /* * run plan @@ -235,12 +233,12 @@ ExecutorRun(QueryDesc *queryDesc, operation, count, direction, - destfunc); + dest); /* * shutdown receiver */ - (*destfunc->cleanup) (destfunc); + (*dest->shutdown) (dest); MemoryContextSwitchTo(oldcontext); @@ -962,7 +960,7 @@ ExecutePlan(EState *estate, CmdType operation, long numberTuples, ScanDirection direction, - DestReceiver *destfunc) + DestReceiver *dest) { JunkFilter *junkfilter; TupleTableSlot *slot; @@ -1162,8 +1160,7 @@ lnext: ; { case CMD_SELECT: ExecSelect(slot, /* slot containing tuple */ - destfunc, /* destination's tuple-receiver - * obj */ + dest, /* destination's tuple-receiver obj */ estate); result = slot; break; @@ -1237,7 +1234,7 @@ lnext: ; */ static void ExecSelect(TupleTableSlot *slot, - DestReceiver *destfunc, + DestReceiver *dest, EState *estate) { HeapTuple tuple; @@ -1251,6 +1248,8 @@ ExecSelect(TupleTableSlot *slot, /* * insert the tuple into the "into relation" + * + * XXX this probably ought to be replaced by a separate destination */ if (estate->es_into_relation_descriptor != NULL) { @@ -1260,9 +1259,9 @@ ExecSelect(TupleTableSlot *slot, } /* - * send the tuple to the front end (or the screen) + * send the tuple to the destination */ - (*destfunc->receiveTuple) (tuple, attrtype, destfunc); + (*dest->receiveTuple) (tuple, attrtype, dest); IncrRetrieved(); (estate->es_processed)++; } |