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 <postg...@jeltef.nl> Reviewed-by: Robert Haas <robertmh...@gmail.com> (earlier versions) Discussion: https://www.postgresql.org/message-id/cageczqtfc_o%2bhxqao5_-xg4r3efvstefueqzsvheyyldba-...@mail.gmail.com Discussion: https://www.postgresql.org/message-id/cageczqrbagqjnnjjxtdkewtsnoovut4bsx3nffofz3m2j-t...@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(-)