pg.ddx.io  pgpool-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tatsuo Ishii <ishii@postgresql.org>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar
Date: Sat, 14 Nov 2026 00:57:39 +0000
Message-ID: <E1xS25L-00000001rUW-11Po@gothos.postgresql.org> (raw)

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@postgresql.org>
Discussion: https://github.com/pgpool/pgpool2/issues/169
Backpatch-through: v4.3

Branch
------
V4_3_STABLE

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

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



view thread (6+ messages)  latest in thread

Message-ID: <E1xS25L-00000001rUW-11Po@gothos.postgresql.org>
Permalink:  ../E1xS25L-00000001rUW-11Po@gothos.postgresql.org/
Also on:    postgresql.org/message-id/E1xS25L-00000001rUW-11Po@gothos.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgpool-committers@postgresql.org
  Cc: ishii@postgresql.org
  Subject: Re: pgpool: Fix Describe to not raise a FATAL error with nonexistent prepar
  In-Reply-To: <E1xS25L-00000001rUW-11Po@gothos.postgresql.org>
  References: <E1xS25L-00000001rUW-11Po@gothos.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox