Re: GRANT SELECT ON table TO $1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Barajas" <david(at)sonrie(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: GRANT SELECT ON table TO $1
Date: 2006-10-31 03:51:59
Message-ID: 23445.1162266719@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"David Barajas" <david(at)sonrie(dot)net> writes:
> CREATE OR REPLACE FUNCTION func(TEXT)
> RETURNS integer
> AS $$
> BEGIN
> GRANT SELECT ON table1 TO $1;

Can't do that: a $-parameter is a placeholder for a data value, not a
name, and GRANT wants a name. You could do

EXECUTE 'GRANT SELECT ON table1 TO ' || quote_ident($1);

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Lenorovitz, Joel 2006-10-31 20:20:48 Trouble with plpgsql generic trigger function using special variables
Previous Message David Barajas 2006-10-31 03:39:05 GRANT SELECT ON table TO $1