pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Konstantin Nikiforov <helllamer@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Bug: table inheritance. Trigger before DELETE for each statement is ignored
Date: Thu, 2 Dec 2010 23:23:43 +0300
Message-ID: <20101202232343.02f9246c@alkaida> (raw)

Version: postgresql 9.0.1
Step to reproduce: use following code. It creates two tables (parent
"xtest" and inherited "xtest_inh"), creates trigger function, creates
BEFORE INSERT/UPDATE/DELETE trigger.

*************************************
CREATE TABLE xtest (id serial, data varchar, primary key(id));
CREATE TABLE xtest_inh (check (id > 0), primary key(id)) 
 INHERITS (xtest); 

-- insert some data to inherited table "xtest_inh"
INSERT INTO xtest_inh(data) values ('ddd'), ('lol'), ('olo');

-- this function just raises an exception every time
CREATE FUNCTION just_raise_exception_tg() returns trigger as $$
BEGIN 
	raise exception 'aaaaaaaaaaaaaaaaaaaaa!';
END; $$ language plpgsql;

-- adding STATEMENT-level trigger to inherited table "xtest_inh"
CREATE TRIGGER just_raise_exception_tg 
 BEFORE INSERT OR UPDATE OF data OR DELETE ON xtest_inh
 FOR EACH STATEMENT execute procedure just_raise_exception_tg(2);

-- do some operations, that should cause to trigger the table
-- INSERT into xtest_inh(data) values ('omg');
DELETE from xtest where id = 2;

drop table xtest cascade;
drop function just_raise_exception_tg() cascade;

**********************************

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.

Comments: 
1. You can uncomment INSERT statement, and try again: exception
will be thrown. BEFORE INSERT works, BEFORE delete - no.
2. If i create trigger FOR EACH STATEMENT, it will work ok for insert,
update and delete.
3. AFTER DELETE statement-level trigger also does not work at all.

bug?

Attachments:

  signature.asc (application/pgp-signature, 835B) download

view thread (5+ messages)  latest in thread

Message-ID: <20101202232343.02f9246c@alkaida>
Permalink:  ../20101202232343.02f9246c@alkaida/
Also on:    postgresql.org/message-id/20101202232343.02f9246c@alkaida

 · 

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: helllamer@gmail.com
  Subject: Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored
  In-Reply-To: <20101202232343.02f9246c@alkaida>
  References: <20101202232343.02f9246c@alkaida>

* 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