Re: getPrimaryKeys() bug in JDBC driver (fix)

From: Peter Mount <peter(at)retep(dot)org(dot)uk>
To: jens(at)jens(dot)de
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: getPrimaryKeys() bug in JDBC driver (fix)
Date: 1999-08-02 12:17:39
Message-ID: Pine.LNX.4.10.9908021316410.19188-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)jens(dot)de
>

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Moray McConnachie 1999-08-02 12:51:46 Re: [INTERFACES] Re: access 2000 and postgres
Previous Message Peter Mount 1999-08-02 12:15:59 Re: [INTERFACES] setTransactionIsolation support for JDBC driver (patch)