Re: [PATCH] pg_permissions

From: David Fetter <david(at)fetter(dot)org>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] pg_permissions
Date: 2021-03-08 01:09:22
Message-ID: 20210308010922.GA7457@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 06, 2021 at 08:03:17PM +0100, Joel Jacobson wrote:
> Hi,
>
> It's easy to answer the question...
>
> - What permissions are there on this specific object?
>
> ...but to answer the question...
>
> - What permissions are there for a specific role in the database?
>
> you need to manually query all relevant pg_catalog or information_schema.*_privileges views,
> which is a O(n) mental effort, while the first question is mentally O(1).
>
> I think this can be improved by providing humans a single pg_permissions system view
> which can be queried to answer the second question. This should save a lot of keyboard punches.
>
> Demo:
>
> SELECT * FROM pg_permissions WHERE 'joel' IN (grantor,grantee);
> regclass | obj_desc | grantor | grantee | privilege_type | is_grantable
> --------------+-----------------------------+---------+---------+----------------+--------------
> pg_namespace | schema foo | joel | joel | USAGE | f
> pg_namespace | schema foo | joel | joel | CREATE | f
> pg_class | table foo.bar | joel | joel | INSERT | f
> pg_class | table foo.bar | joel | joel | SELECT | f
> pg_class | table foo.bar | joel | joel | UPDATE | f
> pg_class | table foo.bar | joel | joel | DELETE | f
> pg_class | table foo.bar | joel | joel | TRUNCATE | f
> pg_class | table foo.bar | joel | joel | REFERENCES | f
> pg_class | table foo.bar | joel | joel | TRIGGER | f
> pg_attribute | column baz of table foo.bar | joel | joel | SELECT | f
> pg_attribute | column baz of table foo.bar | joel | joel | UPDATE | f
> (11 rows)
>
> All catalogs with _aclitem columns have been included in the view.
>
> I think a similar one for ownerships would be nice too.
> But I'll let you digest this one first to see if the concept is fruitful.

+1 for both this and the ownerships view.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-03-08 01:09:33 Re: 011_crash_recovery.pl intermittently fails
Previous Message Justin Pryzby 2021-03-08 01:07:07 Re: alter table set TABLE ACCESS METHOD