1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

PL/Python: Fix crash when colnames() etc. called without result set

The result object methods colnames() etc. would crash when called
after a command that did not produce a result set.  Now they throw an
exception.

discovery and initial patch by Jean-Baptiste Quenot
This commit is contained in:
Peter Eisentraut
2012-04-15 20:23:08 +03:00
parent 4efbb7d04f
commit c03523ed3f
4 changed files with 49 additions and 13 deletions

View File

@@ -93,9 +93,9 @@ SELECT join_sequences(sequences) FROM sequences
-- plan and result objects
--
CREATE FUNCTION result_nrows_test() RETURNS int
CREATE FUNCTION result_metadata_test(cmd text) RETURNS int
AS $$
plan = plpy.prepare("SELECT 1 AS foo, '11'::text AS bar UNION SELECT 2, '22'")
plan = plpy.prepare(cmd)
plpy.info(plan.status()) # not really documented or useful
result = plpy.execute(plan)
if result.status() > 0:
@@ -107,7 +107,8 @@ else:
return None
$$ LANGUAGE plpythonu;
SELECT result_nrows_test();
SELECT result_metadata_test($$SELECT 1 AS foo, '11'::text AS bar UNION SELECT 2, '22'$$);
SELECT result_metadata_test($$CREATE TEMPORARY TABLE foo1 (a int, b text)$$);
-- cursor objects