Skip to content

Commit

Permalink
Keep funky Unicode chars out of jsonb regression test results.
Browse files Browse the repository at this point in the history
  • Loading branch information
adunstan committed Jan 10, 2014
1 parent 72f1c14 commit 7d5b8f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
14 changes: 8 additions & 6 deletions src/test/regress/expected/jsonb.out
Expand Up @@ -66,10 +66,12 @@ SELECT '"\u0000"'::jsonb; -- OK, legal escape
"\\u0000"
(1 row)

SELECT '"\uaBcD"'::jsonb; -- OK, uppercase and lower case both OK
jsonb
-------
"ꯍ"
-- use octet_length here so we don't get an odd unicode char in the
-- output
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
octet_length
--------------
5
(1 row)

-- Numbers.
Expand Down Expand Up @@ -756,10 +758,10 @@ ERROR: cannot call json_populate_recordset on a nested object
select * from jsonb_populate_recordset(row('def',99,null)::jbpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q;
ERROR: cannot call json_populate_recordset on a nested object
-- handling of unicode surrogate pairs
select jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
select octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a')::text) as correct_in_utf8;
correct_in_utf8
-----------------
"😄🐶"
10
(1 row)

select jsonb '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
Expand Down
14 changes: 8 additions & 6 deletions src/test/regress/expected/jsonb_1.out
Expand Up @@ -66,10 +66,12 @@ SELECT '"\u0000"'::jsonb; -- OK, legal escape
"\\u0000"
(1 row)

SELECT '"\uaBcD"'::jsonb; -- OK, uppercase and lower case both OK
-- use octet_length here so we don't get an odd unicode char in the
-- output
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
ERROR: invalid input syntax for type json
LINE 1: SELECT '"\uaBcD"'::jsonb;
^
LINE 1: SELECT octet_length('"\uaBcD"'::jsonb::text);
^
DETAIL: Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8.
CONTEXT: JSON data, line 1: ...
-- Numbers.
Expand Down Expand Up @@ -756,10 +758,10 @@ ERROR: cannot call json_populate_recordset on a nested object
select * from jsonb_populate_recordset(row('def',99,null)::jbpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q;
ERROR: cannot call json_populate_recordset on a nested object
-- handling of unicode surrogate pairs
select jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
select octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a')::text) as correct_in_utf8;
ERROR: invalid input syntax for type json
LINE 1: select jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' a...
^
LINE 1: select octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc3...
^
DETAIL: Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8.
CONTEXT: JSON data, line 1: { "a":...
select jsonb '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
Expand Down
6 changes: 4 additions & 2 deletions src/test/regress/sql/jsonb.sql
Expand Up @@ -11,7 +11,9 @@ SELECT '"\u"'::jsonb; -- ERROR, incomplete escape
SELECT '"\u00"'::jsonb; -- ERROR, incomplete escape
SELECT '"\u000g"'::jsonb; -- ERROR, g is not a hex digit
SELECT '"\u0000"'::jsonb; -- OK, legal escape
SELECT '"\uaBcD"'::jsonb; -- OK, uppercase and lower case both OK
-- use octet_length here so we don't get an odd unicode char in the
-- output
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK

-- Numbers.
SELECT '1'::jsonb; -- OK
Expand Down Expand Up @@ -231,7 +233,7 @@ select * from jsonb_populate_recordset(row('def',99,null)::jbpop,'[{"c":[100,200

-- handling of unicode surrogate pairs

select jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
select octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a')::text) as correct_in_utf8;
select jsonb '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
select jsonb '{ "a": "\ude04\ud83d" }' -> 'a'; -- surrogates in wrong order
select jsonb '{ "a": "\ud83dX" }' -> 'a'; -- orphan high surrogate
Expand Down

0 comments on commit 7d5b8f1

Please sign in to comment.