Bug #28778 | Wrong results from datetime column comparing short, numeric date with BETWEEN | ||
---|---|---|---|
Submitted: | 30 May 2007 15:37 | Modified: | 15 Jun 2007 9:21 |
Reporter: | Chris Calender | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.0.42 | OS: | Any |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
Tags: | between, date, datetime, regression, wrong result |
[30 May 2007 15:37]
Chris Calender
[5 Jun 2007 20:06]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28152 ChangeSet@1.2514, 2007-06-06 00:02:16+04:00, evgen@moonbone.local +3 -0 Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. This bug is introduced by the fix for bug#16377. Before it the Item_func_between::fix_length_and_dec method converted second and third arguments to the type of the first argument is they were const and the first argument is of the DATE/DATETIME type. That approach worked well for integer constants and sometimes produced bad result for string constants. The fix for the bug#16377 wrongly removed that code at all. Due to that fact the comparison of a datetime field and an integer constant was carried out in a wrong way and sometimes with a wrong result. Now the Item_func_between::fix_length_and_dec method converts second and third arguments to the type of the first argument is they are constant, the first argument is of the DATE/DATETIME type and the DATETIME comparator isn't applicable.
[5 Jun 2007 20:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28154 ChangeSet@1.2514, 2007-06-05 23:41:06+04:00, evgen@moonbone.local +3 -0 Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. This bug is introduced by the fix for bug#16377. Before it the Item_func_between::fix_length_and_dec method converted second and third arguments to the type of the first argument is they were const and the first argument is of the DATE/DATETIME type. That approach worked well for integer constants and sometimes produced bad result for string constants. The fix for the bug#16377 wrongly removed that code at all. Due to that fact the comparison of a datetime field and an integer constant was carried out in a wrong way and sometimes with a wrong result. Now the Item_func_between::fix_length_and_dec method converts second and third arguments to the type of the first argument is they are constant, the first argument is of the DATE/DATETIME type and the DATETIME comparator isn't applicable.
[5 Jun 2007 20:28]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28156 ChangeSet@1.2514, 2007-06-06 00:25:06+04:00, evgen@moonbone.local +3 -0 Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. This bug is introduced by the fix for bug#16377. Before the fix the Item_func_between::fix_length_and_dec method converted the second and third arguments to the type of the first argument if they were constant and the first argument is of the DATE/DATETIME type. That approach worked well for integer constants and sometimes produced bad result for string constants. The fix for the bug#16377 wrongly removed that code at all and as a result of this the comparison of a DATETIME field and an integer constant was carried out in a wrong way and sometimes led to wrong result sets. Now the Item_func_between::fix_length_and_dec method converts the second and third arguments to the type of the first argument if they are constant, the first argument is of the DATE/DATETIME type and the DATETIME comparator isn't applicable.
[14 Jun 2007 19:00]
Bugs System
Pushed into 5.1.20-beta
[14 Jun 2007 19:00]
Bugs System
Pushed into 5.0.44
[15 Jun 2007 9:21]
MC Brown
A note has been added to the 5.1.20 and 5.0.44 changelogs.