1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-11365 Split the data type and attribute related code in Item_sum_hybrid::fix_fields into Type_handler::Item_sum_hybrid_fix_length_and_dec()

This patch:
- Implements the task according to the description
- Adds a new class Type_handler_numeric as a common parent
  for Type_handler_real_result, Type_handler_int_result,
  Type_handler_decimal_result, to share the common code
  between numeric data type handlers.
- Removes the dedundant call for collation.set(item->collation) in
  Item_sum_hybrid::setup_hybrid(), because setup_hybrid() is called
  either after fix_length_and_dec() or afte ther constructor
  Item_sum_hybrid(THD *thd, Item_sum_hybrid *item),
  so the collation is already properly set in all cases.
This commit is contained in:
Alexander Barkov
2016-11-28 10:21:01 +04:00
parent 749bbb3d7b
commit 9185f8d4a7
4 changed files with 138 additions and 31 deletions

View File

@ -26,6 +26,7 @@
class Field;
class Item;
class Item_cache;
class Item_sum_hybrid;
class Type_std_attributes;
class Sort_param;
class Arg_comparator;
@ -289,6 +290,7 @@ public:
bool no_conversions) const= 0;
virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0;
virtual bool set_comparator_func(Arg_comparator *cmp) const= 0;
virtual bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *) const= 0;
};
@ -342,12 +344,31 @@ public:
}
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
{
DBUG_ASSERT(0);
return true;
}
};
/*
A common parent class for numeric data type handlers
*/
class Type_handler_numeric: public Type_handler
{
protected:
bool Item_sum_hybrid_fix_length_and_dec_numeric(Item_sum_hybrid *func,
const Type_handler *handler)
const;
public:
virtual ~Type_handler_numeric() { }
};
/*** Abstract classes for every XXX_RESULT */
class Type_handler_real_result: public Type_handler
class Type_handler_real_result: public Type_handler_numeric
{
public:
Item_result result_type() const { return REAL_RESULT; }
@ -361,10 +382,11 @@ public:
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
};
class Type_handler_decimal_result: public Type_handler
class Type_handler_decimal_result: public Type_handler_numeric
{
public:
Item_result result_type() const { return DECIMAL_RESULT; }
@ -379,10 +401,11 @@ public:
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
};
class Type_handler_int_result: public Type_handler
class Type_handler_int_result: public Type_handler_numeric
{
public:
Item_result result_type() const { return INT_RESULT; }
@ -397,6 +420,7 @@ public:
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
};
@ -413,6 +437,7 @@ public:
SORT_FIELD_ATTR *attr) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
};
@ -433,6 +458,7 @@ public:
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
};