Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 51D276347BA for ; Fri, 11 Dec 2009 12:54:24 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 14294-10 for ; Fri, 11 Dec 2009 16:54:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com [209.85.210.181]) by mail.postgresql.org (Postfix) with ESMTP id 5928063355E for ; Fri, 11 Dec 2009 12:54:13 -0400 (AST) Received: by yxe11 with SMTP id 11so904579yxe.15 for ; Fri, 11 Dec 2009 08:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=E/iShpZJWVSX9eW3hqTCsP0rHmSuZp1zD4LceKbhJSY=; b=fo3zmCpvkIZo1buemarYt+GMxU49SUUwusvyPkL0b0mAG3qUrTJvBjT6wv4r7nZMKF Vo5F7Pq2MgBeQtTCbta8NiiRm/TJDp+/8ksHSwhscMmsAdXswaS2+R1rRJOJxRkUsfhI CedGO08ohVqLT+MMJXev1RLi6k9iiWkg9spN4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=mW0fih3wLAgdqjkCwMK7qL27zHKDG9xx3HIa3n5o2y98L5X//cLwzBx2NKL9qZdAzU yckJg+xK3Eop8fIPeYVjzxtFWmjT0tPKEGkm7vkafUHMPO8YbGZkxG215KfQrmmLE/M1 WtbmtgFf731vDuxh4jHOX72WUvnrofGT3AyT0= MIME-Version: 1.0 Received: by 10.150.21.1 with SMTP id 1mr2829560ybu.146.1260550449717; Fri, 11 Dec 2009 08:54:09 -0800 (PST) In-Reply-To: <19400.1260548963@sss.pgh.pa.us> References: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com> <19400.1260548963@sss.pgh.pa.us> Date: Fri, 11 Dec 2009 16:54:09 +0000 Message-ID: <407fa4640912110854y551f47d8q6ba4acb048cdd4f9@mail.gmail.com> Subject: Re: real -> numeric -> real result different through jdbc From: Michael Nacos To: Tom Lane Cc: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=000e0cd630a2c6e1cb047a76c5ce X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.505 tagged_above=-10 required=5 tests=AWL=0.093, BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200912/28 X-Sequence-Number: 20109 --000e0cd630a2c6e1cb047a76c5ce Content-Type: text/plain; charset=UTF-8 2009/12/11 Tom Lane > I seem to recall hearing that JDBC fools with the extra_float_digits > setting. The "0.60000002" looks like it probably is the actual result > of casting 0.6 to float4 --- remember float4 is only good to about six > decimal digits. The default display of float4 rounds off at six digits, > but in some contexts you don't want that rounding to happen because it > might result in losing even more precision. JDBC is being conservative > and taking the latter approach. > thanks tom, we have just discovered this setting hidden away in ConnectionFactoryImpl.java of the JDBC sources. surely, it's not just a case of float4 display, type casting seems to be affected, too. does casting use the default display or does the internal representation change? It is causing our regression tests, which test for equality at the SQL level, to fail. cheers, Michael --000e0cd630a2c6e1cb047a76c5ce Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2009/12/11 Tom Lane <tgl@sss.pgh.pa.us>
I seem to recall hearing that JDBC fools with the extra_float_digits<= br> setting. =C2=A0The "0.60000002" looks like it probably is the act= ual result
of casting 0.6 to float4 --- remember float4 is only good to about six
decimal digits. =C2=A0The default display of float4 rounds off at six digit= s,
but in some contexts you don't want that rounding to happen because it<= br> might result in losing even more precision. =C2=A0JDBC is being conservativ= e
and taking the latter approach.

thanks tom,

we have just discovered this set= ting hidden away in ConnectionFactoryImpl.java of the JDBC sources.
sure= ly, it's not just a case of float4 display, type casting seems to be af= fected, too.
does casting use the default display or does the internal representation ch= ange?
It is causing our regression tests, which test for equality at the= SQL level, to fail.

cheers, Michael

--000e0cd630a2c6e1cb047a76c5ce--