Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dfa15d

Browse files
committed
Make plpython_unicode regression test work in more database encodings.
This test previously used a data value containing U+0080, and wouldtherefore fail if the database encoding didn't have an equivalent tothat; which only about half of our supported server encodings do.We could fall back to using some plain-ASCII character, but that seemslike it's losing most of the point of the test. Instead switch to usingU+00A0 (no-break space), which translates into all our supported encodingsexcept the four in the EUC_xx family.Per buildfarm testing. Back-patch to 9.1, which is as far back as thistest is expected to succeed everywhere. (9.0 has the test, but withoutback-patching some 9.1 code changes we could not expect to get consistentresults across platforms anyway.)
1 parent44445b2 commit2dfa15d

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

‎src/pl/plpython/expected/plpython_unicode.out

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
--
22
-- Unicode handling
33
--
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+
--
49
SET client_encoding TO UTF8;
510
CREATE TABLE unicode_test (
611
testvalue text NOT NULL
712
);
813
CREATE FUNCTION unicode_return() RETURNS text AS E'
9-
return u"\\x80"
14+
return u"\\xA0"
1015
' LANGUAGE plpythonu;
1116
CREATE FUNCTION unicode_trigger() RETURNS trigger AS E'
12-
TD["new"]["testvalue"] = u"\\x80"
17+
TD["new"]["testvalue"] = u"\\xA0"
1318
return "MODIFY"
1419
' LANGUAGE plpythonu;
1520
CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test
1621
FOR EACH ROW EXECUTE PROCEDURE unicode_trigger();
1722
CREATE FUNCTION unicode_plan1() RETURNS text AS E'
1823
plan = plpy.prepare("SELECT $1 AS testvalue", ["text"])
19-
rv = plpy.execute(plan, [u"\\x80"], 1)
24+
rv = plpy.execute(plan, [u"\\xA0"], 1)
2025
return rv[0]["testvalue"]
2126
' LANGUAGE plpythonu;
2227
CREATE FUNCTION unicode_plan2() RETURNS text AS E'
@@ -27,20 +32,20 @@ return rv[0]["testvalue"]
2732
SELECT unicode_return();
2833
unicode_return
2934
----------------
30-
\u0080
35+
 
3136
(1 row)
3237

3338
INSERT INTO unicode_test (testvalue) VALUES ('test');
3439
SELECT * FROM unicode_test;
3540
testvalue
3641
-----------
37-
\u0080
42+
 
3843
(1 row)
3944

4045
SELECT unicode_plan1();
4146
unicode_plan1
4247
---------------
43-
\u0080
48+
 
4449
(1 row)
4550

4651
SELECT unicode_plan2();

‎src/pl/plpython/sql/plpython_unicode.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
--
22
-- Unicode handling
33
--
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+
--
49

510
SET client_encoding TO UTF8;
611

@@ -9,11 +14,11 @@ CREATE TABLE unicode_test (
914
);
1015

1116
CREATEFUNCTIONunicode_return() RETURNStextAS E'
12-
return u"\\x80"
17+
return u"\\xA0"
1318
' LANGUAGE plpythonu;
1419

1520
CREATEFUNCTIONunicode_trigger() RETURNS triggerAS E'
16-
TD["new"]["testvalue"] = u"\\x80"
21+
TD["new"]["testvalue"] = u"\\xA0"
1722
return "MODIFY"
1823
' LANGUAGE plpythonu;
1924

@@ -22,7 +27,7 @@ CREATE TRIGGER unicode_test_bi BEFORE INSERT ON unicode_test
2227

2328
CREATEFUNCTIONunicode_plan1() RETURNStextAS E'
2429
plan = plpy.prepare("SELECT $1 AS testvalue", ["text"])
25-
rv = plpy.execute(plan, [u"\\x80"], 1)
30+
rv = plpy.execute(plan, [u"\\xA0"], 1)
2631
return rv[0]["testvalue"]
2732
' LANGUAGE plpythonu;
2833

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp