Commit 174a0b9e authored by Alexander Barkov's avatar Alexander Barkov

Clean-up: Item_sum_variance and Item_variance_field had hybrid type

infrastructure, though in fact they always return REAL result.
Removing hybrid type artifacts.
parent de1a48e7
...@@ -1829,7 +1829,7 @@ static double variance_fp_recurrence_result(double s, ulonglong count, bool is_s ...@@ -1829,7 +1829,7 @@ static double variance_fp_recurrence_result(double s, ulonglong count, bool is_s
Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item): Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item):
Item_sum_num(thd, item), hybrid_type(item->hybrid_type), Item_sum_num(thd, item),
count(item->count), sample(item->sample), count(item->count), sample(item->sample),
prec_increment(item->prec_increment) prec_increment(item->prec_increment)
{ {
...@@ -1850,7 +1850,6 @@ void Item_sum_variance::fix_length_and_dec() ...@@ -1850,7 +1850,6 @@ void Item_sum_variance::fix_length_and_dec()
type of the result is an implementation-defined aproximate numeric type of the result is an implementation-defined aproximate numeric
type. type.
*/ */
hybrid_type= REAL_RESULT;
switch (args[0]->result_type()) { switch (args[0]->result_type()) {
case REAL_RESULT: case REAL_RESULT:
...@@ -2712,29 +2711,6 @@ double Item_std_field::val_real() ...@@ -2712,29 +2711,6 @@ double Item_std_field::val_real()
} }
my_decimal *Item_std_field::val_decimal(my_decimal *dec_buf)
{
/*
We can't call val_decimal_from_real() for DECIMAL_RESULT as
Item_variance_field::val_real() would cause an infinite loop
*/
my_decimal tmp_dec, *dec;
double nr;
if (hybrid_type == REAL_RESULT)
return val_decimal_from_real(dec_buf);
dec= Item_variance_field::val_decimal(dec_buf);
if (!dec)
return 0;
my_decimal2double(E_DEC_FATAL_ERROR, dec, &nr);
DBUG_ASSERT(nr >= 0.0);
nr= sqrt(nr);
double2my_decimal(E_DEC_FATAL_ERROR, nr, &tmp_dec);
my_decimal_round(E_DEC_FATAL_ERROR, &tmp_dec, decimals, FALSE, dec_buf);
return dec_buf;
}
Item_variance_field::Item_variance_field(THD *thd, Item_sum_variance *item): Item_variance_field::Item_variance_field(THD *thd, Item_sum_variance *item):
Item_result_field(thd) Item_result_field(thd)
{ {
...@@ -2745,25 +2721,12 @@ Item_variance_field::Item_variance_field(THD *thd, Item_sum_variance *item): ...@@ -2745,25 +2721,12 @@ Item_variance_field::Item_variance_field(THD *thd, Item_sum_variance *item):
field=item->result_field; field=item->result_field;
maybe_null=1; maybe_null=1;
sample= item->sample; sample= item->sample;
prec_increment= item->prec_increment;
if ((hybrid_type= item->hybrid_type) == DECIMAL_RESULT)
{
f_scale0= item->f_scale0;
f_precision0= item->f_precision0;
dec_bin_size0= item->dec_bin_size0;
f_scale1= item->f_scale1;
f_precision1= item->f_precision1;
dec_bin_size1= item->dec_bin_size1;
}
} }
double Item_variance_field::val_real() double Item_variance_field::val_real()
{ {
// fix_fields() never calls for this Item // fix_fields() never calls for this Item
if (hybrid_type == DECIMAL_RESULT)
return val_real_from_decimal();
double recurrence_s; double recurrence_s;
ulonglong count; ulonglong count;
float8get(recurrence_s, (field->ptr + sizeof(double))); float8get(recurrence_s, (field->ptr + sizeof(double)));
......
...@@ -826,11 +826,11 @@ class Item_sum_avg; ...@@ -826,11 +826,11 @@ class Item_sum_avg;
class Item_avg_field :public Item_result_field class Item_avg_field :public Item_result_field
{ {
public:
Field *field; Field *field;
Item_result hybrid_type; Item_result hybrid_type;
uint f_precision, f_scale, dec_bin_size; uint f_precision, f_scale, dec_bin_size;
uint prec_increment; uint prec_increment;
public:
Item_avg_field(THD *thd, Item_result res_type, Item_sum_avg *item); Item_avg_field(THD *thd, Item_result res_type, Item_sum_avg *item);
enum Type type() const { return FIELD_AVG_ITEM; } enum Type type() const { return FIELD_AVG_ITEM; }
double val_real(); double val_real();
...@@ -898,14 +898,9 @@ class Item_sum_variance; ...@@ -898,14 +898,9 @@ class Item_sum_variance;
class Item_variance_field :public Item_result_field class Item_variance_field :public Item_result_field
{ {
public:
Field *field; Field *field;
Item_result hybrid_type;
uint f_precision0, f_scale0;
uint f_precision1, f_scale1;
uint dec_bin_size0, dec_bin_size1;
uint sample; uint sample;
uint prec_increment; public:
Item_variance_field(THD *thd, Item_sum_variance *item); Item_variance_field(THD *thd, Item_sum_variance *item);
enum Type type() const {return FIELD_VARIANCE_ITEM; } enum Type type() const {return FIELD_VARIANCE_ITEM; }
double val_real(); double val_real();
...@@ -916,12 +911,8 @@ public: ...@@ -916,12 +911,8 @@ public:
my_decimal *val_decimal(my_decimal *dec_buf) my_decimal *val_decimal(my_decimal *dec_buf)
{ return val_decimal_from_real(dec_buf); } { return val_decimal_from_real(dec_buf); }
bool is_null() { update_null_value(); return null_value; } bool is_null() { update_null_value(); return null_value; }
enum_field_types field_type() const enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
{ enum Item_result result_type () const { return REAL_RESULT; }
return hybrid_type == DECIMAL_RESULT ?
MYSQL_TYPE_NEWDECIMAL : MYSQL_TYPE_DOUBLE;
}
enum Item_result result_type () const { return hybrid_type; }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
return trace_unsupported_by_check_vcol_func_processor("var_field"); return trace_unsupported_by_check_vcol_func_processor("var_field");
...@@ -954,18 +945,13 @@ class Item_sum_variance : public Item_sum_num ...@@ -954,18 +945,13 @@ class Item_sum_variance : public Item_sum_num
void fix_length_and_dec(); void fix_length_and_dec();
public: public:
Item_result hybrid_type;
int cur_dec;
double recurrence_m, recurrence_s; /* Used in recurrence relation. */ double recurrence_m, recurrence_s; /* Used in recurrence relation. */
ulonglong count; ulonglong count;
uint f_precision0, f_scale0;
uint f_precision1, f_scale1;
uint dec_bin_size0, dec_bin_size1;
uint sample; uint sample;
uint prec_increment; uint prec_increment;
Item_sum_variance(THD *thd, Item *item_par, uint sample_arg): Item_sum_variance(THD *thd, Item *item_par, uint sample_arg):
Item_sum_num(thd, item_par), hybrid_type(REAL_RESULT), count(0), Item_sum_num(thd, item_par), count(0),
sample(sample_arg) sample(sample_arg)
{} {}
Item_sum_variance(THD *thd, Item_sum_variance *item); Item_sum_variance(THD *thd, Item_sum_variance *item);
...@@ -983,6 +969,7 @@ public: ...@@ -983,6 +969,7 @@ public:
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length); Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
void cleanup() void cleanup()
{ {
count= 0; count= 0;
...@@ -998,9 +985,6 @@ public: ...@@ -998,9 +985,6 @@ public:
Item_std_field(THD *thd, Item_sum_std *item); Item_std_field(THD *thd, Item_sum_std *item);
enum Type type() const { return FIELD_STD_ITEM; } enum Type type() const { return FIELD_STD_ITEM; }
double val_real(); double val_real();
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
}; };
/* /*
...@@ -1020,8 +1004,6 @@ class Item_sum_std :public Item_sum_variance ...@@ -1020,8 +1004,6 @@ class Item_sum_std :public Item_sum_variance
Item *result_item(THD *thd, Field *field); Item *result_item(THD *thd, Field *field);
const char *func_name() const { return "std("; } const char *func_name() const { return "std("; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
}; };
// This class is a string or number function depending on num_func // This class is a string or number function depending on num_func
......
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