2 -- encoding-sensitive tests for jsonpath
4 -- We provide expected-results files for UTF8 (jsonpath_encoding.out)
5 -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise.
6 SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII')
11 SELECT getdatabaseencoding(); -- just to label the results files
17 -- checks for double-quoted values
18 -- basic unicode input
19 SELECT '"\u"'::jsonpath; -- ERROR, incomplete escape
20 ERROR: invalid unicode sequence at or near "\u" of jsonpath input
21 LINE 1: SELECT '"\u"'::jsonpath;
23 SELECT '"\u00"'::jsonpath; -- ERROR, incomplete escape
24 ERROR: invalid unicode sequence at or near "\u00" of jsonpath input
25 LINE 1: SELECT '"\u00"'::jsonpath;
27 SELECT '"\u000g"'::jsonpath; -- ERROR, g is not a hex digit
28 ERROR: invalid unicode sequence at or near "\u000" of jsonpath input
29 LINE 1: SELECT '"\u000g"'::jsonpath;
31 SELECT '"\u0000"'::jsonpath; -- OK, legal escape
32 ERROR: unsupported Unicode escape sequence
33 LINE 1: SELECT '"\u0000"'::jsonpath;
35 DETAIL: \u0000 cannot be converted to text.
36 SELECT '"\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
42 -- handling of unicode surrogate pairs
43 select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
49 select '"\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
50 ERROR: invalid input syntax for type jsonpath
51 LINE 1: select '"\ud83d\ud83d"'::jsonpath;
53 DETAIL: Unicode high surrogate must not follow a high surrogate.
54 select '"\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
55 ERROR: invalid input syntax for type jsonpath
56 LINE 1: select '"\ude04\ud83d"'::jsonpath;
58 DETAIL: Unicode low surrogate must follow a high surrogate.
59 select '"\ud83dX"'::jsonpath; -- orphan high surrogate
60 ERROR: invalid input syntax for type jsonpath
61 LINE 1: select '"\ud83dX"'::jsonpath;
63 DETAIL: Unicode low surrogate must follow a high surrogate.
64 select '"\ude04X"'::jsonpath; -- orphan low surrogate
65 ERROR: invalid input syntax for type jsonpath
66 LINE 1: select '"\ude04X"'::jsonpath;
68 DETAIL: Unicode low surrogate must follow a high surrogate.
69 --handling of simple unicode escapes
70 select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
72 ------------------------
73 "the Copyright © sign"
76 select '"dollar \u0024 character"'::jsonpath as correct_everywhere;
78 ----------------------
82 select '"dollar \\u0024 character"'::jsonpath as not_an_escape;
84 ----------------------------
85 "dollar \\u0024 character"
88 select '"null \u0000 escape"'::jsonpath as not_unescaped;
89 ERROR: unsupported Unicode escape sequence
90 LINE 1: select '"null \u0000 escape"'::jsonpath as not_unescaped;
92 DETAIL: \u0000 cannot be converted to text.
93 select '"null \\u0000 escape"'::jsonpath as not_an_escape;
95 -----------------------
99 -- checks for quoted key names
100 -- basic unicode input
101 SELECT '$."\u"'::jsonpath; -- ERROR, incomplete escape
102 ERROR: invalid unicode sequence at or near "\u" of jsonpath input
103 LINE 1: SELECT '$."\u"'::jsonpath;
105 SELECT '$."\u00"'::jsonpath; -- ERROR, incomplete escape
106 ERROR: invalid unicode sequence at or near "\u00" of jsonpath input
107 LINE 1: SELECT '$."\u00"'::jsonpath;
109 SELECT '$."\u000g"'::jsonpath; -- ERROR, g is not a hex digit
110 ERROR: invalid unicode sequence at or near "\u000" of jsonpath input
111 LINE 1: SELECT '$."\u000g"'::jsonpath;
113 SELECT '$."\u0000"'::jsonpath; -- OK, legal escape
114 ERROR: unsupported Unicode escape sequence
115 LINE 1: SELECT '$."\u0000"'::jsonpath;
117 DETAIL: \u0000 cannot be converted to text.
118 SELECT '$."\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
124 -- handling of unicode surrogate pairs
125 select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
131 select '$."\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
132 ERROR: invalid input syntax for type jsonpath
133 LINE 1: select '$."\ud83d\ud83d"'::jsonpath;
135 DETAIL: Unicode high surrogate must not follow a high surrogate.
136 select '$."\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
137 ERROR: invalid input syntax for type jsonpath
138 LINE 1: select '$."\ude04\ud83d"'::jsonpath;
140 DETAIL: Unicode low surrogate must follow a high surrogate.
141 select '$."\ud83dX"'::jsonpath; -- orphan high surrogate
142 ERROR: invalid input syntax for type jsonpath
143 LINE 1: select '$."\ud83dX"'::jsonpath;
145 DETAIL: Unicode low surrogate must follow a high surrogate.
146 select '$."\ude04X"'::jsonpath; -- orphan low surrogate
147 ERROR: invalid input syntax for type jsonpath
148 LINE 1: select '$."\ude04X"'::jsonpath;
150 DETAIL: Unicode low surrogate must follow a high surrogate.
151 --handling of simple unicode escapes
152 select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
154 --------------------------
155 $."the Copyright © sign"
158 select '$."dollar \u0024 character"'::jsonpath as correct_everywhere;
160 ------------------------
161 $."dollar $ character"
164 select '$."dollar \\u0024 character"'::jsonpath as not_an_escape;
166 ------------------------------
167 $."dollar \\u0024 character"
170 select '$."null \u0000 escape"'::jsonpath as not_unescaped;
171 ERROR: unsupported Unicode escape sequence
172 LINE 1: select '$."null \u0000 escape"'::jsonpath as not_unescaped;
174 DETAIL: \u0000 cannot be converted to text.
175 select '$."null \\u0000 escape"'::jsonpath as not_an_escape;
177 -------------------------
178 $."null \\u0000 escape"