aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-11-30 20:51:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-11-30 20:51:25 +0000
commitc1f3073333d01987ac9c3e5f6c197b9e2afc3ba9 (patch)
treeb70ddff5404c442ec13a5c182346984d4300f6da /src/backend/executor
parent3f936aacc057e4b391ab953fea2ffb689a12a8bc (diff)
downloadpostgresql-c1f3073333d01987ac9c3e5f6c197b9e2afc3ba9.tar.gz
postgresql-c1f3073333d01987ac9c3e5f6c197b9e2afc3ba9.zip
Clean up the API for DestReceiver objects by eliminating the assumption
that a Portal is a useful and sufficient additional argument for CreateDestReceiver --- it just isn't, in most cases. Instead formalize the approach of passing any needed parameters to the receiver separately. One unexpected benefit of this change is that we can declare typedef Portal in a less surprising location. This patch is just code rearrangement and doesn't change any functionality. I'll tackle the HOLD-cursor-vs-toast problem in a follow-on patch.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execMain.c10
-rw-r--r--src/backend/executor/functions.c10
-rw-r--r--src/backend/executor/spi.c9
-rw-r--r--src/backend/executor/tstoreReceiver.c25
4 files changed, 31 insertions, 23 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index f63ea4e9eba..cb83e86e7bf 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.318 2008/11/19 01:10:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.319 2008/11/30 20:51:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2833,7 +2833,7 @@ OpenIntoRel(QueryDesc *queryDesc)
/*
* Now replace the query's DestReceiver with one for SELECT INTO
*/
- queryDesc->dest = CreateDestReceiver(DestIntoRel, NULL);
+ queryDesc->dest = CreateDestReceiver(DestIntoRel);
myState = (DR_intorel *) queryDesc->dest;
Assert(myState->pub.mydest == DestIntoRel);
myState->estate = estate;
@@ -2877,10 +2877,6 @@ CloseIntoRel(QueryDesc *queryDesc)
/*
* CreateIntoRelDestReceiver -- create a suitable DestReceiver object
- *
- * Since CreateDestReceiver doesn't accept the parameters we'd need,
- * we just leave the private fields zeroed here. OpenIntoRel will
- * fill them in.
*/
DestReceiver *
CreateIntoRelDestReceiver(void)
@@ -2893,6 +2889,8 @@ CreateIntoRelDestReceiver(void)
self->pub.rDestroy = intorel_destroy;
self->pub.mydest = DestIntoRel;
+ /* private fields will be set by OpenIntoRel */
+
return (DestReceiver *) self;
}
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 988f704ad72..b0373da025c 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.129 2008/11/27 00:10:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.130 2008/11/30 20:51:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -398,7 +398,7 @@ postquel_start(execution_state *es, SQLFunctionCachePtr fcache)
{
DR_sqlfunction *myState;
- dest = CreateDestReceiver(DestSQLFunction, NULL);
+ dest = CreateDestReceiver(DestSQLFunction);
/* pass down the needed info to the dest receiver routines */
myState = (DR_sqlfunction *) dest;
Assert(myState->pub.mydest == DestSQLFunction);
@@ -1269,10 +1269,6 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
/*
* CreateSQLFunctionDestReceiver -- create a suitable DestReceiver object
- *
- * Since CreateDestReceiver doesn't accept the parameters we'd need,
- * we just leave the private fields zeroed here. postquel_start will
- * fill them in.
*/
DestReceiver *
CreateSQLFunctionDestReceiver(void)
@@ -1285,6 +1281,8 @@ CreateSQLFunctionDestReceiver(void)
self->pub.rDestroy = sqlfunction_destroy;
self->pub.mydest = DestSQLFunction;
+ /* private fields will be set by postquel_start */
+
return (DestReceiver *) self;
}
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 9cf119eaed9..af475892e47 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.200 2008/11/02 01:45:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.201 2008/11/30 20:51:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1227,7 +1227,7 @@ SPI_cursor_fetch(Portal portal, bool forward, long count)
{
_SPI_cursor_operation(portal,
forward ? FETCH_FORWARD : FETCH_BACKWARD, count,
- CreateDestReceiver(DestSPI, NULL));
+ CreateDestReceiver(DestSPI));
/* we know that the DestSPI receiver doesn't need a destroy call */
}
@@ -1256,7 +1256,7 @@ SPI_scroll_cursor_fetch(Portal portal, FetchDirection direction, long count)
{
_SPI_cursor_operation(portal,
direction, count,
- CreateDestReceiver(DestSPI, NULL));
+ CreateDestReceiver(DestSPI));
/* we know that the DestSPI receiver doesn't need a destroy call */
}
@@ -1744,8 +1744,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
if (!read_only)
CommandCounterIncrement();
- dest = CreateDestReceiver(canSetTag ? DestSPI : DestNone,
- NULL);
+ dest = CreateDestReceiver(canSetTag ? DestSPI : DestNone);
if (snapshot == InvalidSnapshot)
{
diff --git a/src/backend/executor/tstoreReceiver.c b/src/backend/executor/tstoreReceiver.c
index 2b3889615b8..cb78c80b919 100644
--- a/src/backend/executor/tstoreReceiver.c
+++ b/src/backend/executor/tstoreReceiver.c
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.19 2008/01/01 19:45:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.20 2008/11/30 20:51:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,10 +72,9 @@ tstoreDestroyReceiver(DestReceiver *self)
* Initially create a DestReceiver object.
*/
DestReceiver *
-CreateTuplestoreDestReceiver(Tuplestorestate *tStore,
- MemoryContext tContext)
+CreateTuplestoreDestReceiver(void)
{
- TStoreState *self = (TStoreState *) palloc(sizeof(TStoreState));
+ TStoreState *self = (TStoreState *) palloc0(sizeof(TStoreState));
self->pub.receiveSlot = tstoreReceiveSlot;
self->pub.rStartup = tstoreStartupReceiver;
@@ -83,8 +82,22 @@ CreateTuplestoreDestReceiver(Tuplestorestate *tStore,
self->pub.rDestroy = tstoreDestroyReceiver;
self->pub.mydest = DestTuplestore;
- self->tstore = tStore;
- self->cxt = tContext;
+ /* private fields will be set by SetTuplestoreDestReceiverParams */
return (DestReceiver *) self;
}
+
+/*
+ * Set parameters for a TuplestoreDestReceiver
+ */
+void
+SetTuplestoreDestReceiverParams(DestReceiver *self,
+ Tuplestorestate *tStore,
+ MemoryContext tContext)
+{
+ TStoreState *myState = (TStoreState *) self;
+
+ Assert(myState->pub.mydest == DestTuplestore);
+ myState->tstore = tStore;
+ myState->cxt = tContext;
+}