diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 09:41:44 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 09:41:44 +0300 |
commit | 1813d92d0c505a1c752f4a9d6e37db6bffe4efdd (patch) | |
tree | f570314890197949ae55cbbad3a94eb5893c4177 /sql/item_jsonfunc.cc | |
parent | 0fe97c20b341665058491fca4d665207406775c6 (diff) | |
parent | f347b3e0e6592329b1447fa460aca0a4b1f680b1 (diff) | |
download | mariadb-git-1813d92d0c505a1c752f4a9d6e37db6bffe4efdd.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index fe3fae5840c..aec3e1edcd3 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -951,6 +951,41 @@ double Item_func_json_extract::val_real() } +my_decimal *Item_func_json_extract::val_decimal(my_decimal *to) +{ + json_value_types type; + char *value; + int value_len; + + if (read_json(NULL, &type, &value, &value_len) != NULL) + { + switch (type) + { + case JSON_VALUE_STRING: + case JSON_VALUE_NUMBER: + { + my_decimal *res= decimal_from_string_with_check(to, collation.collation, + value, + value + value_len); + null_value= res == NULL; + return res; + } + case JSON_VALUE_TRUE: + int2my_decimal(E_DEC_FATAL_ERROR, 1, false/*unsigned_flag*/, to); + return to; + case JSON_VALUE_OBJECT: + case JSON_VALUE_ARRAY: + case JSON_VALUE_FALSE: + case JSON_VALUE_NULL: + break; + }; + } + int2my_decimal(E_DEC_FATAL_ERROR, 0, false/*unsigned_flag*/, to); + return to; +} + + + bool Item_func_json_contains::fix_length_and_dec() { a2_constant= args[1]->const_item(); |