On Fri, 19 Aug 2005, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > Is the correct answer to continue marking and running the triggers until > > there are no immediate triggers left to run for this case? > > Hmm ... my recollection is that we put in the concept of marking because > we needed it for correct behavior in some cases. I don't recall exactly > why though.
The comment there talks about someone doing a set constraints immediate inside a trigger function. /* * Process all immediate-mode triggers queued by the query, and move * the deferred ones to the main list of deferred events. * * Notice that we decide which ones will be fired, and put the deferred * ones on the main list, before anything is actually fired. This * ensures reasonably sane behavior if a trigger function does * SET CONSTRAINTS ... IMMEDIATE: all events we have decided to defer * will be available for it to fire. * * If we find no firable events, we don't have to increment firing_counter. */ I think we were worried about it either skipping events or potentially running events twice in that case, but I don't remember exactly either. I'm not sure that looping would affect that though, it'd be basically mark (0) increment firing id (0->1) run triggers using the old id (0) - if the set constraints immediate was run here, it'd mark using the - incremented id (hopefully incrementing again - will need to check) and - run using that id (1->2) and (1) mark (2) increment firing id (2->3) run triggers using (2) There might be some other reason that's not enshrined in the comment though. ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings