BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value - Mailing list pgsql-bugs

From grv87@yandex.ru
Subject BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
Date
Msg-id E1V5C2C-0005EG-L3@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8355
Logged by:          Basil Peace
Email address:      grv87@yandex.ru
PostgreSQL version: 9.2.4
Operating system:   Windows 7 x64 (PostgreSQL is x86), Python 3.2.5
Description:

PL/Python can't convert Python's float with infinity value to PostgreSQL's
float.
The reason is that Python's standard representation of infinity is 'inf'
('Infinity' is accepted as well), but PostgreSQL's representation is
'Infinity' only.
I'm speaking of Python 3 version since I have no Python 2 to test.


Consider the following code:


-- CREATE LANGUAGE plpython3u;


CREATE TABLE IF NOT EXISTS test10 (
    a double precision
);


DO LANGUAGE plpython3u $$
    plan = plpy.prepare('INSERT INTO test10 (a) VALUES ($1)', ['double
precision'])
    a = float('inf')
    plpy.execute(plan, [a])
$$;




ERROR:  spiexceptions.InvalidTextRepresentation: invalid input syntax for
type double precision: "inf"
CONTEXT:  Traceback (most recent call last):
  PL/Python anonymous code block, line 4, in <module>
    plpy.execute(plan, [a])
PL/Python anonymous code block




I suppose this should work without any workarounds.

pgsql-bugs by date:

Previous
From: alex@hill.net.au
Date:
Subject: BUG #8354: stripped positions can generate nonzero rank in ts_rank_cd
Next
From: Tom Lane
Date:
Subject: Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value