incorrect values for DatabaseMetaData.getColumns()

From: Craig Longman <craigl(at)begeek(dot)com>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: incorrect values for DatabaseMetaData.getColumns()
Date: 2002-06-08 13:55:33
Message-ID: 1023544534.25760.135.camel@jigra.begeek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


i have been using jdbc to write a quick little database comparison
program for me to compare the table structure of a number of different
databases to make sure they're all in sync, and noticed that the pgsql
driver doesn't provide the correct information for one of the columns in
the ResultSet returned by DatabaseMetaData.getColumns().

the jdbc docs i have say this:

7. COLUMN_SIZE int => column size. For char or date types, this is
the maximum number of characters, __for numeric or decimal types this is
precision___.

the __ emphasize the lines in question. when i use this column on a
pgsql database (7.2 driver, 7.2 and 7.1 servers) the number returned is
'4', not the expected '10' for an integer field. it seems like its
returning the storage space (or bytes) that the field takes up, not the
precision that the field can handle. also, it returns odd values (-1)
for things like long varchar fields and floating fields.

i guess -1 is a more acceptable answer rather than an incorrect answer.

anyway, i'm sure this isn't used all that frequently, but i wanted to
point it out. it has made comparing anything but the names of a pgsql
database impossible, every field (except normal varchar fields) are
showing up as changed because the lengths returned are wrong.

cheers,

--

CraigL->Thx();
Be Developer ID: 5852

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Longman 2002-06-08 14:21:28 more incorrect values for DatabaseMetaData.getColumns()
Previous Message tony 2002-06-08 07:19:44 Re: RE : Java GUI development