numeric input changes
The attached patch changes the rules for input to
int2/int4/int8/float4/float8 to consistently allow leading and
trailing whitespace in the input. This is for conformance with the
SQL standard, as discussed in an earlier -patches thread.
I also added a bunch more regression tests for the input format
accepted by these types.
I noticed one bug, or at least instance of bit rot: the float8 code
attempts to parse "Infinity" and "-Infinity" specially. Unfortunately,
this doesn't actually work:
nconway=# select 'Infinity'::float8;
ERROR: type "double precision" value out of range: overflow
nconway=# select '-Infinity'::float8;
ERROR: type "double precision" value out of range: overflow
I'm inclined to just remove this attempted functionality from the
code, rather than fix it to work properly. Any comments?
I intend to apply this patch tomorrow.
-Neil
Attachments:
numeric_whitespace_input-4.patchtext/x-patchDownload+572-278
I noticed one bug, or at least instance of bit rot: the float8 code
attempts to parse "Infinity" and "-Infinity" specially. Unfortunately,
this doesn't actually work:
Infinity doesn't work for float4 either.
Neil Conway <neilc@samurai.com> writes:
nconway=# select 'Infinity'::float8;
ERROR: type "double precision" value out of range: overflow
nconway=# select '-Infinity'::float8;
ERROR: type "double precision" value out of range: overflow
I'm inclined to just remove this attempted functionality from the
code, rather than fix it to work properly. Any comments?
This works in 7.4 and older releases. Sounds to me like you broke it.
regards, tom lane
On Wed, 10 Mar 2004, Tom Lane wrote:
nconway=# select 'Infinity'::float8;
ERROR: type "double precision" value out of range: overflowThis works in 7.4 and older releases. Sounds to me like you broke it.
It does not work on 7.3 and 7.4 when I try.
Looking at the currect cvs code it's not just parsing 'Infinity' as a
value, there is also an overflow check after float operations that will
exclude Infinity and Nan.
By the way, this thing was discussed on irc and I just sent a mail on
-hackers about it, not knowing about this thread here.
There are too many lists :-)
--
/Dennis Bj�rklund
Dennis Bjorklund <db@zigo.dhs.org> writes:
By the way, this thing was discussed on irc and I just sent a mail on
-hackers about it, not knowing about this thread here.
Yeah, let's take the discussion to -hackers using your message as a
base.
regards, tom lane
Neil Conway <neilc@samurai.com> writes:
The attached patch changes the rules for input to
int2/int4/int8/float4/float8 to consistently allow leading and
trailing whitespace in the input.
I've attached a slightly revised version of the patch, which I've
applied to CVS HEAD. I realized that pg_atoi() can be implemented more
simply -- that's the only change. Also, I decided to apply the patch
tonight, so that I can get started on the float4/float8 Infinity
stuff more easily.
-Neil
Neil Conway <neilc@samurai.com> writes:
I've attached a slightly revised version of the patch, which I've
applied to CVS HEAD.
*sigh*, actually attached this time.
-Neil
Attachments:
numeric_whitespace_input-5.patchtext/x-patchDownload+562-288
Neil Conway <neilc@samurai.com> writes:
The attached patch changes the rules for input to
int2/int4/int8/float4/float8 to consistently allow leading and
trailing whitespace in the input.
BTW, did you look at type "numeric"? Or is that okay already?
regards, tom lane