Debian Codegraph @

src/pl/tcl/expected/pltcl_unicode.out

raw
1 --
2 -- Unicode handling
3 --
4 -- This test case would fail if the database encoding is EUC_CN, EUC_JP,
5 -- EUC_KR, or EUC_TW, for lack of any equivalent to U+00A0 (no-break space) in
6 -- those encodings. However, testing with plain ASCII data would be rather
7 -- useless, so we must live with that.
8 --
9 SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW')
10 AS skip_test \gset
11 \if :skip_test
12 \quit
13 \endif
14 SET client_encoding TO UTF8;
15 CREATE TABLE unicode_test (
16 testvalue text NOT NULL
17 );
18 CREATE FUNCTION unicode_return() RETURNS text AS $$
19 return "\xA0"
20 $$ LANGUAGE pltcl;
21 CREATE FUNCTION unicode_trigger() RETURNS trigger AS $$
22 set NEW(testvalue) "\xA0"
23 return [array get NEW]
24 $$ LANGUAGE pltcl;
25 CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test
26 FOR EACH ROW EXECUTE PROCEDURE unicode_trigger();
27 CREATE FUNCTION unicode_plan1() RETURNS text AS $$
28 set plan [ spi_prepare {SELECT $1 AS testvalue} [ list "text" ] ]
29 spi_execp $plan [ list "\xA0" ]
30 return $testvalue
31 $$ LANGUAGE pltcl;
32 SELECT unicode_return();
33 unicode_return
34 ----------------
35  
36 (1 row)
37
38 INSERT INTO unicode_test (testvalue) VALUES ('test');
39 SELECT * FROM unicode_test;
40 testvalue
41 -----------
42  
43 (1 row)
44
45 SELECT unicode_plan1();
46 unicode_plan1
47 ---------------
48  
49 (1 row)
50