From: David Johnston <polobo@yahoo.com>
To: 'Albe Laurenz' <laurenz.albe@wien.gv.at>
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 11:02:33 -0400
Message-ID: <033801cd90f7$a3e55510$ebafff30$@yahoo.com> (raw)
In-Reply-To: <D960CB61B694CF459DCFB4B0128514C2086259D3@exadv11.host.magwien.gv.at>
References: <504F144C.20108@docsea.com>
<504F0006020000250004A19B@gw.wicourts.gov>
<CAF-4BpPTHo3zXV_hk8Yy_3MHrz2c5KUeeohyzjjVzUHuFtOF3A@mail.gmail.com>
<032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com>
<D960CB61B694CF459DCFB4B0128514C2086259D3@exadv11.host.magwien.gv.at>
> -----Original Message-----
> From: Albe Laurenz [mailto:laurenz.albe@wien.gv.at]
> Sent: Wednesday, September 12, 2012 10:48 AM
> To: David Johnston *EXTERN*; Florent Guillaume; Kevin Grittner
> Cc: DocSea - Patrice Delorme; pgsql-jdbc@postgresql.org
> Subject: RE: [JDBC] Bug : FAST_NUMBER_FAILED when getting NaN on
> BigDecimal
>
> David Johnston wrote:
> >>>> It is impossible to fetch data when numeric value in database is
> >>>> NaN
>
> >>> How do you expect what you read to be represented in Java?
>
> >> java.lang.Double.NaN I guess.
>
> > 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.
>
> I don't think that's a good idea.
>
> Apart from the fact that a null pointer isn't a good representation for an out-
> of-bounds value, that would change the behaviour and might break
> applications that expect the current behaviour.
>
> I think it is OK to throw an exception if a value cannot be represented, but it
> should be a meaningful message.
>
OK. So the API would be more along the lines of: "if you are concerned with NaN/Infinity values you can poll the result first to see if the returned value is valid or not. If the returned value is invalid and the user tries to read the value they get their exception. If the user sees that the value is invalid (from the polling) then they should forego reading the value and instead interpret whatever invalid value is indicated. An actual NULL would be a valid value."
I am unsure exactly WHEN the exception in this case is thrown but if too early then sub-classing BigDecimal is not possible since the exception would preclude the object ever being created (for backwards compatibility).
Personally, I believe there needs to be some way to access this aspect of the PostgreSQL numeric type but it is not something that, aside from a desire for completeness, currently affects me. Even a more fine-grained exception hierarchy (NaNException, PositiveInfinityException, NegativeInfinityException) that the user could catch on could be helpful (instead of having to perform string manipulation of the error message). In any cases a non-standard class would be necessary so whether the driver provides ones or it simply provide information and requires the user to code whatever Class is appropriate is an explicit decision to make.
David J.
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, laurenz.albe@wien.gv.at, fg@nuxeo.com, Kevin.Grittner@wicourts.gov, pdelorme@docsea.com
Subject: Re: Bug : FAST_NUMBER_FAILED when getting NaN on BigDecimal
In-Reply-To: <033801cd90f7$a3e55510$ebafff30$@yahoo.com>
References: <504F144C.20108@docsea.com> <504F0006020000250004A19B@gw.wicourts.gov> <CAF-4BpPTHo3zXV_hk8Yy_3MHrz2c5KUeeohyzjjVzUHuFtOF3A@mail.gmail.com> <032f01cd90f1$0d28d3f0$277a7bd0$@yahoo.com> <D960CB61B694CF459DCFB4B0128514C2086259D3@exadv11.host.magwien.gv.at> <033801cd90f7$a3e55510$ebafff30$@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