Trigger with current user - Mailing list pgsql-general

From Nicolas Kowalski
Subject Trigger with current user
Date
Msg-id Pine.LNX.4.33.0107051332180.13218-100000@girose.imag.fr
Whole thread Raw
Responses Re: Trigger with current user  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello.

We use PostgreSQL 7.1.2 on Debian GNU/Linux as our Intranet database. I
am currently working on a small mailing-lists management application. I
would like to enforce table access permissions depending on the current
username :

- if the current user is declared as one of the lists maintainers
("SELECT maintainer FROM sys_mailing_lists;"), he(she) will be able to
SELECT, INSERT, UPDATE & DELETE rows in the 'sys_mailing_members' table,

- if not he(she) will only be able to do SELECT's on
'sys_mailing_members'.


So, I thought using triggers. However, I am missing some elements :

- how can I get back the currently connected username ?

- when using a "BEFORE" trigger, how can I cancel the
INSERT/UPDATE/DELETE actions to be performed if the user connected does
not match the access permissions ?


Thanks.
Nicolas.



pgsql-general by date:

Previous
From: Marc SCHAEFER
Date:
Subject: SUMMARY: NOT IN issue
Next
From: "omid omoomi"
Date:
Subject: RE: Table Description!!