Bug #19098 max(char_length) for datetime giving wrong value
Submitted: 14 Apr 2006 10:11 Modified: 19 Apr 2006 9:33
Reporter: Ritesh Nadhani Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.7 OS:Any (All)
Assigned to: CPU Architecture:Any

[14 Apr 2006 10:11] Ritesh Nadhani
Description:
Have a table with following statement:

CREATE TABLE `jobnoteslog` (                                     
               `submittime` datetime NOT NULL default '0000-00-00 00:00:00',  
               `clientname` varchar(20) NOT NULL,                             
               `jobname` varchar(40) NOT NULL default '',                     
               `notetime` datetime NOT NULL default '0000-00-00 00:00:00',    
               `username` varchar(20) NOT NULL default '',                    
               `note` varchar(200) NOT NULL default '',                       
               `modtime` datetime NOT NULL default '0000-00-00 00:00:00',     
               PRIMARY KEY  (`submittime`,`clientname`,`jobname`,`notetime`)  
             ) ENGINE=InnoDB DEFAULT CHARSET=latin1                           

When I execute the query "select submittime+0 from jobnoteslog", it returns:

       submittime+0  
---------------------
20060405162152.000000
20060409230004.000000
20060410080004.000000
20060410103013.000000
20060410142348.000000
20060410150003.000000
20060410150003.000000
20060410172941.000000
20060410172941.000000
20060410172941.000000
20060410172941.000000

Why the extra 0s? Is it normal?

How to repeat:
Create the table and insert data using:

insert into `jobnoteslog` (`submittime`,`clientname`,`jobname`,`notetime`,`username`,`note`,`modtime`) values ('2006-04-05 16:21:52','company a','job 1','2006-04-05 17:13:24','bob','note','2006-04-05 17:13:24'),('2006-04-09 23:00:04','company i','job 1','2006-04-10 17:43:06','bob','note','2006-04-10 17:43:06'),('2006-04-10 08:00:04','company n','job 1','2006-04-10 17:40:06','bob','note','2006-04-10 17:40:06'),('2006-04-10 10:30:13','company p','job 1','2006-04-10 17:41:50','bob','note','2006-04-10 17:41:50'),('2006-04-10 14:23:48','test case','job 1','2006-04-10 17:39:59','bob','note','2006-04-10 17:39:59'),('2006-04-10 15:00:03','test case','job 2','2006-04-10 17:39:05','bob','note','2006-04-10 17:39:05'),('2006-04-10 15:00:03','test cast','job 2','2006-04-10 17:39:48','bob','note','2006-04-10 17:39:48'),('2006-04-10 17:29:41','company s','job 3','2006-04-10 17:44:13','bob','note','2006-04-10 17:44:13'),('2006-04-10 17:29:41','company s','job 3','2006-04-10 17:44:18','bob','note','2006-04-10 17:44:18'),('2006-04-10 17:29:41','company s','job 3','2006-04-10 17:44:23','bob','note','2006-04-10 17:44:23'),('2006-04-10 17:29:41','company s','job 3','2006-04-10 17:50:50','bob','note','2006-04-10 17:50:50');

and execute the query.

Suggested fix:
None.
[19 Apr 2006 9:26] Valeriy Kravchuk
Looks like a duplicate of bug #16546. Please, check.
[19 Apr 2006 9:33] Ritesh Nadhani
Yup.

So which version can we expect a bug fix?

-- Ritesh
[20 Apr 2006 14:29] Valeriy Kravchuk
That bug fix is still "work in progress", so I am not sure. But fix can be included in 4.1.19 and/or 5.0.21. The bug is surely not fixed in 4.1.18 and 5.0.20, our lates versions officially released. Wait for that bug to be closed - you'll get exact versions then.