Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4 - Mailing list pgsql-hackers

From Chris Mair
Subject Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4
Date
Msg-id 1105294280.4353.75.camel@dell
Whole thread Raw
In response to Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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.















pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [PORTS] PostgreSQL 8 for Win32 -- installation problem
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4