diff options
| author | Peter Eisentraut <peter_e@gmx.net> | 2009-08-12 16:37:26 +0000 |
|---|---|---|
| committer | Peter Eisentraut <peter_e@gmx.net> | 2009-08-12 16:37:26 +0000 |
| commit | 9d9848668fd868a4e51f3a3f22c2807ff0e46582 (patch) | |
| tree | 22b0152fb889ca42d3e4c6ce888d2024b8b8c98b /src/pl/plpython/sql/plpython_params.sql | |
| parent | ef7574eb014b66d99a5e68cc254e7a2282e69a00 (diff) | |
| download | postgresql-9d9848668fd868a4e51f3a3f22c2807ff0e46582.tar.gz | |
Split the plpython regression test into test cases arranged by topic, instead
of the previous monolithic setup-create-run sequence, that was apparently
inherited from a previous test infrastructure, but makes working with the
tests and adding new ones weird.
Diffstat (limited to 'src/pl/plpython/sql/plpython_params.sql')
| -rw-r--r-- | src/pl/plpython/sql/plpython_params.sql | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_params.sql b/src/pl/plpython/sql/plpython_params.sql new file mode 100644 index 0000000000..f8b610b505 --- /dev/null +++ b/src/pl/plpython/sql/plpython_params.sql @@ -0,0 +1,34 @@ +-- +-- Test named and nameless parameters +-- + +CREATE FUNCTION test_param_names0(integer, integer) RETURNS int AS $$ +return args[0] + args[1] +$$ LANGUAGE plpythonu; + +CREATE FUNCTION test_param_names1(a0 integer, a1 text) RETURNS boolean AS $$ +assert a0 == args[0] +assert a1 == args[1] +return True +$$ LANGUAGE plpythonu; + +CREATE FUNCTION test_param_names2(u users) RETURNS text AS $$ +assert u == args[0] +return str(u) +$$ LANGUAGE plpythonu; + +-- use deliberately wrong parameter names +CREATE FUNCTION test_param_names3(a0 integer) RETURNS boolean AS $$ +try: + assert a1 == args[0] + return False +except NameError, e: + assert e.args[0].find("a1") > -1 + return True +$$ LANGUAGE plpythonu; + + +SELECT test_param_names0(2,7); +SELECT test_param_names1(1,'text'); +SELECT test_param_names2(users) from users; +SELECT test_param_names3(1); |
