Re: writable cte triggers reverse order

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: writable cte triggers reverse order
Дата
Msg-id 3443.1434636106@sss.pgh.pa.us
обсуждение исходный текст
Ответ на writable cte triggers reverse order  (Миша Тюрин <tmihail@bk.ru>)
Список pgsql-general
=?UTF-8?B?0JzQuNGI0LAg0KLRjtGA0LjQvQ==?= <tmihail@bk.ru> writes:
> for me case listed below looks like something goes wrong (at least very strange)
> ...
> see on order of events -- INSERTs come first before DELETEs!

The reason for this is that the AFTER INSERT trigger events are queued
within the INSERT statements executed by the test_trg_inh_func function,
and then executed at the completions of those INSERT statements.  On
the other hand, the AFTER DELETE trigger events are queued by the outer
WITH ... DELETE ... INSERT statement, so they fire at the completion
of that statement.

You could probably get the behavior you want if you make all the triggers
DEFERRED so that they all fire at end-of-transaction, rather than at end
of the statement that queued them.

            regards, tom lane


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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: PL/pgSQL: How to return two columns and multiple rows
Следующее
От: Peter Kroon
Дата:
Сообщение: valgrind