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

Pavel Luzanov <p.luzanov@postgrespro.ru>

From: Pavel Luzanov <p.luzanov@postgrespro.ru>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Jim Nasby <jim.nasby@gmail.com>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2024-06-06T09:08:48Z
Lists: pgsql-hackers

Attachments

On 16.04.2024 09:15, Pavel Luzanov wrote:
> On 16.04.2024 01:06, David G. Johnston wrote:
>> At this point I'm on board with retaining the \dr charter of simply being
>> an easy way to access the detail exposed in pg_roles with some display
>> formatting but without any attempt to convey how the system uses said
>> information.  Without changing pg_roles.  Our level of effort here, and
>> degree of dependence on superuser, doesn't seem to be bothering people
>> enough to push more radical changes here through and we have good
>> improvements that are being held up in the hope of possible perfection.
> I have similar thoughts. I decided to wait for the end of 
> featurefreeze and propose a simpler version of the patch for v18, 
> without changes in pg_roles

Since no votes for the changes in pg_roles, please look the simplified version.
We can return to this topic later.

Butnowthere are nochangesinpg_roles.  Just a special interpretation
of the two values of the "Connection limit" column:
   0 - Now allowed (changed from 'No connections')
  -1 - empty string

Full list of changes in commit message.

Example output:

\du+ regress_du*
                                                 List of roles
     Role name     | Login | Attributes  |         Valid until          | Connection limit |   Description
------------------+-------+-------------+------------------------------+------------------+------------------
  regress_du_admin | yes   | Superuser  +|                              |                  | some description
                   |       | Create DB  +|                              |                  |
                   |       | Create role+|                              |                  |
                   |       | Inherit    +|                              |                  |
                   |       | Replication+|                              |                  |
                   |       | Bypass RLS  |                              |                  |
  regress_du_role0 | yes   | Inherit     | Tue Jun 04 00:00:00 2024 PDT | Not allowed      |
  regress_du_role1 | no    | Create role+| infinity                     |                  |
                   |       | Inherit     |                              |                  |
  regress_du_role2 | yes   | Inherit    +|                              | 42               |
                   |       | Replication+|                              |                  |
                   |       | Bypass RLS  |                              |                  |
(4 rows)

Data:
CREATE ROLE regress_du_role0 LOGIN PASSWORD '123' VALID UNTIL '2024-06-04' CONNECTION LIMIT 0;
CREATE ROLE regress_du_role1 CREATEROLE CONNECTION LIMIT -1 VALID UNTIL 'infinity';
CREATE ROLE regress_du_role2 LOGIN REPLICATION BYPASSRLS CONNECTION LIMIT 42;
CREATE ROLE regress_du_admin LOGIN SUPERUSER CREATEROLE CREATEDB BYPASSRLS REPLICATION INHERIT;
COMMENT ON ROLE regress_du_admin IS 'some description';

-- 
Pavel Luzanov
Postgres Professional:https://postgrespro.com