From: | Ron Peterson <rpeterso(at)mtholyoke(dot)edu> |
---|---|
To: | Rick Schumeyer <rschumeyer(at)ieee(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: simulating row ownership |
Date: | 2005-01-11 13:38:21 |
Message-ID: | 20050111133821.GA27537@mtholyoke.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Peterson | 2005-01-11 13:40:52 | Re: simulating row ownership |
Previous Message | Richard Huxton | 2005-01-11 11:35:25 | Re: Parsing a Calculation from a field |