Skip to content

Commit ea2467d

Browse files
committed
Add alternative expected file for unicode test for client encoding not UTF8
1 parent e2a4195 commit ea2467d

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/pl/plpython/expected/README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Guide to alternative expected files:
33
plpython_error_2.out Python 2.2, 2.3, 2.4
44
plpython_error.out Python 2.5, 2.6
55

6-
plpython_unicode.out any version, when server encoding != SQL_ASCII; else ...
6+
plpython_unicode.out any version, when server encoding != SQL_ASCII and client encoding = UTF8; else ...
7+
plpython_unicode_0.out any version, when server encoding != SQL_ASCII and client encoding != UTF8; else ...
78
plpython_unicode_2.out Python 2.2
89
plpython_unicode_3.out Python 2.3, 2.4
910
plpython_unicode_5.out Python 2.5, 2.6
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
unicode_return
28+
----------------
29+
30+
(1 row)
31+
32+
INSERT INTO unicode_test (testvalue) VALUES ('test');
33+
SELECT * FROM unicode_test;
34+
testvalue
35+
-----------
36+
37+
(1 row)
38+
39+
SELECT unicode_plan1();
40+
unicode_plan1
41+
---------------
42+
43+
(1 row)
44+
45+
SELECT unicode_plan2();
46+
unicode_plan2
47+
---------------
48+
foobar
49+
(1 row)
50+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy