Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Дата
Msg-id 15326.1291348331@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Bug: table inheritance. Trigger before DELETE for each statement is ignored  (Konstantin Nikiforov <helllamer@gmail.com>)
Ответы Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored  (Konstantin Nikiforov <helllamer@gmail.com>)
Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored  (Konstantin Nikiforov <helllamer@gmail.com>)
Список pgsql-bugs
Konstantin Nikiforov <helllamer@gmail.com> writes:
> Expected result: exception will be raised before deletion of rows is
> done.

> Real result: no exception occurs. One of rows is really deleted.
> The trigger is ignored.

I believe this is intentional, though not too well documented.  If we
fired statement triggers on child tables, then we'd have to fire all
such triggers, potentially on hundreds of child tables.  In particular
this would result in a problem for constraint exclusion: discarding
child tables that couldn't be referenced by the query action would
result in a visible change in behavior.  So the designed behavior is
that only the named target table has its statement triggers fired.

> 1. You can uncomment INSERT statement, and try again: exception
> will be thrown. BEFORE INSERT works, BEFORE delete - no.

The reason the INSERT case works is you're naming the child table
as target.

> 2. If i create trigger FOR EACH STATEMENT, it will work ok for insert,
> update and delete.

You mean FOR EACH ROW, no?

            regards, tom lane

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

Предыдущее
От: Konstantin Nikiforov
Дата:
Сообщение: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #5781: unaccent() function should be marked IMMUTABLE