diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-05-02 16:34:07 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-05-03 12:33:11 +0530 |
commit | 4e5b771e980edfdad5c5414aa62c81d409d585a4 (patch) | |
tree | 4025c5b267b38a81b718de56ac92cf1942af4999 /sql/item_jsonfunc.cc | |
parent | 97675570ca1e5a3428be1bf6d125f401e37e539d (diff) | |
download | mariadb-git-11.1.tar.gz |
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
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 903776ddebf..fa0a8cbec7f 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -4731,16 +4731,20 @@ longlong Item_func_json_schema_valid::val_int() if (!schema_parsed) { null_value= 1; - return 0; + return 0; } - val= args[1]->val_json(&tmp_val); + 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, |