v14-0007-Bump-protocol-version-to-3.2.patch
application/octet-stream
Filename: v14-0007-Bump-protocol-version-to-3.2.patch
Type: application/octet-stream
Part: 5
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v14-0007
Subject: Bump protocol version to 3.2
| File | + | − |
|---|---|---|
| doc/src/sgml/libpq.sgml | 3 | 2 |
| src/include/libpq/pqcomm.h | 1 | 2 |
| src/interfaces/libpq/fe-connect.c | 8 | 0 |
From ca341c1c07bb5a40a3dae03c3cae8e78a7e52590 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Tue, 2 Jan 2024 11:19:54 +0100
Subject: [PATCH v14 7/9] Bump protocol version to 3.2
In preparation of new additions to the protocol in a follow up commit
this bumps the minor protocol version number. Instead of bumping the
version number to 3.1, which would be the next minor version, we skip
that one and bump straight to 3.2. The reason for this is that many
PgBouncer releases have, due to an off-by-one bug, reported 3.1 as
supported[1]. These versions would interpret 3.1 as equivalent to 3.0. So
if we would now add extra messages to the 3.1 protocol, clients would
succeed to connect to PgBouncer, but would then cause connection
failures when sending such new messages.
So instead of bumping to 3.1, we bump the protocol version to 3.2, for
which these buggy PgBouncer releases will correctly close the connection
at the startup packet. It's a bit strange to skip a version number due
to a bug in a third-party application, but PgBouncer is used widely
enough that it seems worth it to not cause user confusion when
connecting to recent versions of it. Especially since skipping a single
minor version number in the protocol versioning doesn't really cost us
anything. So, while this is not the most theoretically sound decission,
it is the most pragmatic one.
[1]: https://github.com/pgbouncer/pgbouncer/pull/1007
---
doc/src/sgml/libpq.sgml | 5 +++--
src/include/libpq/pqcomm.h | 3 +--
src/interfaces/libpq/fe-connect.c | 8 ++++++++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index edbceae9f34..2e475bca87e 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -2354,10 +2354,11 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The current supported values are
- <literal>3.0</literal>
+ <literal>3.0</literal>,
+ <literal>3.2</literal>,
and <literal>latest</literal>. The <literal>latest</literal> value is
equivalent to the latest protocol version that is supported by the used
- libpq version, which currently is <literal>3.0</literal>, but this will
+ libpq version, which currently is <literal>3.2</literal>, but this will
change in future libpq releases.
</para>
</listitem>
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index 6925f10602b..b93bc14f109 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -91,11 +91,10 @@ is_unixsock_path(const char *path)
/*
* The earliest and latest frontend/backend protocol version supported.
- * (Only protocol version 3 is currently supported)
*/
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(3,0)
-#define PG_PROTOCOL_LATEST PG_PROTOCOL(3,0)
+#define PG_PROTOCOL_LATEST PG_PROTOCOL(3,2)
typedef uint32 ProtocolVersion; /* FE/BE protocol version number */
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 76fb5312646..21f60c95b92 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1845,6 +1845,14 @@ pqConnectOptions2(PGconn *conn)
{
conn->max_pversion = PG_PROTOCOL_LATEST;
}
+ else if (strcmp(conn->max_protocol_version, "3.1") == 0)
+ {
+ conn->status = CONNECTION_BAD;
+ libpq_append_conn_error(conn, "invalid %s value: \"%s\"",
+ "max_protocol_version",
+ conn->max_protocol_version);
+ return false;
+ }
else
{
char *end;
--
2.34.1