]> granicus.if.org Git - postgresql/blob - src/pl/plpython/expected/plpython_unicode_3.out
Clean up missed change to plpython expected files.
[postgresql] / src / pl / plpython / expected / plpython_unicode_3.out
1 --
2 -- Unicode handling
3 --
4 CREATE TABLE unicode_test (
5         testvalue  text NOT NULL
6 );
7 CREATE FUNCTION unicode_return() RETURNS text AS E'
8 return u"\\x80"
9 ' LANGUAGE plpythonu;
10 CREATE FUNCTION unicode_trigger() RETURNS trigger AS E'
11 TD["new"]["testvalue"] = u"\\x80"
12 return "MODIFY"
13 ' LANGUAGE plpythonu;
14 CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test
15   FOR EACH ROW EXECUTE PROCEDURE unicode_trigger();
16 CREATE FUNCTION unicode_plan1() RETURNS text AS E'
17 plan = plpy.prepare("SELECT $1 AS testvalue", ["text"])
18 rv = plpy.execute(plan, [u"\\x80"], 1)
19 return rv[0]["testvalue"]
20 ' LANGUAGE plpythonu;
21 CREATE FUNCTION unicode_plan2() RETURNS text AS E'
22 plan = plpy.prepare("SELECT $1 || $2 AS testvalue", ["text", u"text"])
23 rv = plpy.execute(plan, ["foo", "bar"], 1)
24 return rv[0]["testvalue"]
25 ' LANGUAGE plpythonu;
26 SELECT unicode_return();
27 ERROR:  could not convert Python Unicode object to PostgreSQL server encoding
28 DETAIL:  UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
29 CONTEXT:  while creating return value
30 PL/Python function "unicode_return"
31 INSERT INTO unicode_test (testvalue) VALUES ('test');
32 ERROR:  could not convert Python Unicode object to PostgreSQL server encoding
33 DETAIL:  UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
34 CONTEXT:  while modifying trigger row
35 PL/Python function "unicode_trigger"
36 SELECT * FROM unicode_test;
37  testvalue 
38 -----------
39 (0 rows)
40
41 SELECT unicode_plan1();
42 ERROR:  plpy.SPIError: could not convert Python Unicode object to PostgreSQL server encoding
43 DETAIL:  UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
44 CONTEXT:  PL/Python function "unicode_plan1"
45 SELECT unicode_plan2();
46  unicode_plan2 
47 ---------------
48  foobar
49 (1 row)
50