X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3315E56584 for ; Tue, 15 Mar 2005 14:54:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64226-04 for ; Tue, 15 Mar 2005 14:54:37 +0000 (GMT) Received: from mail.excilan.com (unknown [217.31.73.115]) by svr1.postgresql.org (Postfix) with ESMTP id ACEA556568 for ; Tue, 15 Mar 2005 14:54:36 +0000 (GMT) Received: from antispam.localhost (localhost [127.0.0.1]) by mail.excilan.com (Postfix) with SMTP id 3AF142D9A9 for ; Tue, 15 Mar 2005 15:54:40 +0100 (CET) Received: from excilan02.excilan.com (excilan02.excilan.com [192.168.102.3]) by mail.excilan.com (Postfix) with ESMTP id EA7AE1AAC8 for ; Tue, 15 Mar 2005 15:54:39 +0100 (CET) Received: excilan02.excilan.com 192.168.102.3 from 192.168.102.128 192.168.102.128 via HTTP with MS-WebStorage 6.0.6249 Received: from ubunex1 by excilan02.excilan.com; 15 Mar 2005 16:00:27 +0100 Subject: grant with pl/pgsql script From: Fred Blaise To: pgsql-admin@postgresql.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-NAKzYkeolmMdoZZo8OGc" Organization: Excilan S.A Date: Tue, 15 Mar 2005 16:00:27 +0100 Message-Id: <1110898827.3954.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-SpamTest-Version: SMTP-Filter Version 2.0.0 [0124], KAS/Release X-Spamtest-Info: Pass through X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/222 X-Sequence-Number: 16720 --=-NAKzYkeolmMdoZZo8OGc Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 :=3D "user" v_schema :=3D "public" FOR t in select tablename from pg_tables where schemaname =3D 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 --=-NAKzYkeolmMdoZZo8OGc Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBCNviKAoNJCRuR6rYRAtdGAKCG5RFeNYQs9RVdVuenfBmohefKkwCeOcYX 7kcFXTiuYclgDwIp4Sheq2Q= =+3md -----END PGP SIGNATURE----- --=-NAKzYkeolmMdoZZo8OGc--