Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8EE42632B36 for ; Tue, 31 Aug 2010 09:10:42 -0300 (ADT) 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 97214-01 for ; Tue, 31 Aug 2010 12:10:34 +0000 (UTC) X-Greylist: delayed 00:06:49.188813 by SQLgrey-1.7.6 Received: from cascavel.ensmp.fr (cascavel.ensmp.fr [194.214.158.227]) by mail.postgresql.org (Postfix) with ESMTP id 5E49B63253E for ; Tue, 31 Aug 2010 09:10:35 -0300 (ADT) Received: from cri.ensmp.fr (nat-int.cri.ensmp.fr [86.65.170.62]) (authenticated bits=0) by cascavel.ensmp.fr (8.14.3/8.14.3/JMMC-11/Mar/2010) with ESMTP id o7VC3h3P016915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 31 Aug 2010 14:03:43 +0200 (MEST) Date: Tue, 31 Aug 2010 14:03:43 +0200 (CEST) From: Fabien COELHO X-X-Sender: fabien@localhost.localdomain Reply-To: Fabien COELHO To: PostgreSQL Bugs List Subject: issue about information_schema REFERENTIAL_CONSTRAINTS Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Miltered: at cascavel with ID 4C7CEF9F.000 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4C7CEF9F.000 from nat-int.cri.ensmp.fr/nat-int.cri.ensmp.fr/86.65.170.62/cri.ensmp.fr/ X-Scores-Stats: 4C7CEF9F.000 B=0.01273 L=0.36213 G=0.00727 Agree X-j-chkmail-Score: MSGID : 4C7CEF9F.000 on cascavel.ensmp.fr : j-chkmail score : . : R=. U=. O=. B=0.007 -> S=0.007 X-j-chkmail-Status: Ham X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/375 X-Sequence-Number: 27958 Hello, I haven't found a bug management system about postgresql, so here is a mail. Maybe this issue was already reported, sorry if it is the case. I have seen anything about the information_schema in pg todo list. This is tested on postgresql 8.4.4. The REFERENTIAL_CONSTRAINTS table in the information_schema references a constaint through its database/schema/name, but this information is not unique, so it may identify several constraints, thus the information derived may not be consistent. CREATE TABLE destination(id SERIAL PRIMARY KEY); CREATE TABLE source1 (id SERIAL PRIMARY KEY, fk INTEGER CONSTRAINT to_destination REFERENCES destination); CREATE TABLE source2 (id SERIAL PRIMARY KEY, fk INTEGER CONSTRAINT to_destination REFERENCES destination); SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS; -- contains two identical lines Other tables about constraints may have the same issue. The direct result is that this table leads to false result on joins, thus is pretty useless. Usually I have plenty of "$1" constraints. Suggestion: constraint names could be systematically prefixed with their corresponding table so that they are indeed unique, possibly with some escaping: '""."constraint_name"'. I'm not sure about the possible consequences of changing the constraint names, but as the information is a set of views on top of pg_catalog, there may be none. -- Fabien.