-
unknown authored
The IN function was comparing DATE/DATETIME values either as ints or as strings. Both methods have their disadvantages and may lead to a wrong result. Now IN function checks whether all of its arguments has the STRING result types and at least one of them is a DATE/DATETIME item. If so it uses either an object of the in_datetime class or an object of the cmp_item_datetime class to perform its work. If the IN() function arguments are rows then row columns are checked whether the DATE/DATETIME comparator should be used to compare them. The in_datetime class is used to find occurence of the item to be checked in the vector of the constant DATE/DATETIME values. The cmp_item_datetime class is used to compare items one by one in the DATE/DATETIME context. Both classes obtain values from items with help of the get_datetime_value() function and cache the left item if it is a constant one. mysql-test/t/type_datetime.test: Added a test case for the bug#28133: Wrong DATE/DATETIME comparison in IN() function. mysql-test/r/type_datetime.result: Added a test case for the bug#28133: Wrong DATE/DATETIME comparison in IN() function. mysql-test/r/func_in.result: A test case result is corrected after the fix for the bug#28133. sql/item_cmpfunc.h: Bug#28133: Wrong DATE/DATETIME comparison in IN() function. Two DATE/DATETIME comparison classes are added. The in_datetime class is used to find occurence of the item to be checked in the vector of the constant DATE/DATETIME values. The cmp_item_datetime class is used to compare items one by one in the DATE/DATETIME context. Both classes obtain values from items with help of the get_datetime_value() function and cache the left item if it is a constant one. sql/item_cmpfunc.cc: Bug#28133: Wrong DATE/DATETIME comparison in IN() function. Now IN function checks whether all of its arguments has the STRING result types and at least one of them is a DATE/DATETIME item. If so it uses either an object of the in_datetime class or an object of the cmp_item_datetime class to perform its work. If the IN() function arguments are rows then row columns are checked whether the DATE/DATETIME comparator should be used to compare them.
0fd2b3dd