pgsql: libpq: Grease the protocol by default

From: Jacob Champion <jchampion(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: libpq: Grease the protocol by default
Date: 2026-02-23 18:58:07
Message-ID: E1vub8B-000rlS-05@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

libpq: Grease the protocol by default

Send PG_PROTOCOL_GREASE and _pq_.test_protocol_negotiation, which were
introduced in commit d8d7c5dc8, by default, and fail the connection if
the server attempts to claim support for them. The hope is to provide
feedback to noncompliant implementations and gain confidence in our
ability to advance the protocol. (See the other commit for details.)

To help end users navigate the situation, a link to our documentation
that explains the behavior is displayed. We append this to the error
message when the NegotiateProtocolVersion response is incorrect, or when
the peer sends an error during startup that appears to be grease-
related.

It's still possible for users to connect to servers that don't support
protocol negotiation, by adding max_protocol_version=3.0 to their
connection strings. Only the default connection behavior is impacted.

This commit is tracked as a PG19 open item and will be reverted before
RC1. (The implementation here doesn't handle negotiation with later
server versions, so it can't be released into the wild as a
five-year-supported feature. But an improved implementation might be
able to do so, in the future...)

Author: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Co-authored-by: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Discussion: https://postgr.es/m/DDPR5BPWH1RJ.1LWAK6QAURVAY%40jeltef.nl

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4966bd3ed95e0d02bf220c4bad2b292963827dd4

Modified Files
--------------
doc/src/sgml/libpq.sgml | 17 ++++++++
doc/src/sgml/protocol.sgml | 11 +++++
src/interfaces/libpq/fe-connect.c | 51 +++++++++++++++++++-----
src/interfaces/libpq/fe-misc.c | 18 +++++++++
src/interfaces/libpq/fe-protocol3.c | 51 ++++++++++++++++++++++--
src/interfaces/libpq/libpq-int.h | 1 +
src/test/modules/libpq_pipeline/libpq_pipeline.c | 6 +--
7 files changed, 140 insertions(+), 15 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-02-23 20:26:10 pgsql: Use LOCKMODE in parse_relation.c/.h
Previous Message Tom Lane 2026-02-23 18:34:34 pgsql: Restore AIX support.

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2026-02-23 19:07:23 Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
Previous Message Srirama Kucherlapati 2026-02-23 18:27:26 RE: AIX support