Skip to content

Commit 48a78d8

Browse files
committed
Factor out encoding specific tests for json
This lets us remove the large alternative results files for the main json and jsonb tests, which makes modifying those tests simpler for committers and patch submitters. Backpatch to 9.4 for jsonb and 9.3 for json.
1 parent fc95734 commit 48a78d8

11 files changed

+564
-5362
lines changed

src/test/regress/expected/json.out

+1-112
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,7 @@ LINE 1: SELECT '"\v"'::json;
4242
^
4343
DETAIL: Escape sequence "\v" is invalid.
4444
CONTEXT: JSON data, line 1: "\v...
45-
SELECT '"\u"'::json; -- ERROR, incomplete escape
46-
ERROR: invalid input syntax for type json
47-
LINE 1: SELECT '"\u"'::json;
48-
^
49-
DETAIL: "\u" must be followed by four hexadecimal digits.
50-
CONTEXT: JSON data, line 1: "\u"
51-
SELECT '"\u00"'::json; -- ERROR, incomplete escape
52-
ERROR: invalid input syntax for type json
53-
LINE 1: SELECT '"\u00"'::json;
54-
^
55-
DETAIL: "\u" must be followed by four hexadecimal digits.
56-
CONTEXT: JSON data, line 1: "\u00"
57-
SELECT '"\u000g"'::json; -- ERROR, g is not a hex digit
58-
ERROR: invalid input syntax for type json
59-
LINE 1: SELECT '"\u000g"'::json;
60-
^
61-
DETAIL: "\u" must be followed by four hexadecimal digits.
62-
CONTEXT: JSON data, line 1: "\u000g...
63-
SELECT '"\u0000"'::json; -- OK, legal escape
64-
json
65-
----------
66-
"\u0000"
67-
(1 row)
68-
69-
SELECT '"\uaBcD"'::json; -- OK, uppercase and lower case both OK
70-
json
71-
----------
72-
"\uaBcD"
73-
(1 row)
74-
45+
-- see json_encoding test for input with unicode escapes
7546
-- Numbers.
7647
SELECT '1'::json; -- OK
7748
json
@@ -1419,88 +1390,6 @@ select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,3
14191390
{"z":true} | 3 | Fri Jan 20 10:42:53 2012
14201391
(2 rows)
14211392

1422-
-- handling of unicode surrogate pairs
1423-
select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
1424-
correct_in_utf8
1425-
----------------------------
1426-
"\ud83d\ude04\ud83d\udc36"
1427-
(1 row)
1428-
1429-
select json '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
1430-
ERROR: invalid input syntax for type json
1431-
DETAIL: Unicode high surrogate must not follow a high surrogate.
1432-
CONTEXT: JSON data, line 1: { "a":...
1433-
select json '{ "a": "\ude04\ud83d" }' -> 'a'; -- surrogates in wrong order
1434-
ERROR: invalid input syntax for type json
1435-
DETAIL: Unicode low surrogate must follow a high surrogate.
1436-
CONTEXT: JSON data, line 1: { "a":...
1437-
select json '{ "a": "\ud83dX" }' -> 'a'; -- orphan high surrogate
1438-
ERROR: invalid input syntax for type json
1439-
DETAIL: Unicode low surrogate must follow a high surrogate.
1440-
CONTEXT: JSON data, line 1: { "a":...
1441-
select json '{ "a": "\ude04X" }' -> 'a'; -- orphan low surrogate
1442-
ERROR: invalid input syntax for type json
1443-
DETAIL: Unicode low surrogate must follow a high surrogate.
1444-
CONTEXT: JSON data, line 1: { "a":...
1445-
--handling of simple unicode escapes
1446-
select json '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8;
1447-
correct_in_utf8
1448-
---------------------------------------
1449-
{ "a": "the Copyright \u00a9 sign" }
1450-
(1 row)
1451-
1452-
select json '{ "a": "dollar \u0024 character" }' as correct_everywhere;
1453-
correct_everywhere
1454-
-------------------------------------
1455-
{ "a": "dollar \u0024 character" }
1456-
(1 row)
1457-
1458-
select json '{ "a": "dollar \\u0024 character" }' as not_an_escape;
1459-
not_an_escape
1460-
--------------------------------------
1461-
{ "a": "dollar \\u0024 character" }
1462-
(1 row)
1463-
1464-
select json '{ "a": "null \u0000 escape" }' as not_unescaped;
1465-
not_unescaped
1466-
--------------------------------
1467-
{ "a": "null \u0000 escape" }
1468-
(1 row)
1469-
1470-
select json '{ "a": "null \\u0000 escape" }' as not_an_escape;
1471-
not_an_escape
1472-
---------------------------------
1473-
{ "a": "null \\u0000 escape" }
1474-
(1 row)
1475-
1476-
select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
1477-
correct_in_utf8
1478-
----------------------
1479-
the Copyright © sign
1480-
(1 row)
1481-
1482-
select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
1483-
correct_everywhere
1484-
--------------------
1485-
dollar $ character
1486-
(1 row)
1487-
1488-
select json '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape;
1489-
not_an_escape
1490-
-------------------------
1491-
dollar \u0024 character
1492-
(1 row)
1493-
1494-
select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
1495-
ERROR: unsupported Unicode escape sequence
1496-
DETAIL: \u0000 cannot be converted to text.
1497-
CONTEXT: JSON data, line 1: { "a":...
1498-
select json '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
1499-
not_an_escape
1500-
--------------------
1501-
null \u0000 escape
1502-
(1 row)
1503-
15041393
--json_typeof() function
15051394
select value, json_typeof(value)
15061395
from (values (json '123.4'),

0 commit comments

Comments
 (0)