From: Kyle <kyle@actarg.com>
To: pgsql-sql@postgresql.org
Subject: Trigger on view
Date: Wed, 17 Sep 2003 13:46:32 -0600
Message-ID: <3F68BA18.2040000@actarg.com> (raw)
I'm trying to set up a trigger that restricts when and how updates are
done to the records in a relation. However, when the administrator
accesses the relation, I want the restriction to be relaxed.
My approach was to have a view that is accessed by the normal users and
have the admin access the table directly. However, it doesn't appear
that I can actually apply a trigger to a view.
Some of this I can do with rules on the view, but certain restrictions
are applicable only on a row-by-row basis, so I think I need to do it in
a BEFORE trigger.
Is there a way I can either:
1. Apply a trigger to a view. The trigger would actually get registered
with the underlying table, but would only be invoked if the user had
entered via the view.
2. Detect inside the trigger function whether the user had accessed the
table directly or through the view so I could invoke conditional code
accordingly.
I want to avoid hardcoding user ID's in the trigger, so I'm trying to
take this approach so it can all be handled simply by granting
privileges on different views to enable/disable the varying levels of
restriction.
Any ideas?
Kyle Bateman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: kyle@actarg.com
Subject: Re: Trigger on view
In-Reply-To: <3F68BA18.2040000@actarg.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox