Commit 54545005 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-11452 JSON_CONTAINS accepts wrong number of arguments.

        Create_func_json_contains::create_native fixed.
parent c89c514e
......@@ -76,6 +76,8 @@ json_contains('"you"', '"you"')
select json_contains('"youth"', '"you"');
json_contains('"youth"', '"you"')
0
select json_contains('[1]', '[1]', '$', '$[0]');
ERROR 42000: Incorrect parameter count in the call to native function 'json_contains'
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]")
1
......
......@@ -30,6 +30,8 @@ SELECT JSON_ARRAY_INSERT('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x');
select json_contains('{"k1":123, "k2":345}', '123', '$.k1');
select json_contains('"you"', '"you"');
select json_contains('"youth"', '"you"');
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select json_contains('[1]', '[1]', '$', '$[0]');
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[10]");
......
......@@ -5218,13 +5218,13 @@ Create_func_json_contains::create_native(THD *thd, LEX_STRING name,
if (item_list != NULL)
arg_count= item_list->elements;
if (arg_count < 2 /* json_doc, val, [path]...*/)
if (arg_count == 2 || arg_count == 3/* json_doc, val, [path] */)
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
func= new (thd->mem_root) Item_func_json_contains(thd, *item_list);
}
else
{
func= new (thd->mem_root) Item_func_json_contains(thd, *item_list);
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
}
return func;
......
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