Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4

From: Chris Mair <list(at)1006(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4
Date: 2005-01-09 18:11:20
Message-ID: 1105294280.4353.75.camel@dell
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general pgsql-hackers pgsql-ports

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("strtod returned 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.

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message Tom Lane 2005-01-09 18:43:28 Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4
Previous Message Tom Lane 2005-01-09 17:09:18 Re: [PORTS] PostgreSQL 8.0.0 Release Candidate 4

Browse pgsql-general by date

  From Date Subject
Next Message mstory 2005-01-09 18:40:35 Re: PYTHON, ODBC
Previous Message Tom Lane 2005-01-09 17:09:18 Re: [PORTS] PostgreSQL 8.0.0 Release Candidate 4

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-01-09 18:43:28 Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4
Previous Message Peter Eisentraut 2005-01-09 17:45:35 Re: PostgreSQL 8 for Win32 -- installation problem

Browse pgsql-ports by date

  From Date Subject
Next Message Tom Lane 2005-01-09 18:43:28 Re: [GENERAL] PostgreSQL 8.0.0 Release Candidate 4
Previous Message Peter Eisentraut 2005-01-09 17:45:35 Re: PostgreSQL 8 for Win32 -- installation problem