X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 695CD329C65 for ; Sat, 11 Sep 2004 07:42:31 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13694-01 for ; Sat, 11 Sep 2004 06:42:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8870C329E5C for ; Sat, 11 Sep 2004 07:42:24 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i8B6gNZw007806; Sat, 11 Sep 2004 02:42:23 -0400 (EDT) To: andrew@pillette.com Cc: pgsql-sql@postgresql.org Subject: Re: CREATE RULE ignored, what did I do wrong In-reply-to: <200409102136.i8ALajP19402@pillette.com> References: <200409102136.i8ALajP19402@pillette.com> Comments: In-reply-to andrew@pillette.com message dated "Fri, 10 Sep 2004 14:36:45 -0700" Date: Sat, 11 Sep 2004 02:42:23 -0400 Message-ID: <7805.1094884943@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/85 X-Sequence-Number: 18931 andrew@pillette.com writes: > Foreign-key constraints: > "$1" FOREIGN KEY (smoothing_id) REFERENCES smoothing_algorithm(smoothing_id) ON UPDATE CASCADE ON DELETE CASCADE > Rules: > del_smoothed_rank_episode AS ON DELETE TO smoothed_rank_episode > WHERE (NOT old.is_deleted) DO INSTEAD ... The DELETE commands generated by the foreign key ON DELETE CASCADE will get rewritten by your ON DELETE rule. You probably do not want to do this; or at least not make it an INSTEAD rule. There has been some debate in the past about whether rules should be able to break foreign-key constraints, but I tend to class it as a "you should know what you're doing" feature. Preventing this kind of error would inevitably result in a serious reduction of the power of the rule feature. regards, tom lane