diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 21:17:16 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 21:17:16 +0200 |
commit | 8cc15c036dbc5fefb025eb957f4d312d41659163 (patch) | |
tree | 6c4d67d677e6bb9bc90b7e3f08d18c8a798680b6 /sql/item_sum.h | |
parent | cc28947315887f55814cb8bc4e68d4e2fe6c65e6 (diff) | |
parent | b86e0f25f896285a34c999515ad50e50d879f3e7 (diff) | |
download | mariadb-git-8cc15c036dbc5fefb025eb957f4d312d41659163.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r-- | sql/item_sum.h | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h index c18454f1506..7fccc4e24aa 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -588,6 +588,7 @@ public: virtual void setup_caches(THD *thd) {}; bool with_sum_func() const { return true; } + virtual void set_partition_row_count(ulonglong count) { DBUG_ASSERT(0); } }; @@ -734,13 +735,33 @@ public: Item_sum_num(THD *thd, Item_sum_num *item): Item_sum(thd, item) {} bool fix_fields(THD *, Item **); - longlong val_int() { return val_int_from_real(); /* Real as default */ } - String *val_str(String*str); - my_decimal *val_decimal(my_decimal *); +}; + + +class Item_sum_double :public Item_sum_num +{ +public: + Item_sum_double(THD *thd): Item_sum_num(thd) {} + Item_sum_double(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {} + Item_sum_double(THD *thd, List<Item> &list): Item_sum_num(thd, list) {} + Item_sum_double(THD *thd, Item_sum_double *item) :Item_sum_num(thd, item) {} + longlong val_int() + { + return val_int_from_real(); + } + String *val_str(String*str) + { + return val_string_from_real(str); + } + my_decimal *val_decimal(my_decimal *to) + { + return val_decimal_from_real(to); + } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { - return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); + return get_date_from_real(thd, ltime, fuzzydate); } + const Type_handler *type_handler() const { return &type_handler_double; } }; @@ -754,6 +775,10 @@ public: double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } String *val_str(String*str); my_decimal *val_decimal(my_decimal *); + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { + return get_date_from_int(thd, ltime, fuzzydate); + } bool fix_length_and_dec() { decimals=0; max_length=21; maybe_null=null_value=0; return FALSE; } }; @@ -794,6 +819,10 @@ public: longlong val_int(); String *val_str(String*str); my_decimal *val_decimal(my_decimal *); + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { + return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); + } const Type_handler *type_handler() const { return Type_handler_hybrid_field_type::type_handler(); } void fix_length_and_dec_double(); @@ -986,7 +1015,7 @@ public: -class Item_sum_variance : public Item_sum_num +class Item_sum_variance : public Item_sum_double { Stddev m_stddev; bool fix_length_and_dec(); @@ -996,7 +1025,7 @@ public: uint prec_increment; Item_sum_variance(THD *thd, Item *item_par, uint sample_arg): - Item_sum_num(thd, item_par), + Item_sum_double(thd, item_par), sample(sample_arg) {} Item_sum_variance(THD *thd, Item_sum_variance *item); @@ -1006,7 +1035,6 @@ public: void clear(); bool add(); double val_real(); - my_decimal *val_decimal(my_decimal *); void reset_field(); void update_field(); Item *result_item(THD *thd, Field *field); @@ -1015,11 +1043,10 @@ public: { return sample ? "var_samp(" : "variance("; } Item *copy_or_same(THD* thd); Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); - const Type_handler *type_handler() const { return &type_handler_double; } void cleanup() { m_stddev= Stddev(); - Item_sum_num::cleanup(); + Item_sum_double::cleanup(); } Item *get_copy(THD *thd) { return get_item_copy<Item_sum_variance>(thd, this); } @@ -1732,15 +1759,15 @@ public: #else /* Dummy functions to get sql_yacc.cc compiled */ -class Item_sum_udf_float :public Item_sum_num +class Item_sum_udf_float :public Item_sum_double { public: Item_sum_udf_float(THD *thd, udf_func *udf_arg): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) - :Item_sum_num(thd, item) {} + :Item_sum_double(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } void clear() {} @@ -1750,15 +1777,15 @@ class Item_sum_udf_float :public Item_sum_num }; -class Item_sum_udf_int :public Item_sum_num +class Item_sum_udf_int :public Item_sum_double { public: Item_sum_udf_int(THD *thd, udf_func *udf_arg): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) - :Item_sum_num(thd, item) {} + :Item_sum_double(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0; } @@ -1769,15 +1796,15 @@ public: }; -class Item_sum_udf_decimal :public Item_sum_num +class Item_sum_udf_decimal :public Item_sum_double { public: Item_sum_udf_decimal(THD *thd, udf_func *udf_arg): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item) - :Item_sum_num(thd, item) {} + :Item_sum_double(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; } @@ -1788,15 +1815,15 @@ class Item_sum_udf_decimal :public Item_sum_num }; -class Item_sum_udf_str :public Item_sum_num +class Item_sum_udf_str :public Item_sum_double { public: Item_sum_udf_str(THD *thd, udf_func *udf_arg): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): - Item_sum_num(thd) {} + Item_sum_double(thd) {} Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) - :Item_sum_num(thd, item) {} + :Item_sum_double(thd, item) {} String *val_str(String *) { DBUG_ASSERT(fixed == 1); null_value=1; return 0; } double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; } |