Re: Making AFTER triggers act properly in PL functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Making AFTER triggers act properly in PL functions
Date
Msg-id 5721.1094596610@sss.pgh.pa.us
Whole thread Raw
In response to Re: Making AFTER triggers act properly in PL functions  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: Making AFTER triggers act properly in PL functions
List pgsql-hackers
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> If I'm reading the above correctly, I think DeferredTriggerSetState may
> need to change a little if EndQuery works on a separate list of triggers
> because I believe set constraints immediate currently depends on EndQuery
> going over the entire list of saved deferred triggers.

But it would.  What I'm imagining is that the current list remains the
same, but it only contains trigger events from already-completed statements.
The per-query lists would be "staging areas" for gathering events from
still-active statements.

The only case where DeferredTriggerSetState would even see any nonempty
per-query list is where you had SET CONSTRAINTS being executed inside a
PL function that is called from an INSERT/UPDATE/DELETE command that has
already generated some trigger events, but is not yet complete.  It is
not appropriate for those triggers to fire yet, because we haven't
completed their generating statement.  When we do complete it, we'll
fire or defer the triggers according to the then-active SET CONSTRAINTS
state.  So AFAICS, DeferredTriggerSetState can and should ignore open
per-query trigger lists.  It will go over the whole list of events from
prior statements, though, the same as it does now.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Why does pg_stat_activity Truncate Queries?
Next
From: Tom Lane
Date:
Subject: Re: Why does pg_stat_activity Truncate Queries?