diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-08-07 14:13:44 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-08-07 14:13:44 +0400 |
commit | e978efd96b9a8146ba2c80a1f3aea755568ac73a (patch) | |
tree | acc499d0c89559db0f9fed5b6d184514f216530c /sql/item_sum.h | |
parent | a8def12e8a65cee915029de46d6e37b338ee9289 (diff) | |
download | mariadb-git-e978efd96b9a8146ba2c80a1f3aea755568ac73a.tar.gz |
MDEV-20273 Add class Item_sum_min_max
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r-- | sql/item_sum.h | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h index ef849782464..df37d0dbfa4 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1025,10 +1025,32 @@ class Item_sum_std :public Item_sum_variance { return get_item_copy<Item_sum_std>(thd, this); } }; + +class Item_sum_hybrid: public Item_sum, + public Type_handler_hybrid_field_type +{ +public: + Item_sum_hybrid(THD *thd, Item *item_par): + Item_sum(thd, item_par), + Type_handler_hybrid_field_type(&type_handler_longlong) + { collation.set(&my_charset_bin); } + Item_sum_hybrid(THD *thd, Item *a, Item *b): + Item_sum(thd, a, b), + Type_handler_hybrid_field_type(&type_handler_longlong) + { collation.set(&my_charset_bin); } + Item_sum_hybrid(THD *thd, Item_sum_hybrid *item) + :Item_sum(thd, item), + Type_handler_hybrid_field_type(item) + { } + const Type_handler *type_handler() const + { return Type_handler_hybrid_field_type::type_handler(); } +}; + + // This class is a string or number function depending on num_func class Arg_comparator; class Item_cache; -class Item_sum_hybrid :public Item_sum, public Type_handler_hybrid_field_type +class Item_sum_min_max :public Item_sum_hybrid { protected: bool direct_added; @@ -1039,16 +1061,14 @@ protected: bool was_values; // Set if we have found at least one row (for max/min only) bool was_null_value; - public: - Item_sum_hybrid(THD *thd, Item *item_par,int sign): - Item_sum(thd, item_par), - Type_handler_hybrid_field_type(&type_handler_longlong), +public: + Item_sum_min_max(THD *thd, Item *item_par,int sign): + Item_sum_hybrid(thd, item_par), direct_added(FALSE), value(0), arg_cache(0), cmp(0), cmp_sign(sign), was_values(TRUE) { collation.set(&my_charset_bin); } - Item_sum_hybrid(THD *thd, Item_sum_hybrid *item) - :Item_sum(thd, item), - Type_handler_hybrid_field_type(item), + Item_sum_min_max(THD *thd, Item_sum_min_max *item) + :Item_sum_hybrid(thd, item), direct_added(FALSE), value(item->value), arg_cache(0), cmp_sign(item->cmp_sign), was_values(item->was_values) { } @@ -1067,8 +1087,6 @@ protected: { return get_arg(0)->real_type_handler(); } - const Type_handler *type_handler() const - { return Type_handler_hybrid_field_type::type_handler(); } TYPELIB *get_typelib() const { return args[0]->get_typelib(); } void update_field(); void min_max_update_str_field(); @@ -1084,11 +1102,11 @@ protected: }; -class Item_sum_min :public Item_sum_hybrid +class Item_sum_min :public Item_sum_min_max { public: - Item_sum_min(THD *thd, Item *item_par): Item_sum_hybrid(thd, item_par, 1) {} - Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_hybrid(thd, item) {} + Item_sum_min(THD *thd, Item *item_par): Item_sum_min_max(thd, item_par, 1) {} + Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_min_max(thd, item) {} enum Sumfunctype sum_func () const {return MIN_FUNC;} bool add(); @@ -1099,11 +1117,11 @@ public: }; -class Item_sum_max :public Item_sum_hybrid +class Item_sum_max :public Item_sum_min_max { public: - Item_sum_max(THD *thd, Item *item_par): Item_sum_hybrid(thd, item_par, -1) {} - Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_hybrid(thd, item) {} + Item_sum_max(THD *thd, Item *item_par): Item_sum_min_max(thd, item_par, -1) {} + Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_min_max(thd, item) {} enum Sumfunctype sum_func () const {return MAX_FUNC;} bool add(); |