libpq: Grease the protocol by default
Jacob Champion <jchampion@postgresql.org>
Author:
Jacob Champion <jchampion@postgresql.org>
Date: 2026-02-23T18:48:20Z
Releases:
19 (unreleased)
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: https://postgr.es/m/DDPR5BPWH1RJ.1LWAK6QAURVAY%40jeltef.nl
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/libpq.sgml | modified | +17 −0 |
| doc/src/sgml/protocol.sgml | modified | +11 −0 |
| src/interfaces/libpq/fe-connect.c | modified | +42 −9 |
| src/interfaces/libpq/fe-misc.c | modified | +18 −0 |
| src/interfaces/libpq/fe-protocol3.c | modified | +48 −3 |
| src/interfaces/libpq/libpq-int.h | modified | +1 −0 |
| src/test/modules/libpq_pipeline/libpq_pipeline.c | modified | +3 −3 |
Discussion
- libpq: Bump protocol version to version 3.2 at least until the first/second beta 31 messages · 2025-10-23 → 2026-02-23