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

Поиск
Список
Период
Сортировка
От Basil Peace
Тема Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
Дата
Msg-id 1122541375634815@web11d.yandex.ru
обсуждение исходный текст
Ответ на Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-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
andNaNs 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
saysme 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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: mnl.post@gmail.com
Дата:
Сообщение: BUG #8363: checksum verification fails with StackBuilder
Следующее
От: kd_sargent@msn.com
Дата:
Сообщение: BUG #8362: postres webserver