1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-03 05:41:09 +03:00

MDEV-12001 Split Item_func_round::fix_length_and_dec to virtual methods in Type_handler

This patch makes the following changes (according to the task description):
- Adds Type_handler::Item_func_round_fix_length_and_dec().
- Splits the code from Item_func_round::fix_length_and_dec() into new
  Item_func_round methods fix_arg_int(), fix_arg_decimal(), fix_arg_double().
- Calls the new Item_func_round methods from the relevant implementations of
  Type_handler_xxx::Item_func_round_fix_length_and_dec().
- Adds a new error message ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
- Makes ROUND() return the new error for GEOMETRY

Additionally:
- Inherits Item_func_round directly from Item_func_numhybrid as it
  uses nothing from Item_func_num1.
- Fixes "MDEV-12000 ROUND(expr,const_expr_returning_NULL) creates DOUBLE(0,0)".
  Now if args[1] returns NULL, the data type is set to DOUBLE with
  NOT_FIXED_DEC decimals instead of 0 decimals.
This commit is contained in:
Alexander Barkov
2017-02-07 21:07:28 +04:00
parent d333e3ad9c
commit 3f83801d82
10 changed files with 232 additions and 73 deletions

View File

@@ -26,7 +26,6 @@ static Type_handler_long type_handler_long;
static Type_handler_int24 type_handler_int24;
static Type_handler_year type_handler_year;
static Type_handler_float type_handler_float;
static Type_handler_double type_handler_double;
static Type_handler_time type_handler_time;
static Type_handler_time2 type_handler_time2;
static Type_handler_date type_handler_date;
@@ -51,6 +50,7 @@ Type_handler_null type_handler_null;
Type_handler_row type_handler_row;
Type_handler_varchar type_handler_varchar;
Type_handler_longlong type_handler_longlong;
Type_handler_double type_handler_double;
Type_handler_newdecimal type_handler_newdecimal;
Type_handler_datetime type_handler_datetime;
Type_handler_bit type_handler_bit;
@@ -2154,4 +2154,64 @@ String *Type_handler_timestamp_common::
}
/***************************************************************************/
bool Type_handler_row::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
DBUG_ASSERT(0);
return false;
}
bool Type_handler_int_result::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
item->fix_arg_int();
return false;
}
bool Type_handler_real_result::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
item->fix_arg_double();
return false;
}
bool Type_handler_decimal_result::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
item->fix_arg_decimal();
return false;
}
bool Type_handler_temporal_result::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
item->fix_arg_double();
return false;
}
bool Type_handler_string_result::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
item->fix_arg_double();
return false;
}
#ifdef HAVE_SPATIAL
bool Type_handler_geometry::
Item_func_round_fix_length_and_dec(Item_func_round *item) const
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
type_handler_geometry.name().ptr(), item->func_name());
return false;
}
#endif
/***************************************************************************/