pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-committers(at)lists(dot)postgresql(dot)org
Subject: pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar
Date: 2026-11-14 00:57:58
Message-ID: E1xS25e-00000001rim-3JEe@gothos.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-committers

Fix Describe to not raise a FATAL error with nonexistent prepared statement.

Previously Describe() threw a FATAL error (and disconnected the
session) if nonexistent prepared statement is provided. This is an
incompatible behavior with PostgreSQL since it returns an ERROR
response and clients can continue the session in this case.

To fix this, create a dummy query context so that the Describe message
is sent to the primary node and an error response is returned from
PostgreSQL. Note that create_dummy_query_context() creates a query
context for a write query.

Below is the minimum test data for pgproto.

'D' 'S' "missing_prepared"
'S'
'Y'
'Q' "SELECT 1"
'Y'
'X'

And expected response. The session is killed anymore and following
simple query returns rows on the same session.

FE=> Describe(stmt="missing_prepared")
FE=> Sync
<= BE ErrorResponse(S ERROR V ERROR C 26000 M prepared statement "missing_prepared" does not exist F prepare.c L 451 R FetchPreparedStatement )
<= BE ReadyForQuery(I)
FE=> Query (query="SELECT 1")
<= BE RowDescription
<= BE DataRow
<= BE CommandComplete(SELECT 1)
<= BE ReadyForQuery(I)
FE=> Terminate

Also a regression test case for this is added.

Reported-by: apkipa
Author: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Discussion: https://github.com/pgpool/pgpool2/issues/169
Backpatch-through: v4.3

Branch
------
V4_7_STABLE

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

Modified Files
--------------
src/protocol/pool_proto_modules.c | 18 ++++++----
.../tests/135.describe_bugs/expected.txt | 10 ++++++
.../tests/135.describe_bugs/pgproto.data | 7 ++++
.../regression/tests/135.describe_bugs/test.sh | 41 ++++++++++++++++++++++
4 files changed, 69 insertions(+), 7 deletions(-)

Browse pgpool-committers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-11-14 00:58:03 pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar
Previous Message Tatsuo Ishii 2026-11-14 00:57:54 pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar