From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Robert Treat <rob@xzilla.net>
Cc: 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: Wed, 4 Jun 2025 20:18:13 +0900
Message-ID: <3e2e6f04-0a85-41a8-bf81-0ff727d23f0c@oss.nttdata.com> (raw)
In-Reply-To: <CABV9wwPOBELmYS5EWBNZJLu1Jjs346b8qWzbdc6fgH_u9VBpxA@mail.gmail.com>
References: <685961b8-b6ce-40bb-b2d5-c2ff135d3388@oss.nttdata.com>
<CAKFQuwasj8LyAg1VQ088fecb1ee8WfE-K2a7io380RB0+Tp67Q@mail.gmail.com>
<f31e3453-4ed6-4742-b290-e1ef332e3876@oss.nttdata.com>
<CAKFQuwZ3Pfx925Z2o8saMEhifL=A80oue5SCa1buv5H_GsD88g@mail.gmail.com>
<9e789ede-b56c-4a27-bb35-5b03e993a26b@oss.nttdata.com>
<CABV9wwPOBELmYS5EWBNZJLu1Jjs346b8qWzbdc6fgH_u9VBpxA@mail.gmail.com>
On 2025/06/03 20:22, Robert Treat wrote:
> +1 on the idea to put it there; if someone gets confused about the
> behavior, that seems like the place they'd go to look it up. Though I
> would wordsmith the patch a little:
>
> + Note that the <structfield>Client User</structfield> field
> shows the user at the time
> + of connection, while the
> <structfield>Superuser</structfield> field 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
> + <command>SET ROLE</command> command.
This looks good to me, thanks for the review! I've updated the patch (0002)
as you suggested and attached it.
I've also re-attached the 0001 patch that makes \conninfo report the full
protocol version, it's the same as the one I posted earlier in the thread.
Regards,
--
Fujii Masao
NTT DATA Japan Corporation
Attachments:download all (2 files, .tar.gz)v2-0001-psql-Report-full-protocol-version-in-conninfo-out.patch (text/plain, 1.6K) download
From fd2af2d3e2d98f015afecd532a33985b2758f0b3 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Mon, 2 Jun 2025 13:22:36 +0900
Subject: [PATCH v2 1/2] 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.cindex 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
v2-0002-doc-Add-note-about-Client-User-and-Superuser-fiel.patch (text/plain, 1.7K) download
From ed85ff0365ab30f629415dc9fa9a141b84cd08ff Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Tue, 3 Jun 2025 16:39:50 +0900
Subject: [PATCH v2 2/2] doc: Add note about "Client User" and "Superuser"
fields in \conninfo output.
In the \conninfo psql command, the "Client User" column shows the user who
established the 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, for example, if the current
user was changed with the SET ROLE command.
This commit adds a note to the \conninfo documentation to clarify
this behavior and avoid potential confusion.
---
doc/src/sgml/ref/psql-ref.sgml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgmlindex 8f7d8758ca0..97d6327ed3b 100644--- a/doc/src/sgml/ref/psql-ref.sgml+++ b/doc/src/sgml/ref/psql-ref.sgml@@ -1103,6 +1103,15 @@ SELECT $1 \parse stmt1
Outputs information about the current database connection,
including TLS-related information if TLS is in use.
</para>
+ <para>+ Note that the <structfield>Client User</structfield> field shows+ the user at the time of connection, while the+ <structfield>Superuser</structfield> field 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+ <command>SET ROLE</command> command.+ </para>
</listitem>
</varlistentry>
--
2.49.0
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, rob@xzilla.net, david.g.johnston@gmail.com
Subject: Re: Suggestions for improving \conninfo output in v18
In-Reply-To: <3e2e6f04-0a85-41a8-bf81-0ff727d23f0c@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> <CAKFQuwZ3Pfx925Z2o8saMEhifL=A80oue5SCa1buv5H_GsD88g@mail.gmail.com> <9e789ede-b56c-4a27-bb35-5b03e993a26b@oss.nttdata.com> <CABV9wwPOBELmYS5EWBNZJLu1Jjs346b8qWzbdc6fgH_u9VBpxA@mail.gmail.com> <3e2e6f04-0a85-41a8-bf81-0ff727d23f0c@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