aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-09-01 19:25:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-09-01 19:25:58 -0400
commite2e78acccaa94e7d64dc2bc0b124cfcf23520918 (patch)
tree84dc2ecb7b8b2da24b1a6707e825d0aabb9796d3
parent813e08123bd9eb7d7eb7bc6eac43b74f5a9a1ef8 (diff)
downloadpostgresql-e2e78acccaa94e7d64dc2bc0b124cfcf23520918.tar.gz
postgresql-e2e78acccaa94e7d64dc2bc0b124cfcf23520918.zip
Document that PL/Python now returns floats using repr() not str().
Commit 1ce7a57ca neglected to update the user-facing documentation, which described the old behavior precisely.
-rw-r--r--doc/src/sgml/plpython.sgml24
1 files changed, 14 insertions, 10 deletions
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index c838c7b79a5..015bbad8dda 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -288,8 +288,9 @@ $$ LANGUAGE plpythonu;
<sect2>
<title>Data Type Mapping</title>
<para>
- Function arguments are converted from their PostgreSQL type to a
- corresponding Python type:
+ When a PL/Python function is called, its arguments are converted from
+ their PostgreSQL data type to a corresponding Python type:
+
<itemizedlist>
<listitem>
<para>
@@ -322,7 +323,7 @@ $$ LANGUAGE plpythonu;
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,
+ than <literal>decimal</literal>. In Python 3.3 and up,
however, <literal>cdecimal</literal> has been integrated into the
standard library under the name <literal>decimal</literal>, so there is
no longer any difference.
@@ -356,8 +357,9 @@ $$ LANGUAGE plpythonu;
</para>
<para>
- Function return values are converted to the declared PostgreSQL
- return data type as follows:
+ When a PL/Python function returns, its return value is converted to the
+ function's declared PostgreSQL return data type as follows:
+
<itemizedlist>
<listitem>
<para>
@@ -373,16 +375,18 @@ $$ LANGUAGE plpythonu;
When the PostgreSQL return type is <type>bytea</type>, the
return value will be converted to a string (Python 2) or bytes
(Python 3) using the respective Python built-ins, with the
- result being converted <type>bytea</type>.
+ result being converted to <type>bytea</type>.
</para>
</listitem>
<listitem>
<para>
- For all other PostgreSQL return types, the returned Python
- value is converted to a string using the Python
- built-in <literal>str</literal>, and the result is passed to the
- input function of the PostgreSQL data type.
+ For all other PostgreSQL return types, the return value is converted
+ to a string using the Python built-in <literal>str</literal>, and the
+ result is passed to the input function of the PostgreSQL data type.
+ (If the Python value is a <type>float</>, it is converted using
+ the <literal>repr</> built-in instead of <literal>str</literal>, to
+ avoid loss of precision.)
</para>
<para>