Commit a9336302 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-17018 JSON_SEARCH and User-Defined Variables.

Item_func_json_search needs a member to store the path.
parent c3124174
...@@ -796,3 +796,11 @@ JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6') ...@@ -796,3 +796,11 @@ JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6')
select json_array_append('[ ]', '$', 'aue'); select json_array_append('[ ]', '$', 'aue');
json_array_append('[ ]', '$', 'aue') json_array_append('[ ]', '$', 'aue')
["aue"] ["aue"]
#
# MDEV-17018 JSON_SEARCH and User-Defined Variables.
#
SET @`json` := '["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', @`value` := 'AB';
SELECT JSON_SEARCH(@`json`, 'one', @`value`);
JSON_SEARCH(@`json`, 'one', @`value`)
"$[2].C"
SET @`json` := NULL, @`value` := NULL;
...@@ -455,3 +455,11 @@ SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6'); ...@@ -455,3 +455,11 @@ SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
select json_array_append('[ ]', '$', 'aue'); select json_array_append('[ ]', '$', 'aue');
--echo #
--echo # MDEV-17018 JSON_SEARCH and User-Defined Variables.
--echo #
SET @`json` := '["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', @`value` := 'AB';
SELECT JSON_SEARCH(@`json`, 'one', @`value`);
SET @`json` := NULL, @`value` := NULL;
...@@ -3056,7 +3056,7 @@ static int append_json_path(String *str, const json_path_t *p) ...@@ -3056,7 +3056,7 @@ static int append_json_path(String *str, const json_path_t *p)
String *Item_func_json_search::val_str(String *str) String *Item_func_json_search::val_str(String *str)
{ {
String *js= args[0]->val_json(&tmp_js); String *js= args[0]->val_json(&tmp_js);
String *s_str= args[2]->val_str(&tmp_js); String *s_str= args[2]->val_str(&tmp_path);
json_engine_t je; json_engine_t je;
json_path_t p, sav_path; json_path_t p, sav_path;
uint n_arg; uint n_arg;
......
...@@ -400,7 +400,7 @@ class Item_func_json_keys: public Item_str_func ...@@ -400,7 +400,7 @@ class Item_func_json_keys: public Item_str_func
class Item_func_json_search: public Item_json_str_multipath class Item_func_json_search: public Item_json_str_multipath
{ {
protected: protected:
String tmp_js, esc_value; String tmp_js, tmp_path, esc_value;
bool mode_one; bool mode_one;
bool ooa_constant, ooa_parsed; bool ooa_constant, ooa_parsed;
int escape; int escape;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment