diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2013-02-03 00:31:01 -0500 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2013-02-03 00:31:01 -0500 |
commit | 330ed4ac6c55294c62bfd975d6e1aafda274e096 (patch) | |
tree | 65a81a116a9d82a9350976d434372f58f6360a0d /src/pl/plpython/sql/plpython_spi.sql | |
parent | d2d153fdb08053d655bd0fef14187eed6a674193 (diff) | |
download | postgresql-330ed4ac6c55294c62bfd975d6e1aafda274e096.tar.gz |
PL/Python: Add result object str handler
This is intended so that say plpy.debug(rv) prints something useful for
debugging query execution results.
reviewed by Steve Singer
Diffstat (limited to 'src/pl/plpython/sql/plpython_spi.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_spi.sql | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_spi.sql b/src/pl/plpython/sql/plpython_spi.sql index 6250e90d19..7a84473803 100644 --- a/src/pl/plpython/sql/plpython_spi.sql +++ b/src/pl/plpython/sql/plpython_spi.sql @@ -169,6 +169,16 @@ $$ LANGUAGE plpythonu; SELECT result_empty_test(); +CREATE FUNCTION result_str_test(cmd text) RETURNS text +AS $$ +plan = plpy.prepare(cmd) +result = plpy.execute(plan) +return str(result) +$$ LANGUAGE plpythonu; + +SELECT result_str_test($$SELECT 1 AS foo, '11'::text AS bar UNION SELECT 2, '22'$$); +SELECT result_str_test($$CREATE TEMPORARY TABLE foo1 (a int, b text)$$); + -- cursor objects CREATE FUNCTION simple_cursor_test() RETURNS int AS $$ |