BUG #18984: Empty prepared statement from psql \parse triggers assert in PortalRunMulti

PG Bug reporting form <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2025-07-14T19:00:02Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18984
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 18beta1
Operating system:   Ubuntu 24.04
Description:        

The following psql script:
\parse s

execute s;

invokes:
TRAP: failed Assert("qc->commandTag != CMDTAG_UNKNOWN"), File: "pquery.c",
Line: 1369, PID: 1123863
ExceptionalCondition at assert.c:52:13
PortalRunMulti at pquery.c:1371:1
PortalRun at pquery.c:792:5
ExecuteQuery at prepare.c:260:2
standard_ProcessUtility at utility.c:757:4
ProcessUtility at utility.c:523:3
PortalRunUtility at pquery.c:1153:2
PortalRunMulti at pquery.c:1310:5
PortalRun at pquery.c:792:5
exec_simple_query at postgres.c:1280:11
...

Reproduced starting from d55322b0d.

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Minor cosmetic tweaks

  2. Simplify coding in ProcessQuery

  3. Remove assertion from PortalRunMulti

  4. Represent command completion tags as structs