1 -- import python modules
2 CREATE FUNCTION import_fail() returns text
7 return "failed as expected"
8 return "succeeded, that wasn''t supposed to happen"'
10 CREATE FUNCTION import_succeed() returns text
24 except Exception as ex:
25 plpy.notice("import failed -- %s" % str(ex))
26 return "failed, that wasn''t supposed to happen"
27 return "succeeded, as expected"'
29 CREATE FUNCTION import_test_one(p text) RETURNS text
33 digest = hashlib.sha1(p.encode("ascii"))
37 return digest.hexdigest()'
39 CREATE FUNCTION import_test_two(u users) RETURNS text
41 'plain = u["fname"] + u["lname"]
44 digest = hashlib.sha1(plain.encode("ascii"))
47 digest = sha.new(plain);
48 return "sha hash of " + plain + " is " + digest.hexdigest()'
50 -- import python modules
58 SELECT import_succeed();
60 ------------------------
61 succeeded, as expected
64 -- test import and simple argument handling
66 SELECT import_test_one('sha hash of this string');
68 ------------------------------------------
69 a04e23cb9b1a09cd1051a04a7c571aae0f90346c
72 -- test import and tuple argument handling
74 select import_test_two(users) from users where fname = 'willem';
76 -------------------------------------------------------------------
77 sha hash of willemdoe is 3cde6b574953b0ca937b4d76ebc40d534d910759