Re: simulating row ownership - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: simulating row ownership
Date
Msg-id 20050107200617.GA91058@winnie.fuhr.org
Whole thread Raw
In response to simulating row ownership  ("Rick Schumeyer" <rschumeyer@ieee.org>)
List 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 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/


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: View with Union and update rule - fails
Next
From: Dave Cramer
Date:
Subject: Re: [JDBC] Calling a table in another database from plpgsql