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 942F55E46F8 for ; Mon, 6 Sep 2004 00:29:58 +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 64071-01 for ; Sun, 5 Sep 2004 23:29:54 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id A7B755E46E9 for ; Mon, 6 Sep 2004 00:29:52 +0100 (BST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 597DE3552D; Sun, 5 Sep 2004 16:29:58 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 5810535521; Sun, 5 Sep 2004 16:29:58 -0700 (PDT) Date: Sun, 5 Sep 2004 16:29:58 -0700 (PDT) From: Stephan Szabo To: Troels Arvin Cc: pgsql-sql@postgresql.org Subject: Re: INFORMATION_SCHEMA and foreign keys In-Reply-To: Message-ID: <20040905162116.K38304@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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/34 X-Sequence-Number: 18880 On Mon, 6 Sep 2004, Troels Arvin wrote: > The query returns double the numer of rows, compared to what I wanted. The > problem seems to stem from PostgreSQL's naming of constraints without > explicit name: They seem to be named $1, $2, etc, and the default names > are reused. [...] > Note, again, that the CONSTRAINT_NAMEs are not unique, although they > affect two different tables. Hence, there doesn't seem to be a way to map > a specifict referential constraint to a specific primary/unique constraint > in the table being referred to. > > Is my only way forward to drop using the INFORMATION_SCHEMA and work with > the pg_catalog if I want to determine which columns are being referred to > in a (set of) foreign key column(s)? Possibly, yes. You'd be better off if you named your constraints rather than letting the system name them for you, but in general you can't rely on someone else doing that. This is a side effect of allowing table unique constraint names rather than schema unique constraint names (as a side note you would need to constrain schema in those joins even if we did schema unique names).