Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: grv87(at)yandex(dot)ru
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
Date: 2013-08-02 21:05:24
Message-ID: 8645.1375477524@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> ... further experimentation says that this doesn't work on my ancient
> HPUX box; and you're complaining about Windows. So what we've got here
> is a platform dependency in the behavior of strtod(). I don't think
> we can promise to hide all such dependencies, but maybe it'd be a good
> idea to take care of this particular one.

I took a look in the C99 standard, and what it has to say about it is
actually this:

[#3] The expected form of the subject sequence is an
optional plus or minus sign, then one of the following:

-- a nonempty sequence of decimal digits optionally
containing a decimal-point character, then an optional
exponent part as defined in 6.4.4.2;

-- a 0x or 0X, then a nonempty sequence of hexadecimal
digits optionally containing a decimal-point character,
then an optional binary-exponent part as defined in
6.4.4.2, where either the decimal-point character or
the binary-exponent part is present;

-- one of INF or INFINITY, ignoring case

-- one of NAN or NAN(n-char-sequence-opt), ignoring case
in the NAN part, where:
n-char-sequence:
digit
nondigit
n-char-sequence digit
n-char-sequence nondigit

Current versions of the POSIX standard say the same, though SUS v2
didn't mention any of the non-numeric variants.

So what we've got is that Windows and some other (obsolete?) platforms
don't accept everything the standard says they should, and that results in
a visible cross-platform behavioral difference for us.

I'm not at all excited about supporting 0x... constants, nor about the
expanded form of NaN. But it seems like maybe we had better cover the
following cases that we do not cover today:

inf
+inf
-inf
+Infinity

We already backstop strtod() for these cases:

NaN
Infinity
-Infinity

but the wording of the spec clearly requires +Infinity as well as the
forms with just "inf". (It also appears to require +/- NaN to be
accepted, but I have no idea what that would mean and suspect it to
be a thinko.)

Barring objections I'll go make this change.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2013-08-02 22:17:43 Re: 9.3beta2: Failure to pg_upgrade
Previous Message Tom Lane 2013-08-02 20:23:51 Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value