Re: getPrimaryKeys() bug in JDBC driver (fix) - Mailing list pgsql-interfaces

From Peter Mount
Subject Re: getPrimaryKeys() bug in JDBC driver (fix)
Date
Msg-id Pine.LNX.4.10.9908021316410.19188-100000@maidast.retep.org.uk
Whole thread Raw
In response to getPrimaryKeys() bug in JDBC driver (fix)  (Jens Glaser <jens@helena.jens.de>)
List pgsql-interfaces
On Mon, 2 Aug 1999, Jens Glaser wrote:

I've been given a patch for getPrimaryKeys() which I'm looking at. If it's
ok, and I get the server back up, I'll commit it before Thursday.

Peter

> Hi,
> 
> as it looks the getPrimaryKeys function in the postgresql
> jdbc driver is broken. With psql 6.5.1, it returns "garbage" because of a
> wrong SQL query in DatabaseMetaData.getPrimaryKeys().
> 
> With my limited knowledge of the postgresql internas I think this is the
> right query to get all the primary key columns of a table (here: 'test'):
> 
> select
>   '' as TABLE_CAT,
>   '' AS TABLE_SCHEM,
>   bc.relname AS TABLE_NAME,
>   a.attname AS COLUMN_NAME,
>   a.attnum as KEY_SEQ,
>   ic.relname as PK_NAME
> from
>   pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t
> where
>   bc.relkind = 'r'
>   and upper(bc.relname) = upper('test')
>   and i.indrelid = bc.oid
>   and i.indexrelid = ic.oid  and a.attrelid = ic.oid
>   and i.indisprimary='t'
> order by table_name, pk_name,key_seq;
> 
> Could you check that please?
> 
> Regards,
> 
> -- 
> Jens Glaser     Am Holderstrauch 13, 36041 Fulda, 0661/9429507    jens@jens.de
> 

--      Peter T Mount peter@retep.org.uk     Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgresJava PDF Generator: http://www.retep.org.uk/pdf



pgsql-interfaces by date:

Previous
From: Peter Mount
Date:
Subject: Re: access 2000 and postgres
Next
From: "Moray McConnachie"
Date:
Subject: Re: [INTERFACES] Re: access 2000 and postgres