summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-05-03 19:10:10 +0300
committerMichael Widenius <monty@askmonty.org>2011-05-03 19:10:10 +0300
commit1be5462d59fa5fbd1ca92286c3a0a049c00f4bb9 (patch)
tree17ba1ed90233efa64bc83364ed1ffb74dd637ead /sql/item_func.cc
parentce55d37929fc91b476541d3a77336a44b20317ac (diff)
parent90e058e0c623f770ee602ebab86e91303f08c90a (diff)
downloadmariadb-git-1be5462d59fa5fbd1ca92286c3a0a049c00f4bb9.tar.gz
Merge with MariaDB 5.1
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 6ff743ed91d..f1af632d790 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -496,7 +496,10 @@ bool Item_func::is_expensive_processor(uchar *arg)
my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed);
- int2my_decimal(E_DEC_FATAL_ERROR, val_int(), unsigned_flag, decimal_value);
+ longlong nr= val_int();
+ if (null_value)
+ return 0; /* purecov: inspected */
+ int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value);
return decimal_value;
}
@@ -854,7 +857,7 @@ longlong Item_func_numhybrid::val_int()
return 0;
char *end= (char*) res->ptr() + res->length();
- CHARSET_INFO *cs= str_value.charset();
+ CHARSET_INFO *cs= res->charset();
return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
}
default:
@@ -1817,9 +1820,10 @@ void Item_func_integer::fix_length_and_dec()
void Item_func_int_val::fix_num_length_and_dec()
{
- max_length= args[0]->max_length - (args[0]->decimals ?
- args[0]->decimals + 1 :
- 0) + 2;
+ ulonglong tmp_max_length= (ulonglong ) args[0]->max_length -
+ (args[0]->decimals ? args[0]->decimals + 1 : 0) + 2;
+ max_length= tmp_max_length > (ulonglong) max_field_size ?
+ max_field_size : (uint32) tmp_max_length;
uint tmp= float_length(decimals);
set_if_smaller(max_length,tmp);
decimals= 0;
@@ -2134,10 +2138,7 @@ my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
if (!(null_value= (args[0]->null_value || args[1]->null_value ||
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
truncate, decimal_value) > 1)))
- {
- decimal_value->frac= decimals;
return decimal_value;
- }
return 0;
}
@@ -3873,6 +3874,7 @@ Item_func_set_user_var::fix_length_and_dec()
maybe_null=args[0]->maybe_null;
max_length=args[0]->max_length;
decimals=args[0]->decimals;
+ unsigned_flag= args[0]->unsigned_flag;
collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
}