getPrimaryKeys() bug in JDBC driver (fix)

Поиск
Список
Период
Сортировка
От Jens Glaser
Тема getPrimaryKeys() bug in JDBC driver (fix)
Дата
Msg-id Pine.LNX.4.05.9908020315360.20222-100000@helena.jens.de
обсуждение исходный текст
Ответы Re: getPrimaryKeys() bug in JDBC driver (fix)
Список 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.relnameas 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



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: rodneyr@embratel.com.br
Дата:
Сообщение: Opening database with PGACCESS
Следующее
От: "Oliver Elphick"
Дата:
Сообщение: Re: [INTERFACES] Opening database with PGACCESS