aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2013-07-05 22:41:25 -0400
committerPeter Eisentraut <peter_e@gmx.net>2013-07-05 22:41:25 -0400
commit7919398bac8bacd75ec5d763ce8b15ffaaa3e071 (patch)
treee5c1a77a161560da6ce1a6879f9bf3d3408a81eb /doc/src
parent02d2b694ee42a9e241d37ce67df122fff43d5bb9 (diff)
downloadpostgresql-7919398bac8bacd75ec5d763ce8b15ffaaa3e071.tar.gz
postgresql-7919398bac8bacd75ec5d763ce8b15ffaaa3e071.zip
PL/Python: Convert numeric to Decimal
The old implementation converted PostgreSQL numeric to Python float, which was always considered a shortcoming. Now numeric is converted to the Python Decimal object. Either the external cdecimal module or the standard library decimal module are supported. From: Szymon Guz <mabewlun@gmail.com> From: Ronan Dunklau <rdunklau@gmail.com> Reviewed-by: Steve Singer <steve@ssinger.info>
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/plpython.sgml23
1 files changed, 17 insertions, 6 deletions
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index aaf758d4959..ad89355d60d 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -310,12 +310,23 @@ $$ LANGUAGE plpythonu;
<listitem>
<para>
- PostgreSQL <type>real</type>, <type>double</type>,
- and <type>numeric</type> are converted to
- Python <type>float</type>. Note that for
- the <type>numeric</type> this loses information and can lead to
- incorrect results. This might be fixed in a future
- release.
+ PostgreSQL <type>real</type> and <type>double</type> are converted to
+ Python <type>float</type>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ PostgreSQL <type>numeric</type> is converted to
+ Python <type>Decimal</type>. This type is imported from
+ the <literal>cdecimal</literal> package if that is available.
+ Otherwise,
+ <literal>decimal.Decimal</literal> from the standard library will be
+ used. <literal>cdecimal</literal> is significantly faster
+ than <literal>decimal</literal>. In Python 3.3,
+ however, <literal>cdecimal</literal> has been integrated into the
+ standard library under the name <literal>decimal</literal>, so there is
+ no longer any difference.
</para>
</listitem>