public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: [email protected]
To: Pg Docs <[email protected]>
Subject: Re: Clarification of triggers with 'OF column_name' in 'Overview of Trigger Behavior'
Date: Mon, 2 May 2022 15:21:41 -0700
Message-ID: <CAKFQuwY=c7t3PpihnsrcQPOGoKGyWFuvA5x9bwSSBZSJTz_tgQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Mon, May 2, 2022 at 11:14 AM PG Doc comments form <[email protected]>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/trigger-datachanges.html
> Description:
>
> UPDATE test SET alpha = 5;
>
> only trigger b2_ab will fire, even though it will update column beta.


Column beta eventually changed but you never issued an UPDATE command with
beta in the SET clause.  The trigger only care about the later.

And in fact triggers on a table should never re-issue an actual command
against the same table or you end up with infinite triggers.

If i
> change the declaration of b3_bc by removing the column list or including
> column alpha,

things work as I expected and b2_ab cascades to b3_bc.
>

But that isn't how this works.  There is no cascading.  As soon as the
UPDATE query is planned the set of triggers it is going to trigger is
basically known and nothing those triggers do individually will change that
(aside from raising an error).  All you did by changing b3_bc is get it
included in the ordered list of triggers that will be executed each time,
and only when, an UPDATE command is executed against the named table.

If you still believe a meaningful change can be had here a concrete
suggestion would be helpful.  Otherwise maybe someone takes an interest at
some point - but this particular confusion seems extremely rare.

David J.


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Clarification of triggers with 'OF column_name' in 'Overview of Trigger Behavior'
  In-Reply-To: <CAKFQuwY=c7t3PpihnsrcQPOGoKGyWFuvA5x9bwSSBZSJTz_tgQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox