pgsql: libpq: Add min/max_protocol_version connection options - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: libpq: Add min/max_protocol_version connection options
Date
Msg-id E1tzyNB-002IXY-0e@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
libpq: Add min/max_protocol_version connection options

All supported version of the PostgreSQL server send the
NegotiateProtocolVersion message when an unsupported minor protocol
version is requested by a client. But many other applications that
implement the PostgreSQL protocol (connection poolers, or other
databases) do not, and the same is true for PostgreSQL server versions
older than 9.3. Connecting to such other applications thus fails if a
client requests a protocol version different than 3.0.

This patch adds a max_protocol_version connection option to libpq that
specifies the protocol version that libpq should request from the
server. Currently only 3.0 is supported, but that will change in a
future commit that bumps the protocol version. Even after that version
bump the default will likely stay 3.0 for the time being. Once more of
the ecosystem supports the NegotiateProtocolVersion message we might
want to change the default to the latest minor version.

This also adds the similar min_protocol_version connection option, to
allow the client to specify that connecting should fail if a lower
protocol version is attempted by the server. This can be used to
ensure that certain protocol features are used, which can be
particularly useful if those features impact security.

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.gmail.com
Discussion: https://www.postgresql.org/message-id/CAGECzQRbAGqJnnJJxTdKewTsNOovUt4bsx3NFfofz3m2j-t7tA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/285613c60a7aff5daaf281c67002483b0d26e715

Modified Files
--------------
doc/src/sgml/libpq.sgml                          |  68 ++++++++++++++
doc/src/sgml/protocol.sgml                       |  33 +++++--
src/include/libpq/pqcomm.h                       |   3 +-
src/interfaces/libpq/fe-connect.c                |  88 +++++++++++++++++-
src/interfaces/libpq/fe-protocol3.c              |  18 ++++
src/interfaces/libpq/libpq-int.h                 |   4 +
src/test/modules/libpq_pipeline/libpq_pipeline.c | 113 ++++++++++++++++++++++-
7 files changed, 315 insertions(+), 12 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Fix code comment
Next
From: Tom Lane
Date:
Subject: pgsql: Need to do CommandCounterIncrement after StoreAttrMissingVal.