pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Judy Loomis <hoodie.judy@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Cascade Trigger Not Firing
Date: Fri, 13 Sep 2019 17:03:01 -0400
Message-ID: <20933.1568408581@sss.pgh.pa.us> (raw)
In-Reply-To: <CADoG1K1=ZsK-NoYxrWiHwhPv1uMiynLzN1x1Hb8CUb6CeZ_idw@mail.gmail.com>
References: <CADoG1K1zHEQJh8xgpy3kYMXLc8X8W6md2WafJkFPcp-CsWYsng@mail.gmail.com>
	<21219.1568401729@sss.pgh.pa.us>
	<CADoG1K1=ZsK-NoYxrWiHwhPv1uMiynLzN1x1Hb8CUb6CeZ_idw@mail.gmail.com>

Judy Loomis <hoodie.judy@gmail.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





view thread (9+ messages)  latest in thread

Message-ID: <20933.1568408581@sss.pgh.pa.us>
Permalink:  ../20933.1568408581@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20933.1568408581@sss.pgh.pa.us

 · 

reply

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, hoodie.judy@gmail.com
  Subject: Re: Cascade Trigger Not Firing
  In-Reply-To: <20933.1568408581@sss.pgh.pa.us>
  References: <CADoG1K1zHEQJh8xgpy3kYMXLc8X8W6md2WafJkFPcp-CsWYsng@mail.gmail.com> <21219.1568401729@sss.pgh.pa.us> <CADoG1K1=ZsK-NoYxrWiHwhPv1uMiynLzN1x1Hb8CUb6CeZ_idw@mail.gmail.com> <20933.1568408581@sss.pgh.pa.us>

* 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