Bug #57564 different behaviour of str_to_date in MySQL 5.0 and 5.5
Submitted: 19 Oct 2010 11:20 Modified: 19 Oct 2010 13:59
Reporter: Anton Dischner Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.5.6rc OS:Any
Assigned to: CPU Architecture:Any
Tags: STR_TO_DATE

[19 Oct 2010 11:20] Anton Dischner
Description:

I have a MySQL 5.0.51a production database and a MySQL 5.5.6rc Test database.

The same query produces different results.

This bug may relate to bug http://bugs.mysql.com/bug.php?id=56271

How to repeat:
CREATE TABLE `ttt_bug` (
  `vondat` datetime NOT NULL,
  `standort` varchar(3) NOT NULL,
  PRIMARY KEY (`vondat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `ttt_bug` VALUES ('2002-01-15 00:00:00','GRH');

select * from ttt_bug where vondat <= str_to_date('19.11.2010 10:05:14', '%d.%m.%Y %T');

Expected result as in 5.0:
+---------------------+----------+
| vondat              | standort |
+---------------------+----------+
| 2002-01-15 00:00:00 | GRH      | 
+---------------------+----------+
1 row in set (0.00 sec)

Wrong result in 5.5.6:
select * from ttt_bug where vondat <= str_to_date('19.11.2010 10:05:14', '%d.%m.%Y %T');
Empty set (0.00 sec);

Suggested fix:
Maybe fixed as stated in Bug #56271
[19 Oct 2010 11:23] MySQL Verification Team
Thank you for the bug report. So it is duplicate of bug: http://bugs.mysql.com/bug.php?id=56271?
[19 Oct 2010 13:23] Anton Dischner
Yes. I think it is a duplicate because:

select * from ttt_bug where vondat <= '2010-11-19 10:05:14';

works correct.

See also: http://dev.mysql.com/doc/refman/5.5/en/news-5-5-7.html 

If a query specified a DATE or DATETIME value in a format different from 'YYYY-MM-DD HH:MM:SS', a greater-than-or-equal (>=) condition matched only greater-than values in an indexed TIMESTAMP column. (Bug#55779)
[19 Oct 2010 13:59] MySQL Verification Team
Thank you for the feedback.