Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E7ED91337B8C for ; Fri, 3 Dec 2010 04:16:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 88278-06 for ; Fri, 3 Dec 2010 08:16:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f49.google.com (mail-ew0-f49.google.com [209.85.215.49]) by mail.postgresql.org (Postfix) with ESMTP id 66B571337B83 for ; Fri, 3 Dec 2010 04:16:32 -0400 (AST) Received: by ewy20 with SMTP id 20so4846792ewy.36 for ; Fri, 03 Dec 2010 00:16:31 -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:cc:subject :message-id:in-reply-to:references:organization:x-mailer :mime-version:content-type; bh=X0Owk8CU2phue9ADHS6P8OElT5e6Z3Q8ADiB8wlNDWA=; b=WNFCxD+Ka4ZDRTl9sInd92BqH7w2lcsofUscfyEvkPmLt9iq7MAuhw98hH1gsP5C08 05+zBmulv816Wg/e8vFI5HAoJYLz51P6X99iRrxjVXUrbx20s5XaHAKp/N9NSZYNQxHR zNQHivyNT9o1jEsLHvWgfN9IqLTm4CeyXxdLs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:x-mailer:mime-version:content-type; b=GkSpfAja0lyA4rSqwGwBwy69tBI0ZM/iRGvukXNebqH3KugeN6xgqHktr4uiF+Nb0B p85p0OAqOb1UFOHOd+E/D0O6whPyZDcYhHFXGyjD8lBIbD/gKj4TyLC/qr69JHacgezo xv0ynVMSkgGw1vAZEZ1rdRvGUVdNV8wMGGlNQ= Received: by 10.213.29.209 with SMTP id r17mr207941ebc.0.1291364191488; Fri, 03 Dec 2010 00:16:31 -0800 (PST) Received: from avers ([213.108.35.158]) by mx.google.com with ESMTPS id v56sm1253709eeh.8.2010.12.03.00.16.30 (version=SSLv3 cipher=RC4-MD5); Fri, 03 Dec 2010 00:16:31 -0800 (PST) Date: Fri, 3 Dec 2010 11:16:12 +0300 From: Konstantin Nikiforov To: Tom Lane Cc: pgsql-bugs@postgresql.org Subject: Re: Bug: table inheritance. Trigger before DELETE for each statement is ignored Message-ID: <20101203111612.3304674e@avers> In-Reply-To: <15326.1291348331@sss.pgh.pa.us> References: <20101202232343.02f9246c@alkaida> <15326.1291348331@sss.pgh.pa.us> Organization: AversImage 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_/kHpDtKfLfZI+sfTNkJ2NwRS"; protocol="application/pgp-signature" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201012/10 X-Sequence-Number: 28816 --Sig_/kHpDtKfLfZI+sfTNkJ2NwRS Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Also another bug and usecase connected with subj. It creates parent table "xtest", inherited table "xtest_inh" with some data, and a trigger BEFORE INSERT/UPDATE/DELETE on table "xtest". After, it deletes one row. ********************************** 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 FOR EACH ROW execute procedure just_raise_exception_tg(2); -- do some operations, that should cause to trigger the table --INSERT into xtest(data) values ('omg'); DELETE from xtest where id =3D 2; drop table xtest cascade; drop function just_raise_exception_tg() cascade; **************************************** Expected result: Trigger should fire the exception before delete. Real result: Row successfully deleted. The trigger is ignored. Comments: 1. Trigger fires ok when INSERT to table "xtest", but not fires for DELETE. You can uncomment the line with INSERT (see above) and check. 2. Trigger fires ok when created with "FOR EACH STATEMENT" clause. Trigger not fires when created with "FOR EACH ROW" clause. --Sig_/kHpDtKfLfZI+sfTNkJ2NwRS 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+KdMAAoJEBSj2gK+1nmKc5oP/jGz4NZYQB6usnQKgqDpQARl mASzCTAKEWUtraJx59yn/KGct6kAnR4JLpIoVp2TuPIHulW8vq02uROrXEaNL4Jy ZGNnMn1j+t/1tXeVTjb7E/mP+Sggab5kveiYuF1RF1o7zj5WrrHJ0AcV3VfuG6gF /goSbL2TYcI+jVs0WsbN+/9XK5Tv6hmOfZRRnu/c64xBs4qw3Pu+RckzJ+XQv2WH JaTPcZSinnBXOaKFEzVjJIoUdjbXH03LnG8nxHsFraSH5XjXWvwZZXO/XHMfZHjH wtmrIOjesfzcrGCkrMASQj6n0oaIQpA1V/tC1HRGCId+iSFEQhinYZvcqjxDhtVW Hg2XDWchpxbXKye1L5JAu5lQ0Qp5PLJusIXOWIEdxNf//+h4PKYMSslfKQjqGGwp zJ1MKd6YFqWRrrj0SOGrFAiApr0g7wzl48vypvIkG8oKobv6lnaZEK6nLvBDn7GY NmOt0dwcOcsGDl/dOB+Tm9za+PR+V3adwJssSE2j2gk7KerYOl08TFP7JV3TvKLG GHH1qMjgMXTlYDhozWXjKzldbmMPHV4nvJqzLHhm30anzIouhLiLSEAhFrKXBPyv rVGnvzUCt7K73Suyuo+DfycGACqAMt1rblbbWFYbVBGmcyWOzIIXuAnJqEhlcsGu hdXJDwla8oVje49ASJuw =aLnW -----END PGP SIGNATURE----- --Sig_/kHpDtKfLfZI+sfTNkJ2NwRS--