pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: libpq: Handle NegotiateProtocolVersion message
2+ messages / 2 participants
[nested] [flat]

* pgsql: libpq: Handle NegotiateProtocolVersion message
@ 2022-11-17 14:47  Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2022-11-17 14:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

libpq: Handle NegotiateProtocolVersion message

Before, receiving a NegotiateProtocolVersion message would result in a
confusing error message like

    expected authentication request from server, but received v

This adds proper handling of this protocol message and produces an
on-topic error message from it.

Reviewed-by: Jacob Champion <jchampion@timescale.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/f9c7862f-b864-8ef7-a861-c4638c83e209%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bbf9c282ce92272ed7bf6771daf0f9efa209e61b

Modified Files
--------------
src/interfaces/libpq/fe-connect.c   | 22 +++++++++++----
src/interfaces/libpq/fe-protocol3.c | 55 +++++++++++++++++++++++++++++++++++++
src/interfaces/libpq/libpq-int.h    |  1 +
3 files changed, 73 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: libpq: Handle NegotiateProtocolVersion message differently
@ 2025-04-02 13:43  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 2+ messages in thread

From: Heikki Linnakangas @ 2025-04-02 13:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@jeltef.nl>
Reviewed-by: Robert Haas <robertmhaas@gmail.com> (earlier versions)
Discussion: https://www.postgresql.org/message-id/CAGECzQTfc_O%2BHXqAo5_-xG4r3EFVsTefUeQzSvhEyyLDba-O9w@mail.gma...
Discussion: https://www.postgresql.org/message-id/CAGECzQRbAGqJnnJJxTdKewTsNOovUt4bsx3NFfofz3m2j-t7tA@mail.gmail...

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-04-02 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 14:47 pgsql: libpq: Handle NegotiateProtocolVersion message Peter Eisentraut <peter@eisentraut.org>
2025-04-02 13:43 pgsql: libpq: Handle NegotiateProtocolVersion message differently Heikki Linnakangas <heikki.linnakangas@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox