From 87daae1143520309da299b78a8e7a68f141a268f Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Tue, 28 Feb 2006 20:03:52 +0000 Subject: Allow PL/Python functions to return void, per gripe from James Robinson (I didn't use his patch, however). A void-returning PL/Python function must return None (from Python), which is translated into a void datum (and *not* NULL) for Postgres. I also added some regression tests for this functionality. --- src/pl/plpython/sql/plpython_function.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/pl/plpython/sql/plpython_function.sql') diff --git a/src/pl/plpython/sql/plpython_function.sql b/src/pl/plpython/sql/plpython_function.sql index e3ec2afe014..7428a599eea 100644 --- a/src/pl/plpython/sql/plpython_function.sql +++ b/src/pl/plpython/sql/plpython_function.sql @@ -341,3 +341,18 @@ plan = plpy.prepare("SELECT $1 AS testvalue1, $2 AS testvalue2", ["text", "text" rv = plpy.execute(plan, u"\\x80", 1) return rv[0]["testvalue1"] ' LANGUAGE plpythonu; + +-- Tests for functions that return void + +CREATE FUNCTION test_void_func1() RETURNS void AS $$ +x = 10 +$$ LANGUAGE plpythonu; + +-- illegal: can't return non-None value in void-returning func +CREATE FUNCTION test_void_func2() RETURNS void AS $$ +return 10 +$$ LANGUAGE plpythonu; + +CREATE FUNCTION test_return_none() RETURNS int AS $$ +None +$$ LANGUAGE plpythonu; -- cgit v1.2.3