Commit f1f2b271 authored by Tom Lane's avatar Tom Lane

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.
parent aa728d5f
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.112 2007/01/05 22:19:39 momjian Exp $ * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.113 2007/02/18 19:49:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -919,6 +919,8 @@ FillPortalStore(Portal portal) ...@@ -919,6 +919,8 @@ FillPortalStore(Portal portal)
PortalCreateHoldStore(portal); PortalCreateHoldStore(portal);
treceiver = CreateDestReceiver(DestTuplestore, portal); treceiver = CreateDestReceiver(DestTuplestore, portal);
completionTag[0] = '\0';
switch (portal->strategy) switch (portal->strategy)
{ {
case PORTAL_ONE_RETURNING: case PORTAL_ONE_RETURNING:
...@@ -929,13 +931,11 @@ FillPortalStore(Portal portal) ...@@ -929,13 +931,11 @@ FillPortalStore(Portal portal)
* tuplestore. Auxiliary query outputs are discarded. * tuplestore. Auxiliary query outputs are discarded.
*/ */
PortalRunMulti(portal, treceiver, None_Receiver, completionTag); PortalRunMulti(portal, treceiver, None_Receiver, completionTag);
/* Override default completion tag with actual command result */
portal->commandTag = pstrdup(completionTag);
break; break;
case PORTAL_UTIL_SELECT: case PORTAL_UTIL_SELECT:
PortalRunUtility(portal, linitial(portal->parseTrees), PortalRunUtility(portal, linitial(portal->parseTrees),
treceiver, NULL); treceiver, completionTag);
break; break;
default: default:
...@@ -944,6 +944,10 @@ FillPortalStore(Portal portal) ...@@ -944,6 +944,10 @@ FillPortalStore(Portal portal)
break; break;
} }
/* Override default completion tag with actual command result */
if (completionTag[0] != '\0')
portal->commandTag = pstrdup(completionTag);
(*treceiver->rDestroy) (treceiver); (*treceiver->rDestroy) (treceiver);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment