Received: from lists.unixathome.org (lists.unixathome.org [210.48.103.158]) by postgresql.org (Postfix) with ESMTP id 0A4FB475972 for ; Sat, 2 Mar 2002 10:19:49 -0500 (EST) Received: from wocker (lists.unixathome.org [210.48.103.158]) by lists.unixathome.org (8.11.6/8.11.6) with ESMTP id g22FJjk52460 for ; Sun, 3 Mar 2002 04:19:46 +1300 (NZDT) (envelope-from dan@lists.unixathome.org) Message-Id: <200203021519.g22FJjk52460@lists.unixathome.org> From: "Dan Langille" Organization: DVL Software Limited To: pgsql-admin@postgresql.org Date: Sat, 2 Mar 2002 10:19:42 -0500 MIME-Version: 1.0 Subject: removing duplicated constraints Reply-To: dan@langille.org X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Archive-Number: 200203/23 X-Sequence-Number: 3558 I was looking through my database schema and noticed that some foreign key declarations were duplicated. For example, I found this statement occurred twice within my DDL: alter table ports add foreign key (category_id) references categories (id) on update cascade on delete cascade; I fixed up the DDL to remove the duplicates. Then I turned to the 7.2 PostgreSQL database to examine that situation. I noticed this duplication: CREATE CONSTRAINT TRIGGER "" AFTER INSERT OR UPDATE ON "ports" FROM "categories" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('', 'ports', 'categories', 'UNSPECIFIED', 'category_id', 'id'); CREATE CONSTRAINT TRIGGER "" AFTER INSERT OR UPDATE ON "ports" FROM "categories" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('', 'ports', 'categories', 'UNSPECIFIED', 'category_id', 'id'); To my eye, those two contraints are identical. Some may consider that as a bug (i.e postgres allowing a FK to be duplicated). I see it as a feature, which in this case, has been misused.