pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Suggestions for improving \conninfo output in v18
Date: Mon, 2 Jun 2025 15:39:54 +0900
Message-ID: <f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com> (raw)
In-Reply-To: <CAKFQuwasj8LyAg1VQ088fecb1ee8WfE-K2a7io380RB0+Tp67Q@mail.gmail.com>
References: <685961b8-b6ce-40bb-b2d5-c2ff135d3388@oss.nttdata.com>
	<CAKFQuwasj8LyAg1VQ088fecb1ee8WfE-K2a7io380RB0+Tp67Q@mail.gmail.com>



On 2025/06/02 14:24, David G. Johnston wrote:
> On Sunday, June 1, 2025, Fujii Masao <masao.fujii@oss.nttdata.com <mailto:masao.fujii@oss.nttdata.com>> wrote:
> 
>     In v18, the "Protocol Version" column shown by \conninfo reports only
>     the major version (e.g., 3). Wouldn't it be more helpful to show the full
>     version (e.g., 3.2) using PQfullProtocolVersion()? Since support for
>     protocol version 3.2 was introduced in v18, users may want to know
>     exactly which version the current session is using.
> 
> 
> This seems like a probable oversight that should be corrected.

Patch attached.


>     Also, I noticed that the "Client User" column reflects the user at
>     the time of connection, while the "Superuser" column reflects whether
>     the current user in the current execution context is a superuser.
>     This means the users referred to in these columns can differ.
>     It might be worth aligning this behavior, or at least noting the distinction
>     clearly in the documentation?
> 
> 
> The behavior seems consistent with the reality of our protocol and libpq.  What did you have in mind for documentation changes?

How about adding a note like this?

----------------------
Note that the "Superuser" column does not necessarily reflect the privileges of the user shown in "Client User". "Client User" shows the user at the time of connection, while "Superuser" indicates whether the current user (in the current execution context) has superuser privileges. These users are usually the same, but they can differ, for example, if the current user was changed with the SET ROLE command.
----------------------

The same question also came up previously in [1],
but seems no clear consensus was reached at that time.

Regards,

[1] https://www.postgresql.org/message-id/CAA5RZ0tbWopM83akPZ5M42V_RtyMTV8UfNUdE9LYw0YsPdOX5g%40mail.gma...

-- 
Fujii Masao
NTT DATA Japan Corporation

Attachments:

v1-0001-psql-Report-full-protocol-version-in-conninfo-out.patch (text/plain, 1.6K) download From 36c36eae542a0f04187b2b773b64962826f9eef2 Mon Sep 17 00:00:00 2001 From: Fujii Masao <fujii@postgresql.org> Date: Mon, 2 Jun 2025 13:22:36 +0900 Subject: [PATCH v1] psql: Report full protocol version in \conninfo output. Commit bba2fbc6238 modified \conninfo to display the protocol version used by the current connection, but it only showed the major version (e.g., 3). This commit updates \conninfo to display the full protocol version (e.g., 3.2). Since support for new version 3.2 was added in v18, and the server supports both 3.0 and 3.2, showing the complete version helps users understand exactly which protocol version the current session is using. --- src/bin/psql/command.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 81a5ba844ba..1f7635d0c23 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -778,6 +778,7 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch) int ssl_in_use, password_used, gssapi_used; + int version_num; char *paramval; if (!active_branch) @@ -793,7 +794,9 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch) /* Get values for the parameters */ host = PQhost(pset.db); hostaddr = PQhostaddr(pset.db); - protocol_version = psprintf("%d", PQprotocolVersion(pset.db)); + version_num = PQfullProtocolVersion(pset.db); + protocol_version = psprintf("%d.%d", version_num / 10000, + version_num % 10000); ssl_in_use = PQsslInUse(pset.db); password_used = PQconnectionUsedPassword(pset.db); gssapi_used = PQconnectionUsedGSSAPI(pset.db); -- 2.49.0

view thread (13+ messages)  latest in thread

Message-ID: <f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com>
Permalink:  ../f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com/
Also on:    postgresql.org/message-id/f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, david.g.johnston@gmail.com
  Subject: Re: Suggestions for improving \conninfo output in v18
  In-Reply-To: <f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com>
  References: <685961b8-b6ce-40bb-b2d5-c2ff135d3388@oss.nttdata.com> <CAKFQuwasj8LyAg1VQ088fecb1ee8WfE-K2a7io380RB0+Tp67Q@mail.gmail.com> <f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox