From: Basil Peace <grv87@yandex.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
Date: Sun, 04 Aug 2013 20:46:55 +0400
Message-ID: <1122541375634815@web11d.yandex.ru> (raw)
In-Reply-To: <8645.1375477524@sss.pgh.pa.us>
References: <E1V5C2C-0005EG-L3@wrigleys.postgresql.org>
<7861.1375475031@sss.pgh.pa.us>
<8645.1375477524@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
I based on the documentation of PostgreSQL (http://www.postgresql.org/docs/9.2/static/datatype-numeric.html#DATATYPE-FLOAT) which says about 'Infinity' and '-Infinity' and doesn't mention other possible spellings, including 'inf'.
And on my installation of 9.2.4 'inf' doesn't work too (as I supposed according to documentation):
SELECT 'inf'::float8
ERROR: invalid input syntax for type double precision: "inf"
LINE 2: SELECT 'inf'::float8
According to Python's documentation (http://docs.python.org/2/library/stdtypes.html#typesnumeric), handle of infinities and NaNs was added in 2.6. At least this works in 2.7.1:
Python 2.7.1 (r271:86832, Apr 1 2013, 01:27:27) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> float('inf')
inf
>>> float('infinity')
inf
>>> float('+inf')
inf
>>> float('-inf')
-inf
So, Python is honest in this way. And, C99 says that style of representation ('inf' or 'infinity') is implementation-defined, so it is all OK with modern Python.
> 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.)
As I can judge, signed NaNs are from the same world as signed zeros and signed infinities. Strictly speaking: (-0)/(+0) is -NaN, (-inf)/(+inf) is -NaN, and so on.
I think that PostgreSQL's ability to handle signed zeros (and all other rare stuff) depends on compiler used. Google says me that '-NaN' exists in modern glibc. I don't know about MSVC. My Python accepts '-nan' as input, but doesn't give me '-NaN' as output.
So, I think it would be good if '-NaN' and other forms were workable.
--
Best regards,
Basil Peace
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: grv87@yandex.ru, tgl@sss.pgh.pa.us
Subject: Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
In-Reply-To: <1122541375634815@web11d.yandex.ru>
References: <E1V5C2C-0005EG-L3@wrigleys.postgresql.org> <7861.1375475031@sss.pgh.pa.us> <8645.1375477524@sss.pgh.pa.us> <1122541375634815@web11d.yandex.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox