RE: Psql meta-command conninfo+

Поиск
Список
Период
Сортировка
От Maiquel Grassi
Тема RE: Psql meta-command conninfo+
Дата
Msg-id CP8P284MB2496B51FC5ED9BD6527D459DEC462@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на Re: Psql meta-command conninfo+  (Erik Wienhold <ewie@ewie.name>)
Ответы Re: Psql meta-command conninfo+  (Nathan Bossart <nathandbossart@gmail.com>)
Список pgsql-hackers
  On 2024-02-06 19:19 +0100, Nathan Bossart wrote:
  > On Tue, Feb 06, 2024 at 05:27:01PM +0000, Maiquel Grassi wrote:
  > > postgres=# \conninfo+
  > >  Current Connection Information
  > >    Attribute    |     Value
  > > ----------------+----------------
  > >  Database       | postgres
  > >  User           | postgres
  > >  Server Version | 16.1
  > >  Server Address | 192.168.0.5/32
  > >  Server Port    | 5433
  > >  Client Address | 192.168.0.5/32
  > >  Client Port    | 52716
  > >  Session PID    | 21624
  > > (8 rows)
  >
  > My first reaction is that this should instead return a single row with the
  > same set of columns for any connection type (the not-applicable ones would
  > just be set to NULL).  That would match the other meta-commands like \l and
  > \du, and you could still get an expanded display with \x if needed.  Also,
  > I think it would simplify the code a bit.
 
  +1 for a single-row result and triggering expanded display with \x for
  consistency with other commands.

--//--

I made the adjustment in the code and updated the patch. I believe this is the format suggested by you all. Would this be it?

[postgres@localhost bin]$ ./psql -h 192.168.0.220 -p 5433 -U postgres -d 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.220" at port "5433".
postgres=# \conninfo+
  Current Connection Information
   Attribute    |      Value
----------------+------------------
 Database       | postgres
 User           | postgres
 Server Version | 16.1
 Server Address | 192.168.0.220/32
 Server Port    | 5433
 Client Address | 192.168.0.220/32
 Client Port    | 56606
 Session PID    | 2424
(8 rows)

[postgres@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
   Attribute    |  Value
----------------+----------
 Database       | postgres
 User           | postgres
 Server Version | 17devel
 Server Address |
 Server Port    | 5432
 Client Address |
 Client Port    |
 Session PID    | 30216
(8 rows)

[postgres@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
   Attribute    |  Value
----------------+----------
 Database       | postgres
 User           | postgres
 Server Version | 17devel
 Server Address | ::1/128
 Server Port    | 5432
 Client Address | ::1/128
 Client Port    | 46872
 Session PID    | 30220
(8 rows)

[postgres@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
   Attribute    |    Value
----------------+--------------
 Database       | postgres
 User           | postgres
 Server Version | 17devel
 Server Address | 127.0.0.1/32
 Server Port    | 5432
 Client Address | 127.0.0.1/32
 Client Port    | 34924
 Session PID    | 30223
(8 rows)

Regards,
Maiquel O. Grassi.
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: Remove Start* macros from postmaster.c to ease understanding of code
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: glibc qsort() vulnerability