Commit 3e1f3d3e authored by Alexander Barkov's avatar Alexander Barkov

A cleanup in Item_sum: removing dead code

parent f78eb52f
...@@ -2679,25 +2679,6 @@ bool Item_sum_and::add() ...@@ -2679,25 +2679,6 @@ bool Item_sum_and::add()
** reset result of a Item_sum with is saved in a tmp_table ** reset result of a Item_sum with is saved in a tmp_table
*************************************************************************/ *************************************************************************/
void Item_sum_num::reset_field()
{
double nr= args[0]->val_real();
uchar *res=result_field->ptr;
if (maybe_null)
{
if (args[0]->null_value)
{
nr=0.0;
result_field->set_null();
}
else
result_field->set_notnull();
}
float8store(res,nr);
}
void Item_sum_hybrid::reset_field() void Item_sum_hybrid::reset_field()
{ {
Item *UNINIT_VAR(tmp_item), *arg0; Item *UNINIT_VAR(tmp_item), *arg0;
......
...@@ -722,24 +722,16 @@ class Aggregator_simple : public Aggregator ...@@ -722,24 +722,16 @@ class Aggregator_simple : public Aggregator
class Item_sum_num :public Item_sum 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: 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_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_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_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_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 **); bool fix_fields(THD *, Item **);
longlong val_int() { return val_int_from_real(); /* Real as default */ } longlong val_int() { return val_int_from_real(); /* Real as default */ }
String *val_str(String*str); String *val_str(String*str);
...@@ -748,7 +740,6 @@ class Item_sum_num :public Item_sum ...@@ -748,7 +740,6 @@ class Item_sum_num :public Item_sum
{ {
return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
} }
void reset_field();
}; };
...@@ -1705,6 +1696,7 @@ class Item_sum_udf_float :public Item_sum_num ...@@ -1705,6 +1696,7 @@ class Item_sum_udf_float :public Item_sum_num
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
void update_field() {} void update_field() {}
}; };
...@@ -1723,6 +1715,7 @@ class Item_sum_udf_int :public Item_sum_num ...@@ -1723,6 +1715,7 @@ class Item_sum_udf_int :public Item_sum_num
double val_real() { DBUG_ASSERT(fixed == 1); return 0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
void update_field() {} void update_field() {}
}; };
...@@ -1741,6 +1734,7 @@ class Item_sum_udf_decimal :public Item_sum_num ...@@ -1741,6 +1734,7 @@ class Item_sum_udf_decimal :public Item_sum_num
my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; } my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
void update_field() {} void update_field() {}
}; };
...@@ -1762,6 +1756,7 @@ class Item_sum_udf_str :public Item_sum_num ...@@ -1762,6 +1756,7 @@ class Item_sum_udf_str :public Item_sum_num
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
void update_field() {} void update_field() {}
}; };
......
...@@ -130,6 +130,7 @@ class Item_sum_row_number: public Item_sum_int ...@@ -130,6 +130,7 @@ class Item_sum_row_number: public Item_sum_int
return false; return false;
} }
void reset_field() { DBUG_ASSERT(0); }
void update_field() {} void update_field() {}
enum Sumfunctype sum_func() const enum Sumfunctype sum_func() const
...@@ -193,11 +194,8 @@ class Item_sum_rank: public Item_sum_int ...@@ -193,11 +194,8 @@ class Item_sum_rank: public Item_sum_int
return cur_rank; return cur_rank;
} }
void reset_field() { DBUG_ASSERT(0); }
void update_field() {} void update_field() {}
/*
void reset_field();
TODO: ^^ what does this do ? It is not called ever?
*/
enum Sumfunctype sum_func () const enum Sumfunctype sum_func () const
{ {
...@@ -261,6 +259,7 @@ class Item_sum_dense_rank: public Item_sum_int ...@@ -261,6 +259,7 @@ class Item_sum_dense_rank: public Item_sum_int
first_add= true; first_add= true;
} }
bool add(); bool add();
void reset_field() { DBUG_ASSERT(0); }
void update_field() {} void update_field() {}
longlong val_int() longlong val_int()
{ {
...@@ -460,6 +459,7 @@ class Item_sum_window_with_row_count : public Item_sum_num ...@@ -460,6 +459,7 @@ class Item_sum_window_with_row_count : public Item_sum_num
void set_row_count(ulonglong count) { partition_row_count_ = count; } void set_row_count(ulonglong count) { partition_row_count_ = count; }
void reset_field() { DBUG_ASSERT(0); }
protected: protected:
longlong get_row_count() { return partition_row_count_; } longlong get_row_count() { return partition_row_count_; }
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment