mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +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:
@@ -9,7 +9,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.102 2008/04/17 21:37:28 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.103 2008/11/30 20:51:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -67,31 +67,16 @@ typedef struct
|
||||
* ----------------
|
||||
*/
|
||||
DestReceiver *
|
||||
printtup_create_DR(CommandDest dest, Portal portal)
|
||||
printtup_create_DR(CommandDest dest)
|
||||
{
|
||||
DR_printtup *self = (DR_printtup *) palloc(sizeof(DR_printtup));
|
||||
DR_printtup *self = (DR_printtup *) palloc0(sizeof(DR_printtup));
|
||||
|
||||
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
|
||||
self->pub.receiveSlot = printtup;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* In protocol 2.0 the Bind message does not exist, so there is no way
|
||||
* for the columns to have different print formats; it's sufficient to
|
||||
* look at the first one.
|
||||
*/
|
||||
if (portal->formats && portal->formats[0] != 0)
|
||||
self->pub.receiveSlot = printtup_internal_20;
|
||||
else
|
||||
self->pub.receiveSlot = printtup_20;
|
||||
}
|
||||
self->pub.receiveSlot = printtup; /* might get changed later */
|
||||
self->pub.rStartup = printtup_startup;
|
||||
self->pub.rShutdown = printtup_shutdown;
|
||||
self->pub.rDestroy = printtup_destroy;
|
||||
self->pub.mydest = dest;
|
||||
|
||||
self->portal = portal;
|
||||
|
||||
/*
|
||||
* Send T message automatically if DestRemote, but not if
|
||||
* DestRemoteExecute
|
||||
@@ -105,6 +90,33 @@ printtup_create_DR(CommandDest dest, Portal portal)
|
||||
return (DestReceiver *) self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set parameters for a DestRemote (or DestRemoteExecute) receiver
|
||||
*/
|
||||
void
|
||||
SetRemoteDestReceiverParams(DestReceiver *self, Portal portal)
|
||||
{
|
||||
DR_printtup *myState = (DR_printtup *) self;
|
||||
|
||||
Assert(myState->pub.mydest == DestRemote ||
|
||||
myState->pub.mydest == DestRemoteExecute);
|
||||
|
||||
myState->portal = portal;
|
||||
|
||||
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
|
||||
{
|
||||
/*
|
||||
* In protocol 2.0 the Bind message does not exist, so there is no way
|
||||
* for the columns to have different print formats; it's sufficient to
|
||||
* look at the first one.
|
||||
*/
|
||||
if (portal->formats && portal->formats[0] != 0)
|
||||
myState->pub.receiveSlot = printtup_internal_20;
|
||||
else
|
||||
myState->pub.receiveSlot = printtup_20;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user