Bug in metadata.getColumns()/ORDINAL_POSITION

Поиск
Список
Период
Сортировка
От j.random.programmer
Тема Bug in metadata.getColumns()/ORDINAL_POSITION
Дата
Msg-id 421136.5291.qm@web32015.mail.mud.yahoo.com
обсуждение исходный текст
Ответы Re: Bug in metadata.getColumns()/ORDINAL_POSITION  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Hi:

This is using postgres 8.2.x and the latest 8.2-504
JDBC driver.

I have a table, defined like so:

test=# \d queue_stat;
Table "public.queue_stat"
      Column       |            Type             |
  Modifiers
-------------------------------------------------------
 queue_stat_id     | bigint                      | not
null default nextval

('queue_stat_queue_stat_id_seq'::regclass)
 start_time        | timestamp without time zone |
 finish_time       | timestamp without time zone |
 processing_error  | text                        |
 status            | character varying(24)       |
 fullpath_scan_dir | character varying(255)      |
========================================
Note, there are 6 columns defined, total in the table.

This snippet of code:
-------------------------------------------------------
String columnpattern = "%";    //all columns
ResultSet rs = md.getColumns(
    catalogname, schemaname, tablename, columnpattern);
QueryUtil.ensureScrollable(rs);
rs.beforeFirst();
while (rs.next())
    {
    String colname     = rs.getString    ("COLUMN_NAME");
    int datatype         = rs.getInt        ("DATA_TYPE");
    String typename = rs.getString    ("TYPE_NAME");
    int    colsize         = rs.getInt        ("COLUMN_SIZE");
    int nullable         = rs.getInt        ("NULLABLE");
    String remarks     = rs.getString    ("REMARKS");
    int    colnum        = rs.getInt        ("ORDINAL_POSITION");
--------------------------------------------------

gives me information about each column. I need the
ordinal
position because I have written a O/R tool that uses
the ordinal
position returned by the database meta data to
generate
methods like:

   result_set.getString(1)

etc.

Here's the bug.

For the above table (queue_stat), I get (via my o/r
tool):

INFO    1  >>>> Processing table: queue_stat
[colname=queue_stat_id,     colnum=1,
typename=bigserial]
[colname=start_time,           colnum=2,
typename=timestamp]
[colname=finish_time,          colnum=3,
typename=timestamp]
[colname=processing_error, colnum=5, typename=text]
[colname=status,                  colnum=6,
typename=varchar]
[colname=fullpath_scan_dir, colnum=7,
typename=varchar]

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

Of course, this results in all sorts of problems when
the tool
tries to say:

   result_set.getString(7)

So in a nutshell: there seems to be a bug in:

ResultSet rs = md.getColumns(
    catalogname, schemaname, tablename, columnpattern);

as far as the:
    "ORDINAL_POSITION" column is concerned.

This is a pretty serious bug for any O/R tool. I have
not
encountered this problem before, so something must
have
changed, either in the database or in the driver. Very
weird...

Best regards,
--j




____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

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

Предыдущее
От: Alex Stienstra
Дата:
Сообщение: setArray
Следующее
От: Miroslav Šulc
Дата:
Сообщение: Re: setArray