pqcomm.h: Explicitly reserve protocol v3.1
authorJacob Champion <jchampion@postgresql.org>
Fri, 23 Jan 2026 20:57:15 +0000 (12:57 -0800)
committerJacob Champion <jchampion@postgresql.org>
Fri, 23 Jan 2026 20:57:15 +0000 (12:57 -0800)
Document this unused version alongside the other special protocol
numbers.

Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOYmi%2BkKyw%3Dh-5NKqqpc7HC5M30_QmzFx3kgq2AdipyNj47nUw%40mail.gmail.com

src/include/libpq/pqcomm.h
src/interfaces/libpq/fe-protocol3.c

index 6df6e0f902dec9b1eeda043086e2400a6cd40009..1bbe5b9ee452421ceddf3dd4993f41685223dc33 100644 (file)
@@ -98,6 +98,12 @@ is_unixsock_path(const char *path)
  * Reserved protocol numbers, which have special semantics:
  */
 
+/*
+ * 3.1 would have collided with old pgbouncer deployments, and was skipped. We
+ * neither emit it nor accept it on the wire.
+ */
+#define PG_PROTOCOL_RESERVED_31        PG_PROTOCOL(3,1)
+
 /*
  * A client can send a cancel-current-operation request to the postmaster.
  * This is uglier than sending it directly to the client's backend, but it
index 34518bbe6ea19871ff26d47640fc5806dcd6ab44..103428033ef8e1ee6bf082bc97e5639000bc85be 100644 (file)
@@ -1465,7 +1465,7 @@ pqGetNegotiateProtocolVersion3(PGconn *conn)
    }
 
    /* 3.1 never existed, we went straight from 3.0 to 3.2 */
-   if (their_version == PG_PROTOCOL(3, 1))
+   if (their_version == PG_PROTOCOL_RESERVED_31)
    {
        libpq_append_conn_error(conn, "received invalid protocol negotiation message: server requested downgrade to non-existent 3.1 protocol version");
        goto failure;