1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

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.
This commit is contained in:
Rucha Deodhar
2024-03-16 00:28:48 +05:30
parent 5ca64e65d0
commit 9e6858a426
3 changed files with 14 additions and 0 deletions

View File

@ -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
#

View File

@ -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 #

View File

@ -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))