| From: | Marko Kreen <markokr(at)gmail(dot)com> |
|---|---|
| To: | Postgres Hackers List <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | [patch] PL/Python is too lossy with floats |
| Date: | 2015-03-03 14:32:16 |
| Message-ID: | 20150303143216.GA12187@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
PL/Python uses str(v) to convert float data, but is lossy
by design. Only repr(v) is guaranteed to have enough
precision to make floats roundtrip properly:
https://docs.python.org/2/library/functions.html#func-repr
https://docs.python.org/2/library/functions.html#str
Example:
$ python
>>> repr(100100100.654321)
'100100100.654321'
>>> str(100100100.654321)
'100100100.654'
Attached patch uses PyObject_Repr() for float data.
As it's annoying-to-debug problem and the patch is simple,
perhaps it's worth backporting?
--
marko
| Attachment | Content-Type | Size |
|---|---|---|
| plpy-float-repr.diff | text/x-diff | 1.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2015-03-03 14:39:03 | Re: autogenerated column names + views are a dump hazard |
| Previous Message | Jan de Visser | 2015-03-03 14:19:34 | Re: Idea: closing the loop for "pg_ctl reload" |