Re: BUG #1274: Trigger sequence incorrect

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: BUG #1274: Trigger sequence incorrect
Дата
Msg-id 20041001062325.GA8787@winnie.fuhr.org
обсуждение исходный текст
Ответ на BUG #1274: Trigger sequence incorrect  ("PostgreSQL Bugs List" <pgsql-bugs@postgresql.org>)
Список pgsql-bugs
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/

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PLPGSQL and FOUND stange behaviour after EXECUTE
Следующее
От: "Aleksey Fedorchenko"
Дата:
Сообщение: Re: BUG #1266: Improper unique constraint / MVCCactivitieswithin