Commit 9e6858a4 authored by Rucha Deodhar's avatar Rucha Deodhar

MDEV-22141: JSON_REMOVE returns NULL on valid arguments

Analysis:
When we scan json to get to a beginning according to the path, we end up
scanning json even if we have exhausted it. When eventually returns error.

Fix:
Continue scanning json only if we have not exhausted it and return result
accordingly.
parent 5ca64e65
......@@ -1711,5 +1711,11 @@ NULL
Warnings:
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5
#
# MDEV-22141: JSON_REMOVE returns NULL on valid arguments
#
SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D')
{"A": {"B": 1}}
#
# End of 10.5 tests
#
......@@ -1140,6 +1140,13 @@ DROP TABLE t;
SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date'));
--echo #
--echo # MDEV-22141: JSON_REMOVE returns NULL on valid arguments
--echo #
SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -3332,6 +3332,7 @@ String *Item_func_json_remove::val_str(String *str)
{
if (je.s.error)
goto js_error;
continue;
}
if (json_read_value(&je))
......
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