diff options
Diffstat (limited to 'src/pl/plpython/sql/plpython_function.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_function.sql | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_function.sql b/src/pl/plpython/sql/plpython_function.sql index 25ac388495a..e3ec2afe014 100644 --- a/src/pl/plpython/sql/plpython_function.sql +++ b/src/pl/plpython/sql/plpython_function.sql @@ -313,3 +313,31 @@ LANGUAGE plpythonu; CREATE OR REPLACE FUNCTION newline_crlf() RETURNS integer AS 'x = 100\r\ny = 23\r\nreturn x + y\r\n' LANGUAGE plpythonu; + +-- +-- Unicode error handling +-- + +CREATE FUNCTION unicode_return_error() RETURNS text AS ' +return u"\\x80" +' LANGUAGE plpythonu; + +CREATE FUNCTION unicode_trigger_error() RETURNS trigger AS ' +TD["new"]["testvalue"] = u"\\x80" +return "MODIFY" +' LANGUAGE plpythonu; + +CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test + FOR EACH ROW EXECUTE PROCEDURE unicode_trigger_error(); + +CREATE FUNCTION unicode_plan_error1() RETURNS text AS ' +plan = plpy.prepare("SELECT $1 AS testvalue", ["text"]) +rv = plpy.execute(plan, [u"\\x80"], 1) +return rv[0]["testvalue"] +' LANGUAGE plpythonu; + +CREATE FUNCTION unicode_plan_error2() RETURNS text AS ' +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; |