Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit075ab42

Browse files
committed
Document that PL/Python now returns floats using repr() not str().
Commit1ce7a57 neglected to update the user-facing documentation,which described the old behavior precisely.
1 parentadb4950 commit075ab42

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

‎doc/src/sgml/plpython.sgml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ $$ LANGUAGE plpythonu;
288288
<sect2>
289289
<title>Data Type Mapping</title>
290290
<para>
291-
Function arguments are converted from their PostgreSQL type to a
292-
corresponding Python type:
291+
When a PL/Python function is called, its arguments are converted from
292+
their PostgreSQL data type to a corresponding Python type:
293+
293294
<itemizedlist>
294295
<listitem>
295296
<para>
@@ -322,7 +323,7 @@ $$ LANGUAGE plpythonu;
322323
Otherwise,
323324
<literal>decimal.Decimal</literal> from the standard library will be
324325
used. <literal>cdecimal</literal> is significantly faster
325-
than <literal>decimal</literal>. In Python 3.3,
326+
than <literal>decimal</literal>. In Python 3.3 and up,
326327
however, <literal>cdecimal</literal> has been integrated into the
327328
standard library under the name <literal>decimal</literal>, so there is
328329
no longer any difference.
@@ -356,8 +357,9 @@ $$ LANGUAGE plpythonu;
356357
</para>
357358

358359
<para>
359-
Function return values are converted to the declared PostgreSQL
360-
return data type as follows:
360+
When a PL/Python function returns, its return value is converted to the
361+
function's declared PostgreSQL return data type as follows:
362+
361363
<itemizedlist>
362364
<listitem>
363365
<para>
@@ -373,16 +375,18 @@ $$ LANGUAGE plpythonu;
373375
When the PostgreSQL return type is <type>bytea</type>, the
374376
return value will be converted to a string (Python 2) or bytes
375377
(Python 3) using the respective Python built-ins, with the
376-
result being converted <type>bytea</type>.
378+
result being convertedto<type>bytea</type>.
377379
</para>
378380
</listitem>
379381

380382
<listitem>
381383
<para>
382-
For all other PostgreSQL return types, the returned Python
383-
value is converted to a string using the Python
384-
built-in <literal>str</literal>, and the result is passed to the
385-
input function of the PostgreSQL data type.
384+
For all other PostgreSQL return types, the return value is converted
385+
to a string using the Python built-in <literal>str</literal>, and the
386+
result is passed to the input function of the PostgreSQL data type.
387+
(If the Python value is a <type>float</>, it is converted using
388+
the <literal>repr</> built-in instead of <literal>str</literal>, to
389+
avoid loss of precision.)
386390
</para>
387391

388392
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp