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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>
Cc: Jim Nasby <jim(dot)nasby(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Things I don't like about \du's "Attributes" column
Date: 2024-01-22 22:59:59
Message-ID: CAKFQuwa4okxwk4xYkf7K2ghVs8jFS8+7cHPMzkKAqtYJ9d-i=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 21, 2024 at 2:35 PM Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2024-01-22 23:01:20 Re: WIP Incremental JSON Parser
Previous Message Christoph Berg 2024-01-22 22:54:36 Re: psql: Allow editing query results with \gedit