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.