Google Groups Home
Help | Sign in
ResultSetMetaData + CachedResultSet bug
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
"Sergii Sinelnychenko"  
View profile
 More options Jun 22 2006, 10:59 am
Newsgroups: pgsql.interfaces.jdbc
From: SSinelnyche...@bossdev.com ("Sergii Sinelnychenko")
Date: Thu, 22 Jun 2006 17:59:03 +0300
Local: Thurs, Jun 22 2006 10:59 am
Subject: ResultSetMetaData + CachedResultSet bug
        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: SSinelnyche...@bossdev.com
w: www.bossdev.com

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kris Jurka  
View profile
 More options Jun 29 2006, 7:47 pm
Newsgroups: pgsql.interfaces.jdbc
From: bo...@ejurka.com (Kris Jurka)
Date: Thu, 29 Jun 2006 18:47:02 -0500 (EST)
Local: Thurs, Jun 29 2006 7:47 pm
Subject: Re: ResultSetMetaData + CachedResultSet bug

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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Hallgren  
View profile
 More options Jun 30 2006, 4:10 am
Newsgroups: pgsql.interfaces.jdbc
From: tho...@tada.se (Thomas Hallgren)
Date: Fri, 30 Jun 2006 10:10:00 +0200
Subject: Re: ResultSetMetaData + CachedResultSet bug

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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kris Jurka  
View profile
 More options Jun 30 2006, 12:23 pm
Newsgroups: pgsql.interfaces.jdbc
From: bo...@ejurka.com (Kris Jurka)
Date: Fri, 30 Jun 2006 11:23:10 -0500 (EST)
Local: Fri, Jun 30 2006 12:23 pm
Subject: Re: ResultSetMetaData + CachedResultSet bug

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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kris Jurka  
View profile
 More options Nov 3 2006, 2:22 am
Newsgroups: pgsql.interfaces.jdbc
From: bo...@ejurka.com (Kris Jurka)
Date: Fri, 3 Nov 2006 02:22:44 -0500 (EST)
Local: Fri, Nov 3 2006 2:22 am
Subject: Re: ResultSetMetaData + CachedResultSet bug

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.htm...)

I've adjusted the driver to follow the new rules and not return -1
anymore.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google