Re: Bug in metadata.getColumns()/ORDINAL_POSITION

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Bug in metadata.getColumns()/ORDINAL_POSITION
Дата
Msg-id Pine.BSO.4.64.0702171404010.30813@leary.csoft.net
обсуждение исходный текст
Ответ на Bug in metadata.getColumns()/ORDINAL_POSITION  ("j.random.programmer" <javadesigner@yahoo.com>)
Список pgsql-jdbc

On Fri, 16 Feb 2007, j.random.programmer wrote:

> This is using postgres 8.2.x and the latest 8.2-504
> JDBC driver.
>
> [DatabaseMetaData.getColumns returns wrong ordinal_position like so:]
>
> NOTE, THE COLNUM (via ("ORDINAL_POSITION")) returns:
>     1, 2, 3, 5, 6, 7
>
> This is WRONG. It should be:
>     1, 2, 3, 4, 5, 6
>

Turns out this is a problem with dropped columns:

CREATE TABLE test (a int, b int, c int);
ALTER TABLE test DROP b;
SELECT attname, attnum FROM pg_attribute
     WHERE attnum > 0 AND attrelid = 'test'::regclass;

            attname            | attnum
------------------------------+--------
  a                            |      1
  ........pg.dropped.2........ |      2
  c                            |      3
(3 rows)

So we need to do our own counting in getColumns instead of relying on
attnum.  I'll look at a fix, but for the moment a workaround would be to
recreate your table without any dropped columns.

Kris Jurka

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

Предыдущее
От: Miroslav Šulc
Дата:
Сообщение: Re: setArray
Следующее
От: "j.random.programmer"
Дата:
Сообщение: Re: Bug in metadata.getColumns()/ORDINAL_POSITION