1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +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

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.73 2008/10/31 19:37:56 tgl Exp $
* $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.74 2008/11/30 20:51:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -94,21 +94,16 @@ BeginCommand(const char *commandTag, CommandDest dest)
/* ----------------
* CreateDestReceiver - return appropriate receiver function set for dest
*
* Note: a Portal must be specified for destinations DestRemote,
* DestRemoteExecute, and DestTuplestore. It can be NULL for the others.
* ----------------
*/
DestReceiver *
CreateDestReceiver(CommandDest dest, Portal portal)
CreateDestReceiver(CommandDest dest)
{
switch (dest)
{
case DestRemote:
case DestRemoteExecute:
if (portal == NULL)
elog(ERROR, "no portal specified for DestRemote receiver");
return printtup_create_DR(dest, portal);
return printtup_create_DR(dest);
case DestNone:
return &donothingDR;
@@ -120,13 +115,7 @@ CreateDestReceiver(CommandDest dest, Portal portal)
return &spi_printtupDR;
case DestTuplestore:
if (portal == NULL)
elog(ERROR, "no portal specified for DestTuplestore receiver");
if (portal->holdStore == NULL ||
portal->holdContext == NULL)
elog(ERROR, "portal has no holdStore");
return CreateTuplestoreDestReceiver(portal->holdStore,
portal->holdContext);
return CreateTuplestoreDestReceiver();
case DestIntoRel:
return CreateIntoRelDestReceiver();