mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-30677: Incorrect result for "SELECT JSON_SCHEMA_VALID('{}', NULL)"
Analysis: null_value is not set if any one of the arguments is NULL. So it returns 1. Fix: when either argument is NULL, set null_value to true, so that null can be returned
This commit is contained in:
parent
97675570ca
commit
4e5b771e98
4 changed files with 33 additions and 6 deletions
|
@ -4704,4 +4704,16 @@ JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000))
|
|||
0
|
||||
Warnings:
|
||||
Warning 4040 Limit of 32 on JSON nested structures depth is reached in argument 2 to function 'json_schema_valid' at position 32
|
||||
#
|
||||
# MDEV-30677: Incorrect result for "SELECT JSON_SCHEMA_VALID('{}', NULL)"
|
||||
#
|
||||
SELECT JSON_SCHEMA_VALID('{}', NULL);
|
||||
JSON_SCHEMA_VALID('{}', NULL)
|
||||
NULL
|
||||
SELECT JSON_SCHEMA_VALID(NULL, '{}');
|
||||
JSON_SCHEMA_VALID(NULL, '{}')
|
||||
NULL
|
||||
SELECT JSON_SCHEMA_VALID(NULL, NULL);
|
||||
JSON_SCHEMA_VALID(NULL, NULL)
|
||||
NULL
|
||||
# End of 11.1 test
|
||||
|
|
|
@ -3586,4 +3586,11 @@ SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());
|
|||
|
||||
SELECT JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000));
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-30677: Incorrect result for "SELECT JSON_SCHEMA_VALID('{}', NULL)"
|
||||
--echo #
|
||||
SELECT JSON_SCHEMA_VALID('{}', NULL);
|
||||
SELECT JSON_SCHEMA_VALID(NULL, '{}');
|
||||
SELECT JSON_SCHEMA_VALID(NULL, NULL);
|
||||
|
||||
--echo # End of 11.1 test
|
||||
|
|
|
@ -4736,11 +4736,15 @@ longlong Item_func_json_schema_valid::val_int()
|
|||
|
||||
val= args[1]->val_json(&tmp_val);
|
||||
|
||||
if (!val || !val->length())
|
||||
if (!val)
|
||||
{
|
||||
null_value= 0;
|
||||
return 1;
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
null_value= 0;
|
||||
|
||||
if (!val->length())
|
||||
return 1;
|
||||
|
||||
json_scan_start(&ve, val->charset(), (const uchar *) val->ptr(),
|
||||
(const uchar *) val->end());
|
||||
|
@ -4799,7 +4803,10 @@ bool Item_func_json_schema_valid::fix_length_and_dec(THD *thd)
|
|||
String *js= args[0]->val_json(&tmp_js);
|
||||
|
||||
if ((null_value= args[0]->null_value))
|
||||
{
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
json_scan_start(&je, js->charset(), (const uchar *) js->ptr(),
|
||||
(const uchar *) js->ptr() + js->length());
|
||||
if (!create_object_and_handle_keyword(thd, &je, &keyword_list,
|
||||
|
|
|
@ -807,6 +807,7 @@ public:
|
|||
{
|
||||
val= NULL;
|
||||
schema_parsed= false;
|
||||
set_maybe_null();
|
||||
}
|
||||
LEX_CSTRING func_name_cstring() const override
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue