Re: Making AFTER triggers act properly in PL functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Making AFTER triggers act properly in PL functions
Date: 2004-09-07 22:36:50
Message-ID: 5721.1094596610@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-09-07 22:43:26 Re: Why does pg_stat_activity Truncate Queries?
Previous Message Josh Berkus 2004-09-07 21:53:13 Why does pg_stat_activity Truncate Queries?