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