Subject: pgpool: Fix empty query case in aborted transaction.

From: Tatsuo Ishii <[email-masked]>
Date: Tue, 19 May 2026 06:16:02 +0000

Fix empty query case in aborted transaction.

Commit eea522ebfcf791a623e865deaa1aa6fb59e3c50b changed user visible
behavior for empty queries (empty string or comment only queries) in
an explicit transaction in abort state. The commit missed the fact
that an empty query can be issued in the aborted state transaction
without any errors. As a result, an empty query raises "current
transaction is aborted, commands ignored until end of transaction
block" error by check_transaction_state_and_abort(), which is
wrong. Before the commit, the error was not raised.

This commit fixes the oversight by adding local flag "is_empty_query"
to SimpleQuery(). If the raw parser finds that a query is empty, the
flag is set to true. Then check_transaction_state_and_abort() is not
called and the empty query is forwarded to backend and processed just
like regular queries.

In passing, checking whether TSTATE in MAIN_NODE_ID is 'E' in
check_transaction_state_and_abort() is removed since it's not
necessary: subsequent code checks the transaction state by calling
pool_is_failed_transaction().

Also add test case to 128.aborted_transaction provided by raivil.

Reported-by: Ronaldo Raivil
Author: Tatsuo Ishii <[email-masked]>
Discussion: https://github.com/pgpool/pgpool2/issues/161
Backpatch-through: v4.3

Branch
------
V4_4_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=6ec39ceb142918d511cf2cc45856d961218440d0

Modified Files
--------------
src/protocol/pool_proto_modules.c                  | 34 +++++++++++-----------
.../tests/078.aborted_transaction/expected.txt     | 22 ++++++++++++++
.../tests/078.aborted_transaction/test.sh          | 11 +++++++
3 files changed, 50 insertions(+), 17 deletions(-)