Skip to content

Commit 50831b0

Browse files
author
Alexey Botchkov
committed
MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
json_no_table.test ported.
1 parent e5398ac commit 50831b0

File tree

10 files changed

+6288
-203
lines changed

10 files changed

+6288
-203
lines changed

include/json_lib.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ typedef struct st_json_engine_t
219219
/* string constants. */
220220

221221
int stack[JSON_DEPTH_LIMIT]; /* Keeps the stack of nested JSON structures. */
222-
int *stack_p; /* The 'stack' pointer. */
222+
int stack_p; /* The 'stack' pointer. */
223223
} json_engine_t;
224224

225225

@@ -308,7 +308,7 @@ typedef const int *json_level_t;
308308
*/
309309
#define json_get_level(j) (j->stack_p)
310310

311-
int json_skip_to_level(json_engine_t *j, json_level_t level);
311+
int json_skip_to_level(json_engine_t *j, int level);
312312

313313
/*
314314
json_skip_level() works as above with just current structre.
@@ -391,6 +391,27 @@ int json_append_ascii(CHARSET_INFO *json_cs,
391391
uchar *json, uchar *json_end,
392392
const uchar *ascii, const uchar *ascii_end);
393393

394+
395+
/*
396+
Scan the JSON and return paths met one-by-one.
397+
json_get_path_start(&p)
398+
while (json_get_path_next(&p))
399+
{
400+
handle_the_next_path();
401+
}
402+
*/
403+
404+
int json_get_path_start(json_engine_t *je, CHARSET_INFO *i_cs,
405+
const uchar *str, const uchar *end,
406+
json_path_t *p);
407+
408+
409+
int json_get_path_next(json_engine_t *je, json_path_t *p);
410+
411+
412+
int json_path_compare(const json_path_t *a, const json_path_t *b);
413+
414+
394415
#ifdef __cplusplus
395416
}
396417
#endif

mysql-test/mysql-test-run.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ END
182182
innodb_fts-
183183
innodb_gis-
184184
innodb_zip-
185+
json-
185186
maria-
186187
multi_source-
187188
optimizer_unfixed_bugs-

mysql-test/r/func_json.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ json_extract('1', '$')
212212
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]');
213213
json_extract('[10, 20, [30, 40], 1, 10]', '$[1]')
214214
20
215+
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]');
216+
json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]')
217+
[20]
218+
select json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a');
219+
json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a')
220+
[[3, 4]]
215221
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
216222
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word')
217223
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}

0 commit comments

Comments
 (0)