Re: Recursion in triggers? - Mailing list pgsql-general

From Tom Lane
Subject Re: Recursion in triggers?
Date
Msg-id 12479.1264361664@sss.pgh.pa.us
Whole thread Raw
In response to Re: Recursion in triggers?  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List pgsql-general
"Gauthier, Dave" <dave.gauthier@intel.com> writes:
> Ya, I worded the original poorley.  Let me try again....
> The after update trigger on the table sets some of the NEW.column values for record A.  Then it executes another
updateon the same table, but on record B.  That second execution of the update trigger needs to see the mods made to
recordA.   

Changing NEW in an after trigger has no effect outside the trigger
function itself.  It's too late to affect the data that went into the
table --- that's more or less the whole point of AFTER vs BEFORE
triggers.

However, once you get that issue straightened out, it is true that
triggers fired pursuant to the UPDATE inside the first trigger will
also see whatever data changes the first trigger saw.  See
http://www.postgresql.org/docs/8.4/static/trigger-datachanges.html

            regards, tom lane

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: port question
Next
From: Alessandro Agosto
Date:
Subject: Fwd: [LibPQ] Trying PQconnectStart: it doesn't seem to connect