Re: grant execute on many functions - Mailing list pgsql-admin

From Joe Conway
Subject Re: grant execute on many functions
Date
Msg-id 40E23F72.4000108@joeconway.com
Whole thread Raw
In response to Re: grant execute on many functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: grant execute on many functions
Re: grant execute on many functions
Re: grant execute on many functions
List pgsql-admin
Tom Lane wrote:
> Also, casting the function's OID to regprocedure may be useful.
> Random example:
>
> regression=# select 1142::regprocedure;
>       regprocedure
> ------------------------
>  date_mii(date,integer)
> (1 row)

That's even better -- I tried regproc, but forgot about regprocedure. I
think the problem will be, though, that the output of the reg* datatypes
is not castable to text, and therefore cannot be used to build a dynamic
sql statement.

   select 'GRANT EXECUTE ON ' || 1142::regprocedure;
   ERROR:  array value must start with "{" or dimension information

But with the help of plpgsql:

   create or replace function regprocedure2text(regprocedure)
   returns text as '
     begin
       return $1;
     end;
   ' language plpgsql;
   CREATE FUNCTION
   select 'GRANT EXECUTE ON ' || regprocedure2text(1142::regprocedure);
                   ?column?
   -----------------------------------------
    GRANT EXECUTE ON date_mii(date,integer)
   (1 row)

Joe

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: grant execute on many functions
Next
From: Tom Lane
Date:
Subject: Re: grant execute on many functions