X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E9783A574C for ; Tue, 11 Jan 2005 13:38:39 +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 89384-05 for ; Tue, 11 Jan 2005 13:38:20 +0000 (GMT) Received: from pagoda.mtholyoke.edu (pagoda.mtholyoke.edu [138.110.30.68]) by svr1.postgresql.org (Postfix) with ESMTP id 785C53A5882 for ; Tue, 11 Jan 2005 13:38:22 +0000 (GMT) Received: from pagoda.mtholyoke.edu (rpeterso@pagoda [127.0.0.1]) by pagoda.mtholyoke.edu (8.12.11/8.12.11/Debian-5) with ESMTP id j0BDcML4027658; Tue, 11 Jan 2005 08:38:22 -0500 Received: (from rpeterso@localhost) by pagoda.mtholyoke.edu (8.12.11/8.12.11/Debian-5) id j0BDcM3u027655; Tue, 11 Jan 2005 08:38:22 -0500 From: Ron Peterson Date: Tue, 11 Jan 2005 08:38:21 -0500 To: Rick Schumeyer Cc: pgsql-sql@postgresql.org Subject: Re: simulating row ownership Message-ID: <20050111133821.GA27537@mtholyoke.edu> Mail-Followup-To: Rick Schumeyer , pgsql-sql@postgresql.org References: <001901c4f4d9$395726f0$0200a8c0@dell8200> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001901c4f4d9$395726f0$0200a8c0@dell8200> Organization: Mount Holyoke College X-Operating-System: Debian GNU/Linux User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/36 X-Sequence-Number: 19824 On Fri, Jan 07, 2005 at 11:52:07AM -0500, Rick Schumeyer wrote: > I have a table where I want everyone to be able to be able to insert > and select. > But they should only be able to update and delete rows that they > "own". The table has a column indicating the owner. > What is the best way to accomplish this? I'm not real familiar with > rules, but it seems that I can do this with rules for update and > delete applied to the table. Using rules, you could do something like the following: CREATE TABLE test ( aname TEXT PRIMARY KEY ); INSERT INTO test ( aname ) VALUES ( 'aaa' ); INSERT INTO test ( aname ) VALUES ( 'yourusername' ); CREATE RULE lock_test_user_update AS ON UPDATE TO test WHERE old.aname = CURRENT_USER DO INSTEAD nothing; CREATE RULE lock_test_user_delete AS ON DELETE TO test WHERE old.aname = CURRENT_USER DO INSTEAD nothing; -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso