diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 10:03:04 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-12 10:03:04 +0200 |
commit | e19a6f3dca7509eb8e042796a9311dba937ad9d7 (patch) | |
tree | 8eb1587285f8d06f57f1915c7ac212ef3e4d4a60 /sql/item_func.cc | |
parent | 0b4c3ad8181b909a3af04847e229900b1e9c5232 (diff) | |
parent | dfb74dea300f83880c11600dc726a9cae559f356 (diff) | |
download | mariadb-git-e19a6f3dca7509eb8e042796a9311dba937ad9d7.tar.gz |
Merge branch 'bb-10.1-serg' into 10.1
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index c1df7bd6a6e..f3d3a54561c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -869,7 +869,7 @@ String *Item_func_hybrid_field_type::val_str(String *str) case DECIMAL_RESULT: { my_decimal decimal_value, *val; - if (!(val= decimal_op(&decimal_value))) + if (!(val= decimal_op_with_null_check(&decimal_value))) return 0; // null is set my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, FALSE, val); str->set_charset(collation.collation); @@ -895,23 +895,21 @@ String *Item_func_hybrid_field_type::val_str(String *str) case TIME_RESULT: { MYSQL_TIME ltime; - if (date_op(<ime, - field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) || - str->alloc(MAX_DATE_STRING_REP_LENGTH)) - { - null_value= 1; + if (date_op_with_null_check(<ime) || + (null_value= str->alloc(MAX_DATE_STRING_REP_LENGTH))) return (String *) 0; - } ltime.time_type= mysql_type_to_time_type(field_type()); str->length(my_TIME_to_str(<ime, const_cast<char*>(str->ptr()), decimals)); str->set_charset(&my_charset_bin); + DBUG_ASSERT(!null_value); return str; } case STRING_RESULT: - return str_op(&str_value); + return str_op_with_null_check(&str_value); case ROW_RESULT: DBUG_ASSERT(0); } + DBUG_ASSERT(!null_value || (str == NULL)); return str; } @@ -924,7 +922,7 @@ double Item_func_hybrid_field_type::val_real() { my_decimal decimal_value, *val; double result; - if (!(val= decimal_op(&decimal_value))) + if (!(val= decimal_op_with_null_check(&decimal_value))) return 0.0; // null is set my_decimal2double(E_DEC_FATAL_ERROR, val, &result); return result; @@ -939,18 +937,14 @@ double Item_func_hybrid_field_type::val_real() case TIME_RESULT: { MYSQL_TIME ltime; - if (date_op(<ime, - field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 )) - { - null_value= 1; + if (date_op_with_null_check(<ime)) return 0; - } ltime.time_type= mysql_type_to_time_type(field_type()); return TIME_to_double(<ime); } case STRING_RESULT: { - String *res= str_op(&str_value); + String *res= str_op_with_null_check(&str_value); return res ? double_from_string_with_check(res) : 0.0; } case ROW_RESULT: @@ -967,7 +961,7 @@ longlong Item_func_hybrid_field_type::val_int() case DECIMAL_RESULT: { my_decimal decimal_value, *val; - if (!(val= decimal_op(&decimal_value))) + if (!(val= decimal_op_with_null_check(&decimal_value))) return 0; // null is set longlong result; my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result); @@ -980,18 +974,14 @@ longlong Item_func_hybrid_field_type::val_int() case TIME_RESULT: { MYSQL_TIME ltime; - if (date_op(<ime, - field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0)) - { - null_value= 1; + if (date_op_with_null_check(<ime)) return 0; - } ltime.time_type= mysql_type_to_time_type(field_type()); return TIME_to_ulonglong(<ime); } case STRING_RESULT: { - String *res= str_op(&str_value); + String *res= str_op_with_null_check(&str_value); return res ? longlong_from_string_with_check(res) : 0; } case ROW_RESULT: @@ -1007,28 +997,30 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value) DBUG_ASSERT(fixed == 1); switch (Item_func_hybrid_field_type::cmp_type()) { case DECIMAL_RESULT: - val= decimal_op(decimal_value); + val= decimal_op_with_null_check(decimal_value); break; case INT_RESULT: { longlong result= int_op(); + if (null_value) + return NULL; int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value); break; } case REAL_RESULT: { double result= (double)real_op(); + if (null_value) + return NULL; double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value); break; } case TIME_RESULT: { MYSQL_TIME ltime; - if (date_op(<ime, - field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0)) + if (date_op_with_null_check(<ime)) { my_decimal_set_zero(decimal_value); - null_value= 1; return 0; } ltime.time_type= mysql_type_to_time_type(field_type()); @@ -1036,7 +1028,7 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value) } case STRING_RESULT: { - String *res= str_op(&str_value); + String *res= str_op_with_null_check(&str_value); return res ? decimal_from_string_with_check(decimal_value, res) : 0; } case ROW_RESULT: @@ -1054,7 +1046,7 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime, case DECIMAL_RESULT: { my_decimal value, *res; - if (!(res= decimal_op(&value)) || + if (!(res= decimal_op_with_null_check(&value)) || decimal_to_datetime_with_warn(res, ltime, fuzzydate, field_name_or_null())) goto err; @@ -1086,7 +1078,7 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime, { char buff[40]; String tmp(buff,sizeof(buff), &my_charset_bin),*res; - if (!(res= str_op(&tmp)) || + if (!(res= str_op_with_null_check(&tmp)) || str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), ltime, fuzzydate)) goto err; |