pgsql: libpq: Grease the protocol by default
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@jeltef.nl>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: /messages/by-id/DDPR5BPWH1RJ.1LWAK6QAURVAY@jeltef.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(-)
On Mon, Feb 23, 2026 at 10:58 AM Jacob Champion
<jchampion@postgresql.org> wrote:
libpq: Grease the protocol by default
crake is angry:
pg_dumpall: error: connection to server on socket "/home/andrew/bf/root/tmp/buildfarm-onigY7/.s.PGSQL.5670" failed: FATAL: unsupported frontend protocol 3.9999: server supports 1.0 to 3.0
This indicates a bug in either the server being contacted
or a proxy handling the connection. Please consider
...
So while this is kind of a nice result, in that it's correctly
diagnosing the problem, I need to add max_protocol_version=3.0 to the
connection strings for these upgrades during beta.
--Jacob
On Mon, 23 Feb 2026 at 22:17, Jacob Champion
<jacob.champion@enterprisedb.com> wrote:
So while this is kind of a nice result, in that it's correctly
diagnosing the problem, I need to add max_protocol_version=3.0 to the
connection strings for these upgrades during beta.
Two thoughts:
1. I think we might want the "This indicates a bug in either the
server being contacted..." note to be added to the error even if you
use 3.2/3.3/3.X. It seems pretty helpful in general. It would need a
bit fancier detection though, with strings to search for based on the
actual requested version.
2. Why only force max_protocol_version=3.0 for beta? It sounds like
this would also be an issue once we eventually bump the default
version.