Re: Psql meta-command conninfo+

From: Hunaid Sohail <hunaidpgml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, pgsql-hackers(at)postgresql(dot)org, Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, "Imseih (AWS), Sami" <simseih(at)amazon(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Erik Wienhold <ewie(at)ewie(dot)name>
Subject: Re: Psql meta-command conninfo+
Date: 2024-09-17 11:53:02
Message-ID: CAMWA6ybtLkLqmFZxYZ2Cjj73WxBWu5n3Wa3g=3VhBVKs3_9wTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Sep 16, 2024 at 8:31 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > On 2024-Sep-16, Jim Jones wrote:
> >> * The value of "Current User" does not match the function current_user()
> >> --- as one might expcect. It is a little confusing, as there is no
> >> mention of "Current User" in the docs. In case this is the intended
> >> behaviour, could you please add it to the docs?
>
> > It is intended. As Peter said[1], what we wanted was to display
> > client-side info, so PQuser() is the right thing to do. Now maybe
> > "Current User" is not the perfect column header, but at least the
> > definition seems consistent with the desired end result.
>
> Seems like "Session User" would be closer to being accurate, since
> PQuser()'s result does not change when you do SET ROLE etc.
>
> > Now, I think
> > the current docs saying to look at session_user() are wrong, they should
> > point to the libpq docs for the function instead; something like "The
> > name of the current user, as returned by PQuser()" and so on.
>
> Sure, but this does not excuse choosing a misleading column name
> when there are better choices readily available.
>

Maybe we can rename "Current User" to "Authenticated User" just like the
previous author because it is a user returned by PQuser().

For the "Session User", I believe it is working as expected, since
session_user can be changed with SET SESSION AUTHORIZATION.

```
$ bin/psql "port=5430 sslmode=disable dbname=postgres" -x -h localhost

postgres=# \conninfo+
Connection Information
-[ RECORD 1 ]--------+----------
Database | postgres
Current User | hunaid
Session User | hunaid
Host | localhost
Host Address | 127.0.0.1
Port | 5430
Protocol Version | 3
SSL Connection | false
GSSAPI Authenticated | false
Client Encoding | UTF8
Server Encoding | UTF8
Backend PID | 1337

postgres=# set SESSION AUTHORIZATION postgres;
SET
postgres=# \conninfo+
Connection Information
-[ RECORD 1 ]--------+----------
Database | postgres
Current User | hunaid
Session User | postgres
Host | localhost
Host Address | 127.0.0.1
Port | 5430
Protocol Version | 3
SSL Connection | false
GSSAPI Authenticated | false
Client Encoding | UTF8
Server Encoding | UTF8
Backend PID | 1337
```

We can update the docs as follows:
Authenticated User: The name of the user returned by PQuser().
Session User: The session user's name.

Opinions?

Regards,
Hunaid Sohail

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Benoit Lobréau 2024-09-17 12:22:59 Re: Parallel workers stats in pg_stat_database
Previous Message Nazir Bilal Yavuz 2024-09-17 11:52:01 Re: per backend I/O statistics