On Thu, Sep 30, 2004 at 07:06:10AM +0100, PostgreSQL Bugs List wrote: > > The problem happens when I was trying the example that is described in > "PostgreSQL 8.0.0beta1 Documentation, chapt 33.4 --- A Complete Example". > > At the last step, as the document says, the result should be: > => DELETE FROM ttest; > INFO: trigf (fired before): there are 2 rows in ttest > INFO: trigf (fired after ): there are 1 rows in ttest > INFO: trigf (fired before): there are 1 rows in ttest > INFO: trigf (fired after ): there are 0 rows in ttest > DELETE 2 > > But what i see is that: > test=# DELETE FROM ttest; > NOTICE: trigf (fired before): there are 2 tuples in ttest > NOTICE: trigf (fired before): there are 1 tuples in ttest > NOTICE: trigf (fired after ): there are 0 tuples in ttest > NOTICE: trigf (fired after ): there are 0 tuples in ttest > DELETE 2 > > The execution sequence of the triggers is incorrect.
Perhaps the execution sequence is correct and the documentation is wrong. Chapter 33.2 "Visibility of Data Changes" says this: When a row-level after trigger is fired, all data changes made by the outer command are already complete, and are visible to the invoked trigger function. I interpret that to mean that all records will have been deleted by the time any AFTER triggers are fired, which is the behavior you're seeing. Incidentally, 7.4.5 behaves the same way. Maybe this behavior change sometime after the example was written and the documentation was never updated. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly