pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Brijesh Shrivastav <Bshrivastav@esri.com>
Cc: Pglibpq (E-mail) <pgsql-interfaces@postgresql.org>
Subject: Re: Filtering tables based on user privileges
Date: Tue, 15 Jun 2004 22:57:44 -0400
Message-ID: <16049.1087354664@sss.pgh.pa.us> (raw)
In-Reply-To: <491DC5F3D279CD4EB4B157DDD62237F401ADE49B@zipwire.esri.com>
References: <491DC5F3D279CD4EB4B157DDD62237F401ADE49B@zipwire.esri.com>

Brijesh Shrivastav <Bshrivastav@esri.com> writes:
> 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?

You likely also want to filter on relkind, but something about like this
is probably a reasonable starting point.

> Is there any way to execute such
> a statement  for any user?

Sure, see the three-parameter variants of has_table_privilege.

> In this case such queries will most
> likely be executed by a super user.

A superuser will always be considered to have all privileges,
so the has_table_privilege filter will be a no-op for such a one.

			regards, tom lane



view thread (3+ messages)

Message-ID: <16049.1087354664@sss.pgh.pa.us>
Permalink:  ../16049.1087354664@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16049.1087354664@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Bshrivastav@esri.com
  Subject: Re: Filtering tables based on user privileges
  In-Reply-To: <16049.1087354664@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox