| From: | weigelt(at)metux(dot)de |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: trigger or function? |
| Date: | 2003-06-14 01:15:39 |
| Message-ID: | 20030614011539.GA16296@metux.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Sat, Jun 14, 2003 at 02:37:01AM +0200, adeon wrote:
<snip>
> There is a table in the database, that has a user_id column.
> Every user is able to insert, update or delete a record from this table,
> but users are only allowed to execute those operations only on their own
> records (that ones that have right user_id). How should be user_id checking
> performed - in trigger or should I create a functions for every operation
> (insert, delete and update)??
perhaps you run better w/ an rule, which drops unauthorized access ?
CREATE RULE foo_update ON foo AS ON UPDATE TO foo
WHERE old.user_id <>
(SELECT usesysid FROM pg_user WHERE usename = current_user)
DO INSTEAD NOTHING;
CREATE RULE foo_delete ON foo AS ON DELETE TO foo
WHERE old.user_id <>
(SELECT usesysid FROM pg_user WHERE usename = current_user)
DO INSTEAD NOTHING;
i didnt test it, but something like this should work.
cu
--
---------------------------------------------------------------------
Enrico Weigelt == metux ITS
Webhosting ab 5 EUR/Monat. UUCP, rawIP und vieles mehr.
phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact(at)metux(dot)de
cellphone: +49 174 7066481 smsgate: sms(dot)weigelt(at)metux(dot)de
---------------------------------------------------------------------
Diese Mail wurde mit UUCP versandt. http://www.metux.de/uucp/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lincoln Yeoh | 2003-06-14 03:00:43 | Re: return records in DB load order?? |
| Previous Message | Matthew Nuzum | 2003-06-14 00:55:12 | Re: Postgres performance comments from a MySQL user |