pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stewart Ben (RBAU/EQS4) * <Ben.Stewart@au.bosch.com>
To: pgsql-sql@postgresql.org
Subject: Scripting GRANT on functions
Date: Thu, 6 Oct 2005 15:27:25 +1000
Message-ID: <E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com> (raw)

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.stewart@au.bosch.com
http://www.bosch.com.au/



view thread (3+ messages)  latest in thread

Message-ID: <E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com>
Permalink:  ../E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com/
Also on:    postgresql.org/message-id/E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: Ben.Stewart@au.bosch.com
  Subject: Re: Scripting GRANT on functions
  In-Reply-To: <E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com>
  References: <E253BDD7F008244585AEE87AF8F0224F116C7AA6@cl-mail01.au.bosch.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox