Commit df87dce0 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-11473 JSON_REMOVE returns invalid results.

        Item_func_json_remove::val_str fixed.
parent 7e03c67a
...@@ -150,7 +150,7 @@ json_remove(@j, '$[0]') ...@@ -150,7 +150,7 @@ json_remove(@j, '$[0]')
[ ["b", "c"], "d"] [ ["b", "c"], "d"]
select json_remove(@j, '$[1]'); select json_remove(@j, '$[1]');
json_remove(@j, '$[1]') json_remove(@j, '$[1]')
["a" "d"] ["a", "d"]
select json_remove(@j, '$[2]'); select json_remove(@j, '$[2]');
json_remove(@j, '$[2]') json_remove(@j, '$[2]')
["a", ["b", "c"]] ["a", ["b", "c"]]
......
...@@ -1667,9 +1667,7 @@ String *Item_func_json_remove::val_str(String *str) ...@@ -1667,9 +1667,7 @@ String *Item_func_json_remove::val_str(String *str)
rem_start= (const char *) (je.s.c_str - je.sav_c_len); rem_start= (const char *) (je.s.c_str - je.sav_c_len);
json_string_set_str(&key_name, lp->key, lp->key_end); json_string_set_str(&key_name, lp->key, lp->key_end);
if (json_key_matches(&je, &key_name)) if (json_key_matches(&je, &key_name))
{
goto v_found; goto v_found;
}
if (json_skip_key(&je)) if (json_skip_key(&je))
goto error; goto error;
...@@ -1693,7 +1691,7 @@ String *Item_func_json_remove::val_str(String *str) ...@@ -1693,7 +1691,7 @@ String *Item_func_json_remove::val_str(String *str)
if (json_skip_key(&je) || json_scan_next(&je)) if (json_skip_key(&je) || json_scan_next(&je))
goto error; goto error;
rem_end= (je.state == JST_VALUE) ? rem_end= (je.state == JST_VALUE && n_item == 0) ?
(const char *) je.s.c_str : (const char *) (je.s.c_str - je.sav_c_len); (const char *) je.s.c_str : (const char *) (je.s.c_str - je.sav_c_len);
str->length(0); str->length(0);
......
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