Re: NaN support in NUMERIC data type

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: NaN support in NUMERIC data type
Date: 2009-04-09 00:00:53
Message-ID: 20090409000053.GL12225@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 08, 2009 at 06:11:59PM -0400, Tom Lane wrote:
> Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> > On Tue, Apr 07, 2009 at 12:51:21PM -0400, Tom Lane wrote:
> >> IIRC, the explicit support for leading/trailing spaces is something that
> >> we added in float8in long after numeric_in was written, and I think just
> >> nobody thought about numeric at the time. But it's clearly inconsistent
> >> to allow spaces around a regular value but not a NaN.
>
> > The included patch was generated against 8.3.5 (because that's what I
> > had lying around when I started playing) but applies with a little fuzz
> > to the latest snapshot and does the right thing for me in both versions.
>
> Hmm, did it do the right thing for NaN with a typmod? I doubt
> apply_typmod is safe for a NaN.

Oops, good catch. Didn't think to check for that.

> Anyway, I revised this a bit and applied to HEAD.

I've not tested; but your changes look as though they will break:

SELECT 'Infinity'::float::numeric;

I think you'll get '0' back instead of an error; either that or it's too
late for me to be thinking straight!

> I'm disinclined to back-patch; it's not really a bug
> but a definition change, and we get flack when we put that sort of
> change into stable branches ...

OK

Out of personal interest; why did you translate:

while(isspace(*p)) p++;

into more verbose forms? Is it so it fits in with the style in rest of
the code, or does it actually do something different that I'm missing?

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-04-09 00:16:52 Re: NaN support in NUMERIC data type
Previous Message Peter Eisentraut 2009-04-08 23:47:29 Re: default parameters for built-in functions