Re: libpq support for NegotiateProtocolVersion - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: libpq support for NegotiateProtocolVersion
Date
Msg-id 20221013210052.GA1567571@nathanxps13
Whole thread Raw
In response to libpq support for NegotiateProtocolVersion  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: libpq support for NegotiateProtocolVersion  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
List pgsql-hackers
On Thu, Oct 13, 2022 at 10:33:01AM +0200, Peter Eisentraut wrote:
> +    if (their_version != conn->pversion)

Shouldn't this be 'their_version < conn->pversion'?  If the server supports
a later protocol than what is requested but not all the requested protocol
extensions, I think libpq would still report "protocol version not
supported."

> +        appendPQExpBuffer(&conn->errorMessage,
> +                          libpq_gettext("protocol version not supported by server: client uses %d.%d, server
supports%d.%d\n"),
 
> +                          PG_PROTOCOL_MAJOR(conn->pversion), PG_PROTOCOL_MINOR(conn->pversion),
> +                          PG_PROTOCOL_MAJOR(their_version), PG_PROTOCOL_MINOR(their_version));

Should this match the error in postmaster.c and provide the range of
versions the server supports?  The FATAL in postmaster.c is for the major
version, but I believe the same information is relevant when a
NegotiateProtocolVersion message is sent.

        ereport(FATAL,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("unsupported frontend protocol %u.%u: server supports %u.0 to %u.%u",

> +    else
> +        appendPQExpBuffer(&conn->errorMessage,
> +                          libpq_gettext("protocol extension not supported by server: %s\n"), buf.data);

nitpick: s/extension/extensions

What if neither the protocol version nor the requested extensions are
supported?  Right now, I think only the unsupported protocol version is
supported in that case, but presumably we could report both pretty easily.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: hash_xlog_split_allocate_page: failed to acquire cleanup lock
Next
From: Corey Huinker
Date:
Subject: WIP: Analyze whether our docs need more granular refentries.