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
37 ERROR: conversion between UTF8 and SQL_ASCII is not supported
38 LINE 1: SELECT '"\uaBcD"'::jsonpath;
40 -- handling of unicode surrogate pairs
41 select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
42 ERROR: conversion between UTF8 and SQL_ASCII is not supported
43 LINE 1: select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_...
45 select '"\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
46 ERROR: invalid input syntax for type jsonpath
47 LINE 1: select '"\ud83d\ud83d"'::jsonpath;
49 DETAIL: Unicode high surrogate must not follow a high surrogate.
50 select '"\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
51 ERROR: invalid input syntax for type jsonpath
52 LINE 1: select '"\ude04\ud83d"'::jsonpath;
54 DETAIL: Unicode low surrogate must follow a high surrogate.
55 select '"\ud83dX"'::jsonpath; -- orphan high surrogate
56 ERROR: invalid input syntax for type jsonpath
57 LINE 1: select '"\ud83dX"'::jsonpath;
59 DETAIL: Unicode low surrogate must follow a high surrogate.
60 select '"\ude04X"'::jsonpath; -- orphan low surrogate
61 ERROR: invalid input syntax for type jsonpath
62 LINE 1: select '"\ude04X"'::jsonpath;
64 DETAIL: Unicode low surrogate must follow a high surrogate.
65 --handling of simple unicode escapes
66 select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
67 ERROR: conversion between UTF8 and SQL_ASCII is not supported
68 LINE 1: select '"the Copyright \u00a9 sign"'::jsonpath as correct_in...
70 select '"dollar \u0024 character"'::jsonpath as correct_everywhere;
72 ----------------------
76 select '"dollar \\u0024 character"'::jsonpath as not_an_escape;
78 ----------------------------
79 "dollar \\u0024 character"
82 select '"null \u0000 escape"'::jsonpath as not_unescaped;
83 ERROR: unsupported Unicode escape sequence
84 LINE 1: select '"null \u0000 escape"'::jsonpath as not_unescaped;
86 DETAIL: \u0000 cannot be converted to text.
87 select '"null \\u0000 escape"'::jsonpath as not_an_escape;
89 -----------------------
93 -- checks for quoted key names
94 -- basic unicode input
95 SELECT '$."\u"'::jsonpath; -- ERROR, incomplete escape
96 ERROR: invalid unicode sequence at or near "\u" of jsonpath input
97 LINE 1: SELECT '$."\u"'::jsonpath;
99 SELECT '$."\u00"'::jsonpath; -- ERROR, incomplete escape
100 ERROR: invalid unicode sequence at or near "\u00" of jsonpath input
101 LINE 1: SELECT '$."\u00"'::jsonpath;
103 SELECT '$."\u000g"'::jsonpath; -- ERROR, g is not a hex digit
104 ERROR: invalid unicode sequence at or near "\u000" of jsonpath input
105 LINE 1: SELECT '$."\u000g"'::jsonpath;
107 SELECT '$."\u0000"'::jsonpath; -- OK, legal escape
108 ERROR: unsupported Unicode escape sequence
109 LINE 1: SELECT '$."\u0000"'::jsonpath;
111 DETAIL: \u0000 cannot be converted to text.
112 SELECT '$."\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
113 ERROR: conversion between UTF8 and SQL_ASCII is not supported
114 LINE 1: SELECT '$."\uaBcD"'::jsonpath;
116 -- handling of unicode surrogate pairs
117 select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
118 ERROR: conversion between UTF8 and SQL_ASCII is not supported
119 LINE 1: select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_i...
121 select '$."\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
122 ERROR: invalid input syntax for type jsonpath
123 LINE 1: select '$."\ud83d\ud83d"'::jsonpath;
125 DETAIL: Unicode high surrogate must not follow a high surrogate.
126 select '$."\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
127 ERROR: invalid input syntax for type jsonpath
128 LINE 1: select '$."\ude04\ud83d"'::jsonpath;
130 DETAIL: Unicode low surrogate must follow a high surrogate.
131 select '$."\ud83dX"'::jsonpath; -- orphan high surrogate
132 ERROR: invalid input syntax for type jsonpath
133 LINE 1: select '$."\ud83dX"'::jsonpath;
135 DETAIL: Unicode low surrogate must follow a high surrogate.
136 select '$."\ude04X"'::jsonpath; -- orphan low surrogate
137 ERROR: invalid input syntax for type jsonpath
138 LINE 1: select '$."\ude04X"'::jsonpath;
140 DETAIL: Unicode low surrogate must follow a high surrogate.
141 --handling of simple unicode escapes
142 select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
143 ERROR: conversion between UTF8 and SQL_ASCII is not supported
144 LINE 1: select '$."the Copyright \u00a9 sign"'::jsonpath as correct_...
146 select '$."dollar \u0024 character"'::jsonpath as correct_everywhere;
148 ------------------------
149 $."dollar $ character"
152 select '$."dollar \\u0024 character"'::jsonpath as not_an_escape;
154 ------------------------------
155 $."dollar \\u0024 character"
158 select '$."null \u0000 escape"'::jsonpath as not_unescaped;
159 ERROR: unsupported Unicode escape sequence
160 LINE 1: select '$."null \u0000 escape"'::jsonpath as not_unescaped;
162 DETAIL: \u0000 cannot be converted to text.
163 select '$."null \\u0000 escape"'::jsonpath as not_an_escape;
165 -------------------------
166 $."null \\u0000 escape"