Re: GRANT SELECT ON table TO $1 - Mailing list pgsql-novice

From Tom Lane
Subject Re: GRANT SELECT ON table TO $1
Date
Msg-id 23445.1162266719@sss.pgh.pa.us
Whole thread Raw
In response to GRANT SELECT ON table TO $1  ("David Barajas" <david@sonrie.net>)
List pgsql-novice
"David Barajas" <david@sonrie.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

pgsql-novice by date:

Previous
From: "David Barajas"
Date:
Subject: GRANT SELECT ON table TO $1
Next
From: "Lenorovitz, Joel"
Date:
Subject: Trouble with plpgsql generic trigger function using special variables