| From: | Jens Glaser <jens(at)helena(dot)jens(dot)de> |
|---|---|
| To: | peter(at)retep(dot)org(dot)uk |
| Cc: | pgsql-interfaces(at)postgresql(dot)org |
| Subject: | getPrimaryKeys() bug in JDBC driver (fix) |
| Date: | 1999-08-02 03:20:53 |
| Message-ID: | Pine.LNX.4.05.9908020315360.20222-100000@helena.jens.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-interfaces |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oliver Elphick | 1999-08-02 04:31:08 | Re: [INTERFACES] Opening database with PGACCESS |
| Previous Message | rodneyr | 1999-08-02 00:41:33 | Opening database with PGACCESS |