Scripting GRANT on functions

From: "Stewart Ben (RBAU/EQS4) *" <Ben(dot)Stewart(at)au(dot)bosch(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Scripting GRANT on functions
Date: 2005-10-06 05:27:25
Message-ID: E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Is there any easy way to script granting privileges to a number of
functions? I've got as far as the following code before realising that
I'll need to pass in the arguments, and the arguments are stored as OIDs
in pg_proc.

Is there any easy way, such as GRANT .... FUNCTION OID 12345?

---CODE---

DECLARE
curs REFCURSOR;
funcname VARCHAR;
BEGIN
OPEN foo FOR
SELECT proname FROM pg_proc
WHERE proname LIKE 'tr\\_%'
OR proname LIKE 'tt\\_%'
OR proname LIKE 'v\\_%'
OR proname LIKE 'vui\\_%';

FETCH curs INTO funcname;

WHILE FOUND LOOP
FETCH curs INTO funcname;
EXECUTE 'GRANT EXECUTE ON FUNCTION ' || funcname || ' TO myuser';
END LOOP;

CLOSE curs;
END;

---END CODE---

Best regards,

Ben Stewart

--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
mailto:ben(dot)stewart(at)au(dot)bosch(dot)com
http://www.bosch.com.au/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message padmanabha konkodi 2005-10-06 06:55:46 catching errors in function
Previous Message Leif B. Kristensen 2005-10-05 17:21:59 Re: Use of partial index