pgsql: libpq: Handle NegotiateProtocolVersion message differently

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: libpq: Handle NegotiateProtocolVersion message differently
Date: 2025-04-02 13:43:17
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

libpq: Handle NegotiateProtocolVersion message differently

Previously libpq would always error out if the server sends a
NegotiateProtocolVersion message. This was fine because libpq only
supported a single protocol version and did not support any protocol
parameters. But in the upcoming commits, we will introduce a new
protocol version and the NegotiateProtocolVersion message starts to
actually be used.

This patch modifies the client side checks to allow a range of
supported protocol versions, instead of only allowing the exact
version that was requested. Currently this "range" only contains the
3.0 version, but in a future commit we'll change this.

Also clarify the error messages, making them suitable for the world
where libpq will support multiple protocol versions and protocol
extensions.

Note that until the later commits that introduce new protocol version,
this change does not have any behavioural effect, because libpq will
only request version 3.0 and will never send protocol parameters, and
therefore will never receive a NegotiateProtocolVersion message from
the server.

Author: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com> (earlier versions)
Discussion: https://www.postgresql.org/message-id/CAGECzQTfc_O%[email protected]
Discussion: https://www.postgresql.org/message-id/CAGECzQRbAGqJnnJJxTdKewTsNOovUt4bsx3NFfofz3m2j-t7tA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5070349102af12832c8528651c8ed18b16346323

Modified Files
--------------
src/interfaces/libpq/fe-connect.c | 13 +++++-
src/interfaces/libpq/fe-protocol3.c | 91 +++++++++++++++++++++++--------------
src/interfaces/libpq/libpq-int.h | 2 +
3 files changed, 71 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-04-02 15:13:18 pgsql: Need to do CommandCounterIncrement after StoreAttrMissingVal.
Previous Message Peter Eisentraut 2025-04-02 12:47:19 pgsql: Fix code comment