Re: BUG #18984: Empty prepared statement from psql \parse triggers assert in PortalRunMulti
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Ã?lvaro Herrera <alvherre@kurilemu.de>, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2025-07-15T23:32:00Z
Lists: pgsql-bugs
On Tue, Jul 15, 2025 at 12:05:34PM -0400, Tom Lane wrote:
> In short, Alvaro's patch definitely seems like the right one,
> modulo quibbles about rewriting the comment.
+++ b/src/backend/tcop/pquery.c
@@ -1350,24 +1350,14 @@ PortalRunMulti(Portal portal,
[...]
- if (qc && qc->commandTag == CMDTAG_UNKNOWN)
- {
- if (portal->qc.commandTag != CMDTAG_UNKNOWN)
- CopyQueryCompletion(qc, &portal->qc);
- /* If the caller supplied a qc, we should have set it by now. */
- Assert(qc->commandTag != CMDTAG_UNKNOWN);
- }
+ if (qc &&
+ qc->commandTag == CMDTAG_UNKNOWN &&
+ portal->qc.commandTag != CMDTAG_UNKNOWN)
+ CopyQueryCompletion(qc, &portal->qc);
Indeed this change looks OK.
> Perhaps we should
> add something about the possibility that an outer Portal level
> can supply a default command tag if we lack one now?
You mean as an extra assertion? I am not sure that this is strongly
necessary but why not.
--
Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Minor cosmetic tweaks
- e76221bd95f0 19 (unreleased) landed
-
Simplify coding in ProcessQuery
- a27c40bfe8ab 19 (unreleased) landed
-
Remove assertion from PortalRunMulti
- e0d3f3cfb6f2 18.0 landed
- c2720ac6010a 15.14 landed
- b9a89682846f 14.19 landed
- b8926a5b4bb8 19 (unreleased) landed
- 4871c1e9cb6e 16.10 landed
- 43cd85962755 13.22 landed
- 0c466f5e0b34 17.6 landed
-
Represent command completion tags as structs
- 2f9661311b83 13.0 cited