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 17A963A482B for ; Fri, 7 Jan 2005 20:06:44 +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 03598-05 for ; Fri, 7 Jan 2005 20:06:19 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 5696D3A4EFE for ; Fri, 7 Jan 2005 20:06:23 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j07K6Ie3044695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Jan 2005 13:06:20 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j07K6HGZ091134; Fri, 7 Jan 2005 13:06:17 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j07K6HIv091133; Fri, 7 Jan 2005 13:06:17 -0700 (MST) (envelope-from mfuhr) Date: Fri, 7 Jan 2005 13:06:17 -0700 From: Michael Fuhr To: Rick Schumeyer Cc: pgsql-sql@postgresql.org Subject: Re: simulating row ownership Message-ID: <20050107200617.GA91058@winnie.fuhr.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> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/26 X-Sequence-Number: 19814 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 does the owner column refer to? A database user? If so, then you could use a trigger that checks CURRENT_USER or SESSION_USER and raises an exception if the user doesn't have permission to update or delete the affected row. In the PostgreSQL documentation, see the "Triggers" chapter and the "Trigger Procedures" section of the "PL/pgSQL - SQL Procedural Language" chapter. -- Michael Fuhr http://www.fuhr.org/~mfuhr/