Re: Why are triggers semi-deferred? - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: Why are triggers semi-deferred?
Date
Msg-id 20030505081001.M82910-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Why are triggers semi-deferred?  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: Why are triggers semi-deferred?  (Philip Warner <pjw@rhyme.com.au>)
Re: Why are triggers semi-deferred?  (Philip Warner <pjw@rhyme.com.au>)
Re: Why are triggers semi-deferred?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, 5 May 2003, Philip Warner wrote:

> At least in 7.3, triggered actions specified as AFTER seem to be deferred
> to the completion of the outer-most SQL statement. So, if two triggering
> statements are executed as part of a PLPGSQL procedure, they will not be
> executed until the outermost statement finishes.
>
> As far as I can tell, this is not the way the spec says it should work:
>
>      The <triggered SQL statement> of a triggered action is
>      effectively executed either immediately before or immediately
>      after the trigger event, as determined by the specified
>      trigger action time.
>
> In the case of statements executed sequentially inside a PLPGSQL procedure,
> I would have expected that the trigger would fire after the first
> triggering statement.

Actually, I think from sql99's description, for after row triggers it
should happen after the row is modified not after the statement as a
whole (so given two 2 row updates in a function you'd getupdate1,row1 afterrow1-1 update1,row2
afterrow1-2,afterstatement1update2,row1afterrow2-1 update2,row2 afterrow2-2,afterstatement2
 
)

I'd been thinking (this came up recently is a bug/query about the foreign
keys that Tom sent me) that it might be better to make times that the
triggers can run be choosable (with the spec behavior becoming default
eventually) because we've got backward compatibility issues and we've kind
overloaded the trigger system to do the foreign keys which have their own
timing issues.



pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: pg_dump future problem.
Next
From: Tom Lane
Date:
Subject: Re: pg_dump future problem.