2005-05-14 13:55:22 -04:00
|
|
|
-- first some tests of basic functionality
|
2009-08-12 12:37:26 -04:00
|
|
|
-- really stupid function just to get the module loaded
|
|
|
|
|
CREATE FUNCTION stupid() RETURNS text AS 'return "zarkon"' LANGUAGE plpythonu;
|
2001-05-09 15:54:38 -04:00
|
|
|
select stupid();
|
|
|
|
|
stupid
|
|
|
|
|
--------
|
|
|
|
|
zarkon
|
|
|
|
|
(1 row)
|
|
|
|
|
|
2005-05-14 13:55:22 -04:00
|
|
|
-- test multiple arguments
|
2009-08-12 12:37:26 -04:00
|
|
|
CREATE FUNCTION argument_test_one(u users, a1 text, a2 text) RETURNS text
|
|
|
|
|
AS
|
|
|
|
|
'keys = u.keys()
|
|
|
|
|
keys.sort()
|
|
|
|
|
out = []
|
|
|
|
|
for key in keys:
|
|
|
|
|
out.append("%s: %s" % (key, u[key]))
|
|
|
|
|
words = a1 + " " + a2 + " => {" + ", ".join(out) + "}"
|
|
|
|
|
return words'
|
|
|
|
|
LANGUAGE plpythonu;
|
2001-05-12 13:49:32 -04:00
|
|
|
select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
|
2003-03-27 11:58:21 -05:00
|
|
|
argument_test_one
|
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
jane doe => {fname: jane, lname: doe, userid: 1, username: j_doe}
|
|
|
|
|
john doe => {fname: john, lname: doe, userid: 2, username: johnd}
|
|
|
|
|
willem doe => {fname: willem, lname: doe, userid: 3, username: w_doe}
|
2001-05-09 15:54:38 -04:00
|
|
|
(3 rows)
|
|
|
|
|
|