Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Date
Msg-id 15326.1291348331@sss.pgh.pa.us
Whole thread Raw
In response to Bug: table inheritance. Trigger before DELETE for each statement is ignored  (Konstantin Nikiforov <helllamer@gmail.com>)
Responses 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>)
List 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 by date:

Previous
From: Konstantin Nikiforov
Date:
Subject: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Next
From: Tom Lane
Date:
Subject: Re: BUG #5781: unaccent() function should be marked IMMUTABLE