From: Dan Langille <dan@langille.org>
To: pgsql-admin@postgresql.org
Subject: removing duplicated constraints
Date: Sat, 2 Mar 2002 10:19:42 -0500
Message-ID: <200203021519.g22FJjk52460@lists.unixathome.org> (raw)
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 "<unnamed>" AFTER INSERT OR UPDATE ON "ports"
FROM "categories" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE
PROCEDURE "RI_FKey_check_ins"
('<unnamed>', 'ports', 'categories', 'UNSPECIFIED', 'category_id', 'id');
CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "ports"
FROM "categories" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE
PROCEDURE "RI_FKey_check_ins"
('<unnamed>', '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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: dan@langille.org
Subject: Re: removing duplicated constraints
In-Reply-To: <200203021519.g22FJjk52460@lists.unixathome.org>
References: <200203021519.g22FJjk52460@lists.unixathome.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox