Skip site navigation (1) Skip section navigation (2)

Re: grant execute on many functions

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jean-Denis Giguere <jdenisgiguere(at)fastmail(dot)fm>,pgsql-admin(at)postgresql(dot)org
Subject: Re: grant execute on many functions
Date: 2004-06-30 04:20:02
Message-ID: 40E23F72.4000108@joeconway.com (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-hackers
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

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2004-06-30 04:26:17
Subject: Re: grant execute on many functions
Previous:From: Tom LaneDate: 2004-06-30 03:45:14
Subject: Re: grant execute on many functions

pgsql-admin by date

Next:From: Tom LaneDate: 2004-06-30 04:26:17
Subject: Re: grant execute on many functions
Previous:From: Tom LaneDate: 2004-06-30 03:45:14
Subject: Re: grant execute on many functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group