grant select on all tables

From: Andrew Borley <BORLEY(at)uk(dot)ibm(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: grant select on all tables
Date: 2005-10-04 10:56:54
Message-ID: OF890422DF.A9F7ED78-ON80257090.003C0274-80257090.003C23AC@uk.ibm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I need to have default privileges like "GRANT SELECT ON
ALL TABLES" for a particular user. Looking at the docs &
mailing list archives there's no easy way to do this. I
seem to have to run a grant statement every time a new
table is created, so I thought of running the grant
automatically as a trigger on the pg_tables table.

I got as far as creating a function to help me do the
grant part:

create or replace function grantAccess(text, text)
returns text as '
DECLARE grantStmt text;
BEGIN
grantStmt := \'grant select on \'||$1||\' to \'||$2;
EXECUTE grantStmt;
RETURN grantStmt;
END;'
language plpgsql returns null on null input;

I wanted to run the function in a trigger on the
pg_tables table, but I can't cos it's a view. So I tried
setting it on the pg_class table, but I can't do this as
it's a system catalog.

Can anyone help?
Can anyone see a better/easier way of doing it?

Cheers

Andrew

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2005-10-04 12:25:44 Re: grant select on all tables
Previous Message A Gilmore 2005-10-04 05:16:01 Re: Comparing arrays