Re: psql: Add role's membership options to the \du+ command
Pavel Luzanov <p.luzanov@postgrespro.ru>
From: Pavel Luzanov <p.luzanov@postgrespro.ru>
To: "David G. Johnston" <david.g.johnston@gmail.com>,
David Zhang <david.zhang@highgo.ca>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2023-02-17T11:02:01Z
Lists: pgsql-hackers
Hello,
> On the one hand, it would be nice to see the membership options with
> the psql command.
After playing with cf5eb37c and e5b8a4c0 I think something must be made
with \du command.
postgres@demo(16.0)=# CREATE ROLE admin LOGIN CREATEROLE;
CREATE ROLE
postgres@demo(16.0)=# \c - admin
You are now connected to database "demo" as user "admin".
admin@demo(16.0)=> SET createrole_self_grant = 'SET, INHERIT';
SET
admin@demo(16.0)=> CREATE ROLE bob LOGIN;
CREATE ROLE
admin@demo(16.0)=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
admin | Create role
| {bob,bob}
bob | | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
| {}
We see two bob roles in the 'Member of' column.Strange? But this is correct.
admin@demo(16.0)=> select roleid::regrole, member::regrole, * from
pg_auth_members where roleid = 'bob'::regrole;
roleid | member | oid | roleid | member | grantor | admin_option |
inherit_option | set_option
--------+--------+-------+--------+--------+---------+--------------+----------------+------------
bob | admin | 16713 | 16712 | 16711 | 10 | t |
f | f
bob | admin | 16714 | 16712 | 16711 | 16711 | f |
t | t
(2 rows)
First 'grant bob to admin' command issued immediately after creating
role bob by superuser(grantor=10). Second command issues by admin role
and set membership options SET and INHERIT.
If we don't ready to display membership options with \du+ may be at
least we must group records in 'Member of' column for \du command?
-----
Pavel Luzanov
Commits
-
Add psql \drg command to display role grants.
- d65ddaca93f6 17.0 landed
- 0a1d2a7df852 16.0 landed