X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 06211D1C4BF for ; Tue, 5 Aug 2003 03:21:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 75963-07 for ; Tue, 5 Aug 2003 00:20:07 -0300 (ADT) Received: from cerebro.int-bytecraft.com (unknown [219.93.229.26]) by svr1.postgresql.org (Postfix) with ESMTP id A1453D1C4ED for ; Tue, 5 Aug 2003 00:21:13 -0300 (ADT) Received: from bytecraft.com.my (home.int-bytecraft.com [127.0.0.1]) by cerebro.int-bytecraft.com (8.11.6/8.11.6) with ESMTP id h753HSA17242; Tue, 5 Aug 2003 11:17:29 +0800 Message-ID: <3F2F2381.3060101@bytecraft.com.my> Date: Tue, 05 Aug 2003 11:24:49 +0800 From: Ang Chin Han User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rajesh Kumar Mallah Cc: MaRcElO PeReIrA , pgsql-admin@postgresql.org Subject: Re: Grant on several tables at once References: <3F2AC832.7090803@yahoo.com.br> <3F2ACA58.4050004@trade-india.com> In-Reply-To: <3F2ACA58.4050004@trade-india.com> X-Enigmail-Version: 0.76.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig76709D8CA79CDD62A2066B72" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/60 X-Sequence-Number: 9783 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig76709D8CA79CDD62A2066B72 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit There was a review of a DB book on Slashdot some time ago, and parts of the book said that SELECTs are always safe since it never modifies anything in the db :) This proves it wrong: Try this (7.4Devel but should work on 7.3): Granting to several users. -- pg_grant(priviledge, table, user) create or replace function pg_grant(text, text, text) returns boolean language plpgsql as 'begin execute ''grant '' || $1 || '' on '' || $2 || '' to '' || $3; return true; end;'; create or replace function pg_revoke(text, text, text) returns boolean language plpgsql as 'begin execute ''revoke '' || $1 || '' on '' || $2 || '' from '' || $3; return true; end;'; -- Check if these are the tables you want: select schemaname || '.' || tablename from pg_tables where schemaname = 'public'; -- Here we go: select count(*) from pg_tables where schemaname = 'public' and pg_grant('select', schemaname || '.' || tablename, 'marcelo'); -- "Undo" select count(*) from pg_tables where schemaname = 'public' and pg_revoke('select', schemaname || '.' || tablename, 'marcelo'); -- Linux homer 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux 11:00am up 222 days, 2:05, 5 users, load average: 5.03, 5.08, 5.08 --------------enig76709D8CA79CDD62A2066B72 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE/LyODNYbTUIgzwfARAkaWAJ9twSDwRlOHTU8ikeUFvd9/nb6vKQCeP6E2 q4BjeWeKodXeP45vQm6hqy4= =roUu -----END PGP SIGNATURE----- --------------enig76709D8CA79CDD62A2066B72--