Re: how to list privileges on the database object itself via SQL?

From: richard coleman <rcoleman(dot)ascentgl(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: how to list privileges on the database object itself via SQL?
Date: 2023-04-26 18:28:57
Message-ID: CAGA3vBvQtkE2pmi2oTj1SpDzz4gZT=EUbz9CrnPOFjvVxOqv5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Tom,

Thanks for your, and everyone else that's contributed's help.

It's good to know where to look, even though I wish it was as simple as
getting the list of role permissions on a table.

rik.

On Wed, Apr 26, 2023 at 2:05 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> richard coleman <rcoleman(dot)ascentgl(at)gmail(dot)com> writes:
> > Thanks for that. It still seems rather weird that there isn't a more
> > straightforward way to get access to that information.
>
> You could just read the system catalog documentation:
>
> https://www.postgresql.org/docs/current/catalogs.html
>
> psql's queries are mostly useful as a shortcut to finding out
> where to look.
>
> > Also the SQL generated by psql -E doesn't seem to work on earlier
> versions
> > of PostgreSQL:
>
> Yeah, you'd need to try it against a server of the vintage you
> care about. (Also read the documentation of the correct version.)
>
> > Are you saying that the only place this information is stored
> > is in an array in the datacl column of the pg_catalog.pg_database table?
>
> Precisely.
>
> > If that's the case then I am going to be forced to either write code to
> > parse out that array, or write a looping union of multiple
> > "has_database_privilege()" calls.
>
> You were already pointed at aclexplode(), which might help.
>
> select datname, a.* from pg_database, aclexplode(datacl) a;
>
> regards, tom lane
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Erik Wienhold 2023-04-26 18:29:51 Re: how to list privileges on the database object itself via SQL?
Previous Message Holger Jakobs 2023-04-26 18:22:56 Re: how to list privileges on the database object itself via SQL?