pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fred Blaise <fred.blaise@excilan.com>
To: pgsql-admin@postgresql.org
Subject: grant with pl/pgsql script
Date: Tue, 15 Mar 2005 16:00:27 +0100
Message-ID: <1110898827.3954.8.camel@localhost.localdomain> (raw)

Hello all

I am trying to grant privs to a user on all tables. I think I understood
there was no command to do that.... :// so I wrote the following:

create or replace function granting() RETURNS integer AS '
declare
        v_schema varchar;
        v_user varchar;
begin
        v_user := "user"
        v_schema := "public"
        FOR t in select tablename from pg_tables where schemaname =
v_schema
        LOOP
                grant select on t to v_user;
        END LOOP;
        return 1;
end;
' LANGUAGE plpgsql;


I then login to psql, and do a \i myscript.sql. It returns CREATE
FUNCTION, but I cannot see anything. The tables are not granted, etc...
Also I am trying to find out how to debug this. How can I print out to
STDOUT the value of t for example?

Thanks for any help

Best,

fred

Attachments:

  signature.asc (application/pgp-signature, 188B) download

Message-ID: <1110898827.3954.8.camel@localhost.localdomain>
Permalink:  ../1110898827.3954.8.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1110898827.3954.8.camel@localhost.localdomain

 · 

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-admin@postgresql.org
  Cc: fred.blaise@excilan.com
  Subject: Re: grant with pl/pgsql script
  In-Reply-To: <1110898827.3954.8.camel@localhost.localdomain>
  References: <1110898827.3954.8.camel@localhost.localdomain>

* 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