From: | Sergio Lob <Sergio_Lob(at)iwaysoftware(dot)com> |
---|---|
To: | oliver(at)opencloud(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org, Sergio Lob <sergio_lob(at)iwaysoftware(dot)com> |
Subject: | Re: BUG #1523: precision column value returned from getTypeInfo() |
Date: | 2005-03-04 13:58:20 |
Message-ID: | 4228697C.6020300@iwaysoftware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-jdbc |
Hi Oliver,
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. I have never seen a definition of precision in any
JDBC doc I have read, however.
According to ODBC 2.0 spec definition of precision, "the precision of a
numeric column or parameter refers to the maximum number of digits used
by the data type of the column or parameter. The precision of a
nonnumeric column or parameter generally refers to either the maximum
length or defined length of the column or parameter. The following table
defines the precision for each ODBC SQL data type:
SQL Type Precision
----------- ----------
SQL_CHAR The defined length of
the column or parameter. For
SQL_VARCHAR example, the precision of a
column defined as CHAR(10)
is 10
SQL_LONGVARCHAR The maximum length of the column
or parameter
SQL_DECIMAL The defined number of
digits. For example, the
SQL_NUMERIC precision of a column
defined as NUMERIC(10,3) is 10
SQL_BIT 1
SQL_TINYINT 3
SQL_SMALLINT 5
SQL_INTEGER 10
SQL_BIGINT 19(if signed) or 20
(if unsigned)
SQL_REAL 7
SQL_FLOAT 15
SQL_DOUBLE
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
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
timestamp data type. For example, if the timestamp does
not
use seconds of fractional digits, the precision is 16
(the
number of characters in the "yyyy-mm-dd hh:mm"
format). If a timestamp uses thousandths of a second,
the
precision is 23 ("yyyy-mm-dd hh:mm:ss.fff" format)
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.
Anyway, I hope I answered your question about precision.
Sergio Lob
oliver(at)opencloud(dot)com wrote:
>(cc'ing -jdbc)
>
>Sergio Lob wrote:
>
>
>
>>After calling Connection.DatabaseMetaData.getTypeInfo() method, the
>>PRECISION column of the ResultSet seems hardcoded to value 9, which of
>>course in incorrect
>>
>>
>
>Well, it's working as intended in the sense that there is no code to
>support retrieving a real precision value -- it is indeed a hardcoded
>placeholder value. I'm not sure why '9' off the top of my head, perhaps
>making that column NULL would be better? What are the units of this
>value anyway?
>
>If you're willing to do the implementation work to improve this, then
>post a patch to pgsql-jdbc and I can look at applying it.
>
>-O
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kelly Burkhart | 2005-03-04 20:14:06 | BUG #1526: SHRT_MIN out of range on explicit type conversion |
Previous Message | Franois LECOMTE | 2005-03-04 10:35:58 | BUG #1525: wrong time when getting timestamp from date field |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Barker | 2005-03-05 04:39:17 | Re: [Patch] JDBC3 Blob support |
Previous Message | Kris Jurka | 2005-03-04 06:55:59 | Re: DatabaseMetaData.getIndexInfo and function-based indexes |