Re: BUG #3686: Incorrect numeric type conversion to long in plpythonu - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #3686: Incorrect numeric type conversion to long in plpythonu
Date
Msg-id 17901.1193008527@sss.pgh.pa.us
Whole thread Raw
In response to BUG #3686: Incorrect numeric type conversion to long in plpythonu  ("Sergi" <sergi.vladykin@googlemail.com>)
List pgsql-bugs
"Sergi" <sergi.vladykin@googlemail.com> writes:
> Problem is that numeric type converts to pythons long
> incorrectly. Here is the simple script that shows this.

The reason you're having a problem is that plpython translates PG's
numeric datatype to Python Float type, and thus the precision is
lost before the long() function ever sees it.

We can't fix this by translating to Long instead, since that would lose
fractional digits.

We could consider translating to the Decimal type proposed in PEP 327
http://www.python.org/dev/peps/pep-0327/
however it appears that that's only standard in Python 2.4 and later
which makes it rather a large portability problem.  I have no idea
what sort of backwards-compatibility issues such a change would
create, either ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3682: Incomplete database restore
Next
From: "Gary Chambers"
Date:
Subject: Re: BUG #3682: Incomplete database restore