Re: Filtering tables based on user privileges

From: Brijesh Shrivastav <Bshrivastav(at)esri(dot)com>
To: "Pglibpq (E-mail)" <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Filtering tables based on user privileges
Date: 2004-06-15 22:51:26
Message-ID: 491DC5F3D279CD4EB4B157DDD62237F401ADE49B@zipwire.esri.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

After researching again I have come with following syntax to select all
table with specific privilege (SELECT/INSERT/UPDATE..)to current user.

SELECT relname
FROM pg_class
WHERE pg_table_is_visible(oid)
AND relname !~ '^pg_'
AND has_table_privilege (oid,'INSERT');

Is this the best way to do it? Is there any way to execute such
a statement for any user? In this case such queries will most
likely be executed by a super user.

regards,
Brijesh

-----Original Message-----
From: Brijesh Shrivastav [mailto:Bshrivastav(at)esri(dot)com]
Sent: Tuesday, June 15, 2004 9:58 AM
To: Pglibpq (E-mail)
Subject: [INTERFACES] Filtering tables based on user privileges

Hi!

I have a need to filter out tables that have specfic privileges for a user.
For example, select
all tables where user 'joe' has 'select' and 'insert' privileges. Can I
somehow filter
that at SQL level or will I have to get all non-system rows from pg_class
and filter it
one by one? How can I use whre clause against aclitem[] array?

Regards,
Brijesh Shrivastav

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2004-06-16 02:57:44 Re: Filtering tables based on user privileges
Previous Message Brijesh Shrivastav 2004-06-15 16:58:00 Filtering tables based on user privileges