Re: Rules aren't doing what I expect
От | Mark Volpe |
---|---|
Тема | Re: Rules aren't doing what I expect |
Дата | |
Msg-id | 399423E4.BECD53E5@epamail.epa.gov обсуждение исходный текст |
Ответ на | Rules aren't doing what I expect (Mark Volpe <volpe.mark@epamail.epa.gov>) |
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: