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 15:08:49 -0400
Message-ID: <21219.1568401729@sss.pgh.pa.us> (raw)
In-Reply-To: <CADoG1K1zHEQJh8xgpy3kYMXLc8X8W6md2WafJkFPcp-CsWYsng@mail.gmail.com>
References: <CADoG1K1zHEQJh8xgpy3kYMXLc8X8W6md2WafJkFPcp-CsWYsng@mail.gmail.com>
Judy Loomis <hoodie.judy@gmail.com> writes:
> I have a trigger that updates a target column when some other columns
> change.
> There is another trigger on the target column to update another table (the
> column can be changed in other ways besides the first trigger).
> If I update the target column directly the expected trigger fires.
> But if the 1st trigger changes the target column and it wasn't in the list
> of updated columns, the 2nd trigger doesn't fire.
> Is this expected behavior?
Per the manual (NOTES section of the CREATE TRIGGER man page):
A column-specific trigger (one defined using the UPDATE OF column_name
syntax) will fire when any of its columns are listed as targets in the
UPDATE command's SET list. It is possible for a column's value to
change even when the trigger is not fired, because changes made to the
row's contents by BEFORE UPDATE triggers are not
considered. Conversely, a command such as UPDATE ... SET x = x ...
will fire a trigger on column x, even though the column's value
did not change.
It's not really practical for trigger firings to depend on what other
triggers did or might do --- you'd soon end up with circularities.
regards, tom lane
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: <21219.1568401729@sss.pgh.pa.us>
References: <CADoG1K1zHEQJh8xgpy3kYMXLc8X8W6md2WafJkFPcp-CsWYsng@mail.gmail.com> <21219.1568401729@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