diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2012-01-30 21:38:52 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2012-01-30 21:38:52 +0200 |
commit | ee7fa66b19f5454fac07caee4b7798810b579a82 (patch) | |
tree | 2cb224c8f99c3626f562f14fa7aa9b6990465010 /src/pl/plpython/sql/plpython_spi.sql | |
parent | c6ea8ccea6bf23501962ddc7ac9ffdb99c8643e1 (diff) | |
download | postgresql-ee7fa66b19f5454fac07caee4b7798810b579a82.tar.gz postgresql-ee7fa66b19f5454fac07caee4b7798810b579a82.zip |
PL/Python: Add result metadata functions
Add result object functions .colnames, .coltypes, .coltypmods to
obtain information about the result column names and types, which was
previously not possible in the PL/Python SPI interface.
reviewed by Abhijit Menon-Sen
Diffstat (limited to 'src/pl/plpython/sql/plpython_spi.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_spi.sql | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pl/plpython/sql/plpython_spi.sql b/src/pl/plpython/sql/plpython_spi.sql index 874b31e6df6..b828744d1f8 100644 --- a/src/pl/plpython/sql/plpython_spi.sql +++ b/src/pl/plpython/sql/plpython_spi.sql @@ -95,10 +95,13 @@ SELECT join_sequences(sequences) FROM sequences CREATE FUNCTION result_nrows_test() RETURNS int AS $$ -plan = plpy.prepare("SELECT 1 UNION SELECT 2") +plan = plpy.prepare("SELECT 1 AS foo, '11'::text AS bar UNION SELECT 2, '22'") plpy.info(plan.status()) # not really documented or useful result = plpy.execute(plan) if result.status() > 0: + plpy.info(result.colnames()) + plpy.info(result.coltypes()) + plpy.info(result.coltypmods()) return result.nrows() else: return None |