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

From: grv87(at)yandex(dot)ru
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value
Date: 2013-08-02 09:52:32
Message-ID: E1V5C2C-0005EG-L3@wrigleys.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8355
Logged by: Basil Peace
Email address: grv87(at)yandex(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2013-08-02 13:22:17 Re: BUG #8328: Unable to start postgresql on the Debian machine.
Previous Message Klaus Ita 2013-08-02 09:29:45 Re: Recovery_target_time misinterpreted?