mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-11485 Split Item_func_between::val_int() into virtual methods in Type_handler
- Removes "Item_result Item_func_opt_neg::m_compare_type" and introduces "Type_handler_hybrid_field_type Item_func_opt_neg::m_comparator" instead. - Removes Item_func_between::compare_as_dates, because the new member m_comparator now contains the precise information about the data type that is used for comparison, which is important for TIME vs DATETIME. - Adds a new method: Type_handler_hybrid_field_type::aggregate_for_comparison(const Type_handler*), as a better replacement for item_cmp_type(), which additionally can handle TIME vs DATE/DATETIME/TIMESTAMP correctly. Additionally, it correctly handles TIMESTAMP which fixes the problem reported in MDEV-11482. The old compare_as_dates/find_date_time_item() based code didn't handle comparison between TIME and TIMESTAMP correctly and erroneously used TIME comparison instead of DATETIME comparison. - Adds a new method: Type_handler_hybrid_field_type::aggregate_for_comparison(Item **, uint nitems), as a better replacement for agg_cmp_type(), which can handle TIME. - Splits Item_func_between::val_int() into pieces val_int_cmp_xxx(), one new method per XXX_RESULT. - Adds a new virtual method Type_handler::Item_func_between_val_int() whose implementations use Item_func_between::val_int_cmp_xxx(). - Makes type_handler_longlong and type_handler_newdecimal public, as they are now needed in item_cmpfunc.cc. Note: This patch does not change Item_func_in to use the new aggregation methods, so it still uses collect_cmp_type()/item_cmp_type() based aggregation. Item_func_in will be changed in a separate patch and item_cmp_type() will be removed.
This commit is contained in:
@ -29,6 +29,7 @@ class Item_cache;
|
||||
class Item_sum_hybrid;
|
||||
class Item_func_hex;
|
||||
class Item_func_hybrid_field_type;
|
||||
class Item_func_between;
|
||||
class Type_std_attributes;
|
||||
class Sort_param;
|
||||
class Arg_comparator;
|
||||
@ -314,6 +315,8 @@ public:
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const= 0;
|
||||
|
||||
virtual longlong
|
||||
Item_func_between_val_int(Item_func_between *func) const= 0;
|
||||
};
|
||||
|
||||
|
||||
@ -410,6 +413,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -457,6 +461,7 @@ public:
|
||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const;
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -489,6 +494,7 @@ public:
|
||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const;
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -521,6 +527,7 @@ public:
|
||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const;
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -551,6 +558,7 @@ public:
|
||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const;
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -585,6 +593,7 @@ public:
|
||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||
MYSQL_TIME *,
|
||||
ulonglong fuzzydate) const;
|
||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||
};
|
||||
|
||||
|
||||
@ -960,6 +969,10 @@ public:
|
||||
{
|
||||
return (m_type_handler= Type_handler::get_handler_by_result_type(type));
|
||||
}
|
||||
const Type_handler *set_handler_by_cmp_type(Item_result type)
|
||||
{
|
||||
return (m_type_handler= Type_handler::get_handler_by_cmp_type(type));
|
||||
}
|
||||
const Type_handler *set_handler_by_result_type(Item_result type,
|
||||
uint max_octet_length,
|
||||
CHARSET_INFO *cs)
|
||||
@ -977,6 +990,8 @@ public:
|
||||
{
|
||||
return (m_type_handler= Type_handler::get_handler_by_real_type(type));
|
||||
}
|
||||
void aggregate_for_comparison(const Type_handler *other);
|
||||
bool aggregate_for_comparison(Item **items, uint nitems);
|
||||
};
|
||||
|
||||
|
||||
@ -997,5 +1012,7 @@ public:
|
||||
extern Type_handler_row type_handler_row;
|
||||
extern Type_handler_null type_handler_null;
|
||||
extern Type_handler_varchar type_handler_varchar;
|
||||
extern Type_handler_longlong type_handler_longlong;
|
||||
extern Type_handler_newdecimal type_handler_newdecimal;
|
||||
|
||||
#endif /* SQL_TYPE_H_INCLUDED */
|
||||
|
Reference in New Issue
Block a user