Skip to content

Parse of an empty query string answers EmptyQueryResponse instead of ParseComplete and registers no statement, so the client is one reply short and every message behind it in the pipeline fails #11028

Closed

Description

@ruispereira

SEVERITY: MEDIUM

Summary

parseCommand() answers a Parse whose text is empty by sending EmptyQueryResponse and returning, having
already removed whatever was registered under that name. PostgreSQL answers Parse of an empty string
with ParseComplete and registers a valid statement that returns no rows; EmptyQueryResponse is what
Execute sends, not Parse. Two things go wrong at once: the client gets a reply of the wrong type for
the message it sent, and the statement name it just created does not exist.

Where (HEAD 21d2a0e)

  • postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:3508, the empty-query arm of parseCommand() that calls emptyQueryResponse() and returns
  • postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:3506, preparedStatements.remove(portalName) just above it, which leaves the name empty

Repro

PROBE 1: Parse of an EMPTY query string
### Parse('pstmt_empty','') + Sync -> [I, Z]
-- real PostgreSQL: ParseComplete('1'), then ReadyForQuery --

### Parse('')+Bind+Describe(P)+Execute+Sync pipeline -> [I, E, Z]
    E {M=prepared statement "pe2" does not exist, S=ERROR, C=26000}
-- real PostgreSQL: 1, 2, n(NoData), I(EmptyQueryResponse), Z --

Through pgjdbc on the same server:

  prepareStatement("") THREW org.postgresql.util.PSQLException: ERROR: unnamed prepared statement does not exist
  connection still usable?
  -> 1

Real PostgreSQL: conn.prepareStatement("").execute() returns false and the statement is usable.

Refutation attempted

Is the client owed nothing for a discarded Parse? This is not a discard. parseCommand() draws that
boundary explicitly for the two cases where PostgreSQL discards rather than refuses, the aborted block
and skip-until-Sync, and both return before the name is invalidated. The empty-query arm sits after the
invalidation, on the refusal side, and still answers with a message type belonging to Execute.

Does the connection survive? Yes, as the pgjdbc probe shows, so the damage is confined to the statement.
That is why MEDIUM rather than HIGH.

Unrealistic input? It is what pooling layers and health checks send, and pgjdbc exposes it directly
through prepareStatement(""). The recorded pgjdbc failure is the user-visible form.

Suggested fix

Register the statement and answer ParseComplete, marking the portal so Describe answers NoData and
Execute answers EmptyQueryResponse. The empty statement then has the same lifecycle as any other,
which is what a client counting one reply per message requires.

The guarantee to ask for: every Parse that is not one of the two documented discard cases leaves the
connection with exactly one ParseComplete or one ErrorResponse, never a message type belonging to a
different request. A test driving the full Parse/Bind/Describe/Execute/Sync pipeline for the empty
statement and asserting the message type sequence, rather than asserting on Parse alone, pins it.

Scope / confidence

Executed: probe 1 on the wire and the pgjdbc call, output verbatim. Read: parseCommand()'s ordering of
the invalidation and the early returns, and the comment block at PostgresNetworkExecutor.java:3489
stating the discard-versus-refusal boundary.

Dedup

Checked 8211 (Bind from a missing prepared statement, the error this produces downstream but not its
cause), 7906 (a refused Parse leaving the previous statement registered), 10922. Searched alltitles.txt
for "empty query" and "EmptyQuery": no hits at all. Not previously reported.


Activity

  1. added
    severity:minor
    on Oct 30, 2026
  2. added this to the 26.11.1 milestone on Oct 31, 2026
  3. added
    in progress
    on Nov 2, 2026
  4. self-assigned this
    on Nov 2, 2026
  5. added 2 commits that reference this issue on Nov 2, 2026
  6. lvca commented on Nov 2, 2026

    @lvca
    Member

    Fixed in #11172.

    Confirmed: a Parse of an empty query got the wrong reply (EmptyQueryResponse instead of ParseComplete), and the statement was never registered. Every message after it in the pipeline failed with "prepared statement does not exist", which is how pgjdbc's prepareStatement("") broke.

    An empty statement now behaves as in PostgreSQL. Parse answers ParseComplete and registers it, Describe answers NoData, and Execute answers EmptyQueryResponse. pgjdbc's prepareStatement("").execute() returns false, and the statement can be executed again. Text made only of ; and whitespace (for example ";;") is treated as the empty query too, on both the simple and the extended protocol.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Nov 2, 2026
  8. added a commit that references this issue on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpostgresql-wireseverity:minor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions