Skip to content

Commit 4871c1e

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 2463886 commit 4871c1e

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
@@ -1353,24 +1353,15 @@ PortalRunMulti(Portal portal,
13531353
PopActiveSnapshot();
13541354

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

13761367
/*

0 commit comments

Comments
 (0)