pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: 'Florent Guillaume' <fg@nuxeo.com>
To: 'Kevin Grittner' <Kevin.Grittner@wicourts.gov>
Cc: 'DocSea - Patrice Delorme' <pdelorme@docsea.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Bug : FAST_NUMBER_FAILED when getting NaN on BigDecimal
Date: Wed, 12 Sep 2012 10:15:24 -0400
Message-ID: <032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com> (raw)
In-Reply-To: <CAF-4BpPTHo3zXV_hk8Yy_3MHrz2c5KUeeohyzjjVzUHuFtOF3A@mail.gmail.com>
References: <504F144C.20108@docsea.com>
	<504F0006020000250004A19B@gw.wicourts.gov>
	<CAF-4BpPTHo3zXV_hk8Yy_3MHrz2c5KUeeohyzjjVzUHuFtOF3A@mail.gmail.com>

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-
> owner@postgresql.org] On Behalf Of Florent Guillaume
> Sent: Wednesday, September 12, 2012 9:36 AM
> To: Kevin Grittner
> Cc: DocSea - Patrice Delorme; pgsql-jdbc@postgresql.org
> Subject: Re: [JDBC] Bug : FAST_NUMBER_FAILED when getting NaN on
> BigDecimal
> 
> On Tue, Sep 11, 2012 at 4:10 PM, Kevin Grittner
> <Kevin.Grittner@wicourts.gov> wrote:
> > DocSea - Patrice Delorme <pdelorme@docsea.com> wrote:
> >
> >> It is impossible to fetch data when numeric value in database is NaN
> >> It throws FAST_NUMBER_FAILED
> >> (postgresql-jdbc-9.1-902:AbstractJdbc2ResultSet:2176) because my
> >> value is not numeric (NaN).
> >> This is incorect behaviour since 'NaN' is a legal value in postgres
> >> for numeric type.
> >
> > How do you expect what you read to be represented in Java?
> 
> java.lang.Double.NaN I guess.
> 
> 

I would think returning a special "Double" value when the expected datatype is "BigDecimal" would cause problems.  I would expect it to return NULL since that is the closest you are going to get to the semantic meaning of NaN with the existing BigDecimal class.

Maybe someone would a add a class to the JDBC driver that is a sub-class of BigDecimal with infinity and NaN query/representation features but since BigDecimal does not have them, and for backwards compatibility number-to-BigDecimal has to remain, there really isn't any better option.

Well, there is one.  If the driver returns NULL is these situations it could still maintain internally whether the NULL is the result of a conversion of INF/-INF/NaN or whether the NULL was in the data itself.  The driver could expose a "isNaN(), isPosInf(), and isNegInf() methods that the user could query upon seeing a NULL BigDecimal so that it knows the "meaning" of the NULL.  Backward compatibility only requires that the BigDecimal is still returned, new features can be added.

You either need to cast to a "float" in PostgreSQL so that the result is stored into a "Double" in Java or figure out some other application specific workaround.

David J.








view thread (13+ messages)  latest in thread

Message-ID: <032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com>
Permalink:  ../032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com/
Also on:    postgresql.org/message-id/032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: polobo@yahoo.com, fg@nuxeo.com, Kevin.Grittner@wicourts.gov, pdelorme@docsea.com
  Subject: Re: Bug : FAST_NUMBER_FAILED when getting NaN on BigDecimal
  In-Reply-To: <032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com>
  References: <504F144C.20108@docsea.com> <504F0006020000250004A19B@gw.wicourts.gov> <CAF-4BpPTHo3zXV_hk8Yy_3MHrz2c5KUeeohyzjjVzUHuFtOF3A@mail.gmail.com> <032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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