RE: Psql meta-command conninfo+

From: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
To: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Psql meta-command conninfo+
Date: 2024-02-07 14:47:31
Message-ID: CP8P284MB24961361A9C1D32C28A7EC0EEC452@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is a good idea about extended connection info.

On 07.02.2024 07:13, Maiquel Grassi wrote:
SELECT
...
current_user AS "User",

This will be inconsistent with \conninfo.
\conninfo returns authenticated user (PQuser), not the current_user.
It might be worth showing current_user, session_user, and authenticated user,
but I can't find the appropriate sql function for PQuser.

What about to include system_user function? It shows useful authentication details.

Also, it seems that the verbose parameter in the listConnectionInformation
is unnecessary.

--//--

Hi,

Tks Pavel.

Analyzing the functions' code more thoroughly, it seems to make more sense.
I liked your suggestions and implemented them for validation.
Regarding "system_user," I believe it is valid and also added it to the row.

"Also, it seems that the verbose parameter in the listConnectionInformation is unnecessary."
Could you point out exactly the line or code snippet you are referring to?

To print the string from the "Authenticated User" column, I chose to use PQuser(pset.db) directly. I did the same for the "Host" column, opting for PQhost(pset.db). This does not contradict the result of \conninfo.

Here are the tests as usual, and v6 patch.

[postgres(at)localhost bin]$ ./psql
psql (17devel)
Type "help" for help.

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | Current User | Session User | System User | Server Version | Server Address | Server Port | Client Address | Client Port | Session PID | Socket Directory | Host
----------+--------------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+-------------+------------------+------
postgres | postgres | postgres | postgres | | 17devel | | 5432 | | | 17240 | /tmp |
(1 row)

postgres=# \q
[postgres(at)localhost bin]$ ./psql -h ::1
psql (17devel)
Type "help" for help.

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "::1" at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | Current User | Session User | System User | Server Version | Server Address | Server Port | Client Address | Client Port | Session PID | Socket Directory | Host
----------+--------------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+-------------+------------------+------
postgres | postgres | postgres | postgres | | 17devel | ::1 | 5432 | ::1 | 47024 | 17242 | /tmp | ::1
(1 row)

postgres=# \q
[postgres(at)localhost bin]$ ./psql -h 127.0.0.1
psql (17devel)
Type "help" for help.

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "127.0.0.1" at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | Current User | Session User | System User | Server Version | Server Address | Server Port | Client Address | Client Port | Session PID | Socket Directory | Host
----------+--------------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+-------------+------------------+-----------
postgres | postgres | postgres | postgres | | 17devel | 127.0.0.1 | 5432 | 127.0.0.1 | 35076 | 17245 | /tmp | 127.0.0.1
(1 row)

postgres=# \q
[postgres(at)localhost bin]$ ./psql -h localhost
psql (17devel)
Type "help" for help.

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "localhost" (address "::1") at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | Current User | Session User | System User | Server Version | Server Address | Server Port | Client Address | Client Port | Session PID | Socket Directory | Host
----------+--------------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+-------------+------------------+-----------
postgres | postgres | postgres | postgres | | 17devel | ::1 | 5432 | ::1 | 47028 | 17248 | /tmp | localhost
(1 row)

postgres=# \q
[postgres(at)localhost bin]$ ./psql -h 192.168.0.5 -p 5433 -d postgres -U postgres
psql (17devel, server 16.1)
Type "help" for help.

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "192.168.0.5" at port "5433".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | Current User | Session User | System User | Server Version | Server Address | Server Port | Client Address | Client Port | Session PID | Socket Directory | Host
----------+--------------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+-------------+------------------+-------------
postgres | postgres | postgres | postgres | | 16.1 | 192.168.0.5 | 5433 | 192.168.0.5 | 60115 | 28896 | | 192.168.0.5
(1 row)

Regards,
Maiquel O. Grassi.

Attachment Content-Type Size
v6-0001-psql-meta-command-conninfo-plus.patch application/octet-stream 8.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2024-02-07 14:52:02 Re: pgjdbc is not working with PKCS8 certificates with password
Previous Message Stephen Frost 2024-02-07 14:43:23 Re: Set log_lock_waits=on by default