pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Konstantin Nikiforov <helllamer@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Date: Thu, 02 Dec 2010 22:52:11 -0500
Message-ID: <15326.1291348331@sss.pgh.pa.us> (raw)
In-Reply-To: <20101202232343.02f9246c@alkaida>
References: <20101202232343.02f9246c@alkaida>

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



view thread (5+ messages)  latest in thread

Message-ID: <15326.1291348331@sss.pgh.pa.us>
Permalink:  ../15326.1291348331@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15326.1291348331@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, helllamer@gmail.com
  Subject: Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
  In-Reply-To: <15326.1291348331@sss.pgh.pa.us>
  References: <20101202232343.02f9246c@alkaida> <15326.1291348331@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox