diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 2991eb4e6fb..8d90a6ec726 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -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 # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 5787ee88960..1b55dcb149e 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -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 # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 5622bf3e803..442c4cbed90 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -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))