Re: Things I don't like about \du's "Attributes" column

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Things I don't like about \du's "Attributes" column
Дата
Msg-id CAKFQuwa4okxwk4xYkf7K2ghVs8jFS8+7cHPMzkKAqtYJ9d-i=A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Things I don't like about \du's "Attributes" column  (Pavel Luzanov <p.luzanov@postgrespro.ru>)
Ответы Re: Things I don't like about \du's "Attributes" column
Список pgsql-hackers
On Sun, Jan 21, 2024 at 2:35 PM Pavel Luzanov <p.luzanov@postgrespro.ru> wrote:
Another approach based on early suggestions.

The Attributes column includes only the enabled logical attributes.
Regardless of whether the attribute is enabled by default or not.
 
The attribute names correspond to the keywords of the CREATE ROLE command.
The attributes are listed in the same order as in the documentation.
(I think that the LOGIN attribute should be moved to the first place,
both in the documentation and in the command.)
I'd just flip INHERIT and LOGIN
 
The "Connection limit" and "Valid until" attributes are placed in separate columns.
The "Password?" column has been added.

Sample output.

Patch v3:
=# \du                                                             List of roles Role name |                            Attributes                             | Password? |      Valid until       | Connection limit 
-----------+-------------------------------------------------------------------+-----------+------------------------+------------------ admin     | INHERIT                                                           | no        |                        |               -1 alice     | SUPERUSER LOGIN                                                   | yes       | infinity               |                5 bob       | CREATEDB INHERIT LOGIN REPLICATION BYPASSRLS                      | no        | 2022-01-01 00:00:00+03 |               -1 charlie   | CREATEROLE INHERIT LOGIN                                          | yes       |                        |                0 postgres  | SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN REPLICATION BYPASSRLS | no        |                        |               -1
(5 rows)
 
Small modification with newline separator for Attributes column:

Patch v3 with newlines:
=# \du                                  List of roles Role name | Attributes  | Password? |      Valid until       | Connection limit 
-----------+-------------+-----------+------------------------+------------------ postgres  | SUPERUSER  +| no        |                        |               -1           | CREATEDB   +|           |                        |            | CREATEROLE +|           |                        |            | INHERIT    +|           |                        |            | LOGIN      +|           |                        |            | REPLICATION+|           |                        |            | BYPASSRLS   |           |                        | 
(5 rows)

I'm strongly in favor of using mixed-case for the attributes.  The SQL Command itself doesn't care about capitalization and it is much easier on the eyes.  I'm also strongly in favor of newlines, as can be seen by the default bootstrap superuser entry putting everything on one line eats up 65 characters.

                                    List of roles
 Role name | Attributes  | Password? | Valid until | Connection limit | Description
-----------+-------------+-----------+-------------+------------------+-------------
 davidj    | Superuser  +| no        |             |               -1 |
           | CreateDB   +|           |             |                  |
           | CreateRole +|           |             |                  |
           | Inherit    +|           |             |                  |
           | Login      +|           |             |                  |
           | Replication+|           |             |                  |
           | BypassRLS   |           |             |                  |
(1 row)

As noted by Peter this patch didn't update the two affected expected output files. psql.out and, due to the system view change, rules.out.  That particular change requires a documentation update to the pg_roles system view page.  I'd suggest pulling out this system view change into its own patch.

I will take another pass later when I get some more time.  I want to re-review some of the older messages.  But the tweaks I show and breaking out the view changes in to a separate patch both appeal to me right now.

David J.

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

Предыдущее
От: Christoph Berg
Дата:
Сообщение: Re: psql: Allow editing query results with \gedit
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: WIP Incremental JSON Parser