Bug #25311 ERROR 22007 ignores sql_mode ALLOW_INVALID_DATES
Submitted: 28 Dec 2006 14:52 Modified: 30 Mar 2007 8:56
Reporter: Gunar Werner Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S1 (Critical)
Version:5.0.27, 5.0.25 OS:Linux (Linux, all)
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: Contribution, regression

[28 Dec 2006 14:52] Gunar Werner
Description:
ERROR 22007 is raised no matter what sql_mode is selected and no matter if month and day are given correctly, if the year is given as unknown.

All date values collected pre-5.0.25 containing "0000" are converted to the zero date value upon update and are those LOST.

How to repeat:
SET SESSION sql_mode="ALLOW_INVALID_DATES";
SELECT MONTH("0000-02-21");

Suggested fix:
Make @ http://lists.mysql.com/commits/9075

@@ -85,7 +86,8 @@
         (!(flags & TIME_INVALID_DATES) &&
          ltime->month && ltime->day > days_in_month[ltime->month-1]
&&
          (ltime->month != 2 || calc_days_in_year(ltime->year) != 366 ||
-          ltime->day != 29)))
+          ltime->day != 29)) ||
+        (ltime->year == 0 && (ltime->month != 0 || ltime->day != 0)))
     {
       *was_cut= 2;
       return TRUE;

sensible to sql_mode ALLOW_INVALID_DATES (or better delete as a whole)
[29 Dec 2006 7:39] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[29 Dec 2006 14:28] Gunar Werner
The correct sql_mode that is ignored is NO_ZERO_IN_DATE, Error 22007 is raised always because of the above mentioned fix for Bug #19370. For detailed discussion see Bug #25301.
[30 Mar 2007 8:56] Ramil Kalimullin
The issue is fixed by patch for bug #25301.