Skip to content

Commit 43cd859

Browse files
author
Álvaro Herrera
committed
Remove assertion from PortalRunMulti
We have an assertion to ensure that a command tag has been assigned by the time we're done executing, but if we happen to execute a command with no queries, the assertion would fail. Per discussion, rather than contort things to get a tag assigned, just remove the assertion. Oversight in 2f96613. That commit also retained a comment that explained logic that had been adjacent to it but diffused into various places, leaving none apt to keep part of the comment. Remove that part, and rewrite what remains for extra clarity. Bug: #18984 Backpatch-through: 13 Reported-by: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Michaël Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/18984-0f4778a6599ac3ae@postgresql.org
1 parent afd2547 commit 43cd859

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/backend/tcop/pquery.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,24 +1347,15 @@ PortalRunMulti(Portal portal,
13471347
PopActiveSnapshot();
13481348

13491349
/*
1350-
* If a query completion data was supplied, use it. Otherwise use the
1351-
* portal's query completion data.
1352-
*
1353-
* Exception: Clients expect INSERT/UPDATE/DELETE tags to have counts, so
1354-
* fake them with zeros. This can happen with DO INSTEAD rules if there
1355-
* is no replacement query of the same type as the original. We print "0
1356-
* 0" here because technically there is no query of the matching tag type,
1357-
* and printing a non-zero count for a different query type seems wrong,
1358-
* e.g. an INSERT that does an UPDATE instead should not print "0 1" if
1359-
* one row was updated. See QueryRewrite(), step 3, for details.
1350+
* If a command tag was requested and we did not fill in a run-time-
1351+
* determined tag above, copy the parse-time tag from the Portal. (There
1352+
* might not be any tag there either, in edge cases such as empty prepared
1353+
* statements. That's OK.)
13601354
*/
1361-
if (qc && qc->commandTag == CMDTAG_UNKNOWN)
1362-
{
1363-
if (portal->qc.commandTag != CMDTAG_UNKNOWN)
1364-
CopyQueryCompletion(qc, &portal->qc);
1365-
/* If the caller supplied a qc, we should have set it by now. */
1366-
Assert(qc->commandTag != CMDTAG_UNKNOWN);
1367-
}
1355+
if (qc &&
1356+
qc->commandTag == CMDTAG_UNKNOWN &&
1357+
portal->qc.commandTag != CMDTAG_UNKNOWN)
1358+
CopyQueryCompletion(qc, &portal->qc);
13681359
}
13691360

13701361
/*

0 commit comments

Comments
 (0)