pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedResultSetMetaData + CachedResultSet bug
5+ messages / 3 participants
[nested] [flat]
* ResultSetMetaData + CachedResultSet bug
@ 2006-06-22 14:59 Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
2006-06-29 23:47 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 5+ messages in thread
From: Sergii Sinelnychenko @ 2006-06-22 14:59 UTC (permalink / raw)
To: pgsql-jdbc
Hello everybody!
Today I have found a strange bug in JDBC driver (I used the last version avilable - 8.2dev-503). The problem is with VARCHAR
fields - driver returns "-1" on "getPrecision()" call. But class javax.sql.rowset.RowSetMetaDataImpl in its "setPrecision()" method
requires values of 0 and more (javadoc sais "precision the total number of decimal digits; must be <code>0</code> or more ").
I understand that in case of VARCHAR type we cannot speak about real number of decimal digits - but could just driver return 0
instead of -1?
Please advise.
Thanks in advance for answer.
---
WBR, Sergii Sinelnychenko
Senior Java Developer, Project Manager
e: SSinelnychenko@bossdev.com
w: www.bossdev.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: ResultSetMetaData + CachedResultSet bug
2006-06-22 14:59 ResultSetMetaData + CachedResultSet bug Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
@ 2006-06-29 23:47 ` Kris Jurka <books@ejurka.com>
2006-06-30 08:10 ` Re: ResultSetMetaData + CachedResultSet bug Thomas Hallgren <thomas@tada.se>
0 siblings, 1 reply; 5+ messages in thread
From: Kris Jurka @ 2006-06-29 23:47 UTC (permalink / raw)
To: Sergii Sinelnychenko <SSinelnychenko@bossdev.com>; +Cc: pgsql-jdbc
On Thu, 22 Jun 2006, Sergii Sinelnychenko wrote:
> Today I have found a strange bug in JDBC driver (I used the last version
> avilable - 8.2dev-503). The problem is with VARCHAR fields - driver returns
> "-1" on "getPrecision()" call. But class javax.sql.rowset.RowSetMetaDataImpl
> in its "setPrecision()" method requires values of 0 and more (javadoc sais
> "precision the total number of decimal digits; must be <code>0</code> or more
> ").
> I understand that in case of VARCHAR type we cannot speak about real number
> of decimal digits - but could just driver return 0 instead of -1?
That certainly looks like a reasonable thing to do for text types. The
one case that needs a little more thinking about is a numeric field that
has neither precision nor scale supplied. For this we currently return -1
for both precision and scale. The maximum precision of a numeric is 1000
digits, so we could divy it up evenly and make an unadorned numeric be
returned as numeric(1000,500), but that seems a little too much like just
making things up. Thoughts?
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: ResultSetMetaData + CachedResultSet bug
2006-06-22 14:59 ResultSetMetaData + CachedResultSet bug Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
2006-06-29 23:47 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
@ 2006-06-30 08:10 ` Thomas Hallgren <thomas@tada.se>
2006-06-30 16:23 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
2006-11-03 07:22 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Hallgren @ 2006-06-30 08:10 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
>
>
> On Thu, 22 Jun 2006, Sergii Sinelnychenko wrote:
>
>> Today I have found a strange bug in JDBC driver (I used the last
>> version avilable - 8.2dev-503). The problem is with VARCHAR fields -
>> driver returns "-1" on "getPrecision()" call. But class
>> javax.sql.rowset.RowSetMetaDataImpl in its "setPrecision()" method
>> requires values of 0 and more (javadoc sais "precision the total
>> number of decimal digits; must be <code>0</code> or more ").
>> I understand that in case of VARCHAR type we cannot speak about real
>> number of decimal digits - but could just driver return 0 instead of -1?
>
>
> That certainly looks like a reasonable thing to do for text types. The
> one case that needs a little more thinking about is a numeric field that
> has neither precision nor scale supplied. For this we currently return
> -1 for both precision and scale. The maximum precision of a numeric is
> 1000 digits, so we could divy it up evenly and make an unadorned numeric
> be returned as numeric(1000,500), but that seems a little too much like
> just making things up. Thoughts?
>
I think the current -1 is reasonable for non numeric types. For the numeric types however,
the interpretation should be that 0 is unlimited. A numeric should never return -1 and
should accept setPrecision(colidx, 0) as 'no limit', i.e.
0 = unlimited
-1 = not applicable
A setPrecision call on types where precision has no meaning should IMO yield an exception.
The rationale is that a) stating that a varchar has zero decimal digits is wrong since it
doesn't have any notion of decimal digits, and b) a precision of zero for a numeric doesn't
make sense when interpreted verbatim.
Regards,
Thomas Hallgren
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: ResultSetMetaData + CachedResultSet bug
2006-06-22 14:59 ResultSetMetaData + CachedResultSet bug Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
2006-06-29 23:47 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
2006-06-30 08:10 ` Re: ResultSetMetaData + CachedResultSet bug Thomas Hallgren <thomas@tada.se>
@ 2006-06-30 16:23 ` Kris Jurka <books@ejurka.com>
1 sibling, 0 replies; 5+ messages in thread
From: Kris Jurka @ 2006-06-30 16:23 UTC (permalink / raw)
To: Thomas Hallgren <thomas@tada.se>; +Cc: pgsql-jdbc
On Fri, 30 Jun 2006, Thomas Hallgren wrote:
> I think the current -1 is reasonable for non numeric types. For the numeric
> types however, the interpretation should be that 0 is unlimited. A numeric
> should never return -1 and should accept setPrecision(colidx, 0) as 'no
> limit', i.e.
>
> 0 = unlimited
> -1 = not applicable
>
> A setPrecision call on types where precision has no meaning should IMO yield
> an exception.
>
> The rationale is that a) stating that a varchar has zero decimal digits is
> wrong since it doesn't have any notion of decimal digits, and b) a precision
> of zero for a numeric doesn't make sense when interpreted verbatim.
I'm not sure what the harm in using zero for text types' precision is.
Yes, I agree it'd be best if all applications were smart enough to use the
type information correctly, but they're not. Especially when it's
something in the standard JDK that everyone uses I think we should try to
work around it if we can.
What about scale for an unspecified numeric? zero is a legitimate scale
so that can't be used for unlimited, but RowSetMetaDataImpl doesn't like
anything < 0.
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: ResultSetMetaData + CachedResultSet bug
2006-06-22 14:59 ResultSetMetaData + CachedResultSet bug Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
2006-06-29 23:47 ` Re: ResultSetMetaData + CachedResultSet bug Kris Jurka <books@ejurka.com>
2006-06-30 08:10 ` Re: ResultSetMetaData + CachedResultSet bug Thomas Hallgren <thomas@tada.se>
@ 2006-11-03 07:22 ` Kris Jurka <books@ejurka.com>
1 sibling, 0 replies; 5+ messages in thread
From: Kris Jurka @ 2006-11-03 07:22 UTC (permalink / raw)
To: Thomas Hallgren <thomas@tada.se>; +Cc: pgsql-jdbc
On Fri, 30 Jun 2006, Thomas Hallgren wrote:
> Kris Jurka wrote:
>>
>> [what to do about precision for non-numeric types]
>>
> I think the current -1 is reasonable for non numeric types. For the numeric
> types however, the interpretation should be that 0 is unlimited. A numeric
> should never return -1 and should accept setPrecision(colidx, 0) as 'no
> limit', i.e.
>
> 0 = unlimited
> -1 = not applicable
>
> The rationale is that a) stating that a varchar has zero decimal digits is
> wrong since it doesn't have any notion of decimal digits, and b) a precision
> of zero for a numeric doesn't make sense when interpreted verbatim.
>
The latest javadocs have clarified what they expect precision to mean for
non-numeric datatypes.
http://download.java.net/jdk6/docs/api/java/sql/ResultSetMetaData.html#getPrecision(int)
I've adjusted the driver to follow the new rules and not return -1
anymore.
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2006-11-03 07:22 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-22 14:59 ResultSetMetaData + CachedResultSet bug Sergii Sinelnychenko <SSinelnychenko@bossdev.com>
2006-06-29 23:47 ` Kris Jurka <books@ejurka.com>
2006-06-30 08:10 ` Thomas Hallgren <thomas@tada.se>
2006-06-30 16:23 ` Kris Jurka <books@ejurka.com>
2006-11-03 07:22 ` Kris Jurka <books@ejurka.com>
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