List of role's privileges in Postgres

73 Views Asked by At
  1. How to get in Postgres list of all privileges granted to a role/user, ex. to the public role?
  2. Is that right, that newly created user in Postgres has no privileges except the ones inherited from default public role?
1

There are 1 best solutions below

2
Zegarek On
  1. In the psql client you can list roles and their attributes with \du+ meta-command which reads pg_catalog.pg_roles. To really list all privileges, you'd have to go through all information_schema views with privileges in the name, and/or all lists of things, reading who's the owner of the thing. This system is trying to be very granular, so listing them all is a big operation even on a freshly created database - you'd be listing access to all things and everything that those things are made up of, including the large and complex built-ins.

    Public isn't a very good example because it's not really a role - you can grant and revoke from it but you can't impersonate or connect as just public. It's a way for things to cascade and apply to everyone. Since it's not a role, it isn't the default role either.

  2. Correct but whatever they can and will create will be theirs, so their "number" of privileges grows through expanding ownership, not just grant.