Bug #21789 DATETIME with 0000-00-00 11:22:33 should be invalid, but is accepted
Submitted: 22 Aug 2006 20:19 Modified: 14 Dec 2006 5:47
Reporter: Timothy Smith
Status: Closed
Category:Server: Types Severity:S3 (Non-critical)
Version:4.1, 5.0, 5.1 OS:Any (all)
Assigned to: Ramil Kalimullin Target Version:

[22 Aug 2006 20:19] Timothy Smith
Description:
See bug #19370, which reported this bug but was closed without fixing it, since the
manual was not clear regarding this specific case.

The server currently accepts a DATETIME value like '0000-00-00 11:22:33' without any
warning or truncation.  It is an invalid value, though, and should be truncated to 0
(0000-00-00 00:00:00) with an associated warning.  In strict mode, it should produce an
error.

Documentation should also be updated to use this as an example of an invalid date. 
Currently the manual does not mention the case of a 0000-00-00 date portion, but a
non-zero time portion, as invalid.

How to repeat:
create table dtzero (dt datetime);
insert into dtzero (dt) values ('0000-00-00 11:22:33');
select * from dtzero;
[4 Oct 2006 13:01] 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/13065

ChangeSet@1.2543, 2006-10-04 16:00:44+05:00, ramil@mysql.com +2 -0
  Fix for bug #21789: DATETIME with 0000-00-00 11:22:33 should be invalid, but is
accepted 
  
  Reject '0000-00-00 01:01:01' dates.
[22 Nov 2006 15:43] Peter Gulutzan
I hope this is fixed too:

mysql> select addtime('0000-00-00 00:00:00', '00:00:00');
+--------------------------------------------+
| addtime('0000-00-00 00:00:00', '00:00:00') |
+--------------------------------------------+
| NULL                                       |
+--------------------------------------------+
1 row in set (0.00 sec)
[14 Dec 2006 5:47] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of
that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available
version, including the bug fix. More information about accessing the source trees is
available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix for 5.0.32 and 5.1.15.