Re: psql: Add role's membership options to the \du+ command

Поиск
Список
Период
Сортировка
От Pavel Luzanov
Тема Re: psql: Add role's membership options to the \du+ command
Дата
Msg-id e9ef999a-7dad-242a-9e71-fdc2901ad245@postgrespro.ru
обсуждение исходный текст
Ответ на Re: psql: Add role's membership options to the \du+ command  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: psql: Add role's membership options to the \du+ command
Re: psql: Add role's membership options to the \du+ command
Список pgsql-hackers
After playing with the \du command, I found that we can't avoid translation.

All attributes are translatable. Also, two of nine attributes shows in new line separated format (connection limit and password valid until).

$ LANGUAGE=fr psql -c "ALTER ROLE postgres CONNECTION LIMIT 3 VALID UNTIL 'infinity'" -c '\du'
ALTER ROLE
                                              Liste des rôles
 Nom du rôle |                                    Attributs                                    | Membre de
-------------+---------------------------------------------------------------------------------+-----------
 postgres    | Superutilisateur, Créer un rôle, Créer une base, Réplication, Contournement RLS+| {}
             | 3 connexions                                                                   +|
             | Mot de passe valide jusqu'à infinity                                            |


So I decided to keep the format suggested by David, but without abbreviations and only for extended mode.

$ psql -c '\duS+'
                                                         List of roles
          Role name          |          Attributes           |                     Member of                     | Description
-----------------------------+-------------------------------+---------------------------------------------------+-------------
 pg_checkpoint               | Cannot login                  |                                                   |
 pg_create_subscription      | Cannot login                  |                                                   |
 pg_database_owner           | Cannot login                  |                                                   |
 pg_execute_server_program   | Cannot login                  |                                                   |
 pg_maintain                 | Cannot login                  |                                                   |
 pg_monitor                  | Cannot login                  | pg_read_all_settings from postgres (inherit, set)+|
                             |                               | pg_read_all_stats from postgres (inherit, set)   +|
                             |                               | pg_stat_scan_tables from postgres (inherit, set)  |
 pg_read_all_data            | Cannot login                  |                                                   |
 pg_read_all_settings        | Cannot login                  |                                                   |
 pg_read_all_stats           | Cannot login                  |                                                   |
 pg_read_server_files        | Cannot login                  |                                                   |
 pg_signal_backend           | Cannot login                  |                                                   |
 pg_stat_scan_tables         | Cannot login                  |                                                   |
 pg_use_reserved_connections | Cannot login                  |                                                   |
 pg_write_all_data           | Cannot login                  |                                                   |
 pg_write_server_files       | Cannot login                  |                                                   |
 postgres                    | Superuser                    +|                                                   |
                             | Create role                  +|                                                   |
                             | Create DB                    +|                                                   |
                             | Replication                  +|                                                   |
                             | Bypass RLS                   +|                                                   |
                             | 3 connections                +|                                                   |
                             | Password valid until infinity |                                                   |


Please look at new version. I understand that this is a compromise choice.
I am ready to change it if a better solution is offered.

P.S. If no objections I plan to add this patch to Open Items for v16
https://wiki.postgresql.org/wiki/PostgreSQL_16_Open_Items

On 05.04.2023 17:24, David G. Johnston wrote:
On Wed, Apr 5, 2023 at 6:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Pavel Luzanov <p.luzanov@postgrespro.ru> writes:
> What if this long output will be available only for \du+, and for \du
> just show distinct (without duplicates)
> roles in the current array format? For those, who don't care about these
> new membership options, nothing will change.
> Those, who need details will use the + modifier.
> ?

I kind of like that.  Would we change to newlines in the Attributes
field in both \du and \du+?  (I'm +1 for that, but maybe others aren't.)


If we don't change the \du "Member of" column display (aside from removing duplicates) I'm disinclined to change the Attributes column.

I too am partial to only exposing this detail on the extended (+) display.

David J.


-- 
Pavel Luzanov
Postgres Professional: https://postgrespro.com
Вложения

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

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Protecting allocator headers with Valgrind
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: longfin missing gssapi_ext.h