Item_sum_num has features of DOUBLE data type by default and implements DOUBLE-applicable methods:
These methods then are overriden to INT-applicable and hybrid-applicable as follows:
- Item_sum_int overrides these methods to INT-applicable.
- Item_sum_window_with_row_count derives DOUBLE-applicable implementations from Item_sum_num.
- Item_sum_ntile derives DOUBLE-applicable implementations from Item_sum_window_with_row_count and overrides val_real() to INT-based implementation. Note, Item_sum_ntile does not override val_decimal() and val_str(), which looks wrong because they work through val_real() by default and therefore may return truncated results on a huge data sets.
- Item_sum_cume_dist derives from Item_sum_window_with_row_count.
- Item_sum_percentile_disc derives from Item_sum_cume_dist and Type_handler_hybrid_field_type and overrides value methods to hybrid-applicable, except get_date().
- Item_sum_percentile_cont derives from Item_sum_cume_dist and Type_handler_hybrid_field_type, but in fact it can olny have the DOUBLE data type.
This multiple overriding is hard to follow. Let's introduce a new abstract class Item_sum_double and change the Item_sum_num hierarchy as follows:
so that the method type_handler() and value methods like val_int(), val_real(), val_decimal(), get_date() are implemented inside the same class, without multiple nested overriding.