diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-18 19:49:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-18 19:49:42 +0000 |
commit | 34f92d2c7786100dd0646bda6fd4ae50f2d37428 (patch) | |
tree | c7fc44dab7c2d6f52bdbae421f21c306eb1349cf /src | |
parent | 0652254108dc6607e26a200b7fcc06cfb932357d (diff) | |
download | postgresql-34f92d2c7786100dd0646bda6fd4ae50f2d37428.tar.gz postgresql-34f92d2c7786100dd0646bda6fd4ae50f2d37428.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tcop/pquery.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index e44ab59db2a..dc46a49eeba 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.89.4.2 2005/02/10 20:36:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.89.4.3 2007/02/18 19:49:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,6 +37,7 @@ static void ProcessQuery(Query *parsetree, ParamListInfo params, DestReceiver *dest, char *completionTag); +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, @@ -580,16 +581,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, linitial(portal->parseTrees), - treceiver, NULL); - (*treceiver->rDestroy) (treceiver); - portal->portalUtilReady = true; - } + FillPortalStore(portal); /* * Now fetch desired portion of results. @@ -820,6 +812,35 @@ PortalRunSelect(Portal portal, } /* + * 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, linitial(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. * @@ -1127,16 +1148,7 @@ PortalRunFetch(Portal portal, * storing its results in the portal's tuplestore. */ if (!portal->portalUtilReady) - { - DestReceiver *treceiver; - - PortalCreateHoldStore(portal); - treceiver = CreateDestReceiver(Tuplestore, portal); - PortalRunUtility(portal, linitial(portal->parseTrees), - treceiver, NULL); - (*treceiver->rDestroy) (treceiver); - portal->portalUtilReady = true; - } + FillPortalStore(portal); /* * Now fetch desired portion of results. |