Bug #85035 str_to_date with mismatched parameters should have failed
Submitted: 17 Feb 2017 4:12 Modified: 17 Feb 2017 10:17
Reporter: 帅 Bang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6, 5.6.35, 5.7.17 OS:Linux
Assigned to: CPU Architecture:Any

[17 Feb 2017 4:12] 帅 Bang
Description:
MySQL:
mysql>  select str_to_date("1997-10-04","%Y-%m-%D");
+--------------------------------------+
| str_to_date("1997-10-04","%Y-%m-%D") |
+--------------------------------------+
| 1997-10-04                           |
+--------------------------------------+
1 row in set (0.00 sec)

seems quite nice and considerate for users. However, it contradicts with the doc described here:

https://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_date-format

%D	Day of the month with English suffix (0th, 1st, 2nd, 3rd, …)

So, it should have failed. 

How to repeat:
select str_to_date("1997-10-04","%Y-%m-%D");

Suggested fix:
returns NULL with a warning
[17 Feb 2017 10:17] MySQL Verification Team
Hello Bang,

Thank you for the report and test case.

Thanks,
Umesh