1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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.
This commit is contained in:
Tom Lane
2008-11-30 20:51:25 +00:00
parent 3f936aacc0
commit c1f3073333
14 changed files with 108 additions and 83 deletions

View File

@ -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;
}