Re: Trigger loop question - Mailing list pgsql-general

From Tom Lane
Subject Re: Trigger loop question
Date
Msg-id 12928.1079412134@sss.pgh.pa.us
Whole thread Raw
In response to Re: Trigger loop question  (Mike Nolan <nolan@gw.tssi.com>)
Responses Re: Trigger loop question
List pgsql-general
Mike Nolan <nolan@gw.tssi.com> writes:
> Yes it does.  OK, that means Tom's original suggestion of checking
> the other table for the same value before updating it should prevent
> an infinite loop, providing that's done from a pair of 'after update'
> triggers, using the NEW.column entries in the triggered table to update
> the other table.

Actually, I wasn't thinking very clearly.  The easiest way to break
the loop is to avoid updating the other table when OLD.x = NEW.x
in the trigger's arguments.  The other way requires a rather-redundant
SELECT to see what is in the other table.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephen Robert Norris
Date:
Subject: Re: Data Corruption in case of abrupt failure
Next
From: Mike Nolan
Date:
Subject: Re: Trigger loop question