From: Oliver Jowett <oliver@opencloud.com>
To: Sergio_Lob@iwaysoftware.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [BUGS] BUG #1523: precision column value returned from getTypeInfo()
Date: Mon, 07 Mar 2005 11:42:26 +1300
Message-ID: <422B8752.3060300@opencloud.com> (raw)
In-Reply-To: <4228697C.6020300@iwaysoftware.com>
References: <4227C2E7.7030308@opencloud.com>
<4228697C.6020300@iwaysoftware.com>
Sergio Lob wrote:
> The Microsoft ODBC 2.0 SDK guide and reference (Appendix D) contains
> a pretty thorough definition of what precision means in relation to
> various data types.
Is this from the ODBC spec or something specific to Microsoft? (I'm not
familiar with ODBC at all).
> SQL_CHAR The defined length of
> the column or parameter. For
> SQL_VARCHAR example, the precision of a
> column defined as CHAR(10)
We can't do this in getTypeInfo() as it's describing all VARCHARs, not a
specific one. What should we return in this case?
> SQL_LONGVARCHAR The maximum length of the column
> or parameter
This is going to be about 1GB if I read it correctly (but that varies
depending on what data you put in there). Is that really a useful value
to return?
> SQL_DECIMAL The defined number of
> digits. For example, the
> SQL_NUMERIC precision of a column
> defined as NUMERIC(10,3) is 10
Again, we can't do this in getTypeInfo() as we're describing all
NUMERICs, not a particular one.
> SQL_BINARY The defined length of
> the column or parameter. For example,
> SQL_VARBINARY the precision of a column
> defined as BINARY(10) is 10
>
> SQL_LONGVARBINBARY The maximum length of the column or
> parameter
Same as for varchar/longvarchar/etc above.
> SQL_DATE 10 (the number of
> characters in yyyy-mm-dd format)
>
> SQL_TIME 8 (the number of
> characters in hh:mm:ss format)
>
> SQL_TIMESTAMP The number of
> characters in the
>
> "yyyy-mm-dd hh:mm:ss[.f...]" format used by the [...]
Gah, those look pretty hairy, especially since JDBC has accessors
specifically for date/time/timestamp -- you're not really meant to deal
with them as text..
For the other types (int/long/etc) I will take a look at returning a
better precision value. We already do this in ResultSetMetadata, as Kris
pointed out, so it shouldn't be too painful.
> I have found problems with the answer set of other JDBC methods which
> return metadata information as well. For instance, the description of
> length values of certain columns in the DatabaseMetadata.getColumns()
> method answer set return negative numbers (-4 ?).
> This data being crucial to applications that I have written, I have
> unforunately had to take PostgresSQL off the list of JDBC data sources
> that I can support through my application.
I'll take a look at the length issue too. What was the actual type of
the column that was returning bad values?
What else have you had problems with? In general the metadata code isn't
heavily used, and is poorly specified in JDBC anyway, so it hasn't had
as much work done on it as the rest of the driver. The only way it's
going to get better is if those people actually using the metadata point
out the problems in detail :)
-O
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oliver@opencloud.com, Sergio_Lob@iwaysoftware.com
Subject: Re: [BUGS] BUG #1523: precision column value returned from getTypeInfo()
In-Reply-To: <422B8752.3060300@opencloud.com>
References: <4227C2E7.7030308@opencloud.com> <4228697C.6020300@iwaysoftware.com> <422B8752.3060300@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox