X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9FDB79DC851 for ; Mon, 13 Mar 2006 10:35:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57662-08 for ; Mon, 13 Mar 2006 10:35:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from twiddle.look.ca (beta1.look.ca [207.136.80.125]) by postgresql.org (Postfix) with ESMTP id A0A1C9DC813 for ; Mon, 13 Mar 2006 10:35:08 -0400 (AST) Received: from 216-154-16-182.dsl.look.ca ([216.154.16.182]) by twiddle.look.ca with esmtp (Exim 4.20) id 1FIo8d-0006DZ-NJ; Mon, 13 Mar 2006 14:35:11 +0000 From: Rod Taylor To: "Eugene E." Cc: pgsql-sql@postgresql.org In-Reply-To: <441540AA.3090202@bankir.ru> References: <441540AA.3090202@bankir.ru> Date: Mon, 13 Mar 2006 09:33:12 -0500 Message-Id: <1142260392.857.49.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.4.2.1 FreeBSD GNOME Team Port X-SA-Exim-Mail-From: pg@rbt.ca Subject: Re: Permission to Select Content-Type: text/plain Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 3.1 (built Tue Feb 24 05:09:27 GMT 2004) X-SA-Exim-Scanned: Yes X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.051 required=5 tests=[AWL=0.051] X-Spam-Score: 0.051 X-Spam-Level: X-Archive-Number: 200603/188 X-Sequence-Number: 24534 On Mon, 2006-03-13 at 12:51 +0300, Eugene E. wrote: > Hi all > the serious problem with permissions is encountered > > NOTE: the following example is really useful but there is no room to > describe it's use. > > > db=# CREATE USER u; > db=# CREATE TABLE t (i int, a text); > db=# REVOKE all ON t FROM u; > db=# GRANT update,insert,delete ON t TO u; > db=# \c - u > > db=> INSERT INTO t VALUES (1,'x'); > INSERT > db=> UPDATE t SET a='y' WHERE i=1; > ERROR: Permission denied for relation t; > db=> UPDATE t SET a='y'; > UPDATE > > 1) The user "u" is permitted but unable to perfom the operation ! > 2) A user is able to update WHOLE table but unable to update ANY part of > it ! > Good chance this was on purpose. BEGIN; UPDATE compensation SET salary = salary WHERE name = 'Tom' and salary BETWEEN 50000 and 60000; -- No rows updated -- that's not Toms salary rollback; BEGIN; UPDATE compensation SET salary = salary WHERE name = 'Tom' and salary BETWEEN 60000 and 70000; -- One row updated so I found the range, I need a raise! rollback; By allowing the user a where clause you grant them select privileges. You will find that delete works the same way. This is one of those times when per column permissions are useful. You could grant them select access on the "name" column but not the "salary" column. --