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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Konstantin Nikiforov <helllamer(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Date: 2010-12-03 03:52:11
Message-ID: 15326.1291348331@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Konstantin Nikiforov <helllamer(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-12-03 04:50:06 Re: BUG #5781: unaccent() function should be marked IMMUTABLE
Previous Message Jorge Augusto Meira 2010-12-02 20:24:43 Problems with max_connections parameter