Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBoJU-0007vf-No for pgsql-jdbc@postgresql.org; Wed, 12 Sep 2012 14:53:12 +0000 Received: from smtp103.prem.mail.ac4.yahoo.com ([76.13.13.42]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TBoJT-0008Ip-0q for pgsql-jdbc@postgresql.org; Wed, 12 Sep 2012 14:53:12 +0000 Received: (qmail 83305 invoked from network); 12 Sep 2012 14:53:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=qtFbOJh+yqxkEZGfOCUvLt2CZ29yITpOVXd6aGpPFfAxkkVAXQ1tra1+ai4lIGvnQ75O9x+Ahezob/2YREg0OsZU/r3I+C/1HNQplkVlMBLjITCPnOW7H9RHRAOG1KDhEbQUiMtHVJabt3QCp14+BNVgJjI4g6Bp+AxcV1RnXkU= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1347461589; bh=lOZ9BHw1/kywhFUrDfbvlaR4u8EcuvXGBfF9dBBCGCo=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=qvgFYMNoRCVHmihXh5yiqUNgeqDqcRkf4Y/EPG4jA4D66g6Dl+Ak8+mE0tSJW+IX32vb3DvIRRpPMqaxyH5JvN6E8h8gsYjMQNVxG2cbEyC346hMQIaP+xwOm6tH/nKynb5Ij+Sri4fnzuR9rBujfKIGQWY5gXuIWPaWKDUFETQ= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 7OBHUOQVM1nzuBZkwH5qsMriGHg7UU4YOchQWlNrbWdR6FD 0wAmWmaS7367lUmytz2QN7dZRDQbSzN1mwANQgPSf_C6c6f8aeg1ScVNQo2s 7XASvdVPvnKD4j_QXmNFTq4bCfHnegO9f8gQTC46GlEGUipk0zJKL_iizr6m 5N4LZUMLUGoOqNP57otFhssn9DafMnnFxkvyrPNBiREJitiRiC_hX5hDVs24 ZcyQjq32SjaXH8vQVlww1fm8JlCiJBOBvw3UCw6rtJJ5KVsepgnzlFSn6QCL IEqTN7bDneD4ajQrS3g_.3UWEFUXN5PnqF3m0sK4kMcizjkjxz08IU2EHxBu WpcouNqbvdcqymKJzA7mZofibCtfNVRIj8NYzMrUstSzfz5_yxnKVq8zHoOr mhhxg51vhfSf9Xl8HthrY8pCZfKcgbfdxQFdz X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.23.188 with login) by smtp103.prem.mail.ac4.yahoo.com with SMTP; 12 Sep 2012 07:53:09 -0700 PDT From: "David Johnston" To: "'DocSea - Patrice Delorme'" , "'Kevin Grittner'" Cc: References: <504F144C.20108@docsea.com> <504F0006020000250004A19B@gw.wicourts.gov> <50504F13.2020607@docsea.com> In-Reply-To: <50504F13.2020607@docsea.com> Subject: Re: Bug : FAST_NUMBER_FAILED when getting NaN on BigDecimal Date: Wed, 12 Sep 2012 10:52:22 -0400 Message-ID: <033701cd90f6$3753dd50$a5fb97f0$@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJspKfO7IO2mxQup5aMm9BveUG6aAMd0kYVAbG8OgeWIiKvsA== Content-Language: en-us X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201209/26 X-Sequence-Number: 23262 > > You are right, as a matter of Fact BigDecimal does not support NaN like > Double, Float does. > However, postgres DOES support it and I find it disturbing that the driver fails > so badly without explaination (I had to dig in the driver source to find out > what the problem was). > The problem is that somehow I managed to write my Double NaN to > database but wasn't able to read it back even though I was using the very > same driver in both cases! > To me, behaviour is not coherent. Either wriiting of NaN is prevented or > reading is functional ! > > Maybe a more explicit Exception like "numeric NaN values not supported" > and not "org.postgresql.util.PSQLException: Bad value for type BigDecimal : > NaN;" which is rather obscure or to Extend BigDecimal with PgBigDecimal that > supports NaN (and infinity)... > While I can understand the frustration the behavior is such because in the vast majority of cases storing a double into a Postgres numeric is a reasonable thing to do (and, from the driver's standpoint, maybe impossible to detect with certainty anyway). The driver assuming the user of BigDecimal knows it cannot handle NaN is also not a bad assumption to make. Wording could maybe be improved but it susiscently reports the problem encountered (the database sent NaN and the BigDecimal had no idea what to do with it. It isn't like the driver has to know that NaN means Not-A-Number. If the database sent along 'Pig' the same error would be generated but with 'Pig' instead of NaN. Implicit conversions can and do cause problems. That is what happened here. As a user you should not have tried storing a Java Double into a Postgres numeric but you should have converted it into a BigDecimal yourself. If you want consistent behavior that is exactly what you would have been forced to do anyway. Of course you or the driver could write a wrapper do that and also check and report meaningful exceptions when the data and the target type do not match - but given the open source nature of the driver and the uncommon situation you presented, it is understandable that the behavior you saw manifested itself. No one else with the problem felt it was important enough to fix. David J.