Thread: Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4

Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4

From
Peter Eisentraut
Date:
Chris Mair wrote:
> The Playstation 2 hardware manuals confirm that the FPU has
> no support for NaN and +/-Inf. That explains the regression diffs.
> (EE Core User's Manual Version 5, p. 153)

Well, it does not readily explain that 'infinity' is rejected as invalid 
input syntax.  You should get an overflow or some large value, at 
least.

The relevant code is in src/backend/utils/adt/float.c.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4

From
Chris Mair
Date:
On Sun, 2005-01-09 at 17:45, Peter Eisentraut wrote:

> Well, it does not readily explain that 'infinity' is rejected as invalid 
> input syntax.  You should get an overflow or some large value, at 
> least.
> 
> The relevant code is in src/backend/utils/adt/float.c.

You're right.
I had a look at the code.
It seems strtod() is to blame.

This sample program
   #include <stdio.h>   #include <stdlib.h>   #include <errno.h>   int main()   {     char *endptr;     double val;
char*num = "Infinity";     errno = 0;     val = strtod(num, &endptr);     printf("input string is '%s'\n", num);
printf("strtodreturned val = %lf\n", val);     printf("errno = %d\n", errno);     printf("endptr points to '%s'\n",
endptr); }
 

on the PlayStation 2 returns:
   input string is 'Infinity'   strtod returned val = inf   errno = 0   endptr points to 'inity'

float.c's conversion routine cannot deal with a strtod that just eats
the 'Inf' part of 'Infinity', so the remaining 'inity' is causing the
syntax error (from line 522 in "float.c").

Consistently, this works with the so compiled version of PG:

postgres=# select 'Inf'::float8; float8
----------Infinity
(1 row)

Would it be worth treating this case apart in float.c, or should we just
blame the PlayStation's 2 Linux (quite old version 2.2.2) Gnu C library
to be broken?

I wonder how many implementations of strtod behave this way?
On a few other boxes of mine I've seen versions that accept 'Infinity'
as a whole or reject it as a whole


Bye, Chris.















Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4

From
Tom Lane
Date:
Chris Mair <list@1006.org> writes:
> It seems strtod() is to blame.
> ...
> on the PlayStation 2 returns:

>     input string is 'Infinity'
>     strtod returned val = inf
>     errno = 0
>     endptr points to 'inity'

> Would it be worth treating this case apart in float.c, or should we just
> blame the PlayStation's 2 Linux (quite old version 2.2.2) Gnu C library
> to be broken?

I'd just say that that version of glibc is broken.  I have not seen this
behavior reported anywhere else.

In any case, I think we can update the Playstation 2 entry for 8.0 ...
        regards, tom lane