Re: Trigger before delete does fire before, but delete doesn't not happen

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Trigger before delete does fire before, but delete doesn't not happen
Дата
Msg-id 24220.1228157636@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Trigger before delete does fire before, but delete doesn't not happen  (Adrian Klaver <aklaver@comcast.net>)
Список pgsql-general
Adrian Klaver <aklaver@comcast.net> writes:
> The problem as far as I can tell is tuple visibility.

Sort of: the triggers on commandeligne fire (and update the commande row)
at completion of the DELETE command inside p_commande_bd.  This means
that by the time control returns from that trigger, the tuple version
that was targeted for deletion is already dead, so there's nothing to
do.  It doesn't chain up to the newer version of the row.

An AFTER trigger would be better for this on general principles, anyway.
The rule of thumb is "use a BEFORE trigger to adjust what happens to the
target row, but use an AFTER trigger to propagate the changes to other
rows".  If you don't do it that way then you have problems whenever
there are multiple triggers, since no individual BEFORE trigger can be
sure it knows the final state of the row.

            regards, tom lane

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

Предыдущее
От: "Malinka Rellikwodahs"
Дата:
Сообщение: Re: db backup script in gentoo
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Detecting changes to certain fields in 'before update' trigger functions