X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4CB939FA60B for ; Fri, 30 Jun 2006 05:10:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 68359-01 for ; Fri, 30 Jun 2006 05:10:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mailrelay1.bredband.net (mailrelay1.bredband.net [195.54.107.83]) by postgresql.org (Postfix) with ESMTP id 6A8199FA5FC for ; Fri, 30 Jun 2006 05:10:04 -0300 (ADT) Received: from [192.168.1.100] (1-1-2-48a.rny.sth.bostream.se [82.182.133.12]) by mailrelay1.bredband.net (Postfix) with ESMTP id 7590F508477; Fri, 30 Jun 2006 10:13:01 +0200 (CEST) Message-ID: <44A4DC58.8030200@tada.se> Date: Fri, 30 Jun 2006 10:10:00 +0200 From: Thomas Hallgren User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Kris Jurka Cc: Postgres-JDBC Subject: Re: ResultSetMetaData + CachedResultSet bug References: <032401c6960c$66ad1170$3a14a8c0@bossdev.com.ua> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/140 X-Sequence-Number: 15420 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 0 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