@@ -820,37 +820,6 @@ class Item_sum_count :public Item_sum_int
820
820
};
821
821
822
822
823
- /* Item to get the value of a stored sum function */
824
-
825
- class Item_sum_avg ;
826
-
827
- class Item_avg_field :public Item_result_field
828
- {
829
- Field *field;
830
- Item_result hybrid_type;
831
- uint f_precision, f_scale, dec_bin_size;
832
- uint prec_increment;
833
- public:
834
- Item_avg_field (THD *thd, Item_result res_type, Item_sum_avg *item);
835
- enum Type type () const { return FIELD_AVG_ITEM; }
836
- double val_real ();
837
- longlong val_int ();
838
- my_decimal *val_decimal (my_decimal *);
839
- bool is_null () { update_null_value (); return null_value; }
840
- String *val_str (String*);
841
- enum_field_types field_type () const
842
- {
843
- return hybrid_type == DECIMAL_RESULT ?
844
- MYSQL_TYPE_NEWDECIMAL : MYSQL_TYPE_DOUBLE;
845
- }
846
- enum Item_result result_type () const { return hybrid_type; }
847
- bool check_vcol_func_processor (uchar *int_arg)
848
- {
849
- return trace_unsupported_by_check_vcol_func_processor (" avg_field" );
850
- }
851
- };
852
-
853
-
854
823
class Item_sum_avg :public Item_sum_sum
855
824
{
856
825
public:
@@ -894,31 +863,6 @@ class Item_sum_avg :public Item_sum_sum
894
863
}
895
864
};
896
865
897
- class Item_sum_variance ;
898
-
899
- class Item_variance_field :public Item_result_field
900
- {
901
- Field *field;
902
- uint sample;
903
- public:
904
- Item_variance_field (THD *thd, Item_sum_variance *item);
905
- enum Type type () const {return FIELD_VARIANCE_ITEM; }
906
- double val_real ();
907
- longlong val_int ()
908
- { /* can't be fix_fields()ed */ return (longlong) rint (val_real ()); }
909
- String *val_str (String *str)
910
- { return val_string_from_real (str); }
911
- my_decimal *val_decimal (my_decimal *dec_buf)
912
- { return val_decimal_from_real (dec_buf); }
913
- bool is_null () { update_null_value (); return null_value; }
914
- enum_field_types field_type () const { return MYSQL_TYPE_DOUBLE; }
915
- enum Item_result result_type () const { return REAL_RESULT; }
916
- bool check_vcol_func_processor (uchar *int_arg)
917
- {
918
- return trace_unsupported_by_check_vcol_func_processor (" var_field" );
919
- }
920
- };
921
-
922
866
923
867
/*
924
868
variance(a) =
@@ -977,16 +921,6 @@ class Item_sum_variance : public Item_sum_num
977
921
}
978
922
};
979
923
980
- class Item_sum_std ;
981
-
982
- class Item_std_field :public Item_variance_field
983
- {
984
- public:
985
- Item_std_field (THD *thd, Item_sum_std *item);
986
- enum Type type () const { return FIELD_STD_ITEM; }
987
- double val_real ();
988
- };
989
-
990
924
/*
991
925
standard_deviation(a) = sqrt(variance(a))
992
926
*/
@@ -1144,6 +1078,117 @@ class Item_sum_xor :public Item_sum_bit
1144
1078
};
1145
1079
1146
1080
1081
+ /* Items to get the value of a stored sum function */
1082
+
1083
+ class Item_sum_field :public Item
1084
+ {
1085
+ protected:
1086
+ Field *field;
1087
+ public:
1088
+ Item_sum_field (THD *thd, Item_sum *item)
1089
+ :Item(thd), field(item->result_field)
1090
+ {
1091
+ name= item->name ;
1092
+ maybe_null= true ;
1093
+ decimals= item->decimals ;
1094
+ max_length= item->max_length ;
1095
+ unsigned_flag= item->unsigned_flag ;
1096
+ }
1097
+ table_map used_tables () const { return (table_map) 1L ; }
1098
+ Field *get_tmp_table_field () { DBUG_ASSERT (0 ); return NULL ; }
1099
+ Field *tmp_table_field (TABLE *) { DBUG_ASSERT (0 ); return NULL ; }
1100
+ void set_result_field (Field *) { DBUG_ASSERT (0 ); }
1101
+ void save_in_result_field (bool no_conversions) { DBUG_ASSERT (0 ); }
1102
+ };
1103
+
1104
+
1105
+ class Item_avg_field :public Item_sum_field
1106
+ {
1107
+ protected:
1108
+ uint prec_increment;
1109
+ public:
1110
+ Item_avg_field (THD *thd, Item_sum_avg *item)
1111
+ :Item_sum_field(thd, item), prec_increment(item->prec_increment)
1112
+ { }
1113
+ enum Type type () const { return FIELD_AVG_ITEM; }
1114
+ bool is_null () { update_null_value (); return null_value; }
1115
+ bool check_vcol_func_processor (uchar *int_arg)
1116
+ {
1117
+ return trace_unsupported_by_check_vcol_func_processor (" avg_field" );
1118
+ }
1119
+ };
1120
+
1121
+
1122
+ class Item_avg_field_double :public Item_avg_field
1123
+ {
1124
+ public:
1125
+ Item_avg_field_double (THD *thd, Item_sum_avg *item)
1126
+ :Item_avg_field(thd, item)
1127
+ { }
1128
+ enum_field_types field_type () const { return MYSQL_TYPE_DOUBLE; }
1129
+ enum Item_result result_type () const { return REAL_RESULT; }
1130
+ longlong val_int () { return (longlong) rint (val_real ()); }
1131
+ my_decimal *val_decimal (my_decimal *dec) { return val_decimal_from_real (dec); }
1132
+ String *val_str (String *str) { return val_string_from_real (str); }
1133
+ double val_real ();
1134
+ };
1135
+
1136
+
1137
+ class Item_avg_field_decimal :public Item_avg_field
1138
+ {
1139
+ uint f_precision, f_scale, dec_bin_size;
1140
+ public:
1141
+ Item_avg_field_decimal (THD *thd, Item_sum_avg *item)
1142
+ :Item_avg_field(thd, item),
1143
+ f_precision (item->f_precision),
1144
+ f_scale(item->f_scale),
1145
+ dec_bin_size(item->dec_bin_size)
1146
+ { }
1147
+ enum_field_types field_type () const { return MYSQL_TYPE_NEWDECIMAL; }
1148
+ enum Item_result result_type () const { return DECIMAL_RESULT; }
1149
+ double val_real () { return val_real_from_decimal (); }
1150
+ longlong val_int () { return val_int_from_decimal (); }
1151
+ String *val_str (String *str) { return val_string_from_decimal (str); }
1152
+ my_decimal *val_decimal (my_decimal *);
1153
+ };
1154
+
1155
+
1156
+ class Item_variance_field :public Item_sum_field
1157
+ {
1158
+ uint sample;
1159
+ public:
1160
+ Item_variance_field (THD *thd, Item_sum_variance *item)
1161
+ :Item_sum_field(thd, item), sample(item->sample)
1162
+ { }
1163
+ enum Type type () const {return FIELD_VARIANCE_ITEM; }
1164
+ double val_real ();
1165
+ longlong val_int ()
1166
+ { /* can't be fix_fields()ed */ return (longlong) rint (val_real ()); }
1167
+ String *val_str (String *str)
1168
+ { return val_string_from_real (str); }
1169
+ my_decimal *val_decimal (my_decimal *dec_buf)
1170
+ { return val_decimal_from_real (dec_buf); }
1171
+ bool is_null () { update_null_value (); return null_value; }
1172
+ enum_field_types field_type () const { return MYSQL_TYPE_DOUBLE; }
1173
+ enum Item_result result_type () const { return REAL_RESULT; }
1174
+ bool check_vcol_func_processor (uchar *int_arg)
1175
+ {
1176
+ return trace_unsupported_by_check_vcol_func_processor (" var_field" );
1177
+ }
1178
+ };
1179
+
1180
+
1181
+ class Item_std_field :public Item_variance_field
1182
+ {
1183
+ public:
1184
+ Item_std_field (THD *thd, Item_sum_std *item)
1185
+ :Item_variance_field(thd, item)
1186
+ { }
1187
+ enum Type type () const { return FIELD_STD_ITEM; }
1188
+ double val_real ();
1189
+ };
1190
+
1191
+
1147
1192
/*
1148
1193
User defined aggregates
1149
1194
*/
0 commit comments