Re: simulating row ownership

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Rick Schumeyer <rschumeyer(at)ieee(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: simulating row ownership
Date: 2005-01-07 20:06:17
Message-ID: 20050107200617.GA91058@winnie.fuhr.org
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 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/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitri Bichko 2005-01-09 11:45:54 Question about insert/update RULEs.
Previous Message Tom Lane 2005-01-07 18:29:00 Re: View with Union and update rule - fails