diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2010-03-29 21:20:58 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2010-03-29 21:20:58 +0000 |
commit | 51d2c9b0bb695e4d876701d0c60acc369cc28ce5 (patch) | |
tree | b0920c158c786d69cc19c336a0a4fe52e3a940c1 /doc/src | |
parent | de66effede5f7cb6da258e1bfe6fc508ad4cf940 (diff) | |
download | postgresql-51d2c9b0bb695e4d876701d0c60acc369cc28ce5.tar.gz postgresql-51d2c9b0bb695e4d876701d0c60acc369cc28ce5.zip |
Add some documentation about PL/Python limitations
suggested by Steve White (bug #5272)
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpython.sgml | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml index 73013840a55..ab9ad2228af 100644 --- a/doc/src/sgml/plpython.sgml +++ b/doc/src/sgml/plpython.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.47 2010/03/21 02:24:29 momjian Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.48 2010/03/29 21:20:58 petere Exp $ --> <chapter id="plpython"> <title>PL/Python - Python Procedural Language</title> @@ -243,7 +243,7 @@ $$ LANGUAGE plpythonu; </para> </sect1> - <sect1> + <sect1 id="plpython-data"> <title>Data Values</title> <para> Generally speaking, the aim of PL/Python is to provide @@ -364,6 +364,18 @@ $$ LANGUAGE plpythonu; return type and the Python data type of the actual return object are not flagged; the value will be converted in any case. </para> + + <tip> + <para> + <application>PL/Python</application> functions cannot return + either type <type>RECORD</type> or <type>SETOF RECORD</type>. A + workaround is to write a <application>PL/pgSQL</application> + function that creates a temporary table, have it call the + <application>PL/Python</application> function to fill the table, + and then have the <application>PL/pgSQL</application> function + return the generic <type>RECORD</type> from the temporary table. + </para> + </tip> </sect2> <sect2> @@ -867,6 +879,20 @@ rv = plpy.execute(plan, [ "name" ], 5) </para> <para> + Query parameters and result row fields are converted between + PostgreSQL and Python data types as described + in <xref linkend="plpython-data">. The exception is that composite + types are currently not supported: They will be rejected as query + parameters and are converted to strings when appearing in a query + result. As a workaround for the latter problem, the query can + sometimes be rewritten so that the composite type result appears as + a result row rather than as a field of the result row. + Alternatively, the resulting string could be parsed apart by hand, + but this approach is not recommended because it is not + future-proof. + </para> + + <para> When you prepare a plan using the PL/Python module it is automatically saved. Read the SPI documentation (<xref linkend="spi">) for a description of what this means. |