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

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.