summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2016-03-28 22:18:38 +0300
committerSergei Petrunia <psergey@askmonty.org>2016-03-28 22:18:38 +0300
commit2bd4dc38e0d5eb257e2e29413dd01239ce075d42 (patch)
treedad0557b1d927d012aebd1c36c8c3e00462adcb1 /sql/item_func.cc
parent44fdb56c977259b2801c612116813beda403df78 (diff)
parent3df261dc31ab18ee1537f327b07320b0a07fb8f5 (diff)
downloadmariadb-git-2bd4dc38e0d5eb257e2e29413dd01239ce075d42.tar.gz
Merge branch '10.2' into bb-10.2-mdev9543
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 9183fd8f81a..57bd004cf88 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -234,7 +234,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
}
}
fix_length_and_dec();
- if (thd->is_error()) // An error inside fix_length_and_dec occured
+ if (thd->is_error()) // An error inside fix_length_and_dec occurred
return TRUE;
fixed= 1;
return FALSE;
@@ -577,18 +577,19 @@ void Item_udf_func::fix_num_length_and_dec()
@retval False on success, true on error.
*/
-void Item_func::count_datetime_length(Item **item, uint nitems)
+void Item_func::count_datetime_length(enum_field_types field_type_arg,
+ Item **item, uint nitems)
{
unsigned_flag= 0;
decimals= 0;
- if (field_type() != MYSQL_TYPE_DATE)
+ if (field_type_arg != MYSQL_TYPE_DATE)
{
for (uint i= 0; i < nitems; i++)
set_if_bigger(decimals, item[i]->decimals);
}
set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
uint len= decimals ? (decimals + 1) : 0;
- len+= mysql_temporal_int_part_length(field_type());
+ len+= mysql_temporal_int_part_length(field_type_arg);
fix_char_length(len);
}
@@ -597,16 +598,16 @@ void Item_func::count_datetime_length(Item **item, uint nitems)
result length/precision depends on argument ones.
*/
-void Item_func::count_decimal_length()
+void Item_func::count_decimal_length(Item **item, uint nitems)
{
int max_int_part= 0;
decimals= 0;
unsigned_flag= 1;
- for (uint i=0 ; i < arg_count ; i++)
+ for (uint i=0 ; i < nitems ; i++)
{
- set_if_bigger(decimals, args[i]->decimals);
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
+ set_if_bigger(decimals, item[i]->decimals);
+ set_if_bigger(max_int_part, item[i]->decimal_int_part());
+ set_if_smaller(unsigned_flag, item[i]->unsigned_flag);
}
int precision= MY_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
fix_char_length(my_decimal_precision_to_length_no_truncation(precision,
@@ -637,19 +638,20 @@ void Item_func::count_only_length(Item **item, uint nitems)
result length/precision depends on argument ones.
*/
-void Item_func::count_real_length()
+void Item_func::count_real_length(Item **items, uint nitems)
{
uint32 length= 0;
decimals= 0;
max_length= 0;
- for (uint i=0 ; i < arg_count ; i++)
+ unsigned_flag= false;
+ for (uint i=0 ; i < nitems ; i++)
{
if (decimals != NOT_FIXED_DEC)
{
- set_if_bigger(decimals, args[i]->decimals);
- set_if_bigger(length, (args[i]->max_length - args[i]->decimals));
+ set_if_bigger(decimals, items[i]->decimals);
+ set_if_bigger(length, (items[i]->max_length - items[i]->decimals));
}
- set_if_bigger(max_length, args[i]->max_length);
+ set_if_bigger(max_length, items[i]->max_length);
}
if (decimals != NOT_FIXED_DEC)
{
@@ -678,11 +680,11 @@ bool Item_func::count_string_result_length(enum_field_types field_type_arg,
if (agg_arg_charsets_for_string_result(collation, items, nitems, 1))
return true;
if (is_temporal_type(field_type_arg))
- count_datetime_length(items, nitems);
+ count_datetime_length(field_type_arg, items, nitems);
else
{
- decimals= NOT_FIXED_DEC;
count_only_length(items, nitems);
+ decimals= max_length ? NOT_FIXED_DEC : 0;
}
return false;
}
@@ -757,7 +759,7 @@ void Item_num_op::fix_length_and_dec(void)
if (r0 == REAL_RESULT || r1 == REAL_RESULT ||
r0 == STRING_RESULT || r1 ==STRING_RESULT)
{
- count_real_length();
+ count_real_length(args, arg_count);
max_length= float_length(decimals);
set_handler_by_result_type(REAL_RESULT);
}
@@ -5622,7 +5624,7 @@ void Item_func_get_user_var::fix_length_and_dec()
/*
If the variable didn't exist it has been created as a STRING-type.
- 'm_var_entry' is NULL only if there occured an error during the call to
+ 'm_var_entry' is NULL only if there occurred an error during the call to
get_var_with_binlog.
*/
if (!error && m_var_entry)