Pgpool-II version
4.8devel (master@5c50ba31a49139b552b28ff2f9fd2f6e434f9621), backend_clustering_mode = raw, connection_cache = on, one PostgreSQL backend.
Description
A protocol Bind for a named statement that has not been prepared returns SQLSTATE 26000 with direct PostgreSQL but XX000 through Pgpool. The error text is the same, and both connections remain usable. Pgpool synthesizes the error when Bind() cannot find the statement in its sent-message cache, hard-coding XX000 pool_proto_modules.c; PostgreSQL maps this condition to 26000 (invalid_sql_statement_name) in its error-code appendix.
Reproduce
Install psycopg[binary] and run:
from psycopg.pq import DiagnosticField, ExecStatus, PGconn
def run(label, dsn):
conn = PGconn.connect(dsn.encode())
try:
result = conn.exec_prepared(b"scm_missing_prepared", None, None, 0)
code = result.error_field(DiagnosticField.SQLSTATE)
message = result.error_message.decode().strip().removeprefix("ERROR: ").strip()
followup = conn.exec_(b"SELECT 1")
value = followup.get_value(0, 0).decode()
print(
f"{label}: {ExecStatus(result.status).name}"
f"[{code.decode() if code else '?'}] {message}; "
f"followup={ExecStatus(followup.status).name}({value})"
)
finally:
conn.finish()
run("direct", DIRECT_DSN)
run("pgpool", PGPOOL_DSN)
Expected behavior
Both endpoints should return SQLSTATE 26000 and remain usable:
direct: FATAL_ERROR[26000] prepared statement "scm_missing_prepared" does not exist; followup=TUPLES_OK(1)
pgpool: FATAL_ERROR[26000] prepared statement "scm_missing_prepared" does not exist; followup=TUPLES_OK(1)
Actual behavior
The reproducer prints:
direct: FATAL_ERROR[26000] prepared statement "scm_missing_prepared" does not exist; followup=TUPLES_OK(1)
pgpool: FATAL_ERROR[XX000] prepared statement "scm_missing_prepared" does not exist; followup=TUPLES_OK(1)
Pgpool-II version
4.8devel(master@5c50ba31a49139b552b28ff2f9fd2f6e434f9621),backend_clustering_mode = raw,connection_cache = on, one PostgreSQL backend.Description
A protocol
Bindfor a named statement that has not been prepared returns SQLSTATE26000with direct PostgreSQL butXX000through Pgpool. The error text is the same, and both connections remain usable. Pgpool synthesizes the error whenBind()cannot find the statement in its sent-message cache, hard-codingXX000pool_proto_modules.c; PostgreSQL maps this condition to26000(invalid_sql_statement_name) in its error-code appendix.Reproduce
Install
psycopg[binary]and run:Expected behavior
Both endpoints should return SQLSTATE
26000and remain usable:Actual behavior
The reproducer prints: