Re: Does the current user have UPDATE privilege on FOO? - Mailing list pgsql-general

From Lionel Elie Mamane
Subject Re: Does the current user have UPDATE privilege on FOO?
Date
Msg-id 20120228040224.GA32207@capsaicin.mamane.lu
Whole thread Raw
In response to Re: Does the current user have UPDATE privilege on FOO?  (Mike Blackwell <mike.blackwell@rrd.com>)
List pgsql-general
On Mon, Feb 27, 2012 at 12:11:23PM -0600, Mike Blackwell wrote:
> On Mon, Feb 27, 2012 at 11:00, Lionel Elie Mamane <lionel@mamane.lu> wrote:

>> I'm trying to understand the "clean" way to determine whether the
>> current role has UPDATE (or SELECT or DELETE or UPDATE) privileges on
>> a specific table (or column). If I can do it in a way that is portable
>> across different DBMSs, even better :)

> For PostgreSQL only, see
> http://www.postgresql.org/docs/9.1/interactive/functions-info.html for a
> list of functions for this.

Ah yes, so basically I can implement the JDBC-alike getTablePrivileges
as something like:

 SELECT (...), tables.table_name, pr.rolname AS grantee,
        has_table_privilege(pr.oid, tables.table_schema, + '.' + tables.table_name, privilege.name), (...)
 FROM information_schema.tables, pg_catalog.pg_roles pr,
      VALUES ('SELECT', 'UPDATE', ...) AS privilege

I'd be missing a sensible value for the grantor column, but at least
it would be complete and robust for the rest of the information.

Thanks for the pointer.

--
Lionel

pgsql-general by date:

Previous
From: Andy Colson
Date:
Subject: Re: strategies for dealing with frequently updated tables
Next
From: chinnaobi
Date:
Subject: archive_cleanup_command recovery.conf Standby server error