Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 9B5281337BBB for ; Thu, 2 Dec 2010 16:24:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 73120-03 for ; Thu, 2 Dec 2010 20:23:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f46.google.com (mail-ew0-f46.google.com [209.85.215.46]) by mail.postgresql.org (Postfix) with ESMTP id D341A1337BBA for ; Thu, 2 Dec 2010 16:23:52 -0400 (AST) Received: by ewy5 with SMTP id 5so4618985ewy.19 for ; Thu, 02 Dec 2010 12:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type; bh=RG8nA7DsYaB5rv2oYV5Gaxggr7APm4Myqllkqf9cQjs=; b=K0ItNm5AuOQ1XSOKCOyFhLHrFm+qgcDq1/bhlZ9rU1aRjfej8cuLf0/fxWaRtpiqA8 hyxdbJngV3MNZOM65BqUDXCQHuir2DdiZlBT+i037A+nzU6v2EZ6KP4heQ+bVdDqB6Il YxH67/jHcERwdkxtLunFBti8QLjgP9LTUs1Eg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=wy+uXa4zYFN9KKMIINGTXBUOqu8dbLtQ870DKkPL6nG4Ntz2WOVBGYFEb+sxvzINBx Rig1uDwbK5uSWGGZXZFlYdD5CO3HzPcfhRvVwpzgSU0e27gXSOdp2mKwuGKE+n8BIAZ3 12XNgsB4awOvw0m1tQOvDTq0enDHTBUcj9nW0= Received: by 10.213.31.74 with SMTP id x10mr6785786ebc.49.1291321431589; Thu, 02 Dec 2010 12:23:51 -0800 (PST) Received: from alkaida ([88.201.233.135]) by mx.google.com with ESMTPS id y5sm766874eeh.16.2010.12.02.12.23.44 (version=SSLv3 cipher=RC4-MD5); Thu, 02 Dec 2010 12:23:46 -0800 (PST) Date: Thu, 2 Dec 2010 23:23:43 +0300 From: Konstantin Nikiforov To: pgsql-bugs@postgresql.org Subject: Bug: table inheritance. Trigger before DELETE for each statement is ignored Message-ID: <20101202232343.02f9246c@alkaida> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.22.0; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/3VajQFI/Mv/k/rWFbtgIBw_"; protocol="application/pgp-signature" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.589 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201012/7 X-Sequence-Number: 28813 --Sig_/3VajQFI/Mv/k/rWFbtgIBw_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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))=20 INHERITS (xtest);=20 -- 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=20 raise exception 'aaaaaaaaaaaaaaaaaaaaa!'; END; $$ language plpgsql; -- adding STATEMENT-level trigger to inherited table "xtest_inh" CREATE TRIGGER just_raise_exception_tg=20 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 =3D 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:=20 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? --Sig_/3VajQFI/Mv/k/rWFbtgIBw_ Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJM+ABPAAoJEBSj2gK+1nmKB8cP/1kUaztLrYjTofJCoOOruccV mE32m6y+LuAZsinbYa+S3bKLkwxC3VGc4jqin7bmkOZVUYyLsgPzQRXjz0EeWpOs 2HqCCKgB1Pn7xALsipdYZ85NcNy4qhpVi1inyqPg5MMZ4LwyxzISwXwwG4LgK4Yj REGWcQitWL6AB6Fyk+HfrGdxLE95Bp1B7jGbf3T7hQlLq47L0kv4sWr3ydEnSGRq MdiPW0PTLWbtnoAFuKFCa2r/UICOlVNzvsyStvAcHkxUw9ZvZCp3VyR5Vg7FT1Ao TK+sQ1DeAVmGiUnHhXtAAaCbeRyQ1VBCue1VnJZ4jVs3kJ9ytdC+upoxdiZ65h1W 31rsLwcN1GW6jB4EyzU5MwAzGVTFn2WJIg4JKl4EYdXPhxItqqeYnpZPH/mcH2us RgtIx64ygPglqVhnMuvwyojc4ZYOS/ToI71HXA2nfNTiOoPmZNsznaRPTMr+Uc66 Qs3uzi2C1omwBuGtc/ou7JI+glx60qssyfV//+3lRnuKI6ttKSG6LDbHlJhY/jpa dNx9QpuVBMpRsIMAAL4tM0pex4Vc8CN1XuMNAnG+qNzWedDyWjnlJebuKSwAgraO uH7cEMEnR0KPuumhNPTR31BvroKQgtUytjtv4W3YfKi6LhfbjUJaOLmqDaL1T3v6 Ca7BcfgxWI4tnqfm1izN =YBtM -----END PGP SIGNATURE----- --Sig_/3VajQFI/Mv/k/rWFbtgIBw_--