X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D99CED1B55D for ; Thu, 30 Oct 2003 17:56:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 01456-03 for ; Thu, 30 Oct 2003 13:55:51 -0400 (AST) Received: from woodfire (ip-a1-37118.keycomm.it [62.152.37.118]) by svr1.postgresql.org (Postfix) with ESMTP id 77D55D1B579 for ; Thu, 30 Oct 2003 13:55:49 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by woodfire (Postfix) with ESMTP id 1F461DB2; Thu, 30 Oct 2003 19:56:18 +0100 (CET) Received: from woodfire ([127.0.0.1]) by localhost (woodfire [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01100-07; Thu, 30 Oct 2003 19:56:11 +0100 (CET) Received: from osts (unknown [192.168.100.27]) by woodfire (Postfix) with ESMTP id 4E563D80; Thu, 30 Oct 2003 19:56:11 +0100 (CET) Subject: Re: Bug in Rule+Foreing key constrain? From: Michele Bendazzoli To: Jan Wieck Cc: pgsql-sql In-Reply-To: <3FA14A86.8080802@Yahoo.com> References: <1067517334.2371.26.camel@mickymouse.sintel> <3FA14A86.8080802@Yahoo.com> Content-Type: text/plain; charset=ISO-8859-1 Organization: Micky Mouse Message-Id: <1067540494.2420.45.camel@mickymouse.sintel> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 30 Oct 2003 20:01:34 +0100 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at sintelnet.it X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/405 X-Sequence-Number: 15805 On Thu, 2003-10-30 at 18:29, Jan Wieck wrote: > Not entirely. On which table(s) are the REFERENCES constraints and are > they separate per column constraints or are they multi-column constraints? here are the constraints of the abilitazione table ALTER TABLE public.abilitazione ADD CONSTRAINT abilitazione_pkey PRIMARY KEY(comuneid, cassonettoid, chiaveid); ALTER TABLE public.abilitazione ADD CONSTRAINT abilitazione_cassonettoid_fkey FOREIGN KEY (comuneid, cassonettoid) REFERENCES public.cassonetto (comuneid, cassonettoid) ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE public.abilitazione ADD CONSTRAINT abilitazione_chiaveid_fkey FOREIGN KEY (comuneid, chiaveid) REFERENCES public.chiave (comuneid, chiaveid) ON UPDATE RESTRICT ON DELETE RESTRICT; here those of cassonetto and chiave: ALTER TABLE public.cassonetto ADD CONSTRAINT cassonetto_pkey PRIMARY KEY(comuneid, cassonettoid); ALTER TABLE public.chiave ADD CONSTRAINT chiave_pkey PRIMARY KEY(comuneid, chiaveid); I get the SQL from pgAdmin3 (great piece of sofware!;-) > It's usually best to cut'n'paste the CREATE TABLE or ALTER TABLE > statements that are used to create the constraints. That way we know > exactly what you're talking about. Excuse me for the missing SQL, but i had tried to keep the message as simple as possible. The unique difference form when the exception was raised and now (that it isn't) is the rule added: CREATE OR REPLACE RULE abilita_ins_rl AS ON INSERT TO abilitazione WHERE (EXISTS ( SELECT 1 FROM abilitazione WHERE (((abilitazione.comuneid = new.comuneid ) AND (abilitazione.cassonettoid = new.cassonettoid )) AND (abilitazione.chiaveid = new.chiaveid ))))ù DO INSTEAD UPDATE abilitazione SET abilitata = new.abilitata WHERE (((abilitazione.comuneid = new.comuneid ) AND (abilitazione.cassonettoid = new.cassonettoid )) AND (abilitazione.chiaveid = new.chiaveid )); I hope now is more clear. The version is that come with debian unstable (7.3.4 if I remember correctly) Thank you for the immediate responses ciao, Michele