BUG #1661: JDBC DatabaseMetaData.getExportedKeys() returns invalid keys.

Lists: pgsql-bugs
From: "Pavel Krupets" <pkrupets(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1661: JDBC DatabaseMetaData.getExportedKeys() returns invalid keys.
Date: 2005-05-11 19:30:52
Message-ID: 20050511193052.28181F0B02@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1661
Logged by: Pavel Krupets
Email address: pkrupets(at)yahoo(dot)com
PostgreSQL version: 8.0.2
Operating system: Windows XP
Description: JDBC DatabaseMetaData.getExportedKeys() returns invalid
keys.
Details:

Hello,

I have two tables:

CREATE TABLE bc4jgen_test_04.table_03
(
id NUMBER(10) NOT NULL,
code1 NUMBER(10) NOT NULL,
code2 NUMBER(20) NOT NULL,
name varchar(25) NOT NULL,
CONSTRAINT pk_table_03 PRIMARY KEY (id),
CONSTRAINT uq_codes UNIQUE (code1, code2)
);

and

CREATE TABLE bc4jgen_test_04.table_05
(
id NUMBER(10) NOT NULL,
code1 NUMBER(10) NOT NULL,
code2 NUMBER(20) NOT NULL,
name varchar(25) NOT NULL,
code3 NUMBER(5) NOT NULL,
CONSTRAINT pk_table_05 PRIMARY KEY (id),
CONSTRAINT fk_table_05_2_table_03 FOREIGN KEY (code1, code2) REFERENCES
bc4jgen_test_04.table_03 (code1, code2),
CONSTRAINT uq_table_05 UNIQUE (code1, code2, code3)
);

If I ask getExportedKeys(null, "bc4jgen_test_04", "table_03") to return
exported foreign keys it will return 'fk_table_05_2_table_03' key. But this
key isn't exported. table_05 does not references table_03's primary key,
just a unique one! Please check javadocs excerpts below.

---------------------------------------------------------
JavaDocs:

ResultSet getExportedKeys(String catalog, String schema, String table)

Retrieves a description of the foreign key columns that reference
the given table's primary key columns (the foreign keys exported by a
table)
---------------------------------------------------------

Thank you.


From: Kris Jurka <books(at)ejurka(dot)com>
To: Pavel Krupets <pkrupets(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1661: JDBC DatabaseMetaData.getExportedKeys() returns
Date: 2005-05-17 17:28:34
Message-ID: Pine.BSO.4.56.0505171221540.20628@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, 11 May 2005, Pavel Krupets wrote:

> Bug reference: 1661
> PostgreSQL version: 8.0.2
> Description: JDBC DatabaseMetaData.getExportedKeys() returns invalid
> keys.
>
> If I ask getExportedKeys(null, "bc4jgen_test_04", "table_03") to return
> exported foreign keys it will return 'fk_table_05_2_table_03' key. But this
> key isn't exported. table_05 does not references table_03's primary key,
> just a unique one! Please check javadocs excerpts below.
>

I guess we consider this a feature, not a bug. Otherwise there is no way
to retrieve foreign key information for foreign keys to unique
constraints. If you've got a concrete reason why this is a bad thing
please let us know. The javadoc does indeed say primary key, but I don't
see why including unique ones as well is a problem.

Kris Jurka