5 select 'strict $'::jsonpath;
6 select 'lax $'::jsonpath;
7 select '$.a'::jsonpath;
8 select '$.a.v'::jsonpath;
9 select '$.a.*'::jsonpath;
10 select '$.*[*]'::jsonpath;
11 select '$.a[*]'::jsonpath;
12 select '$.a[*][*]'::jsonpath;
13 select '$[*]'::jsonpath;
14 select '$[0]'::jsonpath;
15 select '$[*][0]'::jsonpath;
16 select '$[*].a'::jsonpath;
17 select '$[*][0].a.b'::jsonpath;
18 select '$.a.**.b'::jsonpath;
19 select '$.a.**{2}.b'::jsonpath;
20 select '$.a.**{2 to 2}.b'::jsonpath;
21 select '$.a.**{2 to 5}.b'::jsonpath;
22 select '$.a.**{0 to 5}.b'::jsonpath;
23 select '$.a.**{5 to last}.b'::jsonpath;
24 select '$.a.**{last}.b'::jsonpath;
25 select '$.a.**{last to 5}.b'::jsonpath;
26 select '$+1'::jsonpath;
27 select '$-1'::jsonpath;
28 select '$--+1'::jsonpath;
29 select '$.a/+-1'::jsonpath;
30 select '1 * 2 + 4 % -3 != false'::jsonpath;
32 select '"\b\f\r\n\t\v\"\''\\"'::jsonpath;
33 select '"\x50\u0067\u{53}\u{051}\u{00004C}"'::jsonpath;
34 select '$.foo\x50\u0067\u{53}\u{051}\u{00004C}\t\"bar'::jsonpath;
35 select '"\z"'::jsonpath; -- unrecognized escape is just the literal char
37 select '$.g ? ($.a == 1)'::jsonpath;
38 select '$.g ? (@ == 1)'::jsonpath;
39 select '$.g ? (@.a == 1)'::jsonpath;
40 select '$.g ? (@.a == 1 || @.a == 4)'::jsonpath;
41 select '$.g ? (@.a == 1 && @.a == 4)'::jsonpath;
42 select '$.g ? (@.a == 1 || @.a == 4 && @.b == 7)'::jsonpath;
43 select '$.g ? (@.a == 1 || !(@.a == 4) && @.b == 7)'::jsonpath;
44 select '$.g ? (@.a == 1 || !(@.x >= 123 || @.a == 4) && @.b == 7)'::jsonpath;
45 select '$.g ? (@.x >= @[*]?(@.a > "abc"))'::jsonpath;
46 select '$.g ? ((@.x >= 123 || @.a == 4) is unknown)'::jsonpath;
47 select '$.g ? (exists (@.x))'::jsonpath;
48 select '$.g ? (exists (@.x ? (@ == 14)))'::jsonpath;
49 select '$.g ? ((@.x >= 123 || @.a == 4) && exists (@.x ? (@ == 14)))'::jsonpath;
50 select '$.g ? (+@.x >= +-(+@.a + 2))'::jsonpath;
52 select '$a'::jsonpath;
53 select '$a.b'::jsonpath;
54 select '$a[*]'::jsonpath;
55 select '$.g ? (@.zip == $zip)'::jsonpath;
56 select '$.a[1,2, 3 to 16]'::jsonpath;
57 select '$.a[$a + 1, ($b[*]) to -($[0] * 2)]'::jsonpath;
58 select '$.a[$.a.size() - 3]'::jsonpath;
59 select 'last'::jsonpath;
60 select '"last"'::jsonpath;
61 select '$.last'::jsonpath;
62 select '$ ? (last > 0)'::jsonpath;
63 select '$[last]'::jsonpath;
64 select '$[$[0] ? (last > 0)]'::jsonpath;
66 select 'null.type()'::jsonpath;
67 select '1.type()'::jsonpath;
68 select '(1).type()'::jsonpath;
69 select '1.2.type()'::jsonpath;
70 select '"aaa".type()'::jsonpath;
71 select 'true.type()'::jsonpath;
72 select '$.double().floor().ceiling().abs()'::jsonpath;
73 select '$.keyvalue().key'::jsonpath;
74 select '$.datetime()'::jsonpath;
75 select '$.datetime("datetime template")'::jsonpath;
76 select '$.bigint().integer().number().decimal()'::jsonpath;
77 select '$.boolean()'::jsonpath;
78 select '$.date()'::jsonpath;
79 select '$.decimal(4,2)'::jsonpath;
80 select '$.string()'::jsonpath;
81 select '$.time()'::jsonpath;
82 select '$.time(6)'::jsonpath;
83 select '$.time_tz()'::jsonpath;
84 select '$.time_tz(4)'::jsonpath;
85 select '$.timestamp()'::jsonpath;
86 select '$.timestamp(2)'::jsonpath;
87 select '$.timestamp_tz()'::jsonpath;
88 select '$.timestamp_tz(0)'::jsonpath;
90 select '$ ? (@ starts with "abc")'::jsonpath;
91 select '$ ? (@ starts with $var)'::jsonpath;
93 select '$ ? (@ like_regex "(invalid pattern")'::jsonpath;
94 select '$ ? (@ like_regex "pattern")'::jsonpath;
95 select '$ ? (@ like_regex "pattern" flag "")'::jsonpath;
96 select '$ ? (@ like_regex "pattern" flag "i")'::jsonpath;
97 select '$ ? (@ like_regex "pattern" flag "is")'::jsonpath;
98 select '$ ? (@ like_regex "pattern" flag "isim")'::jsonpath;
99 select '$ ? (@ like_regex "pattern" flag "xsms")'::jsonpath;
100 select '$ ? (@ like_regex "pattern" flag "q")'::jsonpath;
101 select '$ ? (@ like_regex "pattern" flag "iq")'::jsonpath;
102 select '$ ? (@ like_regex "pattern" flag "smixq")'::jsonpath;
103 select '$ ? (@ like_regex "pattern" flag "a")'::jsonpath;
105 select '$ < 1'::jsonpath;
106 select '($ < 1) || $.a.b <= $x'::jsonpath;
107 select '@ + 1'::jsonpath;
109 select '($).a.b'::jsonpath;
110 select '($.a.b).c.d'::jsonpath;
111 select '($.a.b + -$.x.y).c.d'::jsonpath;
112 select '(-+$.a.b).c.d'::jsonpath;
113 select '1 + ($.a.b + 2).c.d'::jsonpath;
114 select '1 + ($.a.b > 2).c.d'::jsonpath;
115 select '($)'::jsonpath;
116 select '(($))'::jsonpath;
117 select '((($ + 1)).a + ((2)).b ? ((((@ > 1)) || (exists(@.c)))))'::jsonpath;
119 select '$ ? (@.a < 1)'::jsonpath;
120 select '$ ? (@.a < -1)'::jsonpath;
121 select '$ ? (@.a < +1)'::jsonpath;
122 select '$ ? (@.a < .1)'::jsonpath;
123 select '$ ? (@.a < -.1)'::jsonpath;
124 select '$ ? (@.a < +.1)'::jsonpath;
125 select '$ ? (@.a < 0.1)'::jsonpath;
126 select '$ ? (@.a < -0.1)'::jsonpath;
127 select '$ ? (@.a < +0.1)'::jsonpath;
128 select '$ ? (@.a < 10.1)'::jsonpath;
129 select '$ ? (@.a < -10.1)'::jsonpath;
130 select '$ ? (@.a < +10.1)'::jsonpath;
131 select '$ ? (@.a < 1e1)'::jsonpath;
132 select '$ ? (@.a < -1e1)'::jsonpath;
133 select '$ ? (@.a < +1e1)'::jsonpath;
134 select '$ ? (@.a < .1e1)'::jsonpath;
135 select '$ ? (@.a < -.1e1)'::jsonpath;
136 select '$ ? (@.a < +.1e1)'::jsonpath;
137 select '$ ? (@.a < 0.1e1)'::jsonpath;
138 select '$ ? (@.a < -0.1e1)'::jsonpath;
139 select '$ ? (@.a < +0.1e1)'::jsonpath;
140 select '$ ? (@.a < 10.1e1)'::jsonpath;
141 select '$ ? (@.a < -10.1e1)'::jsonpath;
142 select '$ ? (@.a < +10.1e1)'::jsonpath;
143 select '$ ? (@.a < 1e-1)'::jsonpath;
144 select '$ ? (@.a < -1e-1)'::jsonpath;
145 select '$ ? (@.a < +1e-1)'::jsonpath;
146 select '$ ? (@.a < .1e-1)'::jsonpath;
147 select '$ ? (@.a < -.1e-1)'::jsonpath;
148 select '$ ? (@.a < +.1e-1)'::jsonpath;
149 select '$ ? (@.a < 0.1e-1)'::jsonpath;
150 select '$ ? (@.a < -0.1e-1)'::jsonpath;
151 select '$ ? (@.a < +0.1e-1)'::jsonpath;
152 select '$ ? (@.a < 10.1e-1)'::jsonpath;
153 select '$ ? (@.a < -10.1e-1)'::jsonpath;
154 select '$ ? (@.a < +10.1e-1)'::jsonpath;
155 select '$ ? (@.a < 1e+1)'::jsonpath;
156 select '$ ? (@.a < -1e+1)'::jsonpath;
157 select '$ ? (@.a < +1e+1)'::jsonpath;
158 select '$ ? (@.a < .1e+1)'::jsonpath;
159 select '$ ? (@.a < -.1e+1)'::jsonpath;
160 select '$ ? (@.a < +.1e+1)'::jsonpath;
161 select '$ ? (@.a < 0.1e+1)'::jsonpath;
162 select '$ ? (@.a < -0.1e+1)'::jsonpath;
163 select '$ ? (@.a < +0.1e+1)'::jsonpath;
164 select '$ ? (@.a < 10.1e+1)'::jsonpath;
165 select '$ ? (@.a < -10.1e+1)'::jsonpath;
166 select '$ ? (@.a < +10.1e+1)'::jsonpath;
170 select '0'::jsonpath;
171 select '00'::jsonpath;
172 select '0755'::jsonpath;
173 select '0.0'::jsonpath;
174 select '0.000'::jsonpath;
175 select '0.000e1'::jsonpath;
176 select '0.000e2'::jsonpath;
177 select '0.000e3'::jsonpath;
178 select '0.0010'::jsonpath;
179 select '0.0010e-1'::jsonpath;
180 select '0.0010e+1'::jsonpath;
181 select '0.0010e+2'::jsonpath;
182 select '.001'::jsonpath;
183 select '.001e1'::jsonpath;
184 select '1.'::jsonpath;
185 select '1.e1'::jsonpath;
186 select '1a'::jsonpath;
187 select '1e'::jsonpath;
188 select '1.e'::jsonpath;
189 select '1.2a'::jsonpath;
190 select '1.2e'::jsonpath;
191 select '1.2.e'::jsonpath;
192 select '(1.2).e'::jsonpath;
193 select '1e3'::jsonpath;
194 select '1.e3'::jsonpath;
195 select '1.e3.e'::jsonpath;
196 select '1.e3.e4'::jsonpath;
197 select '1.2e3'::jsonpath;
198 select '1.2e3a'::jsonpath;
199 select '1.2.e3'::jsonpath;
200 select '(1.2).e3'::jsonpath;
201 select '1..e'::jsonpath;
202 select '1..e3'::jsonpath;
203 select '(1.).e'::jsonpath;
204 select '(1.).e3'::jsonpath;
205 select '1?(2>3)'::jsonpath;
208 select '0b100101'::jsonpath;
209 select '0o273'::jsonpath;
210 select '0x42F'::jsonpath;
213 select '0b'::jsonpath;
214 select '1b'::jsonpath;
215 select '0b0x'::jsonpath;
217 select '0o'::jsonpath;
218 select '1o'::jsonpath;
219 select '0o0x'::jsonpath;
221 select '0x'::jsonpath;
222 select '1x'::jsonpath;
223 select '0x0y'::jsonpath;
226 select '1_000_000'::jsonpath;
227 select '1_2_3'::jsonpath;
228 select '0x1EEE_FFFF'::jsonpath;
229 select '0o2_73'::jsonpath;
230 select '0b10_0101'::jsonpath;
232 select '1_000.000_005'::jsonpath;
233 select '1_000.'::jsonpath;
234 select '.000_005'::jsonpath;
235 select '1_000.5e0_1'::jsonpath;
238 select '_100'::jsonpath;
239 select '100_'::jsonpath;
240 select '100__000'::jsonpath;
242 select '_1_000.5'::jsonpath;
243 select '1_000_.5'::jsonpath;
244 select '1_000._5'::jsonpath;
245 select '1_000.5_'::jsonpath;
246 select '1_000.5e_1'::jsonpath;
248 -- underscore after prefix not allowed in JavaScript (but allowed in SQL)
249 select '0b_10_0101'::jsonpath;
250 select '0o_273'::jsonpath;
251 select '0x_42F'::jsonpath;
254 -- test non-error-throwing API
256 SELECT str as jsonpath,
257 pg_input_is_valid(str,'jsonpath') as ok,
258 errinfo.sql_error_code,
262 FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text,
263 '$ ? (@ like_regex "pattern" flag "a")',
267 LATERAL pg_input_error_info(str, 'jsonpath') as errinfo;