From: | Shinya Kato <Shinya11(dot)Kato(at)oss(dot)nttdata(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Remove duplicates of membership from results of \du |
Date: | 2023-05-06 13:37:04 |
Message-ID: | 322f8809-4bb7-6e00-c7f5-c0bf6449d29b@oss.nttdata.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi, hackers
When executing \du, you can see duplicates of the same role in 'member of'.
This happens when admin | inherit | set options are granted by another role.
---
postgres=# create role role_a login createrole;
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
role_a | Create role
| {}
shinya | Superuser, Create role, Create DB, Replication, Bypass RLS
| {}
postgres=# set role role_a;
SET
postgres=> create role role_b;
CREATE ROLE
postgres=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
role_a | Create role
| {role_b}
role_b | Cannot login
| {}
shinya | Superuser, Create role, Create DB, Replication, Bypass RLS
| {}
postgres=> grant role_b to role_a;
GRANT ROLE
postgres=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------------
role_a | Create role
| {role_b,role_b}
role_b | Cannot login
| {}
shinya | Superuser, Create role, Create DB, Replication, Bypass RLS
| {}
postgres=> select rolname, oid from pg_roles where rolname = 'role_b';
rolname | oid
---------+-------
role_b | 16401
(1 row)
postgres=> select * from pg_auth_members where roleid = 16401;
oid | roleid | member | grantor | admin_option | inherit_option |
set_option
-------+--------+--------+---------+--------------+----------------+------------
16402 | 16401 | 16400 | 10 | t | f | f
16403 | 16401 | 16400 | 16400 | f | t | t
(2 rows)
---
Attached patch resolves this issue.
Do you think?
Regards,
Shinya Kato
Attachment | Content-Type | Size |
---|---|---|
v1_0001_remove_duplicates_membership.patch | text/x-patch | 673 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Drouvot, Bertrand | 2023-05-06 16:02:10 | Re: Add two missing tests in 035_standby_logical_decoding.pl |
Previous Message | Amit Kapila | 2023-05-06 13:28:42 | Re: Add two missing tests in 035_standby_logical_decoding.pl |