summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2018-06-19 14:51:50 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2018-06-19 14:51:50 +0200
commit083279f7838d45c475344d20585ead72a147a21d (patch)
treec3ff5b3f6af1c9009b35d9b2560a7073be41ce90 /sql/item_sum.cc
parent0121d5a790983c08dabedc66e70f862e47f7c8c7 (diff)
parent6b8802e8dd5467556a024d807a1df23940b00895 (diff)
downloadmariadb-git-083279f7838d45c475344d20585ead72a147a21d.tar.gz
Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_dec
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc50
1 files changed, 28 insertions, 22 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 0e506cc26f2..3163fb9ea2e 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1139,9 +1139,8 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
result_field=0;
max_length=float_length(decimals);
null_value=1;
- fix_length_and_dec();
-
- if (check_sum_func(thd, ref))
+ if (fix_length_and_dec() ||
+ check_sum_func(thd, ref))
return TRUE;
memcpy (orig_args, args, sizeof (Item *) * arg_count);
@@ -1167,7 +1166,9 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
with_param= args[0]->with_param;
with_window_func|= args[0]->with_window_func;
- fix_length_and_dec();
+ if (fix_length_and_dec())
+ DBUG_RETURN(TRUE);
+
if (!is_window_func_sum_expr())
setup_hybrid(thd, args[0], NULL);
result_field=0;
@@ -1181,11 +1182,11 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
}
-void Item_sum_hybrid::fix_length_and_dec()
+bool Item_sum_hybrid::fix_length_and_dec()
{
DBUG_ASSERT(args[0]->field_type() == args[0]->real_item()->field_type());
DBUG_ASSERT(args[0]->result_type() == args[0]->real_item()->result_type());
- (void) args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
+ return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
}
@@ -1304,7 +1305,8 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
result_field= NULL;
max_length= float_length(decimals);
null_value= 1;
- fix_length_and_dec();
+ if (fix_length_and_dec())
+ return TRUE;
if (check_sum_func(thd, ref))
return TRUE;
@@ -1386,14 +1388,14 @@ Item_sum_sp::cleanup()
@note called from Item::fix_fields.
*/
-void
+bool
Item_sum_sp::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_sp::fix_length_and_dec");
DBUG_ASSERT(sp_result_field);
Type_std_attributes::set(sp_result_field->type_std_attributes());
- Item_sum::fix_length_and_dec();
- DBUG_VOID_RETURN;
+ bool res= Item_sum::fix_length_and_dec();
+ DBUG_RETURN(res);
}
const char *
@@ -1489,14 +1491,16 @@ void Item_sum_sum::fix_length_and_dec_decimal()
}
-void Item_sum_sum::fix_length_and_dec()
+bool Item_sum_sum::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_sum::fix_length_and_dec");
maybe_null=null_value=1;
- args[0]->cast_to_int_type_handler()->Item_sum_sum_fix_length_and_dec(this);
+ if (args[0]->cast_to_int_type_handler()->
+ Item_sum_sum_fix_length_and_dec(this))
+ DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("Type: %s (%d, %d)", type_handler()->name().ptr(),
max_length, (int) decimals));
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
@@ -1913,15 +1917,17 @@ void Item_sum_avg::fix_length_and_dec_double()
}
-void Item_sum_avg::fix_length_and_dec()
+bool Item_sum_avg::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_avg::fix_length_and_dec");
prec_increment= current_thd->variables.div_precincrement;
maybe_null=null_value=1;
- args[0]->cast_to_int_type_handler()->Item_sum_avg_fix_length_and_dec(this);
+ if (args[0]->cast_to_int_type_handler()->
+ Item_sum_avg_fix_length_and_dec(this))
+ DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("Type: %s (%d, %d)", type_handler()->name().ptr(),
max_length, (int) decimals));
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
@@ -2133,7 +2139,7 @@ void Item_sum_variance::fix_length_and_dec_decimal()
}
-void Item_sum_variance::fix_length_and_dec()
+bool Item_sum_variance::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_variance::fix_length_and_dec");
maybe_null= null_value= 1;
@@ -2145,11 +2151,11 @@ void Item_sum_variance::fix_length_and_dec()
type of the result is an implementation-defined aproximate numeric
type.
*/
-
- args[0]->type_handler()->Item_sum_variance_fix_length_and_dec(this);
+ if (args[0]->type_handler()->Item_sum_variance_fix_length_and_dec(this))
+ DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("Type: %s (%d, %d)", type_handler()->name().ptr(),
max_length, (int)decimals));
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
@@ -3375,13 +3381,13 @@ my_decimal *Item_sum_udf_int::val_decimal(my_decimal *dec)
/** Default max_length is max argument length. */
-void Item_sum_udf_str::fix_length_and_dec()
+bool Item_sum_udf_str::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_udf_str::fix_length_and_dec");
max_length=0;
for (uint i = 0; i < arg_count; i++)
set_if_bigger(max_length,args[i]->max_length);
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}