postgres.git / summary / log / commit / refs

commit    59a5f8bb18995a3daa109f70b7616a491b6523d2
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sun Feb 18 19:49:49 2007 +0000
First released in: 8.3.0, 7.4.17, 8.0.13, 8.1.9, 8.2.4

    Fix portal management code to support non-default command completion tags for
    portals using PORTAL_UTIL_SELECT strategy.  This is currently significant only
    for FETCH queries, which are supposed to include a count in the tag.  Seems
    it's been broken since 7.4, but nobody noticed before Knut Lehre.


src/backend/tcop/pquery.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 4ff3d8c7ba0..90773198c15 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.73.2.1 2004/03/05 00:21:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.73.2.2 2007/02/18 19:49:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,7 @@ #include "utils/memutils.h" +static void FillPortalStore(Portal portal); static uint32 RunFromStore(Portal portal, ScanDirection direction, long count, DestReceiver *dest); static long PortalRunSelect(Portal portal, bool forward, long count, @@ -461,16 +462,7 @@ PortalRun(Portal portal, long count, * storing its results in the portal's tuplestore. */ if (!portal->portalUtilReady) - { - DestReceiver *treceiver; - - PortalCreateHoldStore(portal); - treceiver = CreateDestReceiver(Tuplestore, portal); - PortalRunUtility(portal, lfirst(portal->parseTrees), - treceiver, NULL); - (*treceiver->rDestroy) (treceiver); - portal->portalUtilReady = true; - } + FillPortalStore(portal); /* * Now fetch desired portion of results. @@ -662,6 +654,35 @@ PortalRunSelect(Portal portal, return nprocessed; } +/* + * FillPortalStore + * Run the query and load result tuples into the portal's tuple store. + * + * This is used for PORTAL_UTIL_SELECT cases only. + */ +static void +FillPortalStore(Portal portal) +{ + DestReceiver *treceiver; + char completionTag[COMPLETION_TAG_BUFSIZE]; + + PortalCreateHoldStore(portal); + treceiver = CreateDestReceiver(Tuplestore, portal); + + completionTag[0] = '\0'; + + PortalRunUtility(portal, lfirst(portal->parseTrees), + treceiver, completionTag); + + /* Override default completion tag with actual command result */ + if (completionTag[0] != '\0') + portal->commandTag = pstrdup(completionTag); + + (*treceiver->rDestroy) (treceiver); + + portal->portalUtilReady = true; +} + /* * RunFromStore * Fetch tuples from the portal's tuple store. [parent: bcac5703ece2]