summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-12-25 12:23:24 +0400
committerAlexander Barkov <bar@mariadb.com>2019-12-25 12:23:24 +0400
commitee9a19fb054085fcea006a25ec957e0d5cb01ce8 (patch)
tree6680bb8076142514dc71ee4edb8092e14d6afffe /sql/item_sum.h
parentb21dc119865993916abc736081e8ceed1e165961 (diff)
downloadmariadb-git-ee9a19fb054085fcea006a25ec957e0d5cb01ce8.tar.gz
MDEV-21392 Cleanup redundant overriding in Item_sum_num
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h97
1 files changed, 58 insertions, 39 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index a3e10c25763..243b6f28944 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -578,6 +578,7 @@ public:
void mark_as_window_func_sum_expr() { window_func_sum_expr_flag= true; }
bool is_window_func_sum_expr() { return window_func_sum_expr_flag; }
virtual void setup_caches(THD *thd) {};
+ virtual void set_partition_row_count(ulonglong count) { DBUG_ASSERT(0); }
};
@@ -713,33 +714,45 @@ public:
class Item_sum_num :public Item_sum
{
-protected:
- /*
- val_xxx() functions may be called several times during the execution of a
- query. Derived classes that require extensive calculation in val_xxx()
- maintain cache of aggregate value. This variable governs the validity of
- that cache.
- */
- bool is_evaluated;
public:
- Item_sum_num(THD *thd): Item_sum(thd), is_evaluated(FALSE) {}
+ Item_sum_num(THD *thd): Item_sum(thd) {}
Item_sum_num(THD *thd, Item *item_par):
- Item_sum(thd, item_par), is_evaluated(FALSE) {}
+ Item_sum(thd, item_par) {}
Item_sum_num(THD *thd, Item *a, Item* b):
- Item_sum(thd, a, b), is_evaluated(FALSE) {}
+ Item_sum(thd, a, b) {}
Item_sum_num(THD *thd, List<Item> &list):
- Item_sum(thd, list), is_evaluated(FALSE) {}
+ Item_sum(thd, list) {}
Item_sum_num(THD *thd, Item_sum_num *item):
- Item_sum(thd, item),is_evaluated(item->is_evaluated) {}
+ 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 *);
+ void reset_field();
+};
+
+
+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(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
- return type_handler()->Item_get_date(this, ltime, fuzzydate);
+ return get_date_from_real(ltime, fuzzydate);
}
- void reset_field();
+ const Type_handler *type_handler() const { return &type_handler_double; }
};
@@ -753,6 +766,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(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ return get_date_from_int(ltime, fuzzydate);
+ }
const Type_handler *type_handler() const { return &type_handler_longlong; }
bool fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; return FALSE; }
@@ -794,6 +811,10 @@ public:
longlong val_int();
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
+ bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ return type_handler()->Item_get_date(this, ltime, fuzzydate);
+ }
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
void fix_length_and_dec_double();
@@ -964,7 +985,7 @@ But, this falls prey to catastrophic cancellation. Instead, use the recurrence
*/
-class Item_sum_variance : public Item_sum_num
+class Item_sum_variance : public Item_sum_double
{
bool fix_length_and_dec();
@@ -975,7 +996,7 @@ public:
uint prec_increment;
Item_sum_variance(THD *thd, Item *item_par, uint sample_arg):
- Item_sum_num(thd, item_par), count(0),
+ Item_sum_double(thd, item_par), count(0),
sample(sample_arg)
{}
Item_sum_variance(THD *thd, Item_sum_variance *item);
@@ -985,7 +1006,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);
@@ -994,11 +1014,10 @@ public:
{ return sample ? "var_samp(" : "variance("; }
Item *copy_or_same(THD* thd);
Field *create_tmp_field(bool group, TABLE *table);
- const Type_handler *type_handler() const { return &type_handler_double; }
void cleanup()
{
count= 0;
- Item_sum_num::cleanup();
+ Item_sum_double::cleanup();
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_variance>(thd, this); }
@@ -1679,15 +1698,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() {}
@@ -1696,15 +1715,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; }
@@ -1714,15 +1733,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; }
@@ -1732,15 +1751,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; }