summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-13 11:42:31 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-13 11:42:31 +0400
commit95cdc1ca5f006965e1b0e53a8567f6dbb87e01a1 (patch)
tree20f91c9dfc995df26363073737c34e8fe565bfe6 /sql/item_sum.h
parentae1d17f52de045b37e0894e1e6684a911a43696c (diff)
parent43882e764d6867c6855b1ff057758a3f08b25c55 (diff)
downloadmariadb-git-95cdc1ca5f006965e1b0e53a8567f6dbb87e01a1.tar.gz
Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h53
1 files changed, 37 insertions, 16 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 59b8f824c72..99cdf885c7c 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1045,10 +1045,35 @@ 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(); }
+ bool fix_length_and_dec_generic();
+ bool fix_length_and_dec_numeric(const Type_handler *h);
+ bool fix_length_and_dec_string();
+};
+
+
// 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;
@@ -1059,16 +1084,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)
{ }
@@ -1088,8 +1111,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();
@@ -1105,11 +1126,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();
@@ -1120,11 +1141,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();