Re: Cascade Trigger Not Firing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Judy Loomis <hoodie(dot)judy(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Cascade Trigger Not Firing
Date: 2019-09-13 21:03:01
Message-ID: 20933.1568408581@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Judy Loomis <hoodie(dot)judy(at)gmail(dot)com> writes:
> I'm going to have to really look at all my BEFORE UPDATE triggers and make
> sure we're not missing any more.
> And I have to stop telling management that a trigger means we always know
> when a value changes.

Well, you can rely on that, just not like this. Use an AFTER trigger
(else, you can't be sure it fires after all the BEFORE triggers)
and instead of triggering it with a column parameter, have it do
something like "if old.col is distinct from new.col".

Yeah, it's a bit slower that way, but there's no free lunch,
especially if you don't trust your other triggers. (Although,
if you have so many triggers that that's a problem, I think you
might have some other design issues.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Judy Loomis 2019-09-14 03:07:04 Re: Cascade Trigger Not Firing
Previous Message John W Higgins 2019-09-13 20:00:52 Re: PG SQL and LIKE clause