From: Mark Volpe <volpe.mark@epamail.epa.gov>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Rules aren't doing what I expect
Date: Fri, 11 Aug 2000 12:03:48 -0400
Message-ID: <399423E4.BECD53E5@epamail.epa.gov> (raw)
References: <399180FD.2ACF8B2D@epamail.epa.gov>
<2085.966003030@sss.pgh.pa.us>
Tom Lane wrote:
>
> Queries added by non-INSTEAD rules are always performed before the
> initially-given query, so you're right, the rule will see the unmodified
> value.
>
> I'd suggest folding the log-entry-making into your trigger, actually.
> If you have a trigger anyway then the insert into t1_log is only one
> more line in that trigger procedure...
>
> regards, tom lane
Thanks for the explanation, Tom. I left out part of my story though. :) I
would like normal users to be able to modify t1 but not t1_log, and doing what
you said would require INSERT permission on t1_log. So what I did was go ahead
and allow INSERT permission, but create before and after triggers on t1_log
that check the inserted values against reality... but that brings up another
question -
If I do an UPDATE on t1, it calls a trigger which eventually does:
INSERT INTO t1_log VALUES(OLD.a, NEW.a);
If t1_log has before and after triggers, the before trigger will always see
the old row in t1, and the after trigger will always see the new data, right?
At least that's what I'm seeing. The "visibility of data changes" document
was kinda confusing...
Mark
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: volpe.mark@epamail.epa.gov, tgl@sss.pgh.pa.us
Subject: Re: Rules aren't doing what I expect
In-Reply-To: <399423E4.BECD53E5@epamail.epa.gov>
References: <399180FD.2ACF8B2D@epamail.epa.gov> <2085.966003030@sss.pgh.pa.us> <399423E4.BECD53E5@epamail.epa.gov>
* 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