mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Add psql \drg command to display role grants.
With the addition of INHERIT and SET options for role grants, the historical display of role memberships in \du/\dg is woefully inadequate. Besides those options, there are pre-existing shortcomings that you can't see the ADMIN option nor the grantor. To fix this, remove the "Member of" column from \du/\dg altogether (making that output usefully narrower), and invent a new meta-command "\drg" that is specifically for displaying role memberships. It shows one row for each role granted to the selected role(s), with the grant options and grantor. We would not normally back-patch such a feature addition post feature freeze, but in this case the change is mainly driven by v16 changes in the server, so it seems appropriate to include it in v16. Pavel Luzanov, with bikeshedding and review from a lot of people, but particularly David Johnston Discussion: https://postgr.es/m/b9be2d0e-a9bc-0a30-492f-a4f68e4f7740@postgrespro.ru
This commit is contained in:
@@ -1823,3 +1823,29 @@ DROP FUNCTION psql_error;
|
||||
\dP "no.such.database"."no.such.schema"."no.such.partitioned.relation"
|
||||
\dT "no.such.database"."no.such.schema"."no.such.data.type"
|
||||
\dX "no.such.database"."no.such.schema"."no.such.extended.statistics"
|
||||
|
||||
-- check \drg and \du
|
||||
CREATE ROLE regress_du_role0;
|
||||
CREATE ROLE regress_du_role1;
|
||||
CREATE ROLE regress_du_role2;
|
||||
CREATE ROLE regress_du_admin;
|
||||
|
||||
GRANT regress_du_role0 TO regress_du_admin WITH ADMIN TRUE;
|
||||
GRANT regress_du_role1 TO regress_du_admin WITH ADMIN TRUE;
|
||||
GRANT regress_du_role2 TO regress_du_admin WITH ADMIN TRUE;
|
||||
|
||||
GRANT regress_du_role0 TO regress_du_role1 WITH ADMIN TRUE, INHERIT TRUE, SET TRUE GRANTED BY regress_du_admin;
|
||||
GRANT regress_du_role0 TO regress_du_role2 WITH ADMIN TRUE, INHERIT FALSE, SET FALSE GRANTED BY regress_du_admin;
|
||||
GRANT regress_du_role1 TO regress_du_role2 WITH ADMIN TRUE , INHERIT FALSE, SET TRUE GRANTED BY regress_du_admin;
|
||||
GRANT regress_du_role0 TO regress_du_role1 WITH ADMIN FALSE, INHERIT TRUE, SET FALSE GRANTED BY regress_du_role1;
|
||||
GRANT regress_du_role0 TO regress_du_role2 WITH ADMIN FALSE, INHERIT TRUE , SET TRUE GRANTED BY regress_du_role1;
|
||||
GRANT regress_du_role0 TO regress_du_role1 WITH ADMIN FALSE, INHERIT FALSE, SET TRUE GRANTED BY regress_du_role2;
|
||||
GRANT regress_du_role0 TO regress_du_role2 WITH ADMIN FALSE, INHERIT FALSE, SET FALSE GRANTED BY regress_du_role2;
|
||||
|
||||
\drg regress_du_role*
|
||||
\du regress_du_role*
|
||||
|
||||
DROP ROLE regress_du_role0;
|
||||
DROP ROLE regress_du_role1;
|
||||
DROP ROLE regress_du_role2;
|
||||
DROP ROLE regress_du_admin;
|
||||
|
||||
Reference in New Issue
Block a user