1drop table if exists t1,t2,t3;
2set time_zone="+03:00";
3select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
4from_days(to_days("960101"))	to_days(960201)-to_days("19960101")	to_days(date_add(curdate(), interval 1 day))-to_days(curdate())	weekday("1997-11-29")
51996-01-01	31	1	5
6select period_add("9602",-12),period_diff(199505,"9404") ;
7period_add("9602",-12)	period_diff(199505,"9404")
8199502	13
9select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
10now()-now()	weekday(curdate())-weekday(now())	unix_timestamp()-unix_timestamp(now())
110	0	0
12select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
13from_unixtime(unix_timestamp("1994-03-02 10:11:12"))	from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s")	from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
141994-03-02 10:11:12	1994-03-02 10:11:12	19940302101112
15select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
16sec_to_time(time_to_sec("0:30:47")/6.21);
17sec_to_time(9001)	sec_to_time(9001)+0	time_to_sec("15:12:22")	sec_to_time(time_to_sec("0:30:47")/6.21)
1802:30:01	23001	54742	00:04:57.4235
19select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
20sec_to_time(9001.1)	time_to_sec('15:12:22.123456')	time_to_sec(15.5566778899)
2102:30:01.1	54742.123456	15.556677
22select sec_to_time(time_to_sec('-838:59:59'));
23sec_to_time(time_to_sec('-838:59:59'))
24-838:59:59
25select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
26sec_to_time('9001.1')	sec_to_time('1234567890123.123')
2702:30:01.100000	838:59:59.999999
28Warnings:
29Warning	1292	Truncated incorrect seconds value: '1234567890123.123000'
30select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1,
31sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1;
32sec_to_time(-9001.1)	sec_to_time(-9001.1) / 1	sec_to_time(-9001.1) / 1e0	sec_to_time(-9001) div 1
33-02:30:01.1	-23001.10000	-23001.1	-23001
34select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
35sec_to_time(90011e-1)	sec_to_time(1234567890123e30)
3602:30:01.100000	838:59:59.999999
37Warnings:
38Warning	1292	Truncated incorrect seconds value: '1.234567890123e42'
39select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999');
40sec_to_time(1234567890123)	sec_to_time('99999999999999999999999999999')
41838:59:59	838:59:59.999999
42Warnings:
43Warning	1292	Truncated incorrect seconds value: '1234567890123'
44Warning	1292	Truncated incorrect seconds value: '99999999999999999999999999999'
45select now()-curdate()*1000000-curtime();
46now()-curdate()*1000000-curtime()
470
48select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
49strcmp(current_timestamp(),concat(current_date()," ",current_time()))
500
51select strcmp(localtime(),concat(current_date()," ",current_time()));
52strcmp(localtime(),concat(current_date()," ",current_time()))
530
54select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
55strcmp(localtimestamp(),concat(current_date()," ",current_time()))
560
57select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
58date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")
59January Thursday 2nd 1997 97 01 02 03 04 05 4
60select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
61date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"))
62January Thursday 2nd 1997 97 01 02 12 00 00 4
63select dayofmonth("1997-01-02"),dayofmonth(19970323);
64dayofmonth("1997-01-02")	dayofmonth(19970323)
652	23
66select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
67month("1997-01-02")	year("98-02-03")	dayofyear("1997-12-31")
681	1998	365
69select month("2001-02-00"),year("2001-00-00");
70month("2001-02-00")	year("2001-00-00")
712	2001
72select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
73DAYOFYEAR("1997-03-03")	WEEK("1998-03-03")	QUARTER(980303)
7462	9	1
75select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
76HOUR("1997-03-03 23:03:22")	MINUTE("23:03:22")	SECOND(230322)
7723	3	22
78select TIME(230322), TIME(230322.33), TIME("230322.33");
79TIME(230322)	TIME(230322.33)	TIME("230322.33")
8023:03:22	23:03:22.33	23:03:22.33
81select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
82week(19980101)	week(19970101)	week(19980101,1)	week(19970101,1)
830	0	1	1
84select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
85week(19981231)	week(19971231)	week(19981231,1)	week(19971231,1)
8652	52	53	53
87select week(19950101),week(19950101,1);
88week(19950101)	week(19950101,1)
891	0
90select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
91yearweek('1981-12-31',1)	yearweek('1982-01-01',1)	yearweek('1982-12-31',1)	yearweek('1983-01-01',1)
92198153	198153	198252	198252
93select yearweek('1987-01-01',1),yearweek('1987-01-01');
94yearweek('1987-01-01',1)	yearweek('1987-01-01')
95198701	198652
96select week("2000-01-01",0) as '2000', week("2001-01-01",0) as '2001', week("2002-01-01",0) as '2002',week("2003-01-01",0) as '2003', week("2004-01-01",0) as '2004', week("2005-01-01",0) as '2005', week("2006-01-01",0) as '2006';
972000	2001	2002	2003	2004	2005	2006
980	0	0	0	0	0	1
99select week("2000-01-06",0) as '2000', week("2001-01-06",0) as '2001', week("2002-01-06",0) as '2002',week("2003-01-06",0) as '2003', week("2004-01-06",0) as '2004', week("2005-01-06",0) as '2005', week("2006-01-06",0) as '2006';
1002000	2001	2002	2003	2004	2005	2006
1011	0	1	1	1	1	1
102select week("2000-01-01",1) as '2000', week("2001-01-01",1) as '2001', week("2002-01-01",1) as '2002',week("2003-01-01",1) as '2003', week("2004-01-01",1) as '2004', week("2005-01-01",1) as '2005', week("2006-01-01",1) as '2006';
1032000	2001	2002	2003	2004	2005	2006
1040	1	1	1	1	0	0
105select week("2000-01-06",1) as '2000', week("2001-01-06",1) as '2001', week("2002-01-06",1) as '2002',week("2003-01-06",1) as '2003', week("2004-01-06",1) as '2004', week("2005-01-06",1) as '2005', week("2006-01-06",1) as '2006';
1062000	2001	2002	2003	2004	2005	2006
1071	1	1	2	2	1	1
108select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",0) as '2006';
1092000	2001	2002	2003	2004	2005	2006
110199952	200053	200152	200252	200352	200452	200601
111select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006';
1122000	2001	2002	2003	2004	2005	2006
113200001	200053	200201	200301	200401	200501	200601
114select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006';
1152000	2001	2002	2003	2004	2005	2006
116199952	200101	200201	200301	200401	200453	200552
117select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
1182000	2001	2002	2003	2004	2005	2006
119200001	200101	200201	200302	200402	200501	200601
120select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
121week(19981231,2)	week(19981231,3)	week(20000101,2)	week(20000101,3)
12252	53	52	52
123select week(20001231,2),week(20001231,3);
124week(20001231,2)	week(20001231,3)
12553	52
126select week(19981231,0) as '0', week(19981231,1) as '1', week(19981231,2) as '2', week(19981231,3) as '3', week(19981231,4) as '4', week(19981231,5) as '5', week(19981231,6) as '6', week(19981231,7) as '7';
1270	1	2	3	4	5	6	7
12852	53	52	53	52	52	52	52
129select week(20000101,0) as '0', week(20000101,1) as '1', week(20000101,2) as '2', week(20000101,3) as '3', week(20000101,4) as '4', week(20000101,5) as '5', week(20000101,6) as '6', week(20000101,7) as '7';
1300	1	2	3	4	5	6	7
1310	0	52	52	0	0	52	52
132select week(20000106,0) as '0', week(20000106,1) as '1', week(20000106,2) as '2', week(20000106,3) as '3', week(20000106,4) as '4', week(20000106,5) as '5', week(20000106,6) as '6', week(20000106,7) as '7';
1330	1	2	3	4	5	6	7
1341	1	1	1	1	1	1	1
135select week(20001231,0) as '0', week(20001231,1) as '1', week(20001231,2) as '2', week(20001231,3) as '3', week(20001231,4) as '4', week(20001231,5) as '5', week(20001231,6) as '6', week(20001231,7) as '7';
1360	1	2	3	4	5	6	7
13753	52	53	52	53	52	1	52
138select week(20010101,0) as '0', week(20010101,1) as '1', week(20010101,2) as '2', week(20010101,3) as '3', week(20010101,4) as '4', week(20010101,5) as '5', week(20010101,6) as '6', week(20010101,7) as '7';
1390	1	2	3	4	5	6	7
1400	1	53	1	1	1	1	1
141select yearweek(20001231,0), yearweek(20001231,1), yearweek(20001231,2), yearweek(20001231,3), yearweek(20001231,4), yearweek(20001231,5), yearweek(20001231,6), yearweek(20001231,7);
142yearweek(20001231,0)	yearweek(20001231,1)	yearweek(20001231,2)	yearweek(20001231,3)	yearweek(20001231,4)	yearweek(20001231,5)	yearweek(20001231,6)	yearweek(20001231,7)
143200053	200052	200053	200052	200101	200052	200101	200052
144set default_week_format = 6;
145select week(20001231), week(20001231,6);
146week(20001231)	week(20001231,6)
1471	1
148set default_week_format = 0;
149set default_week_format = 2;
150select week(20001231),week(20001231,2),week(20001231,0);
151week(20001231)	week(20001231,2)	week(20001231,0)
15253	53	53
153set default_week_format = 0;
154select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
155date_format('1998-12-31','%x-%v')	date_format('1999-01-01','%x-%v')
1561998-53	1998-53
157select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
158date_format('1999-12-31','%x-%v')	date_format('2000-01-01','%x-%v')
1591999-52	1999-52
160select dayname("1962-03-03"),dayname("1962-03-03")+0;
161dayname("1962-03-03")	dayname("1962-03-03")+0
162Saturday	0
163Warnings:
164Warning	1292	Truncated incorrect DOUBLE value: 'Saturday'
165select monthname("1972-03-04"),monthname("1972-03-04")+0;
166monthname("1972-03-04")	monthname("1972-03-04")+0
167March	0
168Warnings:
169Warning	1292	Truncated incorrect DOUBLE value: 'March'
170select time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
171time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T')	date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
17200|12|0|12|00|AM|12:00:00 AM|00|00:00:00	00|12|0|12|00|AM|12:00:00 AM|00|00:00:00
173select time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
174time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T')	date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
17501|01|1|1|02|AM|01:02:03 AM|03|01:02:03	01|01|1|1|02|AM|01:02:03 AM|03|01:02:03
176select time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
177time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T')	date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
17813|01|13|1|14|PM|01:14:15 PM|15|13:14:15	13|01|13|1|14|PM|01:14:15 PM|15|13:14:15
179select time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
180time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T')	date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
18101|01|1|1|00|AM|01:00:15 AM|15|01:00:15	01|01|1|1|00|AM|01:00:15 AM|15|01:00:15
182select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
183date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w')
18413|01|13|1|14|PM|01:14:15 PM|15|13:14:15| January|Saturday|31st|1998|98|Sat|Jan|031|01|31|01|15|6
185select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
186date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w')
187NULL
188select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
189date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)
1901998-01-01 00:00:00
191select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
192date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE)
1931998-01-01 00:00:59
194select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
195date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR)
1961998-01-01 00:59:59
197select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
198date_add("1997-12-31 23:59:59",INTERVAL 1 DAY)
1991998-01-01 23:59:59
200select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
201date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH)
2021998-01-31 23:59:59
203select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
204date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR)
2051998-12-31 23:59:59
206select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
207date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND)
2081998-01-01 00:01:00
209select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
210date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE)
2111998-01-01 01:00:59
212select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
213date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR)
2141998-01-02 00:59:59
215select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
216date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH)
2171999-01-31 23:59:59
218select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
219date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND)
2201998-01-01 01:01:00
221select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
222date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE)
2231998-01-02 01:00:59
224select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
225date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND)
2261998-01-02 01:01:00
227select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
228date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND)
2291997-12-31 23:59:59
230select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
231date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE)
2321997-12-31 23:59:00
233select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
234date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR)
2351997-12-31 23:00:00
236select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
237date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY)
2381997-12-31 00:00:00
239select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
240date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH)
2411997-12-01 00:00:00
242select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
243date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR)
2441997-01-01 00:00:00
245select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
246date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND)
2471997-12-31 23:58:59
248select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
249date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE)
2501997-12-31 22:59:00
251select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
252date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR)
2531997-12-30 23:00:00
254select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
255date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH)
2561996-12-01 00:00:00
257select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
258date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND)
2591997-12-31 22:58:59
260select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
261date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE)
2621997-12-30 22:59:00
263select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
264date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND)
2651997-12-30 22:58:59
266select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
267date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND)
2681998-01-02 03:46:39
269select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
270date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE)
2711997-10-23 13:19:59
272select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
273date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR)
2742009-05-29 15:59:59
275select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
276date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY)
2771724-03-17 23:59:59
278select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
279date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH)
280NULL
281Warnings:
282Warning	1441	Datetime function: datetime field overflow
283select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
284date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR)
285NULL
286Warnings:
287Warning	1441	Datetime function: datetime field overflow
288select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
289date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND)
2901998-01-07 22:40:00
291select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
292date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE)
2931996-11-10 07:58:59
294select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
295date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR)
2962025-05-19 00:59:59
297select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
298date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH)
2991897-11-30 23:59:59
300select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
301date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND)
3021999-02-21 17:40:38
303select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
304date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE)
3051970-08-11 19:20:59
306select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
307date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND)
3082025-05-23 04:40:38
309select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
310"1997-12-31 23:59:59" + INTERVAL 1 SECOND
3111998-01-01 00:00:00
312select INTERVAL 1 DAY + "1997-12-31";
313INTERVAL 1 DAY + "1997-12-31"
3141998-01-01
315select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
316"1998-01-01 00:00:00" - INTERVAL 1 SECOND
3171997-12-31 23:59:59
318select date_sub("1998-01-02",INTERVAL 31 DAY);
319date_sub("1998-01-02",INTERVAL 31 DAY)
3201997-12-02
321select date_add("1997-12-31",INTERVAL 1 SECOND);
322date_add("1997-12-31",INTERVAL 1 SECOND)
3231997-12-31 00:00:01
324select date_add("1997-12-31",INTERVAL 1 DAY);
325date_add("1997-12-31",INTERVAL 1 DAY)
3261998-01-01
327select date_add(NULL,INTERVAL 100000 SECOND);
328date_add(NULL,INTERVAL 100000 SECOND)
329NULL
330select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
331date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND)
332NULL
333select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
334date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND)
335NULL
336select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
337date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND)
338NULL
339Warnings:
340Warning	1441	Datetime function: datetime field overflow
341select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
342date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND)
343NULL
344Warnings:
345Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00'
346select date_add('1998-01-30',Interval 1 month);
347date_add('1998-01-30',Interval 1 month)
3481998-02-28
349select date_add('1998-01-30',Interval '2:1' year_month);
350date_add('1998-01-30',Interval '2:1' year_month)
3512000-02-29
352select date_add('1996-02-29',Interval '1' year);
353date_add('1996-02-29',Interval '1' year)
3541997-02-28
355select extract(YEAR FROM "1999-01-02 10:11:12");
356extract(YEAR FROM "1999-01-02 10:11:12")
3571999
358select extract(YEAR_MONTH FROM "1999-01-02");
359extract(YEAR_MONTH FROM "1999-01-02")
360199901
361select extract(DAY FROM "1999-01-02");
362extract(DAY FROM "1999-01-02")
3632
364select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
365extract(DAY_HOUR FROM "1999-01-02 10:11:12")
366210
367select extract(DAY_MINUTE FROM "02 10:11:12");
368extract(DAY_MINUTE FROM "02 10:11:12")
36921011
370select extract(DAY_SECOND FROM "225 10:11:12");
371extract(DAY_SECOND FROM "225 10:11:12")
372225101112
373select extract(HOUR FROM "1999-01-02 10:11:12");
374extract(HOUR FROM "1999-01-02 10:11:12")
37510
376select extract(HOUR_MINUTE FROM "10:11:12");
377extract(HOUR_MINUTE FROM "10:11:12")
3781011
379select extract(HOUR_SECOND FROM "10:11:12");
380extract(HOUR_SECOND FROM "10:11:12")
381101112
382select extract(MINUTE FROM "10:11:12");
383extract(MINUTE FROM "10:11:12")
38411
385select extract(MINUTE_SECOND FROM "10:11:12");
386extract(MINUTE_SECOND FROM "10:11:12")
3871112
388select extract(SECOND FROM "1999-01-02 10:11:12");
389extract(SECOND FROM "1999-01-02 10:11:12")
39012
391select extract(MONTH FROM "2001-02-00");
392extract(MONTH FROM "2001-02-00")
3932
394SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
395quarter
3961
397SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
398quarter
3991
400SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
401quarter
4021
403SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
404quarter
4052
406SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
407quarter
4082
409SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
410quarter
4112
412SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
413quarter
4143
415SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
416quarter
4173
418SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
419quarter
4203
421SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
422quarter
4234
424SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
425quarter
4264
427SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
428quarter
4294
430SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
431DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
4329999-12-31 00:00:00
433SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
434DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
4359999-12-31 00:00:00
436SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
437"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
4381968-01-20 03:14:08
439SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
440"1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND
4411968-01-20 03:15:07
442SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
443"1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND
4448895-03-27 22:11:40
445SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
446"1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND
4476255-04-08 15:04:32
448SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
449"1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE
4505983-01-24 02:08:00
451SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
452"1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR
4532019-08-15 16:00:00
454SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
455"1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND
456NULL
457Warnings:
458Warning	1441	Datetime function: datetime field overflow
459SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
460"1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE
461NULL
462Warnings:
463Warning	1441	Datetime function: datetime field overflow
464SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
465"1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR
466NULL
467Warnings:
468Warning	1441	Datetime function: datetime field overflow
469SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
470"1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
471NULL
472Warnings:
473Warning	1441	Datetime function: datetime field overflow
474create table t1 (ctime varchar(20));
475insert into t1 values ('2001-01-12 12:23:40');
476select ctime, hour(ctime) from t1;
477ctime	hour(ctime)
4782001-01-12 12:23:40	12
479select ctime from t1 where extract(MONTH FROM ctime) = 1 AND extract(YEAR FROM ctime) = 2001;
480ctime
4812001-01-12 12:23:40
482drop table t1;
483create table t1 (id int);
484create table t2 (id int, date date);
485insert into t1 values (1);
486insert into t2 values (1, "0000-00-00");
487insert into t1 values (2);
488insert into t2 values (2, "2000-01-01");
489select monthname(date) from t1 inner join t2 on t1.id = t2.id;
490monthname(date)
491NULL
492January
493select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
494monthname(date)
495NULL
496January
497drop table t1,t2;
498CREATE TABLE t1 (updated text) ENGINE=MyISAM;
499INSERT INTO t1 VALUES ('');
500SELECT month(updated) from t1;
501month(updated)
502NULL
503Warnings:
504Warning	1292	Incorrect datetime value: ''
505SELECT year(updated) from t1;
506year(updated)
507NULL
508Warnings:
509Warning	1292	Incorrect datetime value: ''
510drop table t1;
511create table t1 (d date, dt datetime, t timestamp, c char(10));
512insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
513select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
514dayofyear("0000-00-00")	dayofyear(d)	dayofyear(dt)	dayofyear(t)	dayofyear(c)
515NULL	NULL	NULL	NULL	NULL
516Warnings:
517Warning	1292	Incorrect datetime value: '0000-00-00'
518Warning	1292	Incorrect datetime value: '0000-00-00'
519select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
520dayofmonth("0000-00-00")	dayofmonth(d)	dayofmonth(dt)	dayofmonth(t)	dayofmonth(c)
5210	0	0	0	0
522select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
523month("0000-00-00")	month(d)	month(dt)	month(t)	month(c)
5240	0	0	0	0
525select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
526quarter("0000-00-00")	quarter(d)	quarter(dt)	quarter(t)	quarter(c)
5270	0	0	0	0
528select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1;
529week("0000-00-00")	week(d)	week(dt)	week(t)	week(c)
530NULL	NULL	NULL	NULL	NULL
531Warnings:
532Warning	1292	Incorrect datetime value: '0000-00-00'
533Warning	1292	Incorrect datetime value: '0000-00-00'
534select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
535year("0000-00-00")	year(d)	year(dt)	year(t)	year(c)
5360	0	0	0	0
537select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1;
538yearweek("0000-00-00")	yearweek(d)	yearweek(dt)	yearweek(t)	yearweek(c)
539NULL	NULL	NULL	NULL	NULL
540Warnings:
541Warning	1292	Incorrect datetime value: '0000-00-00'
542Warning	1292	Incorrect datetime value: '0000-00-00'
543select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
544to_days("0000-00-00")	to_days(d)	to_days(dt)	to_days(t)	to_days(c)
545NULL	NULL	NULL	NULL	NULL
546Warnings:
547Warning	1292	Incorrect datetime value: '0000-00-00'
548Warning	1292	Incorrect datetime value: '0000-00-00'
549select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
550extract(MONTH FROM "0000-00-00")	extract(MONTH FROM d)	extract(MONTH FROM dt)	extract(MONTH FROM t)	extract(MONTH FROM c)
5510	0	0	0	0
552drop table t1;
553CREATE TABLE t1 ( start datetime default NULL);
554INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
555CREATE TABLE t2 ( ctime1 timestamp NOT NULL, ctime2 timestamp NOT NULL);
556INSERT INTO t2 VALUES (20021029165106,20021105164731);
557CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
558INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
559select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
560start	ctime1	ctime2
5612002-11-04 00:00:00	2002-10-29 16:51:06	2002-11-05 16:47:31
562select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
563start	ctime1	ctime2
5642002-11-04 00:00:00	2002-10-29 16:51:06	2002-11-05 16:47:31
565select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
566start	ctime1	ctime2
5672002-11-04 00:00:00	2002-10-29 16:51:06	2002-11-05 16:47:31
568drop table t1,t2,t3;
569select @a:=FROM_UNIXTIME(1);
570@a:=FROM_UNIXTIME(1)
5711970-01-01 03:00:01
572select unix_timestamp(@a);
573unix_timestamp(@a)
5741
575select unix_timestamp('1969-12-01 19:00:01');
576unix_timestamp('1969-12-01 19:00:01')
577NULL
578select from_unixtime(-1);
579from_unixtime(-1)
580NULL
581select from_unixtime(2147483647);
582from_unixtime(2147483647)
5832038-01-19 06:14:07
584select from_unixtime(2147483648);
585from_unixtime(2147483648)
586NULL
587Warnings:
588Warning	1292	Truncated incorrect unixtime value: '2147483648'
589select from_unixtime(0);
590from_unixtime(0)
5911970-01-01 03:00:00
592select unix_timestamp(from_unixtime(2147483647));
593unix_timestamp(from_unixtime(2147483647))
5942147483647
595select unix_timestamp(from_unixtime(2147483648));
596unix_timestamp(from_unixtime(2147483648))
597NULL
598Warnings:
599Warning	1292	Truncated incorrect unixtime value: '2147483648'
600select unix_timestamp('2039-01-20 01:00:00');
601unix_timestamp('2039-01-20 01:00:00')
602NULL
603select unix_timestamp('1968-01-20 01:00:00');
604unix_timestamp('1968-01-20 01:00:00')
605NULL
606select unix_timestamp('2038-02-10 01:00:00');
607unix_timestamp('2038-02-10 01:00:00')
608NULL
609select unix_timestamp('1969-11-20 01:00:00');
610unix_timestamp('1969-11-20 01:00:00')
611NULL
612select unix_timestamp('2038-01-20 01:00:00');
613unix_timestamp('2038-01-20 01:00:00')
614NULL
615select unix_timestamp('1969-12-30 01:00:00');
616unix_timestamp('1969-12-30 01:00:00')
617NULL
618select unix_timestamp('2038-01-17 12:00:00');
619unix_timestamp('2038-01-17 12:00:00')
6202147331600
621select unix_timestamp('1970-01-01 03:00:01');
622unix_timestamp('1970-01-01 03:00:01')
6231
624select unix_timestamp('2038-01-19 07:14:07');
625unix_timestamp('2038-01-19 07:14:07')
626NULL
627SELECT CHARSET(DAYNAME(19700101));
628CHARSET(DAYNAME(19700101))
629latin1
630SELECT CHARSET(MONTHNAME(19700101));
631CHARSET(MONTHNAME(19700101))
632latin1
633SELECT LOWER(DAYNAME(19700101));
634LOWER(DAYNAME(19700101))
635thursday
636SELECT LOWER(MONTHNAME(19700101));
637LOWER(MONTHNAME(19700101))
638january
639SELECT COERCIBILITY(MONTHNAME('1970-01-01')),COERCIBILITY(DAYNAME('1970-01-01'));
640COERCIBILITY(MONTHNAME('1970-01-01'))	COERCIBILITY(DAYNAME('1970-01-01'))
6414	4
642CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
643INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
644SELECT * from t1;
645datetime	timestamp	date	time
6462001-01-02 03:04:05	2002-01-02 03:04:05	2003-01-02	06:07:08
647select date_add("1997-12-31",INTERVAL 1 SECOND);
648date_add("1997-12-31",INTERVAL 1 SECOND)
6491997-12-31 00:00:01
650select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
651date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH)
6521999-01-31
653select date_add(datetime, INTERVAL 1 SECOND) from t1;
654date_add(datetime, INTERVAL 1 SECOND)
6552001-01-02 03:04:06
656select date_add(datetime, INTERVAL 1 YEAR) from t1;
657date_add(datetime, INTERVAL 1 YEAR)
6582002-01-02 03:04:05
659select date_add(date,INTERVAL 1 SECOND) from t1;
660date_add(date,INTERVAL 1 SECOND)
6612003-01-02 00:00:01
662select date_add(date,INTERVAL 1 MINUTE) from t1;
663date_add(date,INTERVAL 1 MINUTE)
6642003-01-02 00:01:00
665select date_add(date,INTERVAL 1 HOUR) from t1;
666date_add(date,INTERVAL 1 HOUR)
6672003-01-02 01:00:00
668select date_add(date,INTERVAL 1 DAY) from t1;
669date_add(date,INTERVAL 1 DAY)
6702003-01-03
671select date_add(date,INTERVAL 1 MONTH) from t1;
672date_add(date,INTERVAL 1 MONTH)
6732003-02-02
674select date_add(date,INTERVAL 1 YEAR) from t1;
675date_add(date,INTERVAL 1 YEAR)
6762004-01-02
677select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
678date_add(date,INTERVAL "1:1" MINUTE_SECOND)
6792003-01-02 00:01:01
680select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
681date_add(date,INTERVAL "1:1" HOUR_MINUTE)
6822003-01-02 01:01:00
683select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
684date_add(date,INTERVAL "1:1" DAY_HOUR)
6852003-01-03 01:00:00
686select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
687date_add(date,INTERVAL "1 1" YEAR_MONTH)
6882004-02-02
689select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
690date_add(date,INTERVAL "1:1:1" HOUR_SECOND)
6912003-01-02 01:01:01
692select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
693date_add(date,INTERVAL "1 1:1" DAY_MINUTE)
6942003-01-03 01:01:00
695select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
696date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
6972003-01-03 01:01:01
698select date_add(date,INTERVAL "1" WEEK) from t1;
699date_add(date,INTERVAL "1" WEEK)
7002003-01-09
701select date_add(date,INTERVAL "1" QUARTER) from t1;
702date_add(date,INTERVAL "1" QUARTER)
7032003-04-02
704select timestampadd(MINUTE, 1, date) from t1;
705timestampadd(MINUTE, 1, date)
7062003-01-02 00:01:00
707select timestampadd(WEEK, 1, date) from t1;
708timestampadd(WEEK, 1, date)
7092003-01-09
710select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
711timestampadd(SQL_TSI_SECOND, 1, date)
7122003-01-02 00:00:01
713select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
714a
7153
716select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
717a
718-1
719select timestampdiff(QUARTER, '2002-05-01', '2001-01-01') as a;
720a
721-5
722select timestampdiff(MONTH, '2000-03-28', '2000-02-29') as a;
723a
7240
725select timestampdiff(MONTH, '1991-03-28', '2000-02-29') as a;
726a
727107
728select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a;
729a
73012
731select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
732a
7332136
734select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
735a
73689
737select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
738a
739128159
740select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
741a
7427689539
743select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
744timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
745timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
746timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
747a1	a2	a3	a4
74828	28	29	29
749SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
750TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27')
7510
752SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
753TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28')
7541
755SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
756TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29')
7571
758SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
759TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27')
7601
761SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
762TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28')
7632
764SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
765TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29')
7662
767SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
768TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27')
7690
770SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
771TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28')
7721
773SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
774TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29')
7751
776SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
777TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27')
7781
779SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
780TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28')
7812
782SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
783TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29')
7842
785SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
786TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27')
7870
788SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
789TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28')
7901
791SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
792TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29')
7931
794SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
795TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27')
7961
797SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
798TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28')
7992
800SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
801TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29')
8022
803SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
804TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27')
8050
806SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
807TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28')
8081
809SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
810TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29')
8111
812SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
813TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27')
8141
815SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
816TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28')
8172
818SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
819TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
8202
821select date_add(time,INTERVAL 1 SECOND) from t1;
822date_add(time,INTERVAL 1 SECOND)
82306:07:09
824drop table t1;
825select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
826last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
827last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
828last_day('2001-02-12');
829f1	f2	f3	f4	f5	last_day(NULL)	last_day('2001-02-12')
8302000-02-29	2002-12-31	NULL	2003-04-30	2001-01-31	NULL	2001-02-28
831Warnings:
832Warning	1292	Incorrect datetime value: '2003-03-32'
833create table t1 select last_day('2000-02-05') as a,
834from_days(to_days("960101")) as b;
835describe t1;
836Field	Type	Null	Key	Default	Extra
837a	date	YES		NULL
838b	date	YES		NULL
839select * from t1;
840a	b
8412000-02-29	1996-01-01
842drop table t1;
843select last_day('2000-02-05') as a,
844from_days(to_days("960101")) as b;
845a	b
8462000-02-29	1996-01-01
847select date_add(last_day("1997-12-1"), INTERVAL 1 DAY);
848date_add(last_day("1997-12-1"), INTERVAL 1 DAY)
8491998-01-01
850select length(last_day("1997-12-1"));
851length(last_day("1997-12-1"))
85210
853select last_day("1997-12-1")+0;
854last_day("1997-12-1")+0
85519971231
856select last_day("1997-12-1")+0.0;
857last_day("1997-12-1")+0.0
85819971231.0
859select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
860strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
8611
862select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
863strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0
8641
865select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
866strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0
8671
868select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
869strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0
8701
871select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
872strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
8731
874select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
875strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0
8761
877explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_days(to_days("960101")),dayofmonth("1997-01-02"), month("1997-01-02"), monthname("1972-03-04"),dayofyear("0000-00-00"),HOUR("1997-03-03 23:03:22"),MINUTE("23:03:22"),SECOND(230322),QUARTER(980303),WEEK("1998-03-03"),yearweek("2000-01-01",1),week(19950101,1),year("98-02-03"),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),sec_to_time(time_to_sec("0:30:47")/6.21),curtime(),utc_time(),curdate(),utc_date(),utc_timestamp(),date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w"),from_unixtime(unix_timestamp("1994-03-02 10:11:12")),"1997-12-31 23:59:59" + INTERVAL 1 SECOND,"1998-01-01 00:00:00" - INTERVAL 1 SECOND,INTERVAL 1 DAY + "1997-12-31", extract(YEAR FROM "1999-01-02 10:11:12"),date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
878id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
8791	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
880Warnings:
881Note	1003	select period_add('9602',-12) AS `period_add("9602",-12)`,period_diff(199505,'9404') AS `period_diff(199505,"9404")`,from_days(to_days('960101')) AS `from_days(to_days("960101"))`,dayofmonth('1997-01-02') AS `dayofmonth("1997-01-02")`,month('1997-01-02') AS `month("1997-01-02")`,monthname('1972-03-04') AS `monthname("1972-03-04")`,dayofyear('0000-00-00') AS `dayofyear("0000-00-00")`,hour('1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute('23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week('1998-03-03') AS `WEEK("1998-03-03")`,yearweek('2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year('98-02-03') AS `year("98-02-03")`,weekday(curdate()) - weekday(current_timestamp()) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time(time_to_sec('0:30:47') / 6.21) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format('1997-01-02 03:04:05','%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp('1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,'1997-12-31 23:59:59' + interval 1 second AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,'1998-01-01 00:00:00' - interval 1 second AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,'1997-12-31' + interval 1 day AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from '1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,'1997-12-31 23:59:59' + interval 1 second AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
882SET @TMP='2007-08-01 12:22:49';
883CREATE TABLE t1 (d DATETIME);
884INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
885INSERT INTO t1 VALUES ('2007-08-01 12:23:01');
886INSERT INTO t1 VALUES ('2007-08-01 12:23:20');
887SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1);
888count(*)
8893
890DROP TABLE t1;
891select last_day('2005-00-00');
892last_day('2005-00-00')
893NULL
894select last_day('2005-00-01');
895last_day('2005-00-01')
896NULL
897select last_day('2005-01-00');
898last_day('2005-01-00')
8992005-01-31
900select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
901monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
902monthname(str_to_date(null, '%m'))	monthname(str_to_date(null, '%m'))	monthname(str_to_date(1, '%m'))	monthname(str_to_date(0, '%m'))
903NULL	NULL	January	NULL
904set time_zone='-6:00';
905create table t1(a timestamp);
906insert into t1 values (19691231190001);
907select * from t1;
908a
9091969-12-31 19:00:01
910drop table t1;
911create table t1(f1 date, f2 time, f3 datetime);
912insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
913insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
914select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
915f1
9162006-01-01
917select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
918f1
9192006-01-01
920select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
921f1
9222006-01-01
923select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
924f2
92512:01:02
926select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
927f2
92812:01:02
929select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
930f3
9312006-01-01 12:01:01
932select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
933f3
9342006-01-01 12:01:01
935select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
936f1
9372006-01-01
938select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
939f1
9402006-01-01
941select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
942f1
943Warnings:
944Warning	1292	Truncated incorrect datetime value: 'zzz'
945select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
946f1
9472006-01-01
948select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
949f1
9502006-01-02
951drop table t1;
952create table t1 select now() - now(), curtime() - curtime(),
953sec_to_time(1) + 0, from_unixtime(1) + 0;
954show create table t1;
955Table	Create Table
956t1	CREATE TABLE `t1` (
957  `now() - now()` bigint(16) NOT NULL,
958  `curtime() - curtime()` int(9) NOT NULL,
959  `sec_to_time(1) + 0` int(9) DEFAULT NULL,
960  `from_unixtime(1) + 0` bigint(16) DEFAULT NULL
961) ENGINE=MyISAM DEFAULT CHARSET=latin1
962drop table t1;
963SELECT SEC_TO_TIME(3300000);
964SEC_TO_TIME(3300000)
965838:59:59
966Warnings:
967Warning	1292	Truncated incorrect seconds value: '3300000'
968SELECT SEC_TO_TIME(3300000)+0;
969SEC_TO_TIME(3300000)+0
9708385959
971Warnings:
972Warning	1292	Truncated incorrect seconds value: '3300000'
973SELECT SEC_TO_TIME(3600 * 4294967296);
974SEC_TO_TIME(3600 * 4294967296)
975838:59:59
976Warnings:
977Warning	1292	Truncated incorrect seconds value: '15461882265600'
978SELECT TIME_TO_SEC('916:40:00');
979TIME_TO_SEC('916:40:00')
9803020399
981Warnings:
982Warning	1292	Truncated incorrect time value: '916:40:00'
983SELECT ADDTIME('500:00:00', '416:40:00');
984ADDTIME('500:00:00', '416:40:00')
985838:59:59.999999
986Warnings:
987Warning	1292	Truncated incorrect time value: '916:40:00'
988SELECT ADDTIME('916:40:00', '416:40:00');
989ADDTIME('916:40:00', '416:40:00')
990838:59:59.999999
991Warnings:
992Warning	1292	Truncated incorrect time value: '916:40:00'
993Warning	1292	Truncated incorrect time value: '1255:39:59.999999'
994SELECT SUBTIME('916:40:00', '416:40:00');
995SUBTIME('916:40:00', '416:40:00')
996422:19:59.999999
997Warnings:
998Warning	1292	Truncated incorrect time value: '916:40:00'
999SELECT SUBTIME('-916:40:00', '416:40:00');
1000SUBTIME('-916:40:00', '416:40:00')
1001-838:59:59.999999
1002Warnings:
1003Warning	1292	Truncated incorrect time value: '-916:40:00'
1004Warning	1292	Truncated incorrect time value: '-1255:39:59.999999'
1005SELECT MAKETIME(916,0,0);
1006MAKETIME(916,0,0)
1007838:59:59
1008Warnings:
1009Warning	1292	Truncated incorrect time value: '916:00:00'
1010SELECT MAKETIME(4294967296, 0, 0);
1011MAKETIME(4294967296, 0, 0)
1012838:59:59
1013Warnings:
1014Warning	1292	Truncated incorrect time value: '4294967296:00:00'
1015SELECT MAKETIME(-4294967296, 0, 0);
1016MAKETIME(-4294967296, 0, 0)
1017-838:59:59
1018Warnings:
1019Warning	1292	Truncated incorrect time value: '-4294967296:00:00'
1020SELECT MAKETIME(0, 4294967296, 0);
1021MAKETIME(0, 4294967296, 0)
1022NULL
1023SELECT MAKETIME(0, 0, 4294967296);
1024MAKETIME(0, 0, 4294967296)
1025NULL
1026Warnings:
1027Warning	1292	Truncated incorrect seconds value: '4294967296'
1028SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
1029MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
1030838:59:59
1031Warnings:
1032Note	1105	Cast to unsigned converted negative integer to it's positive complement
1033Warning	1292	Truncated incorrect time value: '18446744073709551615:00:00'
1034SELECT EXTRACT(HOUR FROM '10000:02:03');
1035EXTRACT(HOUR FROM '10000:02:03')
103616
1037CREATE TABLE t1(f1 TIME);
1038INSERT IGNORE INTO t1 VALUES('916:00:00 a');
1039Warnings:
1040Warning	1265	Data truncated for column 'f1' at row 1
1041Warning	1264	Out of range value for column 'f1' at row 1
1042SELECT * FROM t1;
1043f1
1044838:59:59
1045DROP TABLE t1;
1046SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
1047SEC_TO_TIME(CAST(-1 AS UNSIGNED))
1048838:59:59
1049Warnings:
1050Note	1105	Cast to unsigned converted negative integer to it's positive complement
1051Warning	1292	Truncated incorrect seconds value: '18446744073709551615'
1052SET NAMES latin1;
1053SET character_set_results = NULL;
1054SHOW VARIABLES LIKE 'character_set_results';
1055Variable_name	Value
1056character_set_results
1057CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
1058INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
1059SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
1060fmtddate	field2
1061Sep-4 12:00AM	abcd
1062DROP TABLE testBug8868;
1063SET NAMES DEFAULT;
1064SET TIMESTAMP=UNIX_TIMESTAMP('2001-01-01 11:22:33');
1065CREATE TABLE t1 (
1066a TIMESTAMP
1067);
1068INSERT INTO t1 VALUES (now()), (now());
1069SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
10701
10711
10721
1073Warnings:
1074Warning	1292	Truncated incorrect seconds value: '20010101112233'
1075Warning	1292	Truncated incorrect seconds value: '20010101112233'
1076DROP TABLE t1;
1077SET TIMESTAMP=DEFAULT;
1078(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
1079union
1080(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
1081H
1082120
1083(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
1084union
1085(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
1086H
1087120
1088(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
1089union
1090(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
1091H
109205
1093(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
1094union
1095(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
1096H
10975
1098select last_day('0000-00-00');
1099last_day('0000-00-00')
1100NULL
1101select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
1102week(20061108), week(20061108.01), week(20061108085411.000002);
1103isnull(week(now() + 0))	isnull(week(now() + 0.2))	week(20061108)	week(20061108.01)	week(20061108085411.000002)
11040	0	45	45	45
1105Warnings:
1106Note	1292	Truncated incorrect date value: '20061108.01'
1107End of 4.1 tests
1108select time_format('100:00:00', '%H %k %h %I %l');
1109time_format('100:00:00', '%H %k %h %I %l')
1110100 100 04 04 4
1111SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
1112SET GLOBAL log_bin_trust_function_creators = 1;
1113create table t1 (a timestamp default '2005-05-05 01:01:01',
1114b timestamp default '2005-05-05 01:01:01');
1115drop function if exists t_slow_sysdate;
1116create function t_slow_sysdate() returns timestamp
1117begin
1118do sleep(2);
1119return sysdate();
1120end;
1121//
1122insert into t1 set a = sysdate(), b = t_slow_sysdate();//
1123create trigger t_before before insert on t1
1124for each row begin
1125set new.b = t_slow_sysdate();
1126end
1127//
1128insert into t1 set a = sysdate();
1129select a != b from t1;
1130a != b
11311
11321
1133drop trigger t_before;
1134drop function t_slow_sysdate;
1135drop table t1;
1136SET GLOBAL log_bin_trust_function_creators = 0;
1137create table t1 (a datetime, i int, b datetime);
1138insert into t1 select sysdate(), sleep(2), sysdate() from dual;
1139select a != b from t1;
1140a != b
11411
1142drop table t1;
1143create procedure t_sysdate()
1144begin
1145select sysdate() into @a;
1146do sleep(2);
1147select sysdate() into @b;
1148select @a != @b;
1149end;
1150//
1151call t_sysdate();
1152@a != @b
11531
1154drop procedure t_sysdate;
1155SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
1156select timestampdiff(month,'2004-09-11','2004-09-11');
1157timestampdiff(month,'2004-09-11','2004-09-11')
11580
1159select timestampdiff(month,'2004-09-11','2005-09-11');
1160timestampdiff(month,'2004-09-11','2005-09-11')
116112
1162select timestampdiff(month,'2004-09-11','2006-09-11');
1163timestampdiff(month,'2004-09-11','2006-09-11')
116424
1165select timestampdiff(month,'2004-09-11','2007-09-11');
1166timestampdiff(month,'2004-09-11','2007-09-11')
116736
1168select timestampdiff(month,'2005-09-11','2004-09-11');
1169timestampdiff(month,'2005-09-11','2004-09-11')
1170-12
1171select timestampdiff(month,'2005-09-11','2003-09-11');
1172timestampdiff(month,'2005-09-11','2003-09-11')
1173-24
1174select timestampdiff(month,'2004-02-28','2005-02-28');
1175timestampdiff(month,'2004-02-28','2005-02-28')
117612
1177select timestampdiff(month,'2004-02-29','2005-02-28');
1178timestampdiff(month,'2004-02-29','2005-02-28')
117911
1180select timestampdiff(month,'2004-02-28','2005-02-28');
1181timestampdiff(month,'2004-02-28','2005-02-28')
118212
1183select timestampdiff(month,'2004-03-29','2005-03-28');
1184timestampdiff(month,'2004-03-29','2005-03-28')
118511
1186select timestampdiff(month,'2003-02-28','2004-02-29');
1187timestampdiff(month,'2003-02-28','2004-02-29')
118812
1189select timestampdiff(month,'2003-02-28','2005-02-28');
1190timestampdiff(month,'2003-02-28','2005-02-28')
119124
1192select timestampdiff(month,'1999-09-11','2001-10-10');
1193timestampdiff(month,'1999-09-11','2001-10-10')
119424
1195select timestampdiff(month,'1999-09-11','2001-9-11');
1196timestampdiff(month,'1999-09-11','2001-9-11')
119724
1198select timestampdiff(year,'1999-09-11','2001-9-11');
1199timestampdiff(year,'1999-09-11','2001-9-11')
12002
1201select timestampdiff(year,'2004-02-28','2005-02-28');
1202timestampdiff(year,'2004-02-28','2005-02-28')
12031
1204select timestampdiff(year,'2004-02-29','2005-02-28');
1205timestampdiff(year,'2004-02-29','2005-02-28')
12060
1207CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, day date);
1208CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, day date);
1209INSERT INTO t1 VALUES
1210(1, '2005-06-01'), (2, '2005-02-01'), (3, '2005-07-01');
1211INSERT INTO t2 VALUES
1212(1, '2005-08-01'), (2, '2005-06-15'), (3, '2005-07-15');
1213SELECT * FROM t1, t2
1214WHERE t1.day BETWEEN
1215'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
1216id	day	id	day
12171	2005-06-01	1	2005-08-01
12183	2005-07-01	1	2005-08-01
12191	2005-06-01	2	2005-06-15
12201	2005-06-01	3	2005-07-15
12213	2005-07-01	3	2005-07-15
1222SELECT * FROM t1, t2
1223WHERE CAST(t1.day AS DATE) BETWEEN
1224'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
1225id	day	id	day
12261	2005-06-01	1	2005-08-01
12273	2005-07-01	1	2005-08-01
12281	2005-06-01	2	2005-06-15
12291	2005-06-01	3	2005-07-15
12303	2005-07-01	3	2005-07-15
1231DROP TABLE t1,t2;
1232set time_zone= @@global.time_zone;
1233select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
1234str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
123522:10:00
1236select str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute;
1237str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute
1238NULL
1239Warnings:
1240Warning	1292	Truncated incorrect date value: '1997-00-04 22:23:00'
1241Warning	1292	Incorrect datetime value: '1997-00-04 00:00:00'
1242create table t1 (field DATE);
1243insert into t1 values ('2006-11-06');
1244select * from t1 where field < '2006-11-06 04:08:36.0';
1245field
12462006-11-06
1247select * from t1 where field = '2006-11-06 04:08:36.0';
1248field
1249select * from t1 where field = '2006-11-06';
1250field
12512006-11-06
1252select * from t1 where CAST(field as DATETIME) < '2006-11-06 04:08:36.0';
1253field
12542006-11-06
1255select * from t1 where CAST(field as DATE) < '2006-11-06 04:08:36.0';
1256field
12572006-11-06
1258drop table t1;
1259CREATE TABLE t1 (a int, t1 time, t2 time, d date, PRIMARY KEY  (a));
1260INSERT INTO t1 VALUES (1, '10:00:00', NULL, NULL),
1261(2, '11:00:00', '11:15:00', '1972-02-06');
1262SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
1263FROM t1;
1264t1	t2	SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) )	QUARTER(d)
126510:00:00	NULL	NULL	NULL
126611:00:00	11:15:00	00:15:00	1
1267SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
1268FROM t1 ORDER BY a DESC;
1269t1	t2	SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) )	QUARTER(d)
127011:00:00	11:15:00	00:15:00	1
127110:00:00	NULL	NULL	NULL
1272DROP TABLE t1;
1273SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
1274TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s")
1275838:59:58
1276838:59:59
1277set names latin1;
1278create table t1 (a varchar(15) character set ascii not null);
1279insert into t1 values ('070514-000000');
1280select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1281concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull'))
1282#
1283set names swe7;
1284select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1285ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (swe7_swedish_ci,COERCIBLE) for operation 'concat'
1286set names latin1;
1287set lc_time_names=fr_FR;
1288select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1289ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'concat'
1290set lc_time_names=en_US;
1291drop table t1;
1292select DATE_ADD('20071108181000', INTERVAL 1 DAY);
1293DATE_ADD('20071108181000', INTERVAL 1 DAY)
12942007-11-09 18:10:00
1295select DATE_ADD(20071108181000,   INTERVAL 1 DAY);
1296DATE_ADD(20071108181000,   INTERVAL 1 DAY)
12972007-11-09 18:10:00
1298select DATE_ADD('20071108',       INTERVAL 1 DAY);
1299DATE_ADD('20071108',       INTERVAL 1 DAY)
13002007-11-09
1301select DATE_ADD(20071108,         INTERVAL 1 DAY);
1302DATE_ADD(20071108,         INTERVAL 1 DAY)
13032007-11-09
1304select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
1305LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND
13062007-12-30 23:59:59
1307select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
1308date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond)
13091000-01-02 03:02:01.050000
1310select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
1311date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond)
13121000-01-01 00:00:01.020000
1313#
1314# Bug #52315 part 2 : utc_date() crashes when system time > year 2037
1315#
1316SET TIMESTAMP=-147490000;
1317SELECT UTC_TIMESTAMP();
1318SET TIMESTAMP=2147483648;
1319SELECT UTC_TIMESTAMP();
1320SET TIMESTAMP=2147483646;
1321SELECT UTC_TIMESTAMP();
1322SET TIMESTAMP=2147483647;
1323SELECT UTC_TIMESTAMP();
1324SET TIMESTAMP=0;
1325SELECT UTC_TIMESTAMP();
1326SET TIMESTAMP=-1;
1327SELECT UTC_TIMESTAMP();
1328SET TIMESTAMP=1;
1329SELECT UTC_TIMESTAMP();
1330SET TIMESTAMP=0;
1331End of 5.0 tests
1332select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
1333date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
13340049-12-31 23:59:59
1335select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
1336date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND)
13370198-12-31 23:59:59
1338select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
1339date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND)
13400200-01-01 00:00:01
1341select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
1342date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
13430199-12-31 23:59:59
1344select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND);
1345date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND)
13460200-01-01 00:00:00
1347select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
1348date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
13490199-12-31 23:59:59
1350select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR);
1351date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR)
13520001-01-01 23:59:59
1353select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND);
1354date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND)
13552049-12-31 23:59:59
1356select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND);
1357date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND)
13581989-12-31 23:59:59
1359select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
1360date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
13610068-12-31 23:59:59
1362select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
1363date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
13640168-12-31 23:59:59
1365CREATE TABLE t1(a DOUBLE NOT NULL);
1366INSERT INTO t1 VALUES (0),(9.216e-096);
1367# should not crash
1368SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
13691
13701
13711
1372DROP TABLE t1;
1373#
1374# Bug #52160: crash and inconsistent results when grouping
1375#             by a function and column
1376#
1377CREATE TABLE t1(a CHAR(10) NOT NULL);
1378INSERT INTO t1 VALUES (''),('');
1379SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
1380COUNT(*)
13812
1382Warnings:
1383Warning	1292	Incorrect time value: ''
1384Warning	1292	Incorrect time value: ''
1385Warning	1292	Incorrect time value: ''
1386DROP TABLE t1;
1387#
1388# Bug#11766112  59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
1389#
1390SELECT STR_TO_DATE(SPACE(2),'1');
1391STR_TO_DATE(SPACE(2),'1')
13920000-00-00
1393#
1394# Bug#11765216  58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
1395#
1396SET GLOBAL SQL_MODE='';
1397DO  STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
1398SET GLOBAL SQL_MODE=DEFAULT;
1399#
1400# Bug#11766087  59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
1401#
1402SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
1403FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1)
1404NULL
1405#
1406# Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
1407#
1408SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
1409#
1410# Bug#11766124  59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
1411#
1412SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
1413ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR)
1414NULL
1415#
1416# Bug#11889186  60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
1417#
1418SELECT DATE_FORMAT('0000-00-11', '%W');
1419DATE_FORMAT('0000-00-11', '%W')
1420NULL
1421SELECT DATE_FORMAT('0000-00-11', '%a');
1422DATE_FORMAT('0000-00-11', '%a')
1423NULL
1424SELECT DATE_FORMAT('0000-00-11', '%w');
1425DATE_FORMAT('0000-00-11', '%w')
1426NULL
1427#
1428# Bug#12403504  AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
1429#
1430SELECT MAKEDATE(11111111,1);
1431MAKEDATE(11111111,1)
1432NULL
1433SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
1434WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1)
1435NULL
1436Warnings:
1437Warning	1292	Incorrect datetime value: '0000-00-00'
1438#
1439# Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
1440#
1441DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5);
1442Warnings:
1443Warning	1292	Incorrect datetime value: '0000-00-00'
1444#
1445# BUG#13458237 INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY
1446# SIMILAR TO '2009-10-00'
1447#
1448SELECT
1449DATE('20091000'),
1450STR_TO_DATE('200910','%Y%m'),
1451LAST_DAY('2009-10-00'),
1452LAST_DAY(DATE('2009-10-00')),
1453LAST_DAY(DATE'2009-10-00'),
1454LAST_DAY(STR_TO_DATE('200910','%Y%m')),
1455WEEK('2009-10-00'),
1456WEEK(DATE('2009-10-00')),
1457WEEK(DATE'2009-10-00'),
1458WEEK(STR_TO_DATE('200910','%Y%m')),
1459WEEKOFYEAR('2009-10-00'),
1460WEEKOFYEAR(DATE('2009-10-00')),
1461WEEKOFYEAR(DATE'2009-10-00'),
1462WEEKOFYEAR(STR_TO_DATE('200910','%Y%m')),
1463DAYOFYEAR('2009-10-00'),
1464DAYOFYEAR(DATE('2009-10-00')),
1465DAYOFYEAR(DATE'2009-10-00'),
1466DAYOFYEAR(STR_TO_DATE('200910','%Y%m')),
1467WEEKDAY('2009-10-00'),
1468WEEKDAY(DATE('2009-10-00')),
1469WEEKDAY(DATE'2009-10-00'),
1470WEEKDAY(STR_TO_DATE('200910','%Y%m')),
1471TO_DAYs('2009-10-00'),
1472TO_DAYs(DATE('2009-10-00')),
1473TO_DAYs(DATE'2009-10-00'),
1474TO_DAYs(STR_TO_DATE('200910','%Y%m'));
1475DATE('20091000')	2009-10-00
1476STR_TO_DATE('200910','%Y%m')	2009-10-00
1477LAST_DAY('2009-10-00')	2009-10-31
1478LAST_DAY(DATE('2009-10-00'))	2009-10-31
1479LAST_DAY(DATE'2009-10-00')	2009-10-31
1480LAST_DAY(STR_TO_DATE('200910','%Y%m'))	2009-10-31
1481WEEK('2009-10-00')	NULL
1482WEEK(DATE('2009-10-00'))	NULL
1483WEEK(DATE'2009-10-00')	NULL
1484WEEK(STR_TO_DATE('200910','%Y%m'))	NULL
1485WEEKOFYEAR('2009-10-00')	NULL
1486WEEKOFYEAR(DATE('2009-10-00'))	NULL
1487WEEKOFYEAR(DATE'2009-10-00')	NULL
1488WEEKOFYEAR(STR_TO_DATE('200910','%Y%m'))	NULL
1489DAYOFYEAR('2009-10-00')	NULL
1490DAYOFYEAR(DATE('2009-10-00'))	NULL
1491DAYOFYEAR(DATE'2009-10-00')	NULL
1492DAYOFYEAR(STR_TO_DATE('200910','%Y%m'))	NULL
1493WEEKDAY('2009-10-00')	NULL
1494WEEKDAY(DATE('2009-10-00'))	NULL
1495WEEKDAY(DATE'2009-10-00')	NULL
1496WEEKDAY(STR_TO_DATE('200910','%Y%m'))	NULL
1497TO_DAYs('2009-10-00')	NULL
1498TO_DAYs(DATE('2009-10-00'))	NULL
1499TO_DAYs(DATE'2009-10-00')	NULL
1500TO_DAYs(STR_TO_DATE('200910','%Y%m'))	NULL
1501Warnings:
1502Level	Warning
1503Code	1292
1504Message	Incorrect datetime value: '2009-10-00'
1505Level	Warning
1506Code	1292
1507Message	Incorrect datetime value: '2009-10-00'
1508Level	Warning
1509Code	1292
1510Message	Incorrect datetime value: '2009-10-00'
1511Level	Warning
1512Code	1411
1513Message	Incorrect datetime value: '200910' for function str_to_date
1514Level	Warning
1515Code	1292
1516Message	Incorrect datetime value: '2009-10-00'
1517Level	Warning
1518Code	1292
1519Message	Incorrect datetime value: '2009-10-00'
1520Level	Warning
1521Code	1292
1522Message	Incorrect datetime value: '2009-10-00'
1523Level	Warning
1524Code	1411
1525Message	Incorrect datetime value: '200910' for function str_to_date
1526Level	Warning
1527Code	1292
1528Message	Incorrect datetime value: '2009-10-00'
1529Level	Warning
1530Code	1292
1531Message	Incorrect datetime value: '2009-10-00'
1532Level	Warning
1533Code	1292
1534Message	Incorrect datetime value: '2009-10-00'
1535Level	Warning
1536Code	1411
1537Message	Incorrect datetime value: '200910' for function str_to_date
1538Level	Warning
1539Code	1292
1540Message	Incorrect datetime value: '2009-10-00'
1541Level	Warning
1542Code	1292
1543Message	Incorrect datetime value: '2009-10-00'
1544Level	Warning
1545Code	1292
1546Message	Incorrect datetime value: '2009-10-00'
1547Level	Warning
1548Code	1411
1549Message	Incorrect datetime value: '200910' for function str_to_date
1550Level	Warning
1551Code	1292
1552Message	Incorrect datetime value: '2009-10-00'
1553Level	Warning
1554Code	1292
1555Message	Incorrect datetime value: '2009-10-00'
1556Level	Warning
1557Code	1292
1558Message	Incorrect datetime value: '2009-10-00'
1559Level	Warning
1560Code	1411
1561Message	Incorrect datetime value: '200910' for function str_to_date
1562SELECT
1563DATE('00000100'),
1564STR_TO_DATE('000001','%Y%m'),
1565LAST_DAY('0000-01-00'),
1566LAST_DAY(DATE('0000-01-00')),
1567LAST_DAY(DATE'0000-01-00'),
1568LAST_DAY(STR_TO_DATE('000001','%Y%m')),
1569WEEK('0000-01-00'),
1570WEEK(DATE('0000-01-00')),
1571WEEK(DATE'0000-01-00'),
1572WEEK(STR_TO_DATE('000001','%Y%m')),
1573WEEKOFYEAR('0000-01-00'),
1574WEEKOFYEAR(DATE('0000-01-00')),
1575WEEKOFYEAR(DATE'0000-01-00'),
1576WEEKOFYEAR(STR_TO_DATE('000001','%Y%m')),
1577DAYOFYEAR('0000-01-00'),
1578DAYOFYEAR(DATE('0000-01-00')),
1579DAYOFYEAR(DATE'0000-01-00'),
1580DAYOFYEAR(STR_TO_DATE('000001','%Y%m')),
1581WEEKDAY('0000-01-00'),
1582WEEKDAY(DATE('0000-01-00')),
1583WEEKDAY(DATE'0000-01-00'),
1584WEEKDAY(STR_TO_DATE('000001','%Y%m')),
1585TO_DAYs('0000-01-00'),
1586TO_DAYs(DATE('0000-01-00')),
1587TO_DAYs(DATE'0000-01-00'),
1588TO_DAYs(STR_TO_DATE('000001','%Y%m'));
1589DATE('00000100')	0000-01-00
1590STR_TO_DATE('000001','%Y%m')	0000-01-00
1591LAST_DAY('0000-01-00')	0000-01-31
1592LAST_DAY(DATE('0000-01-00'))	0000-01-31
1593LAST_DAY(DATE'0000-01-00')	0000-01-31
1594LAST_DAY(STR_TO_DATE('000001','%Y%m'))	0000-01-31
1595WEEK('0000-01-00')	NULL
1596WEEK(DATE('0000-01-00'))	NULL
1597WEEK(DATE'0000-01-00')	NULL
1598WEEK(STR_TO_DATE('000001','%Y%m'))	NULL
1599WEEKOFYEAR('0000-01-00')	NULL
1600WEEKOFYEAR(DATE('0000-01-00'))	NULL
1601WEEKOFYEAR(DATE'0000-01-00')	NULL
1602WEEKOFYEAR(STR_TO_DATE('000001','%Y%m'))	NULL
1603DAYOFYEAR('0000-01-00')	NULL
1604DAYOFYEAR(DATE('0000-01-00'))	NULL
1605DAYOFYEAR(DATE'0000-01-00')	NULL
1606DAYOFYEAR(STR_TO_DATE('000001','%Y%m'))	NULL
1607WEEKDAY('0000-01-00')	NULL
1608WEEKDAY(DATE('0000-01-00'))	NULL
1609WEEKDAY(DATE'0000-01-00')	NULL
1610WEEKDAY(STR_TO_DATE('000001','%Y%m'))	NULL
1611TO_DAYs('0000-01-00')	NULL
1612TO_DAYs(DATE('0000-01-00'))	NULL
1613TO_DAYs(DATE'0000-01-00')	NULL
1614TO_DAYs(STR_TO_DATE('000001','%Y%m'))	NULL
1615Warnings:
1616Level	Warning
1617Code	1292
1618Message	Incorrect datetime value: '0000-01-00'
1619Level	Warning
1620Code	1292
1621Message	Incorrect datetime value: '0000-01-00'
1622Level	Warning
1623Code	1292
1624Message	Incorrect datetime value: '0000-01-00'
1625Level	Warning
1626Code	1411
1627Message	Incorrect datetime value: '000001' for function str_to_date
1628Level	Warning
1629Code	1292
1630Message	Incorrect datetime value: '0000-01-00'
1631Level	Warning
1632Code	1292
1633Message	Incorrect datetime value: '0000-01-00'
1634Level	Warning
1635Code	1292
1636Message	Incorrect datetime value: '0000-01-00'
1637Level	Warning
1638Code	1411
1639Message	Incorrect datetime value: '000001' for function str_to_date
1640Level	Warning
1641Code	1292
1642Message	Incorrect datetime value: '0000-01-00'
1643Level	Warning
1644Code	1292
1645Message	Incorrect datetime value: '0000-01-00'
1646Level	Warning
1647Code	1292
1648Message	Incorrect datetime value: '0000-01-00'
1649Level	Warning
1650Code	1411
1651Message	Incorrect datetime value: '000001' for function str_to_date
1652Level	Warning
1653Code	1292
1654Message	Incorrect datetime value: '0000-01-00'
1655Level	Warning
1656Code	1292
1657Message	Incorrect datetime value: '0000-01-00'
1658Level	Warning
1659Code	1292
1660Message	Incorrect datetime value: '0000-01-00'
1661Level	Warning
1662Code	1411
1663Message	Incorrect datetime value: '000001' for function str_to_date
1664Level	Warning
1665Code	1292
1666Message	Incorrect datetime value: '0000-01-00'
1667Level	Warning
1668Code	1292
1669Message	Incorrect datetime value: '0000-01-00'
1670Level	Warning
1671Code	1292
1672Message	Incorrect datetime value: '0000-01-00'
1673Level	Warning
1674Code	1411
1675Message	Incorrect datetime value: '000001' for function str_to_date
1676End of 5.1 tests
1677#
1678# Bug#57039: constant subtime expression returns incorrect result.
1679#
1680CREATE TABLE t1 (`date_date` datetime NOT NULL);
1681INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00');
1682SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00");
1683date_date
1684SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00");
1685date_date
1686DROP TABLE t1;
1687#
1688# Bug#57512 str_to_date crash...
1689#
1690SELECT WEEK(STR_TO_DATE(NULL,0));
1691WEEK(STR_TO_DATE(NULL,0))
1692NULL
1693SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR);
1694SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR)
1695NULL
1696#
1697# BUG#59895 - setting storage engine to null segfaults mysqld
1698#
1699SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1;
1700MONTHNAME(0)	MONTHNAME(0) IS NULL	MONTHNAME(0) + 1
1701NULL	1	NULL
1702SET storage_engine=NULL;
1703ERROR 42000: Variable 'storage_engine' can't be set to the value of 'NULL'
1704#
1705# BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP
1706# Part1 (5.5)
1707SET time_zone='+03:00';
1708CREATE TABLE t1 (a DATETIME NOT NULL);
1709INSERT INTO t1 VALUES ('2009-09-20 07:32:39.06');
1710INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00');
1711CREATE VIEW v1 AS SELECT * FROM t1;
1712SELECT CAST(UNIX_TIMESTAMP(a) AS DECIMAL(25,3)) AS c1 FROM v1 ORDER BY 1;
1713c1
1714NULL
17151253421159.000
1716DROP VIEW v1;
1717DROP TABLE t1;
1718SET time_zone=DEFAULT;
1719#
1720# Bug #59686 crash in String::copy() with time data type
1721#
1722SELECT min(timestampadd(month, 1>'', from_days('%Z')));
1723min(timestampadd(month, 1>'', from_days('%Z')))
1724NULL
1725Warnings:
1726Warning	1292	Truncated incorrect INTEGER value: '%Z'
1727Warning	1292	Incorrect datetime value: '0000-00-00'
1728SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00');
1729create table t1(a time);
1730insert into t1 values ('00:00:00'),('00:01:00');
1731select 1 from t1 where 1 < some (select cast(a as datetime) from t1);
17321
17331
17341
1735Warnings:
1736Warning	1292	Truncated incorrect datetime value: '1'
1737drop table t1;
1738SET timestamp=DEFAULT;
1739#
1740# Bug #21564557: INCONSISTENT OUTPUT FROM 5.5 AND 5.6
1741#                UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%M"
1742#
1743SELECT UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"));
1744UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"))
1745NULL
1746Warnings:
1747Warning	1411	Incorrect datetime value: '201506' for function str_to_date
1748SELECT UNIX_TIMESTAMP('2015-06-00');
1749UNIX_TIMESTAMP('2015-06-00')
1750NULL
1751Warnings:
1752Warning	1292	Incorrect datetime value: '2015-06-00'
1753SELECT UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'));
1754UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'))
1755NULL
1756Warnings:
1757Warning	1411	Incorrect datetime value: '0000-00-00 10:30:30' for function str_to_date
1758set sql_mode= 'TRADITIONAL';
1759SELECT @@sql_mode;
1760@@sql_mode
1761STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
1762SELECT UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"));
1763UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"))
1764NULL
1765Warnings:
1766Warning	1411	Incorrect datetime value: '201506' for function str_to_date
1767SELECT UNIX_TIMESTAMP('2015-06-00');
1768UNIX_TIMESTAMP('2015-06-00')
1769NULL
1770Warnings:
1771Warning	1292	Incorrect datetime value: '2015-06-00'
1772SELECT UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'));
1773UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'))
1774NULL
1775Warnings:
1776Warning	1411	Incorrect datetime value: '0000-00-00 10:30:30' for function str_to_date
1777set sql_mode= default;
1778select time('10:10:10') > 10;
1779time('10:10:10') > 10
17801
1781select time('10:10:10') > 1010;
1782time('10:10:10') > 1010
17831
1784select time('10:10:09') > 101010;
1785time('10:10:09') > 101010
17860
1787select time('10:10:10') > 101010;
1788time('10:10:10') > 101010
17890
1790select time('10:10:11') > 101010;
1791time('10:10:11') > 101010
17921
1793select time(' 1 02:03:04') + interval 9 microsecond;
1794time(' 1 02:03:04') + interval 9 microsecond
179526:03:04.000009
1796select time(' 1 02:03:04') - interval 9 microsecond;
1797time(' 1 02:03:04') - interval 9 microsecond
179826:03:03.999991
1799select time('-1 02:03:04') + interval 9 microsecond;
1800time('-1 02:03:04') + interval 9 microsecond
1801-26:03:03.999991
1802select time('-1 02:03:04') - interval 9 microsecond;
1803time('-1 02:03:04') - interval 9 microsecond
1804-26:03:04.000009
1805select time(' 1 02:03:04') + interval '4:4:4' hour_second;
1806time(' 1 02:03:04') + interval '4:4:4' hour_second
180730:07:08
1808select time(' 1 02:03:04') - interval '4:4:4' hour_second;
1809time(' 1 02:03:04') - interval '4:4:4' hour_second
181021:59:00
1811select time('-1 02:03:04') + interval '4:4:4' hour_second;
1812time('-1 02:03:04') + interval '4:4:4' hour_second
1813-21:59:00
1814select time('-1 02:03:04') - interval '4:4:4' hour_second;
1815time('-1 02:03:04') - interval '4:4:4' hour_second
1816-30:07:08
1817select time(' 1 02:03:04') + interval 2 day;
1818time(' 1 02:03:04') + interval 2 day
181974:03:04
1820select time(' 1 02:03:04') - interval 2 day;
1821time(' 1 02:03:04') - interval 2 day
1822-21:56:56
1823select time('-1 02:03:04') + interval 2 day;
1824time('-1 02:03:04') + interval 2 day
182521:56:56
1826select time('-1 02:03:04') - interval 2 day;
1827time('-1 02:03:04') - interval 2 day
1828-74:03:04
1829select time('10 02:03:04') + interval 30 day;
1830time('10 02:03:04') + interval 30 day
1831NULL
1832Warnings:
1833Warning	1441	Datetime function: time field overflow
1834select time('10 02:03:04') + interval 1 year;
1835time('10 02:03:04') + interval 1 year
1836NULL
1837Warnings:
1838Warning	1441	Datetime function: time field overflow
1839select cast('131415.123e0' as time);
1840cast('131415.123e0' as time)
1841NULL
1842Warnings:
1843Warning	1292	Incorrect time value: '131415.123e0'
1844select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
1845cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04'
18460
1847select least(time('1:2:3'), '01:02:04', null) div 1;
1848least(time('1:2:3'), '01:02:04', null) div 1
1849NULL
1850select truncate(least(time('1:2:3'), '01:02:04', null), 6);
1851truncate(least(time('1:2:3'), '01:02:04', null), 6)
1852NULL
1853select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
1854cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1))
1855NULL
1856select unix_timestamp(null);
1857unix_timestamp(null)
1858NULL
1859select truncate(date('2010-40-10'), 6);
1860truncate(date('2010-40-10'), 6)
1861NULL
1862Warnings:
1863Warning	1292	Incorrect datetime value: '2010-40-10'
1864select extract(month from '2010-40-50');
1865extract(month from '2010-40-50')
1866NULL
1867Warnings:
1868Warning	1292	Incorrect datetime value: '2010-40-50'
1869select subtime('0000-00-10 10:10:10', '30 10:00:00');
1870subtime('0000-00-10 10:10:10', '30 10:00:00')
1871NULL
1872select cast(str_to_date(NULL, '%H:%i:%s') as time);
1873cast(str_to_date(NULL, '%H:%i:%s') as time)
1874NULL
1875create table t1 (f1 datetime, key (f1));
1876insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
1877select * from t1 where f1 > time('-23:00:06');
1878f1
1879drop table t1;
1880select maketime(20,61,10)+0;
1881maketime(20,61,10)+0
1882NULL
1883create table t1 (f2 int not null) ;
1884insert into t1 values (0),(0);
1885select last_day(f2) from t1;
1886last_day(f2)
1887NULL
1888NULL
1889select last_day(f2) from t1 where last_day(f2) is null;
1890last_day(f2)
1891NULL
1892NULL
1893select * from t1 order by last_day (f2);
1894f2
18950
18960
1897drop table t1;
1898SET timestamp=unix_timestamp('2001-02-03 10:20:30');
1899select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow');
1900convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow')
1901NULL
1902SET timestamp=DEFAULT;
1903create table t1 (f1 integer, f2 date);
1904insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'),(6, '2011-05-06');
1905select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
1906f1	f2
19071	2011-05-05
19082	2011-05-05
19093	2011-05-05
19104	2011-05-05
19115	2011-05-05
1912drop table t1;
1913create table t1 (f1 timestamp);
1914insert into t1 values ('0000-00-00 00:00:00');
1915select least(1, f1) from t1;
1916least(1, f1)
19170000-00-00 00:00:00
1918Warnings:
1919Warning	1292	Truncated incorrect datetime value: '1'
1920drop table t1;
1921SET timestamp=UNIX_TIMESTAMP('2014-04-14 10:10:10');
1922select now() > coalesce(time('21:43:24'), date('2010-05-03'));
1923now() > coalesce(time('21:43:24'), date('2010-05-03'))
19240
1925SET timestamp=UNIX_TIMESTAMP('2014-04-14 22:22:22');
1926select now() > coalesce(time('21:43:24'), date('2010-05-03'));
1927now() > coalesce(time('21:43:24'), date('2010-05-03'))
19281
1929SET timestamp=DEFAULT;
1930create table t1 (f1 timestamp);
1931select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
1932f1
1933drop table t1;
1934create table t1 (f1 date);
1935insert into t1 values ('0000-00-00');
1936select timestampadd(week, 1, f1) from t1;
1937timestampadd(week, 1, f1)
1938NULL
1939Warnings:
1940Warning	1292	Incorrect datetime value: '0000-00-00'
1941select timestampadd(week, 1, date("0000-00-00"));
1942timestampadd(week, 1, date("0000-00-00"))
1943NULL
1944Warnings:
1945Warning	1292	Incorrect datetime value: '0000-00-00'
1946drop table t1;
1947create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
1948insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
1949select least(greatest(f3, f2, f4), f5) from t1;
1950least(greatest(f3, f2, f4), f5)
19510000-00-00 00:00:00
1952drop table t1;
1953select day(coalesce(null));
1954day(coalesce(null))
1955NULL
1956select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
1957timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'))
19582002-08-20 00:00:00
1959create table t1 (f1 datetime);
1960insert into t1 values ('0000-00-00 00:00:00');
1961select cast(f1 AS time) from t1;
1962cast(f1 AS time)
196300:00:00
1964drop table t1;
1965SET timestamp=UNIX_TIMESTAMP('2014-06-01 10:20:30');
1966select greatest(cast("0-0-0" as date), cast("10:20:05" as time));
1967greatest(cast("0-0-0" as date), cast("10:20:05" as time))
19682014-06-01 10:20:05
1969select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00';
1970greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00'
19710
1972select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01';
1973greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01'
19740
1975select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01 10:20:05';
1976greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01 10:20:05'
19771
1978select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6));
1979cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6))
19802014-06-01 10:20:05.000000
1981SET timestamp=DEFAULT;
1982select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
1983microsecond('12:00:00.123456')	microsecond('2009-12-31 23:59:59.000010')
1984123456	10
1985select now(258);
1986ERROR 42000: Too big precision 258 specified for 'current_timestamp'. Maximum is 6
1987SELECT 1 FROM DUAL WHERE YEAR(TIMEDIFF(NULL, '12:12:12'));
19881
1989SELECT 1 FROM DUAL WHERE MONTH(TIMEDIFF(NULL, '12:12:12'));
19901
1991SELECT 1 FROM DUAL WHERE DAYOFMONTH(TIMEDIFF(NULL, '12:12:12'));
19921
1993SELECT 1 FROM DUAL WHERE HOUR(TIMEDIFF(NULL, '12:12:12'));
19941
1995SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
19961
1997SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));
19981
1999#
2000# MDEV-4511 Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types
2001#
2002CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2003INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2004SELECT a FROM t1 GROUP BY TIMEDIFF('2004-06-12',a) * 1;
2005a
20062005-05-04
2007Warnings:
2008Warning	1292	Truncated incorrect time value: '2004-06-12'
2009Warning	1292	Truncated incorrect time value: '2004-06-12'
2010DROP TABLE t1;
2011CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2012INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2013SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
2014a
20152000-02-23
20162005-05-04
2017DROP TABLE t1;
2018CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2019INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2020SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
2021a
20222000-02-23
20232005-05-04
2024Warnings:
2025Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2026Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2027DROP TABLE t1;
2028CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2029INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2030SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
2031a
20322005-05-04
20332000-02-23
2034DROP TABLE t1;
2035CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2036INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2037SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
2038a
20392000-02-23
20402005-05-04
2041DROP TABLE t1;
2042CREATE TABLE t1 AS SELECT
2043STR_TO_DATE('2001-01-01', '%Y-%m-%d') AS date_only,
2044STR_TO_DATE('10:10:10', '%H:%i:%s') AS time_only,
2045STR_TO_DATE('10:10:10.123', '%H:%i:%s.%f') AS time_microsecond,
2046STR_TO_DATE('2001-01-01 10:10:10', '%Y-%m-%d %H:%i:%s') AS date_time,
2047STR_TO_DATE('2001-01-01 10:10:10.123', '%Y-%m-%d %H:%i:%s.%f') AS date_time_microsecond;
2048SHOW COLUMNS FROM t1;
2049Field	Type	Null	Key	Default	Extra
2050date_only	date	YES		NULL
2051time_only	time	YES		NULL
2052time_microsecond	time(6)	YES		NULL
2053date_time	datetime	YES		NULL
2054date_time_microsecond	datetime(6)	YES		NULL
2055DROP TABLE t1;
2056CREATE TABLE t1 AS SELECT
2057SEC_TO_TIME(1)+0.1,
2058SEC_TO_TIME(1.1)+0.1,
2059SEC_TO_TIME(1.12)+0.1,
2060SEC_TO_TIME(1.123456)+0.1,
2061SEC_TO_TIME(1.1234567)+0.1;
2062SHOW COLUMNS FROM t1;
2063Field	Type	Null	Key	Default	Extra
2064SEC_TO_TIME(1)+0.1	decimal(9,1)	YES		NULL
2065SEC_TO_TIME(1.1)+0.1	decimal(9,1)	YES		NULL
2066SEC_TO_TIME(1.12)+0.1	decimal(10,2)	YES		NULL
2067SEC_TO_TIME(1.123456)+0.1	decimal(14,6)	YES		NULL
2068SEC_TO_TIME(1.1234567)+0.1	decimal(14,6)	YES		NULL
2069DROP TABLE t1;
2070CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2071INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2072SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
2073a
20742000-02-23
20752005-05-04
2076Warnings:
2077Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2078Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2079SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
2080a
20812005-05-04
20822000-02-23
2083Warnings:
2084Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2085Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2086SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
2087a
20882005-05-04
20892000-02-23
2090Warnings:
2091Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2092Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2093SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
2094a
20952000-02-23
20962005-05-04
2097Warnings:
2098Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2099Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2100SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);
2101a
21022000-02-23
21032005-05-04
2104Warnings:
2105Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2106Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2107DROP TABLE t1;
2108SET TIME_ZONE='+02:00';
2109#
2110# MDEV-6302 Wrong result set when using GROUP BY FROM_UNIXTIME(...)+0
2111#
2112CREATE TABLE t1 (a DATE);
2113INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2114SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, FROM_UNIXTIME(CONCAT(a,'10'))+0 AS f2 FROM t1;
2115a	f1	f2
21162005-05-04	1970-01-01 02:33:25	19700101023325.000000
21172000-02-23	1970-01-01 02:33:20	19700101023320.000000
2118Warnings:
2119Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2120Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2121Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2122Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2123SELECT * FROM t1 GROUP BY FROM_UNIXTIME(CONCAT(a,'10'))+0;
2124a
21252000-02-23
21262005-05-04
2127Warnings:
2128Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2129Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2130DROP TABLE t1;
2131CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
2132INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
2133SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))/1;
2134a
21352000-02-23
21362005-05-04
2137Warnings:
2138Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2139Warning	1292	Truncated incorrect DECIMAL value: '2000-02-2310'
2140DROP TABLE t1;
2141CREATE TABLE t1 (a DATE);
2142INSERT INTO t1 VALUES ('2005-05-04');
2143SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
2144f2
21450.000000
2146Warnings:
2147Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2148Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2149SELECT CHAR_LENGTH(CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10')))) AS f2 FROM t1;
2150f2
21518
2152Warnings:
2153Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2154Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2155SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
2156CREATE TABLE t2 AS SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
2157Warnings:
2158Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2159Warning	1292	Truncated incorrect DECIMAL value: '2005-05-0410'
2160SHOW CREATE TABLE t2;
2161Table	Create Table
2162t2	CREATE TABLE `t2` (
2163  `f2` varchar(22) DEFAULT NULL
2164) ENGINE=MyISAM DEFAULT CHARSET=latin1
2165SELECT * FROM t2;
2166f2
21670.000000
2168DROP TABLE t1,t2;
2169#
2170# MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
2171#
2172SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'));
2173UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
2174NULL
2175Warnings:
2176Warning	1411	Incorrect datetime value: '2020' for function str_to_date
2177SET TIME_ZONE=DEFAULT;
2178#
2179#  MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context
2180#
2181CREATE TABLE t1 (a TIMESTAMP(3));
2182INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999');
2183SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2  FROM t1;
2184c1	c2	c2
218520010101102030	20010101102030.999	2001-01-01 10:20:31
2186DROP TABLE t1;
2187CREATE TABLE t1 (a TIME(3));
2188INSERT INTO t1 VALUES ('10:20:30.999');
2189SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2  FROM t1;
2190c1	c2	c2
2191102030	102030.999	10:20:31
2192DROP TABLE t1;
2193SELECT
2194CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
2195CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
2196COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
2197CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
2198TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
2199DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
2200TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
2201c1	c2	c3	c4	c5	c6	c7
220220010101000000	20010101000000.0000	20010101000000	2001-01-01 00:00:00	00:00:00	2001-01-01	2001-01-01 00:00:00
2203SELECT
2204CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
2205CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
2206COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
2207CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
2208TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
2209DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
2210TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
2211c1	c2	c3	c4	c5	c6	c7
221220010102102030	20010102102030.0000	20010102102030	2001-01-02 10:20:30	10:20:30	2001-01-02	2001-01-02 10:20:30
2213SELECT
2214CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
2215CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
2216IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
2217CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
2218TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
2219DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
2220TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
2221c1	c2	c3	c4	c5	c6	c7
222220010101000000	20010101000000.0000	20010101000000	2001-01-01 00:00:00	00:00:00	2001-01-01	2001-01-01 00:00:00
2223SELECT
2224CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
2225CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
2226IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
2227CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
2228TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
2229DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
2230TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
2231c1	c2	c3	c4	c5	c6	c7
223220010102102030	20010102102030.0000	20010102102030	2001-01-02 10:20:30	10:20:30	2001-01-02	2001-01-02 10:20:30
2233SELECT
2234CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
2235CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
2236IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
2237CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
2238TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
2239DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
2240TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
2241c1	c2	c3	c4	c5	c6	c7
224220010101000000	20010101000000.0000	20010101000000	2001-01-01 00:00:00	00:00:00	2001-01-01	2001-01-01 00:00:00
2243SELECT
2244CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
2245CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
2246IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
2247CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
2248TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
2249DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
2250TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
2251c1	c2	c3	c4	c5	c6	c7
225220010102102030	20010102102030.0000	20010102102030	2001-01-02 10:20:30	10:20:30	2001-01-02	2001-01-02 10:20:30
2253SELECT
2254CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
2255CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
2256CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
2257CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
2258TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
2259DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
2260TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
2261c1	c2	c3	c4	c5	c6	c7
226220010101000000	20010101000000.0000	20010101000000	2001-01-01 00:00:00	00:00:00	2001-01-01	2001-01-01 00:00:00
2263SELECT
2264CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
2265CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
2266CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
2267CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
2268TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
2269DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
2270TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
2271c1	c2	c3	c4	c5	c6	c7
227220010102102030	20010102102030.0000	20010102102030	2001-01-02 10:20:30	10:20:30	2001-01-02	2001-01-02 10:20:30
2273CREATE TABLE t1 AS SELECT
2274CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1,
2275CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2,
2276CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3,
2277CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4;
2278SHOW CREATE TABLE t1;
2279Table	Create Table
2280t1	CREATE TABLE `t1` (
2281  `c1` varchar(10) DEFAULT NULL,
2282  `c2` varchar(10) DEFAULT NULL,
2283  `c3` varchar(10) DEFAULT NULL,
2284  `c4` varchar(10) DEFAULT NULL
2285) ENGINE=MyISAM DEFAULT CHARSET=latin1
2286DROP TABLE t1;
2287#
2288# MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
2289#
2290SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
2291CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
2292INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
2293SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
2294CASE WHEN 0 THEN dt2 ELSE t3 END
22952001-01-01 00:00:00.567
2296CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
2297SELECT * FROM t2;
2298CASE WHEN 0 THEN dt2 ELSE t3 END
22992001-01-01 00:00:00.567
2300SHOW COLUMNS FROM t2;
2301Field	Type	Null	Key	Default	Extra
2302CASE WHEN 0 THEN dt2 ELSE t3 END	datetime(3)	YES		NULL
2303DROP TABLE t2;
2304SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
2305CASE WHEN 1 THEN dt2 ELSE t3 END
23062001-01-01 00:00:00.120
2307SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
2308CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END)
23092001-01-01 00:00:00.120
2310SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
2311CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END)
23122001-01-01 00:00:00.120
2313SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
2314CONCAT(CASE WHEN 1 THEN d ELSE t3 END)
23152002-01-01 00:00:00.000
2316SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
2317CASE WHEN 1 THEN t3 ELSE d END
23182001-01-01 00:00:00.567
2319SELECT COALESCE(d, t3) FROM t1;
2320COALESCE(d, t3)
23212002-01-01 00:00:00.000
2322SELECT CONCAT(COALESCE(d, t3)) FROM t1;
2323CONCAT(COALESCE(d, t3))
23242002-01-01 00:00:00.000
2325SELECT COALESCE(dt2, t3) FROM t1;
2326COALESCE(dt2, t3)
23272001-01-01 00:00:00.120
2328SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
2329CONCAT(COALESCE(dt2, t3))
23302001-01-01 00:00:00.120
2331SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
2332IFNULL(dt2, t3)	CONCAT(IFNULL(dt2, t3))
23332001-01-01 00:00:00.120	2001-01-01 00:00:00.120
2334SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
2335IFNULL(d, t3)	CONCAT(IFNULL(d, t3))
23362002-01-01 00:00:00.000	2002-01-01 00:00:00.000
2337DROP TABLE t1;
2338SET timestamp=DEFAULT;
2339#
2340# MDEV-4724 Some temporal functions do not preserve microseconds
2341#
2342SELECT MAKETIME(10,10,10.231);
2343MAKETIME(10,10,10.231)
234410:10:10.231
2345SELECT MAKETIME(0, 0, 59.9);
2346MAKETIME(0, 0, 59.9)
234700:00:59.9
2348CREATE TABLE t1 AS SELECT
2349MAKETIME(10,00,00),
2350MAKETIME(10,00,00.1),
2351MAKETIME(10,00,00.12),
2352MAKETIME(10,00,00.123),
2353MAKETIME(10,00,00.1234),
2354MAKETIME(10,00,00.12345),
2355MAKETIME(10,00,00.123456);
2356SHOW COLUMNS FROM t1;
2357Field	Type	Null	Key	Default	Extra
2358MAKETIME(10,00,00)	time	YES		NULL
2359MAKETIME(10,00,00.1)	time(1)	YES		NULL
2360MAKETIME(10,00,00.12)	time(2)	YES		NULL
2361MAKETIME(10,00,00.123)	time(3)	YES		NULL
2362MAKETIME(10,00,00.1234)	time(4)	YES		NULL
2363MAKETIME(10,00,00.12345)	time(5)	YES		NULL
2364MAKETIME(10,00,00.123456)	time(6)	YES		NULL
2365DROP TABLE t1;
2366CREATE TABLE t1 AS SELECT
2367TIME('10:00:00'),
2368TIME('10:00:00.1'),
2369TIME('10:00:00.12'),
2370TIME('10:00:00.123'),
2371TIME('10:00:00.1234'),
2372TIME('10:00:00.12345'),
2373TIME('10:00:00.12346');
2374SHOW COLUMNS FROM t1;
2375Field	Type	Null	Key	Default	Extra
2376TIME('10:00:00')	time	YES		NULL
2377TIME('10:00:00.1')	time(1)	YES		NULL
2378TIME('10:00:00.12')	time(2)	YES		NULL
2379TIME('10:00:00.123')	time(3)	YES		NULL
2380TIME('10:00:00.1234')	time(4)	YES		NULL
2381TIME('10:00:00.12345')	time(5)	YES		NULL
2382TIME('10:00:00.12346')	time(5)	YES		NULL
2383DROP TABLE t1;
2384SET TIME_ZONE='+00:00';
2385SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17');
2386SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17');
2387NOW()	UNIX_TIMESTAMP()	UNIX_TIMESTAMP(NOW())	UNIX_TIMESTAMP('2012-10-16 22:46:17')
23882012-10-16 22:46:17	1350427577	1350427577	1350427577
2389SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456');
2390SELECT @@timestamp, FROM_UNIXTIME(@@timestamp);
2391@@timestamp	FROM_UNIXTIME(@@timestamp)
239297445.123456	1970-01-02 03:04:05.123456
2393SET TIME_ZONE=DEFAULT;
2394SET TIMESTAMP=DEFAULT;
2395SELECT TIME('2012-10-16 15:54:16.12');
2396TIME('2012-10-16 15:54:16.12')
239715:54:16.12
2398SELECT TIMESTAMP('2012-10-16 15:54:16.12');
2399TIMESTAMP('2012-10-16 15:54:16.12')
24002012-10-16 15:54:16.12
2401SELECT TIMEDIFF('10:10:10.1','00:00:00');
2402TIMEDIFF('10:10:10.1','00:00:00')
240310:10:10.1
2404SELECT TIME_TO_SEC('10:10:10');
2405TIME_TO_SEC('10:10:10')
240636610
2407SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12');
2408ADDTIME(TIME('10:10:10.1'),'10:10:10.12')
240920:20:20.22
2410SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12');
2411ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12')
24122001-01-01 20:20:20.22
2413SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
2414DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND)
24152001-01-01 00:00:01
2416SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND);
2417DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND)
24182001-01-01 00:00:01.1
2419SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND);
2420DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND)
24212001-01-01 00:00:01.12
2422SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND);
2423DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND)
24242001-01-01 00:00:01.123
2425SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND);
2426DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND)
24272001-01-01 00:00:01.1234
2428SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND);
2429DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND)
24302001-01-01 00:00:01.12345
2431SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND);
2432DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND)
24332001-01-01 00:00:01.123456
2434SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
2435DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND)
24362001-01-01 00:00:01
2437SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND);
2438DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND)
24392001-01-01 00:00:01.1
2440SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND);
2441DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND)
24422001-01-01 00:00:01.12
2443SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND);
2444DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND)
24452001-01-01 00:00:01.123
2446SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND);
2447DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND)
24482001-01-01 00:00:01.1234
2449SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND);
2450DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND)
24512001-01-01 00:00:01.12345
2452SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND);
2453DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND)
24542001-01-01 00:00:01.123456
2455SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND);
2456DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND)
24572000-12-31 23:59:59
2458SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND);
2459DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND)
24602000-12-31 23:59:58.9
2461SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND);
2462DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND)
24632000-12-31 23:59:58.88
2464SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND);
2465DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND)
24662000-12-31 23:59:58.877
2467SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND);
2468DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND)
24692000-12-31 23:59:58.8766
2470SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND);
2471DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND)
24722000-12-31 23:59:58.87655
2473SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND);
2474DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND)
24752000-12-31 23:59:58.876544
2476SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND);
2477DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND)
24782001-01-01 00:00:00.000000
2479Warnings:
2480Warning	1292	Truncated incorrect DECIMAL value: 'xxx'
2481SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00');
2482CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00')
24832001-01-01 11:20:30.12
2484#
2485# MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision
2486#
2487CREATE TABLE t1 (t0 TIME);
2488INSERT INTO t1 VALUES ('00:00:00');
2489SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
2490t0 + INTERVAL 1.1 SECOND
249100:00:01.1
2492CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
2493SHOW COLUMNS FROM t2;
2494Field	Type	Null	Key	Default	Extra
2495t0 + INTERVAL 1.1 SECOND	time(1)	YES		NULL
2496DROP TABLE t1,t2;
2497CREATE TABLE t1 (t0 DATETIME);
2498INSERT INTO t1 VALUES ('2001-01-01 00:00:00');
2499SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
2500t0 + INTERVAL 1.1 SECOND
25012001-01-01 00:00:01.1
2502CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
2503SHOW COLUMNS FROM t2;
2504Field	Type	Null	Key	Default	Extra
2505t0 + INTERVAL 1.1 SECOND	datetime(1)	YES		NULL
2506DROP TABLE t1, t2;
2507#
2508# MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10')
2509#
2510CREATE TABLE t1 AS SELECT
2511TIMESTAMP('2001-01-01','10:10:10'),
2512TIMESTAMP('2001-01-01','10:10:10.1'),
2513TIMESTAMP('2001-01-01','10:10:10.12'),
2514TIMESTAMP('2001-01-01','10:10:10.123'),
2515TIMESTAMP('2001-01-01','10:10:10.1234'),
2516TIMESTAMP('2001-01-01','10:10:10.12345'),
2517TIMESTAMP('2001-01-01','10:10:10.123456'),
2518TIMESTAMP('2001-01-01','10:10:10.1234567');
2519Warnings:
2520Note	1292	Truncated incorrect INTERVAL DAY TO SECOND value: '10:10:10.1234567'
2521SHOW COLUMNS FROM t1;
2522Field	Type	Null	Key	Default	Extra
2523TIMESTAMP('2001-01-01','10:10:10')	datetime	YES		NULL
2524TIMESTAMP('2001-01-01','10:10:10.1')	datetime(1)	YES		NULL
2525TIMESTAMP('2001-01-01','10:10:10.12')	datetime(2)	YES		NULL
2526TIMESTAMP('2001-01-01','10:10:10.123')	datetime(3)	YES		NULL
2527TIMESTAMP('2001-01-01','10:10:10.1234')	datetime(4)	YES		NULL
2528TIMESTAMP('2001-01-01','10:10:10.12345')	datetime(5)	YES		NULL
2529TIMESTAMP('2001-01-01','10:10:10.123456')	datetime(6)	YES		NULL
2530TIMESTAMP('2001-01-01','10:10:10.1234567')	datetime(6)	YES		NULL
2531SELECT * FROM t1;
2532TIMESTAMP('2001-01-01','10:10:10')	TIMESTAMP('2001-01-01','10:10:10.1')	TIMESTAMP('2001-01-01','10:10:10.12')	TIMESTAMP('2001-01-01','10:10:10.123')	TIMESTAMP('2001-01-01','10:10:10.1234')	TIMESTAMP('2001-01-01','10:10:10.12345')	TIMESTAMP('2001-01-01','10:10:10.123456')	TIMESTAMP('2001-01-01','10:10:10.1234567')
25332001-01-01 10:10:10	2001-01-01 10:10:10.1	2001-01-01 10:10:10.12	2001-01-01 10:10:10.123	2001-01-01 10:10:10.1234	2001-01-01 10:10:10.12345	2001-01-01 10:10:10.123456	2001-01-01 10:10:10.123456
2534DROP TABLE t1;
2535CREATE TABLE t1 AS SELECT
2536TIMESTAMP('2001-01-01 00:00:00','10:10:10'),
2537TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'),
2538TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'),
2539TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'),
2540TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'),
2541TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'),
2542TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'),
2543TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10');
2544Warnings:
2545Note	1292	Truncated incorrect datetime value: '2001-01-01 00:00:00.1234567'
2546SHOW COLUMNS FROM t1;
2547Field	Type	Null	Key	Default	Extra
2548TIMESTAMP('2001-01-01 00:00:00','10:10:10')	datetime	YES		NULL
2549TIMESTAMP('2001-01-01 00:00:00.1','10:10:10')	datetime(1)	YES		NULL
2550TIMESTAMP('2001-01-01 00:00:00.12','10:10:10')	datetime(2)	YES		NULL
2551TIMESTAMP('2001-01-01 00:00:00.123','10:10:10')	datetime(3)	YES		NULL
2552TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10')	datetime(4)	YES		NULL
2553TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10')	datetime(5)	YES		NULL
2554TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10')	datetime(6)	YES		NULL
2555TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10')	datetime(6)	YES		NULL
2556SELECT * FROM t1;
2557TIMESTAMP('2001-01-01 00:00:00','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.1','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.12','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.123','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10')	TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10')
25582001-01-01 10:10:10	2001-01-01 10:10:10.1	2001-01-01 10:10:10.12	2001-01-01 10:10:10.123	2001-01-01 10:10:10.1234	2001-01-01 10:10:10.12345	2001-01-01 10:10:10.123456	2001-01-01 10:10:10.123456
2559DROP TABLE t1;
2560SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2561CREATE TABLE t1 AS SELECT
2562TIMESTAMP('00:00:00','10:10:10'),
2563TIMESTAMP(TIME('00:00:00'),'10:10:10');
2564SHOW COLUMNS FROM t1;
2565Field	Type	Null	Key	Default	Extra
2566TIMESTAMP('00:00:00','10:10:10')	datetime	YES		NULL
2567TIMESTAMP(TIME('00:00:00'),'10:10:10')	datetime	YES		NULL
2568SELECT * FROM t1;
2569TIMESTAMP('00:00:00','10:10:10')	TIMESTAMP(TIME('00:00:00'),'10:10:10')
2570NULL	2001-02-03 10:10:10
2571DROP TABLE t1;
2572SET timestamp=DEFAULT;
2573#
2574# MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1)
2575#
2576SELECT MAKETIME(0, 0, -0.1);
2577MAKETIME(0, 0, -0.1)
2578NULL
2579#
2580# MDEV-4857 Wrong result of HOUR('1 00:00:00')
2581#
2582SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2583SELECT HOUR('1 02:00:00'), HOUR('26:00:00');
2584HOUR('1 02:00:00')	HOUR('26:00:00')
258526	26
2586SELECT HOUR(TIME'1 02:00:00'), HOUR(TIME'26:00:00');
2587HOUR(TIME'1 02:00:00')	HOUR(TIME'26:00:00')
258826	26
2589SELECT HOUR(TIME('1 02:00:00')), HOUR(TIME('26:00:00'));
2590HOUR(TIME('1 02:00:00'))	HOUR(TIME('26:00:00'))
259126	26
2592SELECT DAY(TIME('1 02:00:00')), DAY(TIME('26:00:00'));
2593DAY(TIME('1 02:00:00'))	DAY(TIME('26:00:00'))
25944	4
2595SELECT EXTRACT(HOUR FROM '1 02:00:00'), EXTRACT(HOUR FROM '26:00:00');
2596EXTRACT(HOUR FROM '1 02:00:00')	EXTRACT(HOUR FROM '26:00:00')
25972	2
2598SELECT EXTRACT(HOUR FROM TIME'1 02:00:00'), EXTRACT(HOUR FROM TIME'26:00:00');
2599EXTRACT(HOUR FROM TIME'1 02:00:00')	EXTRACT(HOUR FROM TIME'26:00:00')
26002	2
2601SELECT EXTRACT(HOUR FROM TIME('1 02:00:00')), EXTRACT(HOUR FROM TIME('26:00:00'));
2602EXTRACT(HOUR FROM TIME('1 02:00:00'))	EXTRACT(HOUR FROM TIME('26:00:00'))
26032	2
2604SELECT EXTRACT(DAY FROM TIME('1 02:00:00')), EXTRACT(DAY FROM TIME('26:00:00'));
2605EXTRACT(DAY FROM TIME('1 02:00:00'))	EXTRACT(DAY FROM TIME('26:00:00'))
26061	1
2607SET timestamp=DEFAULT;
2608#
2609# MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.'
2610#
2611SET TIMESTAMP=UNIX_TIMESTAMP('2014-01-22 18:19:20');
2612CREATE TABLE t1 (t TIME);
2613INSERT INTO t1 VALUES ('03:22:30'),('18:30:05');
2614SELECT CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00') FROM t1;
2615CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00')
26162014-01-22 11:22:30
26172014-01-23 02:30:05
2618SELECT GREATEST(t, CURRENT_DATE()) FROM t1;
2619GREATEST(t, CURRENT_DATE())
26202014-01-22 03:22:30
26212014-01-22 18:30:05
2622DROP TABLE t1;
2623SET TIMESTAMP=DEFAULT;
2624#
2625# MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
2626#
2627CREATE TABLE t1 (i INT);
2628INSERT INTO t1 VALUES (1),(2);
2629SELECT 1 FROM t1 GROUP BY MONTHNAME(0) WITH ROLLUP;
26301
26311
26321
2633DROP TABLE t1;
2634#
2635# MDEV-6099 Bad results for DATE_ADD(.., INTERVAL 2000000000000000000.0 SECOND)
2636#
2637SELECT DATE_ADD('2001-01-01 10:20:30',INTERVAL 250000000000.0 SECOND) AS c1, DATE_ADD('2001-01-01 10:20:30',INTERVAL 2000000000000000000.0 SECOND) AS c2;
2638c1	c2
26399923-03-10 22:47:10.0	NULL
2640Warnings:
2641Warning	1292	Truncated incorrect seconds value: '2000000000000000000.0'
2642#
2643# MDEV-4838 Wrong metadata for DATE_ADD('string', INVERVAL)
2644#
2645SELECT DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE);
2646Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
2647def					DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE)	254	19	19	Y	0	0	8
2648DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE)
26492011-01-02 12:14:14
2650#
2651# MDEV-5450 Assertion `cached_field_ type == MYSQL_TYPE_STRING || ltime.time_type == MYSQL_TIMESTAMP_NONE || mysql_type_to_time_type(cached_field_type) == ltime.time_type' fails with IF, ISNULL, ADDDATE
2652#
2653CREATE TABLE t1 (a DATETIME, b DATE);
2654INSERT INTO t1 VALUES (NULL, '2012-12-21');
2655SELECT IF(1,ADDDATE(IFNULL(a,b),0),1) FROM t1;
2656IF(1,ADDDATE(IFNULL(a,b),0),1)
26572012-12-21 00:00:00
2658SELECT CAST(ADDDATE(IFNULL(a,b),0) AS CHAR) FROM t1;
2659CAST(ADDDATE(IFNULL(a,b),0) AS CHAR)
26602012-12-21 00:00:00
2661SELECT CAST(ADDDATE(COALESCE(a,b),0) AS CHAR) FROM t1;
2662CAST(ADDDATE(COALESCE(a,b),0) AS CHAR)
26632012-12-21 00:00:00
2664SELECT CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
2665CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR)
26662012-12-21 00:00:00
2667SELECT IF(1,ADDTIME(IFNULL(a,b),0),1) FROM t1;
2668IF(1,ADDTIME(IFNULL(a,b),0),1)
26692012-12-21 00:00:00
2670SELECT CAST(ADDTIME(IFNULL(a,b),0) AS CHAR) FROM t1;
2671CAST(ADDTIME(IFNULL(a,b),0) AS CHAR)
26722012-12-21 00:00:00
2673SELECT CAST(ADDTIME(COALESCE(a,b),0) AS CHAR) FROM t1;
2674CAST(ADDTIME(COALESCE(a,b),0) AS CHAR)
26752012-12-21 00:00:00
2676SELECT CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
2677CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR)
26782012-12-21 00:00:00
2679DROP TABLE t1;
2680SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2681CREATE TABLE t1 (a DATETIME, b TIME);
2682INSERT INTO t1 VALUES (NULL, '00:20:12');
2683SELECT IF(1,ADDDATE(IFNULL(a,b),0),1) FROM t1;
2684IF(1,ADDDATE(IFNULL(a,b),0),1)
26852001-02-03 00:20:12
2686SELECT CAST(ADDDATE(IFNULL(a,b),0) AS CHAR) FROM t1;
2687CAST(ADDDATE(IFNULL(a,b),0) AS CHAR)
26882001-02-03 00:20:12
2689SELECT CAST(ADDDATE(COALESCE(a,b),0) AS CHAR) FROM t1;
2690CAST(ADDDATE(COALESCE(a,b),0) AS CHAR)
26912001-02-03 00:20:12
2692SELECT CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
2693CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR)
26942001-02-03 00:20:12
2695SELECT IF(1,ADDTIME(IFNULL(a,b),0),1) FROM t1;
2696IF(1,ADDTIME(IFNULL(a,b),0),1)
26972001-02-03 00:20:12
2698SELECT CAST(ADDTIME(IFNULL(a,b),0) AS CHAR) FROM t1;
2699CAST(ADDTIME(IFNULL(a,b),0) AS CHAR)
27002001-02-03 00:20:12
2701SELECT CAST(ADDTIME(COALESCE(a,b),0) AS CHAR) FROM t1;
2702CAST(ADDTIME(COALESCE(a,b),0) AS CHAR)
27032001-02-03 00:20:12
2704SELECT CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
2705CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR)
27062001-02-03 00:20:12
2707DROP TABLE t1;
2708SET timestamp=DEFAULT;
2709#
2710# MDEV-5870 Assertion `ltime->neg == 0' fails with COALESCE, ADDDATE, MAKEDATE
2711#
2712CREATE TABLE t1 (dt DATETIME);
2713INSERT INTO t1 VALUES ('2003-05-13 19:36:05'), ('2012-12-12 09:20:06');
2714SELECT COALESCE(ADDDATE(MAKEDATE(2011,121), dt), '2006-09-12' ) FROM t1;
2715COALESCE(ADDDATE(MAKEDATE(2011,121), dt), '2006-09-12' )
27162006-09-12
27172006-09-12
2718Warnings:
2719Warning	1441	Datetime function: datetime field overflow
2720Warning	1441	Datetime function: datetime field overflow
2721DROP TABLE t1;
2722#
2723# MDEV-6101 Hybrid functions do not add CURRENT_DATE when converting TIME to DATETIME
2724#
2725SET timestamp=UNIX_TIMESTAMP('2014-04-15 01:02:03');
2726SELECT IF(1,TIME'10:20:30',DATE'2001-01-01');
2727IF(1,TIME'10:20:30',DATE'2001-01-01')
27282014-04-15 10:20:30
2729SELECT IFNULL(TIME'10:20:30',DATE'2001-01-01');
2730IFNULL(TIME'10:20:30',DATE'2001-01-01')
27312014-04-15 10:20:30
2732SELECT CASE WHEN 1 THEN TIME'10:20:30' ELSE DATE'2001-01-01' END;
2733CASE WHEN 1 THEN TIME'10:20:30' ELSE DATE'2001-01-01' END
27342014-04-15 10:20:30
2735SELECT COALESCE(TIME'10:20:30',DATE'2001-01-01');
2736COALESCE(TIME'10:20:30',DATE'2001-01-01')
27372014-04-15 10:20:30
2738SET timestamp=DEFAULT;
2739#
2740# MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column
2741#
2742SET timestamp=UNIX_TIMESTAMP('2010-01-01 00:00:00');
2743CREATE TABLE t1 ( d DATE, t TIME );
2744INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02');
2745SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1;
2746EXTRACT(DAY_MINUTE FROM GREATEST(t,d))	GREATEST(t,d)
274712234	2010-01-01 22:34:09
274811426	2010-01-01 14:26:02
2749DROP TABLE t1;
2750SET timestamp=DEFAULT;
2751#
2752# MDEV-7221 from_days fails after null value
2753#
2754CREATE TABLE t1 (
2755id INT(11) NOT NULL PRIMARY KEY,
2756date1 DATE NULL DEFAULT NULL
2757);
2758INSERT INTO t1 VALUES (12, '2011-05-12');
2759INSERT INTO t1 VALUES (13, NULL);
2760INSERT INTO t1 VALUES (14, '2009-10-23');
2761INSERT INTO t1 VALUES (15, '2014-10-30');
2762INSERT INTO t1 VALUES (16, NULL);
2763INSERT INTO t1 VALUES (17, NULL);
2764INSERT INTO t1 VALUES (18, '2010-10-13');
2765SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id;
2766id	date1	date2	DATE_ADD(a.date1,INTERVAL -10 DAY)	TO_DAYS(a.date1)-10
276712	2011-05-12	2011-05-02	2011-05-02	734624
276813	NULL	NULL	NULL	NULL
276914	2009-10-23	2009-10-13	2009-10-13	734058
277015	2014-10-30	2014-10-20	2014-10-20	735891
277116	NULL	NULL	NULL	NULL
277217	NULL	NULL	NULL	NULL
277318	2010-10-13	2010-10-03	2010-10-03	734413
2774DROP TABLE t1;
2775#
2776# MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
2777#
2778SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;
27791 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2
27803
2781#
2782# MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
2783#
2784SET sql_mode='NO_ZERO_IN_DATE';
2785CREATE TABLE t1 (a TIME(6));
2786INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
2787SELECT * FROM t1;
2788a
278946:58:57.999999
2790DROP TABLE t1;
2791SET sql_mode=DEFAULT;
2792#
2793# MDEV-13972 crash in Item_func_sec_to_time::get_date
2794#
2795DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
2796DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
2797Warnings:
2798Warning	1292	Truncated incorrect INTEGER value: ''
2799Warning	1292	Truncated incorrect INTEGER value: ''
2800Warning	1292	Truncated incorrect seconds value: '20000101'
2801SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
2802SEC_TO_TIME(MAKEDATE(0,RAND(~0)))
2803838:59:59
2804Warnings:
2805Warning	1292	Truncated incorrect seconds value: '20000101'
2806SELECT PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'));
2807PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'))
280824257
2809Warnings:
2810Warning	1292	Truncated incorrect INTEGER value: '-3S\xFA\xDE?\x00\x00\xCA\xB3\xEEE\xA4\xD1\xC1\xA8'
2811#
2812# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
2813#
2814SELECT
2815MAKETIME(1e10,0,0),
2816MAKETIME(-1e10,0,0),
2817MAKETIME(1e50,0,0),
2818MAKETIME(-1e50,0,0),
2819MAKETIME(COALESCE(1e50),0,0),
2820MAKETIME(COALESCE(-1e50),0,0);
2821MAKETIME(1e10,0,0)	838:59:59
2822MAKETIME(-1e10,0,0)	-838:59:59
2823MAKETIME(1e50,0,0)	838:59:59
2824MAKETIME(-1e50,0,0)	-838:59:59
2825MAKETIME(COALESCE(1e50),0,0)	838:59:59
2826MAKETIME(COALESCE(-1e50),0,0)	-838:59:59
2827Warnings:
2828Level	Warning
2829Code	1292
2830Message	Truncated incorrect time value: '10000000000:00:00'
2831Level	Warning
2832Code	1292
2833Message	Truncated incorrect time value: '-10000000000:00:00'
2834Level	Warning
2835Code	1292
2836Message	Truncated incorrect time value: '9223372036854775807:00:00'
2837Level	Warning
2838Code	1292
2839Message	Truncated incorrect time value: '-9223372036854775808:00:00'
2840Level	Warning
2841Code	1292
2842Message	Truncated incorrect time value: '9223372036854775807:00:00'
2843Level	Warning
2844Code	1292
2845Message	Truncated incorrect time value: '-9223372036854775808:00:00'
2846CREATE TABLE t1 (a FLOAT);
2847INSERT INTO t1 VALUES (1e30),(-1e30);
2848SELECT MAKETIME(a,0,0) FROM t1;
2849MAKETIME(a,0,0)
2850838:59:59
2851-838:59:59
2852Warnings:
2853Warning	1292	Truncated incorrect time value: '9223372036854775807:00:00'
2854Warning	1292	Truncated incorrect time value: '-9223372036854775808:00:00'
2855DROP TABLE t1;
2856#
2857# MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
2858#
2859SELECT MAKETIME(900,0,0);
2860MAKETIME(900,0,0)
2861838:59:59
2862Warnings:
2863Warning	1292	Truncated incorrect time value: '900:00:00'
2864SELECT MAKETIME(900,0,0.1);
2865MAKETIME(900,0,0.1)
2866838:59:59.9
2867Warnings:
2868Warning	1292	Truncated incorrect time value: '900:00:00'
2869SELECT MAKETIME(900,0,0.11);
2870MAKETIME(900,0,0.11)
2871838:59:59.99
2872Warnings:
2873Warning	1292	Truncated incorrect time value: '900:00:00'
2874SELECT MAKETIME(900,0,0.111);
2875MAKETIME(900,0,0.111)
2876838:59:59.999
2877Warnings:
2878Warning	1292	Truncated incorrect time value: '900:00:00'
2879SELECT MAKETIME(900,0,0.1111);
2880MAKETIME(900,0,0.1111)
2881838:59:59.9999
2882Warnings:
2883Warning	1292	Truncated incorrect time value: '900:00:00'
2884SELECT MAKETIME(900,0,0.11111);
2885MAKETIME(900,0,0.11111)
2886838:59:59.99999
2887Warnings:
2888Warning	1292	Truncated incorrect time value: '900:00:00'
2889SELECT MAKETIME(900,0,0.111111);
2890MAKETIME(900,0,0.111111)
2891838:59:59.999999
2892Warnings:
2893Warning	1292	Truncated incorrect time value: '900:00:00'
2894SELECT MAKETIME(900,0,0.1111111);
2895MAKETIME(900,0,0.1111111)
2896838:59:59.999999
2897Warnings:
2898Warning	1292	Truncated incorrect time value: '900:00:00'
2899SELECT MAKETIME(900,0,0.11111111);
2900MAKETIME(900,0,0.11111111)
2901838:59:59.999999
2902Warnings:
2903Warning	1292	Truncated incorrect time value: '900:00:00'
2904SELECT MAKETIME(900,0,0.111111111);
2905MAKETIME(900,0,0.111111111)
2906838:59:59.999999
2907Warnings:
2908Warning	1292	Truncated incorrect time value: '900:00:00'
2909SELECT MAKETIME(900,0,EXP(1));
2910MAKETIME(900,0,EXP(1))
2911838:59:59.999999
2912Warnings:
2913Warning	1292	Truncated incorrect time value: '900:00:02'
2914SELECT MAKETIME(-900,0,0);
2915MAKETIME(-900,0,0)
2916-838:59:59
2917Warnings:
2918Warning	1292	Truncated incorrect time value: '-900:00:00'
2919SELECT MAKETIME(-900,0,0.1);
2920MAKETIME(-900,0,0.1)
2921-838:59:59.9
2922Warnings:
2923Warning	1292	Truncated incorrect time value: '-900:00:00'
2924SELECT MAKETIME(-900,0,0.11);
2925MAKETIME(-900,0,0.11)
2926-838:59:59.99
2927Warnings:
2928Warning	1292	Truncated incorrect time value: '-900:00:00'
2929SELECT MAKETIME(-900,0,0.111);
2930MAKETIME(-900,0,0.111)
2931-838:59:59.999
2932Warnings:
2933Warning	1292	Truncated incorrect time value: '-900:00:00'
2934SELECT MAKETIME(-900,0,0.1111);
2935MAKETIME(-900,0,0.1111)
2936-838:59:59.9999
2937Warnings:
2938Warning	1292	Truncated incorrect time value: '-900:00:00'
2939SELECT MAKETIME(-900,0,0.11111);
2940MAKETIME(-900,0,0.11111)
2941-838:59:59.99999
2942Warnings:
2943Warning	1292	Truncated incorrect time value: '-900:00:00'
2944SELECT MAKETIME(-900,0,0.111111);
2945MAKETIME(-900,0,0.111111)
2946-838:59:59.999999
2947Warnings:
2948Warning	1292	Truncated incorrect time value: '-900:00:00'
2949SELECT MAKETIME(-900,0,0.1111111);
2950MAKETIME(-900,0,0.1111111)
2951-838:59:59.999999
2952Warnings:
2953Warning	1292	Truncated incorrect time value: '-900:00:00'
2954SELECT MAKETIME(-900,0,0.11111111);
2955MAKETIME(-900,0,0.11111111)
2956-838:59:59.999999
2957Warnings:
2958Warning	1292	Truncated incorrect time value: '-900:00:00'
2959SELECT MAKETIME(-900,0,0.111111111);
2960MAKETIME(-900,0,0.111111111)
2961-838:59:59.999999
2962Warnings:
2963Warning	1292	Truncated incorrect time value: '-900:00:00'
2964SELECT MAKETIME(-900,0,EXP(1));
2965MAKETIME(-900,0,EXP(1))
2966-838:59:59.999999
2967Warnings:
2968Warning	1292	Truncated incorrect time value: '-900:00:02'
2969#
2970# End of 5.5 tests
2971#
2972#
2973# MDEV-8205 timediff returns null when comparing decimal time to time string value
2974#
2975SELECT
2976TIMEDIFF('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ) AS str_str,
2977TIMEDIFF('2014-01-01 00:00:00' , 20140101010000.000    ) AS str_dec,
2978TIMEDIFF(20140101000000.000    , 20140101010000.000    ) AS dec_dec,
2979TIMEDIFF(20140101000000.000    , '2014-01-01 01:00:00' ) AS dec_str;
2980str_str	str_dec	dec_dec	dec_str
2981-01:00:00	-01:00:00.000	-01:00:00.000	-01:00:00.000
2982SELECT
2983TIMEDIFF('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ) AS str_str,
2984TIMEDIFF('2014-01-01 00:00:00' , 20140102010000.000    ) AS str_dec,
2985TIMEDIFF(20140101000000.000    , 20140102010000.000    ) AS dec_dec,
2986TIMEDIFF(20140101000000.000    , '2014-01-02 01:00:00' ) AS dec_str;
2987str_str	str_dec	dec_dec	dec_str
2988-25:00:00	-25:00:00.000	-25:00:00.000	-25:00:00.000
2989SELECT
2990TIMEDIFF('2014-01-01 00:00:00' , '2014-02-02 01:00:00' ) AS str_str,
2991TIMEDIFF('2014-01-01 00:00:00' , 20140202010000.000    ) AS str_dec,
2992TIMEDIFF(20140101000000.000    , 20140202010000.000    ) AS dec_dec,
2993TIMEDIFF(20140101000000.000    , '2014-02-02 01:00:00' ) AS dec_str;
2994str_str	str_dec	dec_dec	dec_str
2995-769:00:00	-769:00:00.000	-769:00:00.000	-769:00:00.000
2996SELECT
2997TIMEDIFF('2014-01-01 00:00:00' , '2014-03-02 01:00:00' ) AS str_str,
2998TIMEDIFF('2014-01-01 00:00:00' , 20140302010000.000    ) AS str_dec,
2999TIMEDIFF(20140101000000.000    , 20140302010000.000    ) AS dec_dec,
3000TIMEDIFF(20140101000000.000    , '2014-03-02 01:00:00' ) AS dec_str;
3001str_str	str_dec	dec_dec	dec_str
3002-838:59:59	-838:59:59.999	-838:59:59.999	-838:59:59.999
3003Warnings:
3004Warning	1292	Truncated incorrect time value: '-1441:00:00'
3005Warning	1292	Truncated incorrect time value: '-1441:00:00'
3006Warning	1292	Truncated incorrect time value: '-1441:00:00'
3007Warning	1292	Truncated incorrect time value: '-1441:00:00'
3008#
3009# MDEV-10787 Assertion `ltime->neg == 0' failed in void date_to_datetime(MYSQL_TIME*)
3010#
3011CREATE TABLE t1 (d DATE);
3012INSERT INTO t1 VALUES ('2005-07-20'),('2012-12-21');
3013SELECT REPLACE( ADDDATE( d, INTERVAL 0.6732771076944444 HOUR_SECOND ), '2', 'x' ) FROM t1;
3014REPLACE( ADDDATE( d, INTERVAL 0.6732771076944444 HOUR_SECOND ), '2', 'x' )
3015NULL
3016NULL
3017Warnings:
3018Warning	1441	Datetime function: datetime field overflow
3019Warning	1441	Datetime function: datetime field overflow
3020SELECT REPLACE( ADDDATE( d, INTERVAL '0.6732771076944444' HOUR_SECOND ), '2', 'x' ) FROM t1;
3021REPLACE( ADDDATE( d, INTERVAL '0.6732771076944444' HOUR_SECOND ), '2', 'x' )
3022NULL
3023NULL
3024Warnings:
3025Warning	1441	Datetime function: datetime field overflow
3026Warning	1441	Datetime function: datetime field overflow
3027SELECT CAST(ADDDATE( d, INTERVAL 6732771076944444 SECOND) AS CHAR) FROM t1;
3028CAST(ADDDATE( d, INTERVAL 6732771076944444 SECOND) AS CHAR)
3029NULL
3030NULL
3031Warnings:
3032Warning	1441	Datetime function: datetime field overflow
3033Warning	1441	Datetime function: datetime field overflow
3034SELECT CAST(ADDDATE( d, INTERVAL '67327710769444:44' HOUR_SECOND) AS CHAR) FROM t1;
3035CAST(ADDDATE( d, INTERVAL '67327710769444:44' HOUR_SECOND) AS CHAR)
3036NULL
3037NULL
3038Warnings:
3039Warning	1441	Datetime function: datetime field overflow
3040Warning	1441	Datetime function: datetime field overflow
3041SELECT CAST(ADDDATE( d, INTERVAL '673277107694:44:44' HOUR_SECOND) AS CHAR) FROM t1;
3042CAST(ADDDATE( d, INTERVAL '673277107694:44:44' HOUR_SECOND) AS CHAR)
3043NULL
3044NULL
3045Warnings:
3046Warning	1441	Datetime function: datetime field overflow
3047Warning	1441	Datetime function: datetime field overflow
3048DROP TABLE t1;
3049SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:23:59:59' DAY_SECOND);
3050ADDDATE(DATE'0000-01-01', INTERVAL '3652423:23:59:59' DAY_SECOND)
30519999-12-31 23:59:59
3052SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:59:59' DAY_SECOND);
3053ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:59:59' DAY_SECOND)
30549999-12-31 23:59:59
3055SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:59' DAY_SECOND);
3056ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:59' DAY_SECOND)
30579999-12-31 23:59:59
3058SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:0:315569433599' DAY_SECOND);
3059ADDDATE(DATE'0000-01-01', INTERVAL '0:0:0:315569433599' DAY_SECOND)
30609999-12-31 23:59:59
3061SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:0:0:315569433559' DAY_SECOND);
3062ADDDATE(DATE'0000-01-01', INTERVAL '3652423:0:0:315569433559' DAY_SECOND)
3063NULL
3064Warnings:
3065Warning	1441	Datetime function: datetime field overflow
3066SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:0:315569433559' DAY_SECOND);
3067ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:0:315569433559' DAY_SECOND)
3068NULL
3069Warnings:
3070Warning	1441	Datetime function: datetime field overflow
3071SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:315569433599' DAY_SECOND);
3072ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:315569433599' DAY_SECOND)
3073NULL
3074Warnings:
3075Warning	1441	Datetime function: datetime field overflow
3076#
3077# MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime
3078#
3079CREATE TABLE t1 (i INT, d DATE);
3080INSERT INTO t1 VALUES (1, '1970-01-01');
3081SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR);
3082MAX(NULLIF(i,1))
3083NULL
3084Warnings:
3085Warning	1441	Datetime function: datetime field overflow
3086DROP TABLE t1;
3087CREATE TABLE t1 (i INT, d DATE);
3088INSERT INTO t1 VALUES (1, '1970-01-01');
3089SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1;
3090CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR))
3091NULL
3092Warnings:
3093Warning	1441	Datetime function: datetime field overflow
3094DROP TABLE t1;
3095SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR));
3096CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR))
3097NULL
3098Warnings:
3099Warning	1441	Datetime function: datetime field overflow
3100#
3101# End of 10.0 tests
3102#
3103#
3104# Start of 10.1 tests
3105#
3106#
3107# MDEV-10317 EXCTACT(MINUTE_MICROSECOND) truncates data
3108#
3109CREATE TABLE t1 (a DATETIME(6));
3110INSERT INTO t1 VALUES ('1999-12-31 23:59:59.999999');
3111SELECT
3112a,
3113EXTRACT(YEAR FROM a),
3114EXTRACT(YEAR_MONTH FROM a),
3115EXTRACT(QUARTER FROM a),
3116EXTRACT(MONTH FROM a),
3117EXTRACT(WEEK FROM a),
3118EXTRACT(DAY FROM a),
3119EXTRACT(DAY_HOUR FROM a),
3120EXTRACT(DAY_MINUTE FROM a),
3121EXTRACT(DAY_SECOND FROM a),
3122EXTRACT(HOUR FROM a),
3123EXTRACT(HOUR_MINUTE FROM a),
3124EXTRACT(HOUR_SECOND FROM a),
3125EXTRACT(MINUTE FROM a),
3126EXTRACT(MINUTE_SECOND FROM a),
3127EXTRACT(SECOND FROM a),
3128EXTRACT(MICROSECOND FROM a),
3129EXTRACT(DAY_MICROSECOND FROM a),
3130EXTRACT(HOUR_MICROSECOND FROM a),
3131EXTRACT(MINUTE_MICROSECOND FROM a),
3132EXTRACT(SECOND_MICROSECOND FROM a)
3133FROM t1;
3134Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
3135def	test	t1	t1	a	a	12	26	26	Y	128	6	63
3136def					EXTRACT(YEAR FROM a)	3	4	4	Y	32896	0	63
3137def					EXTRACT(YEAR_MONTH FROM a)	3	6	6	Y	32896	0	63
3138def					EXTRACT(QUARTER FROM a)	3	2	1	Y	32896	0	63
3139def					EXTRACT(MONTH FROM a)	3	2	2	Y	32896	0	63
3140def					EXTRACT(WEEK FROM a)	3	2	2	Y	32896	0	63
3141def					EXTRACT(DAY FROM a)	3	3	2	Y	32896	0	63
3142def					EXTRACT(DAY_HOUR FROM a)	3	5	4	Y	32896	0	63
3143def					EXTRACT(DAY_MINUTE FROM a)	3	7	6	Y	32896	0	63
3144def					EXTRACT(DAY_SECOND FROM a)	3	9	8	Y	32896	0	63
3145def					EXTRACT(HOUR FROM a)	3	3	2	Y	32896	0	63
3146def					EXTRACT(HOUR_MINUTE FROM a)	3	5	4	Y	32896	0	63
3147def					EXTRACT(HOUR_SECOND FROM a)	3	7	6	Y	32896	0	63
3148def					EXTRACT(MINUTE FROM a)	3	3	2	Y	32896	0	63
3149def					EXTRACT(MINUTE_SECOND FROM a)	3	5	4	Y	32896	0	63
3150def					EXTRACT(SECOND FROM a)	3	3	2	Y	32896	0	63
3151def					EXTRACT(MICROSECOND FROM a)	3	7	6	Y	32896	0	63
3152def					EXTRACT(DAY_MICROSECOND FROM a)	8	15	14	Y	32896	0	63
3153def					EXTRACT(HOUR_MICROSECOND FROM a)	8	13	12	Y	32896	0	63
3154def					EXTRACT(MINUTE_MICROSECOND FROM a)	8	11	10	Y	32896	0	63
3155def					EXTRACT(SECOND_MICROSECOND FROM a)	3	9	8	Y	32896	0	63
3156a	1999-12-31 23:59:59.999999
3157EXTRACT(YEAR FROM a)	1999
3158EXTRACT(YEAR_MONTH FROM a)	199912
3159EXTRACT(QUARTER FROM a)	4
3160EXTRACT(MONTH FROM a)	12
3161EXTRACT(WEEK FROM a)	52
3162EXTRACT(DAY FROM a)	31
3163EXTRACT(DAY_HOUR FROM a)	3123
3164EXTRACT(DAY_MINUTE FROM a)	312359
3165EXTRACT(DAY_SECOND FROM a)	31235959
3166EXTRACT(HOUR FROM a)	23
3167EXTRACT(HOUR_MINUTE FROM a)	2359
3168EXTRACT(HOUR_SECOND FROM a)	235959
3169EXTRACT(MINUTE FROM a)	59
3170EXTRACT(MINUTE_SECOND FROM a)	5959
3171EXTRACT(SECOND FROM a)	59
3172EXTRACT(MICROSECOND FROM a)	999999
3173EXTRACT(DAY_MICROSECOND FROM a)	31235959999999
3174EXTRACT(HOUR_MICROSECOND FROM a)	235959999999
3175EXTRACT(MINUTE_MICROSECOND FROM a)	5959999999
3176EXTRACT(SECOND_MICROSECOND FROM a)	59999999
3177CREATE TABLE t2 AS SELECT
3178a,
3179EXTRACT(YEAR FROM a),
3180EXTRACT(YEAR_MONTH FROM a),
3181EXTRACT(QUARTER FROM a),
3182EXTRACT(MONTH FROM a),
3183EXTRACT(WEEK FROM a),
3184EXTRACT(DAY FROM a),
3185EXTRACT(DAY_HOUR FROM a),
3186EXTRACT(DAY_MINUTE FROM a),
3187EXTRACT(DAY_SECOND FROM a),
3188EXTRACT(HOUR FROM a),
3189EXTRACT(HOUR_MINUTE FROM a),
3190EXTRACT(HOUR_SECOND FROM a),
3191EXTRACT(MINUTE FROM a),
3192EXTRACT(MINUTE_SECOND FROM a),
3193EXTRACT(SECOND FROM a),
3194EXTRACT(MICROSECOND FROM a),
3195EXTRACT(DAY_MICROSECOND FROM a),
3196EXTRACT(HOUR_MICROSECOND FROM a),
3197EXTRACT(MINUTE_MICROSECOND FROM a),
3198EXTRACT(SECOND_MICROSECOND FROM a)
3199FROM t1;
3200SELECT * FROM t2;
3201a	1999-12-31 23:59:59.999999
3202EXTRACT(YEAR FROM a)	1999
3203EXTRACT(YEAR_MONTH FROM a)	199912
3204EXTRACT(QUARTER FROM a)	4
3205EXTRACT(MONTH FROM a)	12
3206EXTRACT(WEEK FROM a)	52
3207EXTRACT(DAY FROM a)	31
3208EXTRACT(DAY_HOUR FROM a)	3123
3209EXTRACT(DAY_MINUTE FROM a)	312359
3210EXTRACT(DAY_SECOND FROM a)	31235959
3211EXTRACT(HOUR FROM a)	23
3212EXTRACT(HOUR_MINUTE FROM a)	2359
3213EXTRACT(HOUR_SECOND FROM a)	235959
3214EXTRACT(MINUTE FROM a)	59
3215EXTRACT(MINUTE_SECOND FROM a)	5959
3216EXTRACT(SECOND FROM a)	59
3217EXTRACT(MICROSECOND FROM a)	999999
3218EXTRACT(DAY_MICROSECOND FROM a)	31235959999999
3219EXTRACT(HOUR_MICROSECOND FROM a)	235959999999
3220EXTRACT(MINUTE_MICROSECOND FROM a)	5959999999
3221EXTRACT(SECOND_MICROSECOND FROM a)	59999999
3222SHOW CREATE TABLE t2;
3223Table	Create Table
3224t2	CREATE TABLE `t2` (
3225  `a` datetime(6) DEFAULT NULL,
3226  `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL,
3227  `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL,
3228  `EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL,
3229  `EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL,
3230  `EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL,
3231  `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
3232  `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
3233  `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
3234  `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
3235  `EXTRACT(HOUR FROM a)` int(3) DEFAULT NULL,
3236  `EXTRACT(HOUR_MINUTE FROM a)` int(5) DEFAULT NULL,
3237  `EXTRACT(HOUR_SECOND FROM a)` int(7) DEFAULT NULL,
3238  `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL,
3239  `EXTRACT(MINUTE_SECOND FROM a)` int(5) DEFAULT NULL,
3240  `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL,
3241  `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL,
3242  `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL,
3243  `EXTRACT(HOUR_MICROSECOND FROM a)` bigint(13) DEFAULT NULL,
3244  `EXTRACT(MINUTE_MICROSECOND FROM a)` bigint(11) DEFAULT NULL,
3245  `EXTRACT(SECOND_MICROSECOND FROM a)` int(9) DEFAULT NULL
3246) ENGINE=MyISAM DEFAULT CHARSET=latin1
3247DROP TABLE t1,t2;
3248CREATE TABLE t1 (a TIME(6));
3249INSERT INTO t1 VALUES ('-838:59:59.999999'),('838:59:59.999999');
3250SELECT
3251a,
3252EXTRACT(YEAR FROM a),
3253EXTRACT(YEAR_MONTH FROM a),
3254EXTRACT(QUARTER FROM a),
3255EXTRACT(MONTH FROM a),
3256EXTRACT(WEEK FROM a),
3257EXTRACT(DAY FROM a),
3258EXTRACT(DAY_HOUR FROM a),
3259EXTRACT(DAY_MINUTE FROM a),
3260EXTRACT(DAY_SECOND FROM a),
3261EXTRACT(HOUR FROM a),
3262EXTRACT(HOUR_MINUTE FROM a),
3263EXTRACT(HOUR_SECOND FROM a),
3264EXTRACT(MINUTE FROM a),
3265EXTRACT(MINUTE_SECOND FROM a),
3266EXTRACT(SECOND FROM a),
3267EXTRACT(MICROSECOND FROM a),
3268EXTRACT(DAY_MICROSECOND FROM a),
3269EXTRACT(HOUR_MICROSECOND FROM a),
3270EXTRACT(MINUTE_MICROSECOND FROM a),
3271EXTRACT(SECOND_MICROSECOND FROM a)
3272FROM t1;
3273Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
3274def	test	t1	t1	a	a	11	17	17	Y	128	6	63
3275def					EXTRACT(YEAR FROM a)	3	4	1	Y	32896	0	63
3276def					EXTRACT(YEAR_MONTH FROM a)	3	6	1	Y	32896	0	63
3277def					EXTRACT(QUARTER FROM a)	3	2	1	Y	32896	0	63
3278def					EXTRACT(MONTH FROM a)	3	2	1	Y	32896	0	63
3279def					EXTRACT(WEEK FROM a)	3	2	9	Y	32896	0	63
3280def					EXTRACT(DAY FROM a)	3	3	3	Y	32896	0	63
3281def					EXTRACT(DAY_HOUR FROM a)	3	5	5	Y	32896	0	63
3282def					EXTRACT(DAY_MINUTE FROM a)	3	7	7	Y	32896	0	63
3283def					EXTRACT(DAY_SECOND FROM a)	3	9	9	Y	32896	0	63
3284def					EXTRACT(HOUR FROM a)	3	3	3	Y	32896	0	63
3285def					EXTRACT(HOUR_MINUTE FROM a)	3	5	5	Y	32896	0	63
3286def					EXTRACT(HOUR_SECOND FROM a)	3	7	7	Y	32896	0	63
3287def					EXTRACT(MINUTE FROM a)	3	3	3	Y	32896	0	63
3288def					EXTRACT(MINUTE_SECOND FROM a)	3	5	5	Y	32896	0	63
3289def					EXTRACT(SECOND FROM a)	3	3	3	Y	32896	0	63
3290def					EXTRACT(MICROSECOND FROM a)	3	7	7	Y	32896	0	63
3291def					EXTRACT(DAY_MICROSECOND FROM a)	8	15	15	Y	32896	0	63
3292def					EXTRACT(HOUR_MICROSECOND FROM a)	8	13	13	Y	32896	0	63
3293def					EXTRACT(MINUTE_MICROSECOND FROM a)	8	11	11	Y	32896	0	63
3294def					EXTRACT(SECOND_MICROSECOND FROM a)	3	9	9	Y	32896	0	63
3295a	-838:59:59.999999
3296EXTRACT(YEAR FROM a)	0
3297EXTRACT(YEAR_MONTH FROM a)	0
3298EXTRACT(QUARTER FROM a)	0
3299EXTRACT(MONTH FROM a)	0
3300EXTRACT(WEEK FROM a)	613566757
3301EXTRACT(DAY FROM a)	-34
3302EXTRACT(DAY_HOUR FROM a)	-3422
3303EXTRACT(DAY_MINUTE FROM a)	-342259
3304EXTRACT(DAY_SECOND FROM a)	-34225959
3305EXTRACT(HOUR FROM a)	-22
3306EXTRACT(HOUR_MINUTE FROM a)	-2259
3307EXTRACT(HOUR_SECOND FROM a)	-225959
3308EXTRACT(MINUTE FROM a)	-59
3309EXTRACT(MINUTE_SECOND FROM a)	-5959
3310EXTRACT(SECOND FROM a)	-59
3311EXTRACT(MICROSECOND FROM a)	-999999
3312EXTRACT(DAY_MICROSECOND FROM a)	-34225959999999
3313EXTRACT(HOUR_MICROSECOND FROM a)	-225959999999
3314EXTRACT(MINUTE_MICROSECOND FROM a)	-5959999999
3315EXTRACT(SECOND_MICROSECOND FROM a)	-59999999
3316a	838:59:59.999999
3317EXTRACT(YEAR FROM a)	0
3318EXTRACT(YEAR_MONTH FROM a)	0
3319EXTRACT(QUARTER FROM a)	0
3320EXTRACT(MONTH FROM a)	0
3321EXTRACT(WEEK FROM a)	613566757
3322EXTRACT(DAY FROM a)	34
3323EXTRACT(DAY_HOUR FROM a)	3422
3324EXTRACT(DAY_MINUTE FROM a)	342259
3325EXTRACT(DAY_SECOND FROM a)	34225959
3326EXTRACT(HOUR FROM a)	22
3327EXTRACT(HOUR_MINUTE FROM a)	2259
3328EXTRACT(HOUR_SECOND FROM a)	225959
3329EXTRACT(MINUTE FROM a)	59
3330EXTRACT(MINUTE_SECOND FROM a)	5959
3331EXTRACT(SECOND FROM a)	59
3332EXTRACT(MICROSECOND FROM a)	999999
3333EXTRACT(DAY_MICROSECOND FROM a)	34225959999999
3334EXTRACT(HOUR_MICROSECOND FROM a)	225959999999
3335EXTRACT(MINUTE_MICROSECOND FROM a)	5959999999
3336EXTRACT(SECOND_MICROSECOND FROM a)	59999999
3337CREATE TABLE t2 AS SELECT
3338a,
3339EXTRACT(YEAR FROM a),
3340EXTRACT(YEAR_MONTH FROM a),
3341EXTRACT(QUARTER FROM a),
3342EXTRACT(MONTH FROM a),
3343EXTRACT(WEEK FROM a),
3344EXTRACT(DAY FROM a),
3345EXTRACT(DAY_HOUR FROM a),
3346EXTRACT(DAY_MINUTE FROM a),
3347EXTRACT(DAY_SECOND FROM a),
3348EXTRACT(HOUR FROM a),
3349EXTRACT(HOUR_MINUTE FROM a),
3350EXTRACT(HOUR_SECOND FROM a),
3351EXTRACT(MINUTE FROM a),
3352EXTRACT(MINUTE_SECOND FROM a),
3353EXTRACT(SECOND FROM a),
3354EXTRACT(MICROSECOND FROM a),
3355EXTRACT(DAY_MICROSECOND FROM a),
3356EXTRACT(HOUR_MICROSECOND FROM a),
3357EXTRACT(MINUTE_MICROSECOND FROM a),
3358EXTRACT(SECOND_MICROSECOND FROM a)
3359FROM t1;
3360SELECT * FROM t2;
3361a	-838:59:59.999999
3362EXTRACT(YEAR FROM a)	0
3363EXTRACT(YEAR_MONTH FROM a)	0
3364EXTRACT(QUARTER FROM a)	0
3365EXTRACT(MONTH FROM a)	0
3366EXTRACT(WEEK FROM a)	613566757
3367EXTRACT(DAY FROM a)	-34
3368EXTRACT(DAY_HOUR FROM a)	-3422
3369EXTRACT(DAY_MINUTE FROM a)	-342259
3370EXTRACT(DAY_SECOND FROM a)	-34225959
3371EXTRACT(HOUR FROM a)	-22
3372EXTRACT(HOUR_MINUTE FROM a)	-2259
3373EXTRACT(HOUR_SECOND FROM a)	-225959
3374EXTRACT(MINUTE FROM a)	-59
3375EXTRACT(MINUTE_SECOND FROM a)	-5959
3376EXTRACT(SECOND FROM a)	-59
3377EXTRACT(MICROSECOND FROM a)	-999999
3378EXTRACT(DAY_MICROSECOND FROM a)	-34225959999999
3379EXTRACT(HOUR_MICROSECOND FROM a)	-225959999999
3380EXTRACT(MINUTE_MICROSECOND FROM a)	-5959999999
3381EXTRACT(SECOND_MICROSECOND FROM a)	-59999999
3382a	838:59:59.999999
3383EXTRACT(YEAR FROM a)	0
3384EXTRACT(YEAR_MONTH FROM a)	0
3385EXTRACT(QUARTER FROM a)	0
3386EXTRACT(MONTH FROM a)	0
3387EXTRACT(WEEK FROM a)	613566757
3388EXTRACT(DAY FROM a)	34
3389EXTRACT(DAY_HOUR FROM a)	3422
3390EXTRACT(DAY_MINUTE FROM a)	342259
3391EXTRACT(DAY_SECOND FROM a)	34225959
3392EXTRACT(HOUR FROM a)	22
3393EXTRACT(HOUR_MINUTE FROM a)	2259
3394EXTRACT(HOUR_SECOND FROM a)	225959
3395EXTRACT(MINUTE FROM a)	59
3396EXTRACT(MINUTE_SECOND FROM a)	5959
3397EXTRACT(SECOND FROM a)	59
3398EXTRACT(MICROSECOND FROM a)	999999
3399EXTRACT(DAY_MICROSECOND FROM a)	34225959999999
3400EXTRACT(HOUR_MICROSECOND FROM a)	225959999999
3401EXTRACT(MINUTE_MICROSECOND FROM a)	5959999999
3402EXTRACT(SECOND_MICROSECOND FROM a)	59999999
3403SHOW CREATE TABLE t2;
3404Table	Create Table
3405t2	CREATE TABLE `t2` (
3406  `a` time(6) DEFAULT NULL,
3407  `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL,
3408  `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL,
3409  `EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL,
3410  `EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL,
3411  `EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL,
3412  `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
3413  `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
3414  `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
3415  `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
3416  `EXTRACT(HOUR FROM a)` int(3) DEFAULT NULL,
3417  `EXTRACT(HOUR_MINUTE FROM a)` int(5) DEFAULT NULL,
3418  `EXTRACT(HOUR_SECOND FROM a)` int(7) DEFAULT NULL,
3419  `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL,
3420  `EXTRACT(MINUTE_SECOND FROM a)` int(5) DEFAULT NULL,
3421  `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL,
3422  `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL,
3423  `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL,
3424  `EXTRACT(HOUR_MICROSECOND FROM a)` bigint(13) DEFAULT NULL,
3425  `EXTRACT(MINUTE_MICROSECOND FROM a)` bigint(11) DEFAULT NULL,
3426  `EXTRACT(SECOND_MICROSECOND FROM a)` int(9) DEFAULT NULL
3427) ENGINE=MyISAM DEFAULT CHARSET=latin1
3428DROP TABLE t1,t2;
3429#
3430# MDEV-14926 AddressSanitizer: heap-use-after-free in make_date_time on weird combination of functions
3431#
3432DO INET_ATON( FROM_UNIXTIME( @@timestamp, ( TRIM( UNHEX(HEX('%m.%d.%Y') ) ) ) ) );
3433CREATE TABLE t1 (d DATE);
3434INSERT INTO t1 VALUES ('1989-03-10');
3435SELECT TIME_FORMAT('23:59:43', BINARY d) AS f FROM t1 GROUP BY 'foo';
3436f
34371989-03-10
3438DROP TABLE t1;
3439CREATE TABLE t1 (d DATE) ENGINE=MyISAM;
3440INSERT INTO t1 VALUES ('1900-01-01');
3441SELECT LENGTH( DATE_FORMAT( d, BINARY DATABASE() ) ) AS f FROM t1 GROUP BY d;
3442f
34434
3444DROP TABLE t1;
3445#
3446# MDEV-18667 ASAN heap-use-after-free in make_date_time / Arg_comparator::compare_string / Item_func_nullif::compare
3447#
3448SELECT NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0)));
3449NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0)))
3450foo
3451Warnings:
3452Warning	1292	Truncated incorrect DECIMAL value: '2012-12-12 12:12:12'
3453#
3454# MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT
3455#
3456SELECT DATE_FORMAT(100000000000, '%j');
3457DATE_FORMAT(100000000000, '%j')
3458NULL
3459#
3460# End of 10.1 tests
3461#
3462#
3463# MDEV-16217: Assertion `!table || (!table->read_set ||
3464# bitmap_is_set(table->read_set, field_index))'
3465# failed in Field_num::get_date
3466#
3467CREATE TABLE t1 (pk int  default 0, a1 date);
3468INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL);
3469CREATE VIEW v1 AS
3470SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1;
3471SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1;
3472a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk))
34730
3474NULL
3475NULL
3476NULL
3477SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1;
3478a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk))
34790
3480NULL
3481NULL
3482NULL
3483Warnings:
3484Warning	1292	Truncated incorrect datetime value: '18446744073709551615'
3485CREATE TABLE t2 (pk int  default 1, a1 date);
3486INSERT INTO t2 VALUES (4,NULL);
3487CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2;
3488select * from v2;
3489default(t1.pk)	default(t2.pk)	pk
34900	1	1
34910	1	2
34920	1	3
34930	1	4
3494show create view v2;
3495View	Create View	character_set_client	collation_connection
3496v2	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select default(`t1`.`pk`) AS `default(t1.pk)`,default(`t2`.`pk`) AS `default(t2.pk)`,`t1`.`pk` AS `pk` from (`t1` join `t2`)	latin1	latin1_swedish_ci
3497CREATE view v3 as SELECT default(pk) from t2;
3498select * from v3;
3499default(pk)
35001
3501explain extended select * from v3;
3502id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
35031	SIMPLE	t2	system	NULL	NULL	NULL	NULL	1	100.00
3504Warnings:
3505Note	1003	select default(`test`.`t2`.`pk`) AS `default(pk)` from dual
3506explain extended select default(pk) from t2;
3507id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
35081	SIMPLE	t2	system	NULL	NULL	NULL	NULL	1	100.00
3509Warnings:
3510Note	1003	select default(`test`.`t2`.`pk`) AS `default(pk)` from dual
3511show create view v3;
3512View	Create View	character_set_client	collation_connection
3513v3	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select default(`t2`.`pk`) AS `default(pk)` from `t2`	latin1	latin1_swedish_ci
3514DROP VIEW v1,v2,v3;
3515DROP TABLE t1,t2;
3516#
3517# MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on
3518#
3519SELECT DAYNAME('2019-01-05')+0;
3520DAYNAME('2019-01-05')+0
35210
3522Warnings:
3523Warning	1292	Truncated incorrect DOUBLE value: 'Saturday'
3524SELECT CAST(DAYNAME('2019-01-05') AS SIGNED);
3525CAST(DAYNAME('2019-01-05') AS SIGNED)
35260
3527Warnings:
3528Warning	1292	Truncated incorrect INTEGER value: 'Saturday'
3529#
3530# End of 10.2 tests
3531#
3532#
3533#  MDEV-12515 Wrong value when storing DATE_ADD() and ADDTIME() to a numeric field
3534#
3535SET sql_mode='';
3536CREATE TABLE t1 AS SELECT
3537DATE_ADD('2001-01-01',INTERVAL 1 DAY) AS c1,
3538ADDTIME('10:20:30',1) AS c2;
3539SHOW CREATE TABLE t1;
3540Table	Create Table
3541t1	CREATE TABLE `t1` (
3542  `c1` varchar(19) DEFAULT NULL,
3543  `c2` varchar(26) DEFAULT NULL
3544) ENGINE=MyISAM DEFAULT CHARSET=latin1
3545SELECT * FROM t1;
3546c1	c2
35472001-01-02	10:20:31
3548DROP TABLE t1;
3549CREATE TABLE t2 (c INT);
3550INSERT INTO t2 SELECT DATE_ADD('2001-01-01',INTERVAL 1 DAY);
3551Warnings:
3552Warning	1265	Data truncated for column 'c' at row 1
3553INSERT INTO t2 VALUES ('2001-01-02');
3554Warnings:
3555Warning	1265	Data truncated for column 'c' at row 1
3556SELECT * FROM t2;
3557c
35582001
35592001
3560DROP TABLE t2;
3561CREATE TABLE t2 (a INT);
3562INSERT INTO t2 VALUES (ADDTIME('10:20:30',1));
3563Warnings:
3564Warning	1265	Data truncated for column 'a' at row 1
3565INSERT INTO t2 VALUES ('10:20:31');
3566Warnings:
3567Warning	1265	Data truncated for column 'a' at row 1
3568SELECT * FROM t2;
3569a
357010
357110
3572DROP TABLE t2;
3573SET sql_mode=DEFAULT;
3574#
3575# MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and EXTRACT(MINUTE_MICROSECOND..)
3576#
3577SET sql_mode=STRICT_ALL_TABLES;
3578CREATE TABLE t1 (
3579id bigint(11) NOT NULL PRIMARY KEY,
3580dt datetime(6)
3581);
3582INSERT INTO t1 VALUES (1,'2001-01-01 11:22:33.123456');
3583CREATE OR REPLACE VIEW v1 AS SELECT EXTRACT(MINUTE_MICROSECOND FROM dt) AS dt2 FROM t1;
3584DESCRIBE v1;
3585Field	Type	Null	Key	Default	Extra
3586dt2	bigint(11)	YES		NULL
3587SELECT * FROM v1;
3588dt2
35892233123456
3590CREATE TABLE t2 AS SELECT MAX(dt2) FROM v1;
3591DESCRIBE t2;
3592Field	Type	Null	Key	Default	Extra
3593MAX(dt2)	bigint(11)	YES		NULL
3594SELECT * FROM t2;
3595MAX(dt2)
35962233123456
3597DROP TABLE t2;
3598DROP VIEW v1;
3599DROP TABLE t1;
3600SET sql_mode=DEFAULT;
3601#
3602# MDEV-12866 Out-of-range error with CREATE..SELECT..TO_SECONDS(NOW())
3603#
3604SET sql_mode=STRICT_ALL_TABLES;
3605CREATE TABLE t1 AS SELECT TO_SECONDS('9999-12-31 23:59:59');
3606SHOW CREATE TABLE t1;
3607Table	Create Table
3608t1	CREATE TABLE `t1` (
3609  `TO_SECONDS('9999-12-31 23:59:59')` bigint(12) DEFAULT NULL
3610) ENGINE=MyISAM DEFAULT CHARSET=latin1
3611DROP TABLE t1;
3612SET sql_mode=DEFAULT;
3613#
3614# MDEV-13966 Parameter data type control for Item_temporal_func
3615#
3616SELECT FROM_DAYS(ROW(1,1));
3617ERROR HY000: Illegal parameter data type row for operation 'from_days'
3618SELECT MAKEDATE(ROW(1,1),1);
3619ERROR HY000: Illegal parameter data type row for operation 'makedate'
3620SELECT MAKEDATE(1, ROW(1,1));
3621ERROR HY000: Illegal parameter data type row for operation 'makedate'
3622SELECT LAST_DAY(ROW(1,1));
3623ERROR HY000: Illegal parameter data type row for operation 'last_day'
3624SELECT SEC_TO_TIME(ROW(1,1));
3625ERROR HY000: Illegal parameter data type row for operation 'sec_to_time'
3626SELECT TIMEDIFF(ROW(1,1),1);
3627ERROR HY000: Illegal parameter data type row for operation 'timediff'
3628SELECT TIMEDIFF(1, ROW(1,1));
3629ERROR HY000: Illegal parameter data type row for operation 'timediff'
3630SELECT MAKETIME(ROW(1,1),1,1);
3631ERROR HY000: Illegal parameter data type row for operation 'maketime'
3632SELECT MAKETIME(1, ROW(1,1), 1);
3633ERROR HY000: Illegal parameter data type row for operation 'maketime'
3634SELECT MAKETIME(1, 1, ROW(1,1));
3635ERROR HY000: Illegal parameter data type row for operation 'maketime'
3636SELECT FROM_UNIXTIME(ROW(1,1));
3637ERROR HY000: Illegal parameter data type row for operation 'from_unixtime'
3638SELECT CONVERT_TZ(ROW(1,1),1,1);
3639ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
3640SELECT CONVERT_TZ(1, ROW(1,1), 1);
3641ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
3642SELECT CONVERT_TZ(1, 1, ROW(1,1));
3643ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
3644#
3645# MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime)
3646#
3647SET TIMESTAMP=UNIX_TIMESTAMP('2018-02-17 01:02:03');
3648SELECT
3649COALESCE(TIME'800:00:00', NOW()) AS c,
3650HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc;
3651c	hc
36522018-03-22 08:00:00	8
3653SELECT
3654CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c,
3655HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc;
3656c	hc
36572018-03-22 08:00:00	8
3658SELECT
3659IFNULL(TIME'800:00:00', NOW()) AS c,
3660HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc;
3661c	hc
36622018-03-22 08:00:00	8
3663SELECT
3664IF(TRUE,TIME'800:00:00', NOW()) AS c,
3665HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc;
3666c	hc
36672018-03-22 08:00:00	8
3668SELECT
3669ADDTIME(TIME'10:20:30', TIMESTAMP'2001-01-01 00:00:00') AS c1,
3670ADDTIME(TIME'10:20:30', COALESCE(TIMESTAMP'2001-01-01 00:00:00',TIMESTAMP'2001-01-01 00:00:00')) AS c2,
3671ADDTIME(TIME'10:20:30', DATE'2001-01-01') AS c3,
3672ADDTIME(TIME'10:20:30', COALESCE(DATE'2001-01-01',TIMESTAMP'2001-01-01 00:00:00')) AS c4;
3673c1	c2	c3	c4
3674NULL	NULL	NULL	NULL
3675Warnings:
3676Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
3677Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
3678Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01'
3679Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
3680SELECT
3681HOUR(TIMESTAMP'0000-00-01 10:00:00') AS h0,
3682TIME_TO_SEC(TIMESTAMP'0000-00-01 10:00:00') AS tts0,
3683TIME_TO_SEC(TIMESTAMP'0000-00-01 10:00:00.1') AS tts1,
3684CAST(TIMESTAMP'0000-00-01 10:00:00' AS TIME) AS c0,
3685CAST(TIMESTAMP'0000-00-01 10:00:00.1' AS TIME(1)) AS c2;
3686h0	tts0	tts1	c0	c2
368710	36000	36000.1	10:00:00	10:00:00.1
3688SET TIMESTAMP=DEFAULT;
3689#
3690# MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
3691#
3692SET TIMESTAMP=UNIX_TIMESTAMP('2018-02-17 01:02:03');
3693SELECT
3694LAST_DAY(TIME'00:00:00') AS c1,
3695CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
3696CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
3697c1	c2	c3
36982018-02-28	00:00:00	00:00:00
3699SET TIMESTAMP=DEFAULT;
3700#
3701# MDEV-15702 Remove the use of STRING_ITEM from Item_func_date_format::fix_length_and_dec()
3702#
3703SELECT DATE_FORMAT('2001-01-01',POINT(1,1));
3704ERROR HY000: Illegal parameter data type geometry for operation 'date_format'
3705SELECT DATE_FORMAT(POINT(1,1),'10');
3706ERROR HY000: Illegal parameter data type geometry for operation 'date_format'
3707SELECT DATE_FORMAT('2001-01-01',ROW(1,1));
3708ERROR HY000: Illegal parameter data type row for operation 'date_format'
3709SELECT DATE_FORMAT(ROW(1,1),'10');
3710ERROR HY000: Illegal parameter data type row for operation 'date_format'
3711SELECT DATE_FORMAT('2001-01-01','%Y',POINT(1,1));
3712ERROR HY000: Illegal parameter data type geometry for operation 'date_format'
3713SELECT DATE_FORMAT('2001-01-01','%Y',ROW(1,1));
3714ERROR HY000: Illegal parameter data type row for operation 'date_format'
3715SELECT DATE_FORMAT('2001-01-01','%Y',@unknown_user_variable);
3716DATE_FORMAT('2001-01-01','%Y',@unknown_user_variable)
37172001
3718Warnings:
3719Warning	1649	Unknown locale: 'NULL'
3720CREATE TABLE t1 AS SELECT
3721DATE_FORMAT('2001-01-01',NULL) AS c0,
3722DATE_FORMAT('2001-01-01','10') AS c1,
3723DATE_FORMAT('2001-01-01',10) AS c2,
3724DATE_FORMAT('2001-01-01',10.0) AS c3,
3725DATE_FORMAT('2001-01-01',10e0) AS c4,
3726DATE_FORMAT('2001-01-01',TIME'10:20:30') AS c5;
3727SHOW CREATE TABLE t1;
3728Table	Create Table
3729t1	CREATE TABLE `t1` (
3730  `c0` char(0) DEFAULT NULL,
3731  `c1` varchar(2) DEFAULT NULL,
3732  `c2` varchar(2) DEFAULT NULL,
3733  `c3` varchar(4) DEFAULT NULL,
3734  `c4` varchar(2) DEFAULT NULL,
3735  `c5` varchar(8) DEFAULT NULL
3736) ENGINE=MyISAM DEFAULT CHARSET=latin1
3737DROP TABLE t1;
3738EXECUTE IMMEDIATE
3739"CREATE TABLE t1 AS SELECT
3740   DATE_FORMAT('2001-01-01',?) AS c0,
3741   DATE_FORMAT('2001-01-01',?) AS c1,
3742   DATE_FORMAT('2001-01-01',?) AS c2,
3743   DATE_FORMAT('2001-01-01',?) AS c3,
3744   DATE_FORMAT('2001-01-01',?) AS c4,
3745   DATE_FORMAT('2001-01-01',?) AS c5"
3746USING NULL, '10', 10, 10.0, 10e0, TIME'10:20:30';
3747SHOW CREATE TABLE t1;
3748Table	Create Table
3749t1	CREATE TABLE `t1` (
3750  `c0` char(0) DEFAULT NULL,
3751  `c1` varchar(2) DEFAULT NULL,
3752  `c2` varchar(2) DEFAULT NULL,
3753  `c3` varchar(4) DEFAULT NULL,
3754  `c4` varchar(2) DEFAULT NULL,
3755  `c5` varchar(100) DEFAULT NULL
3756) ENGINE=MyISAM DEFAULT CHARSET=latin1
3757DROP TABLE t1;
3758#
3759# MDEV-16152 Expressions with INTERVAL return bad results in some cases
3760#
3761SELECT TIMESTAMP'2001-01-01 10:20:30' - INTERVAL '10' YEAR AS c1,
3762-INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c2;
3763c1	c2
37641991-01-01 10:20:30	1991-01-01 10:20:30
3765SELECT TIMESTAMP'2001-01-01 10:20:30' + INTERVAL '10' YEAR AS c1,
3766INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c2,
3767+INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c3;
3768c1	c2	c3
37692011-01-01 10:20:30	2011-01-01 10:20:30	2011-01-01 10:20:30
3770EXPLAIN EXTENDED SELECT
3771TIMESTAMP'2001-01-01 10:20:30' - INTERVAL '10' YEAR AS c1,
3772-INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c2;
3773id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
37741	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
3775Warnings:
3776Note	1003	select TIMESTAMP'2001-01-01 10:20:30' - interval '10' year AS `c1`,TIMESTAMP'2001-01-01 10:20:30' - interval '10' year AS `c2`
3777EXPLAIN EXTENDED SELECT
3778TIMESTAMP'2001-01-01 10:20:30' + INTERVAL '10' YEAR AS c1,
3779INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c2,
3780+INTERVAL '10' YEAR + TIMESTAMP'2001-01-01 10:20:30' AS c3;
3781id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
37821	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
3783Warnings:
3784Note	1003	select TIMESTAMP'2001-01-01 10:20:30' + interval '10' year AS `c1`,TIMESTAMP'2001-01-01 10:20:30' + interval '10' year AS `c2`,TIMESTAMP'2001-01-01 10:20:30' + interval '10' year AS `c3`
3785CREATE TABLE t_ts   (a timestamp(6));
3786CREATE TABLE t_trig (a timestamp(6));
3787CREATE FUNCTION fn_sleep_before_now() returns int
3788BEGIN
3789INSERT INTO t_ts SET a= current_timestamp(6);
3790RETURN 0;
3791END//
3792CREATE TRIGGER trg_insert_t_ts after INSERT on t_ts for each row
3793BEGIN
3794INSERT into t_trig set a= current_timestamp(6);
3795END//
3796SET @sav_slow_query_log= @@session.slow_query_log;
3797SET @@session.slow_query_log= ON;
3798SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @ts_func;
3799SELECT a FROM t_ts   LIMIT 1 into @ts_func;
3800Warnings:
3801Warning	1287	'<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
3802SELECT a FROM t_trig LIMIT 1 into @ts_trig;
3803Warnings:
3804Warning	1287	'<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
3805DELETE FROM t_ts;
3806DELETE FROM t_trig;
3807SET @@session.slow_query_log= OFF;
3808SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @func_ts;
3809SELECT a FROM t_ts   LIMIT 1 into @ts_func;
3810Warnings:
3811Warning	1287	'<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
3812SELECT a FROM t_trig LIMIT 1 into @ts_trig;
3813Warnings:
3814Warning	1287	'<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
3815SET @@session.slow_query_log= @sav_slow_query_log;
3816DROP FUNCTION fn_sleep_before_now;
3817DROP TRIGGER trg_insert_t_ts;
3818DROP TABLE t_ts, t_trig;
3819#
3820# MDEV-16878 Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer
3821#
3822CREATE TABLE t1 (a TIME);
3823INSERT INTO t1 VALUES ('00:00:10'),('00:00:20');
3824SELECT a, SUBTIME(a,TIME'00:00:01'), ADDTIME(a,TIME'00:00:01') FROM t1;
3825a	SUBTIME(a,TIME'00:00:01')	ADDTIME(a,TIME'00:00:01')
382600:00:10	00:00:09	00:00:11
382700:00:20	00:00:19	00:00:21
3828SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09';
3829a
383000:00:10
3831SELECT * FROM t1 WHERE ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
3832a
3833SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
3834a
3835EXPLAIN EXTENDED SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
3836id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
38371	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
3838Warnings:
3839Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where subtime(`test`.`t1`.`a`,TIME'00:00:01') = TIME'00:00:09' and addtime(`test`.`t1`.`a`,TIME'00:00:01') <= TIME'00:00:09'
3840DROP TABLE t1;
3841#
3842# MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
3843#
3844set timestamp=unix_timestamp('2018-08-02 10:10:10');
3845SELECT
3846LAST_DAY(TIME'00:00:00') AS c1,
3847CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
3848CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
3849c1	c2	c3
38502018-08-31	00:00:00	00:00:00
3851#
3852# End of 10.3 tests
3853#
3854#
3855# MDEV-14032 SEC_TO_TIME executes side effect two times
3856#
3857SET @a=10000000;
3858SELECT SEC_TO_TIME(@a:=@a+1);
3859SEC_TO_TIME(@a:=@a+1)
3860838:59:59
3861Warnings:
3862Warning	1292	Truncated incorrect seconds value: '10000001'
3863SELECT @a;
3864@a
386510000001
3866CREATE TABLE t1 (a TEXT);
3867CREATE FUNCTION f1() RETURNS INT
3868BEGIN
3869INSERT INTO t1 VALUES ('f1 was called');
3870RETURN 10000000;
3871END;
3872$$
3873SELECT SEC_TO_TIME(f1());
3874SEC_TO_TIME(f1())
3875838:59:59
3876Warnings:
3877Warning	1292	Truncated incorrect seconds value: '10000000'
3878SELECT * FROM t1;
3879a
3880f1 was called
3881DROP TABLE t1;
3882DROP FUNCTION f1;
3883#
3884# MDEV-17351 MICROSECOND(XXX(int_number_out_of_range)) erroneously returns 999999
3885#
3886# Reject anything that's parsed as DATETIME or DATE
3887CREATE TABLE t1 (a VARCHAR(64));
3888INSERT INTO t1 VALUES
3889('2001-01-01 10:20:30'),
3890('01-01-01 10:20:30'),
3891('2001-01-01       '),
3892('20010101102030'),
3893('010101102030');
3894SELECT ADDTIME(DATE'2001-01-01',a), a FROM t1;
3895ADDTIME(DATE'2001-01-01',a)	a
3896NULL	2001-01-01 10:20:30
3897NULL	01-01-01 10:20:30
3898NULL	2001-01-01
3899NULL	20010101102030
3900NULL	010101102030
3901Warnings:
3902Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 10:20:30'
3903Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '01-01-01 10:20:30'
3904Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '2001-01-01       '
3905Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '20010101102030'
3906Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '010101102030'
3907DROP TABLE t1;
3908# GREATEST(decimal, time)
3909SELECT
3910GREATEST(8395959, TIME'00:00:00') AS c0,
3911GREATEST(8395959.0, TIME'00:00:00') AS c1,
3912GREATEST(8395959.00, TIME'00:00:00') AS c2,
3913GREATEST(8395959.000, TIME'00:00:00') AS c3,
3914GREATEST(8395959.0000, TIME'00:00:00') AS c4,
3915GREATEST(8395959.00000, TIME'00:00:00') AS c5,
3916GREATEST(8395959.000000, TIME'00:00:00') AS c6,
3917GREATEST(8395959.0000000, TIME'00:00:00') AS c7;
3918c0	838:59:59
3919c1	838:59:59.9
3920c2	838:59:59.99
3921c3	838:59:59.999
3922c4	838:59:59.9999
3923c5	838:59:59.99999
3924c6	838:59:59.999999
3925c7	838:59:59.999999
3926Warnings:
3927Level	Warning
3928Code	1292
3929Message	Truncated incorrect time value: '8395959'
3930Level	Warning
3931Code	1292
3932Message	Truncated incorrect time value: '8395959.0'
3933Level	Warning
3934Code	1292
3935Message	Truncated incorrect time value: '8395959.00'
3936Level	Warning
3937Code	1292
3938Message	Truncated incorrect time value: '8395959.000'
3939Level	Warning
3940Code	1292
3941Message	Truncated incorrect time value: '8395959.0000'
3942Level	Warning
3943Code	1292
3944Message	Truncated incorrect time value: '8395959.00000'
3945Level	Warning
3946Code	1292
3947Message	Truncated incorrect time value: '8395959.000000'
3948Level	Warning
3949Code	1292
3950Message	Truncated incorrect time value: '8395959.0000000'
3951SELECT
3952MICROSECOND(GREATEST(8395959, TIME'00:00:00')) AS c0,
3953MICROSECOND(GREATEST(8395959.0, TIME'00:00:00')) AS c1,
3954MICROSECOND(GREATEST(8395959.00, TIME'00:00:00')) AS c2,
3955MICROSECOND(GREATEST(8395959.000, TIME'00:00:00')) AS c3,
3956MICROSECOND(GREATEST(8395959.0000, TIME'00:00:00')) AS c4,
3957MICROSECOND(GREATEST(8395959.00000, TIME'00:00:00')) AS c5,
3958MICROSECOND(GREATEST(8395959.000000, TIME'00:00:00')) AS c6,
3959MICROSECOND(GREATEST(8395959.0000000, TIME'00:00:00')) AS c7;
3960c0	0
3961c1	900000
3962c2	990000
3963c3	999000
3964c4	999900
3965c5	999990
3966c6	999999
3967c7	999999
3968Warnings:
3969Level	Warning
3970Code	1292
3971Message	Truncated incorrect time value: '8395959'
3972Level	Warning
3973Code	1292
3974Message	Truncated incorrect time value: '8395959.0'
3975Level	Warning
3976Code	1292
3977Message	Truncated incorrect time value: '8395959.00'
3978Level	Warning
3979Code	1292
3980Message	Truncated incorrect time value: '8395959.000'
3981Level	Warning
3982Code	1292
3983Message	Truncated incorrect time value: '8395959.0000'
3984Level	Warning
3985Code	1292
3986Message	Truncated incorrect time value: '8395959.00000'
3987Level	Warning
3988Code	1292
3989Message	Truncated incorrect time value: '8395959.000000'
3990Level	Warning
3991Code	1292
3992Message	Truncated incorrect time value: '8395959.0000000'
3993SELECT
3994CAST(GREATEST(8395959, TIME'00:00:00') AS SIGNED) AS ci,
3995CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
3996CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
3997CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
3998CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
3999CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
4000CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
4001CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
4002CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
4003ci	8385959
4004c0	8385959
4005c1	8385959.0
4006c2	8385959.00
4007c3	8385959.000
4008c4	8385959.0000
4009c5	8385959.00000
4010c6	8385959.000000
4011c7	8385959.0000000
4012Warnings:
4013Level	Warning
4014Code	1292
4015Message	Truncated incorrect time value: '8395959'
4016Level	Warning
4017Code	1292
4018Message	Truncated incorrect time value: '8395959'
4019Level	Warning
4020Code	1292
4021Message	Truncated incorrect time value: '8395959'
4022Level	Warning
4023Code	1292
4024Message	Truncated incorrect time value: '8395959'
4025Level	Warning
4026Code	1292
4027Message	Truncated incorrect time value: '8395959'
4028Level	Warning
4029Code	1292
4030Message	Truncated incorrect time value: '8395959'
4031Level	Warning
4032Code	1292
4033Message	Truncated incorrect time value: '8395959'
4034Level	Warning
4035Code	1292
4036Message	Truncated incorrect time value: '8395959'
4037Level	Warning
4038Code	1292
4039Message	Truncated incorrect time value: '8395959'
4040SELECT
4041GREATEST(8395959, TIME'00:00:00') AS ci,
4042GREATEST(8395959, TIME'00:00:00')+0 AS c0,
4043GREATEST(8395959, TIME'00:00:00')+0.0 AS c1,
4044GREATEST(8395959, TIME'00:00:00')+0.00 AS c2,
4045GREATEST(8395959, TIME'00:00:00')+0.000 AS c3,
4046GREATEST(8395959, TIME'00:00:00')+0.0000 AS c4,
4047GREATEST(8395959, TIME'00:00:00')+0.00000 AS c5,
4048GREATEST(8395959, TIME'00:00:00')+0.000000 AS c6,
4049GREATEST(8395959, TIME'00:00:00')+0.0000000 AS c7;
4050ci	838:59:59
4051c0	8385959
4052c1	8385959.0
4053c2	8385959.00
4054c3	8385959.000
4055c4	8385959.0000
4056c5	8385959.00000
4057c6	8385959.000000
4058c7	8385959.0000000
4059Warnings:
4060Level	Warning
4061Code	1292
4062Message	Truncated incorrect time value: '8395959'
4063Level	Warning
4064Code	1292
4065Message	Truncated incorrect time value: '8395959'
4066Level	Warning
4067Code	1292
4068Message	Truncated incorrect time value: '8395959'
4069Level	Warning
4070Code	1292
4071Message	Truncated incorrect time value: '8395959'
4072Level	Warning
4073Code	1292
4074Message	Truncated incorrect time value: '8395959'
4075Level	Warning
4076Code	1292
4077Message	Truncated incorrect time value: '8395959'
4078Level	Warning
4079Code	1292
4080Message	Truncated incorrect time value: '8395959'
4081Level	Warning
4082Code	1292
4083Message	Truncated incorrect time value: '8395959'
4084Level	Warning
4085Code	1292
4086Message	Truncated incorrect time value: '8395959'
4087# GREATEST(string, time)
4088SELECT
4089GREATEST('839:59:59', TIME'00:00:00') AS ci,
4090GREATEST('839:59:59.0', TIME'00:00:00') AS c1,
4091GREATEST('839:59:59.00', TIME'00:00:00') AS c2,
4092GREATEST('839:59:59.000', TIME'00:00:00') AS c3,
4093GREATEST('839:59:59.0000', TIME'00:00:00') AS c4,
4094GREATEST('839:59:59.00000', TIME'00:00:00') AS c5,
4095GREATEST('839:59:59.000000', TIME'00:00:00') AS c6,
4096GREATEST('839:59:59.0000000', TIME'00:00:00') AS c7;
4097ci	838:59:59
4098c1	838:59:59.9
4099c2	838:59:59.99
4100c3	838:59:59.999
4101c4	838:59:59.9999
4102c5	838:59:59.99999
4103c6	838:59:59.999999
4104c7	838:59:59.999999
4105Warnings:
4106Level	Warning
4107Code	1292
4108Message	Truncated incorrect time value: '839:59:59'
4109Level	Warning
4110Code	1292
4111Message	Truncated incorrect time value: '839:59:59.0'
4112Level	Warning
4113Code	1292
4114Message	Truncated incorrect time value: '839:59:59.00'
4115Level	Warning
4116Code	1292
4117Message	Truncated incorrect time value: '839:59:59.000'
4118Level	Warning
4119Code	1292
4120Message	Truncated incorrect time value: '839:59:59.0000'
4121Level	Warning
4122Code	1292
4123Message	Truncated incorrect time value: '839:59:59.00000'
4124Level	Warning
4125Code	1292
4126Message	Truncated incorrect time value: '839:59:59.000000'
4127Level	Warning
4128Code	1292
4129Message	Truncated incorrect time value: '839:59:59.0000000'
4130SELECT
4131MICROSECOND(GREATEST('839:59:59', TIME'00:00:00')) AS ci,
4132MICROSECOND(GREATEST('839:59:59.0', TIME'00:00:00')) AS c1,
4133MICROSECOND(GREATEST('839:59:59.00', TIME'00:00:00')) AS c2,
4134MICROSECOND(GREATEST('839:59:59.000', TIME'00:00:00')) AS c3,
4135MICROSECOND(GREATEST('839:59:59.0000', TIME'00:00:00')) AS c4,
4136MICROSECOND(GREATEST('839:59:59.00000', TIME'00:00:00')) AS c5,
4137MICROSECOND(GREATEST('839:59:59.000000', TIME'00:00:00')) AS c6,
4138MICROSECOND(GREATEST('839:59:59.0000000', TIME'00:00:00')) AS c7;
4139ci	0
4140c1	900000
4141c2	990000
4142c3	999000
4143c4	999900
4144c5	999990
4145c6	999999
4146c7	999999
4147Warnings:
4148Level	Warning
4149Code	1292
4150Message	Truncated incorrect time value: '839:59:59'
4151Level	Warning
4152Code	1292
4153Message	Truncated incorrect time value: '839:59:59.0'
4154Level	Warning
4155Code	1292
4156Message	Truncated incorrect time value: '839:59:59.00'
4157Level	Warning
4158Code	1292
4159Message	Truncated incorrect time value: '839:59:59.000'
4160Level	Warning
4161Code	1292
4162Message	Truncated incorrect time value: '839:59:59.0000'
4163Level	Warning
4164Code	1292
4165Message	Truncated incorrect time value: '839:59:59.00000'
4166Level	Warning
4167Code	1292
4168Message	Truncated incorrect time value: '839:59:59.000000'
4169Level	Warning
4170Code	1292
4171Message	Truncated incorrect time value: '839:59:59.0000000'
4172SELECT
4173CAST(GREATEST('839:59:59', TIME'00:00:00') AS SIGNED) AS ci,
4174CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
4175CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
4176CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
4177CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
4178CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
4179CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
4180CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
4181CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
4182ci	8385959
4183c0	8385959
4184c1	8385959.0
4185c2	8385959.00
4186c3	8385959.000
4187c4	8385959.0000
4188c5	8385959.00000
4189c6	8385959.000000
4190c7	8385959.0000000
4191Warnings:
4192Level	Warning
4193Code	1292
4194Message	Truncated incorrect time value: '839:59:59'
4195Level	Warning
4196Code	1292
4197Message	Truncated incorrect time value: '839:59:59'
4198Level	Warning
4199Code	1292
4200Message	Truncated incorrect time value: '839:59:59'
4201Level	Warning
4202Code	1292
4203Message	Truncated incorrect time value: '839:59:59'
4204Level	Warning
4205Code	1292
4206Message	Truncated incorrect time value: '839:59:59'
4207Level	Warning
4208Code	1292
4209Message	Truncated incorrect time value: '839:59:59'
4210Level	Warning
4211Code	1292
4212Message	Truncated incorrect time value: '839:59:59'
4213Level	Warning
4214Code	1292
4215Message	Truncated incorrect time value: '839:59:59'
4216Level	Warning
4217Code	1292
4218Message	Truncated incorrect time value: '839:59:59'
4219SELECT
4220GREATEST('839:59:59', TIME'00:00:00') AS ci,
4221GREATEST('839:59:59', TIME'00:00:00')+0 AS c0,
4222GREATEST('839:59:59', TIME'00:00:00')+0.0 AS c1,
4223GREATEST('839:59:59', TIME'00:00:00')+0.00 AS c2,
4224GREATEST('839:59:59', TIME'00:00:00')+0.000 AS c3,
4225GREATEST('839:59:59', TIME'00:00:00')+0.0000 AS c4,
4226GREATEST('839:59:59', TIME'00:00:00')+0.00000 AS c5,
4227GREATEST('839:59:59', TIME'00:00:00')+0.000000 AS c6,
4228GREATEST('839:59:59', TIME'00:00:00')+0.0000000 AS c7;
4229ci	838:59:59
4230c0	8385959
4231c1	8385959.0
4232c2	8385959.00
4233c3	8385959.000
4234c4	8385959.0000
4235c5	8385959.00000
4236c6	8385959.000000
4237c7	8385959.0000000
4238Warnings:
4239Level	Warning
4240Code	1292
4241Message	Truncated incorrect time value: '839:59:59'
4242Level	Warning
4243Code	1292
4244Message	Truncated incorrect time value: '839:59:59'
4245Level	Warning
4246Code	1292
4247Message	Truncated incorrect time value: '839:59:59'
4248Level	Warning
4249Code	1292
4250Message	Truncated incorrect time value: '839:59:59'
4251Level	Warning
4252Code	1292
4253Message	Truncated incorrect time value: '839:59:59'
4254Level	Warning
4255Code	1292
4256Message	Truncated incorrect time value: '839:59:59'
4257Level	Warning
4258Code	1292
4259Message	Truncated incorrect time value: '839:59:59'
4260Level	Warning
4261Code	1292
4262Message	Truncated incorrect time value: '839:59:59'
4263Level	Warning
4264Code	1292
4265Message	Truncated incorrect time value: '839:59:59'
4266# ADDTIME(datetime, decimal)
4267SELECT
4268ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS c0,
4269ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0) AS c1,
4270ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00) AS c2,
4271ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000) AS c3,
4272ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000) AS c4,
4273ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000) AS c5,
4274ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000) AS c6,
4275ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000) AS c7;
4276c0	2001-02-04 23:59:59
4277c1	2001-02-04 23:59:59.0
4278c2	2001-02-04 23:59:59.00
4279c3	2001-02-04 23:59:59.000
4280c4	2001-02-04 23:59:59.0000
4281c5	2001-02-04 23:59:59.00000
4282c6	2001-02-04 23:59:59.000000
4283c7	2001-02-04 23:59:59.000000
4284Warnings:
4285Level	Note
4286Code	1292
4287Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4288SELECT
4289MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)) AS c0,
4290MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0)) AS c1,
4291MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00)) AS c2,
4292MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000)) AS c3,
4293MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000)) AS c4,
4294MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000)) AS c5,
4295MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000)) AS c6,
4296MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000)) AS c7;
4297c0	0
4298c1	0
4299c2	0
4300c3	0
4301c4	0
4302c5	0
4303c6	0
4304c7	0
4305Warnings:
4306Level	Note
4307Code	1292
4308Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4309SELECT
4310CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS SIGNED) AS ci,
4311CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
4312CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
4313CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
4314CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
4315CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
4316CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
4317CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
4318CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
4319ci	20010204235959
4320c0	20010204235959
4321c1	20010204235959.0
4322c2	20010204235959.00
4323c3	20010204235959.000
4324c4	20010204235959.0000
4325c5	20010204235959.00000
4326c6	20010204235959.000000
4327c7	20010204235959.0000000
4328SELECT
4329ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS ci,
4330ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0 AS c0,
4331ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0 AS c1,
4332ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00 AS c2,
4333ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000 AS c3,
4334ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000 AS c4,
4335ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00000 AS c5,
4336ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000000 AS c6,
4337ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000000 AS c7;
4338ci	2001-02-04 23:59:59
4339c0	20010204235959
4340c1	20010204235959.0
4341c2	20010204235959.00
4342c3	20010204235959.000
4343c4	20010204235959.0000
4344c5	20010204235959.00000
4345c6	20010204235959.000000
4346c7	20010204235959.0000000
4347# ADDTIME(datetime, string)
4348SELECT
4349ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS c0,
4350ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0') AS c1,
4351ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00') AS c2,
4352ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000') AS c3,
4353ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000') AS c4,
4354ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000') AS c5,
4355ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000') AS c6,
4356ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000') AS c7;
4357c0	2001-02-04 23:59:59
4358c1	2001-02-04 23:59:59.0
4359c2	2001-02-04 23:59:59.00
4360c3	2001-02-04 23:59:59.000
4361c4	2001-02-04 23:59:59.0000
4362c5	2001-02-04 23:59:59.00000
4363c6	2001-02-04 23:59:59.000000
4364c7	2001-02-04 23:59:59.000000
4365Warnings:
4366Level	Note
4367Code	1292
4368Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
4369SELECT
4370MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')) AS c0,
4371MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0')) AS c1,
4372MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00')) AS c2,
4373MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000')) AS c3,
4374MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000')) AS c4,
4375MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000')) AS c5,
4376MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000')) AS c6,
4377MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000')) AS c7;
4378c0	0
4379c1	0
4380c2	0
4381c3	0
4382c4	0
4383c5	0
4384c6	0
4385c7	0
4386Warnings:
4387Level	Note
4388Code	1292
4389Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
4390SELECT
4391CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS SIGNED) AS ci,
4392CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
4393CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
4394CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
4395CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
4396CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
4397CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
4398CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
4399CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
4400ci	20010204235959
4401c0	20010204235959
4402c1	20010204235959.0
4403c2	20010204235959.00
4404c3	20010204235959.000
4405c4	20010204235959.0000
4406c5	20010204235959.00000
4407c6	20010204235959.000000
4408c7	20010204235959.0000000
4409SELECT
4410ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS ci,
4411ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0 AS c0,
4412ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0 AS c1,
4413ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00 AS c2,
4414ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000 AS c3,
4415ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000 AS c4,
4416ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00000 AS c5,
4417ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000000 AS c6,
4418ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000000 AS c7;
4419ci	2001-02-04 23:59:59
4420c0	20010204235959
4421c1	20010204235959.0
4422c2	20010204235959.00
4423c3	20010204235959.000
4424c4	20010204235959.0000
4425c5	20010204235959.00000
4426c6	20010204235959.000000
4427c7	20010204235959.0000000
4428# ADDTIME(time, decimal)
4429SELECT
4430ADDTIME(TIME'00:00:00', 8395959) AS c0,
4431ADDTIME(TIME'00:00:00', 8395959.0) AS c1,
4432ADDTIME(TIME'00:00:00', 8395959.00) AS c2,
4433ADDTIME(TIME'00:00:00', 8395959.000) AS c3,
4434ADDTIME(TIME'00:00:00', 8395959.0000) AS c4,
4435ADDTIME(TIME'00:00:00', 8395959.00000) AS c5,
4436ADDTIME(TIME'00:00:00', 8395959.000000) AS c6,
4437ADDTIME(TIME'00:00:00', 8395959.0000000) AS c7;
4438c0	838:59:59
4439c1	838:59:59.9
4440c2	838:59:59.99
4441c3	838:59:59.999
4442c4	838:59:59.9999
4443c5	838:59:59.99999
4444c6	838:59:59.999999
4445c7	838:59:59.999999
4446Warnings:
4447Level	Warning
4448Code	1292
4449Message	Truncated incorrect time value: '839:59:59'
4450Level	Warning
4451Code	1292
4452Message	Truncated incorrect time value: '839:59:59'
4453Level	Warning
4454Code	1292
4455Message	Truncated incorrect time value: '839:59:59'
4456Level	Warning
4457Code	1292
4458Message	Truncated incorrect time value: '839:59:59'
4459Level	Warning
4460Code	1292
4461Message	Truncated incorrect time value: '839:59:59'
4462Level	Warning
4463Code	1292
4464Message	Truncated incorrect time value: '839:59:59'
4465Level	Warning
4466Code	1292
4467Message	Truncated incorrect time value: '839:59:59'
4468Level	Note
4469Code	1292
4470Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4471Level	Warning
4472Code	1292
4473Message	Truncated incorrect time value: '839:59:59'
4474SELECT
4475MICROSECOND(ADDTIME(TIME'00:00:00', 8395959)) AS c0,
4476MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0)) AS c1,
4477MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00)) AS c2,
4478MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000)) AS c3,
4479MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000)) AS c4,
4480MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00000)) AS c5,
4481MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000000)) AS c6,
4482MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000000)) AS c7;
4483c0	0
4484c1	900000
4485c2	990000
4486c3	999000
4487c4	999900
4488c5	999990
4489c6	999999
4490c7	999999
4491Warnings:
4492Level	Warning
4493Code	1292
4494Message	Truncated incorrect time value: '839:59:59'
4495Level	Warning
4496Code	1292
4497Message	Truncated incorrect time value: '839:59:59'
4498Level	Warning
4499Code	1292
4500Message	Truncated incorrect time value: '839:59:59'
4501Level	Warning
4502Code	1292
4503Message	Truncated incorrect time value: '839:59:59'
4504Level	Warning
4505Code	1292
4506Message	Truncated incorrect time value: '839:59:59'
4507Level	Warning
4508Code	1292
4509Message	Truncated incorrect time value: '839:59:59'
4510Level	Warning
4511Code	1292
4512Message	Truncated incorrect time value: '839:59:59'
4513Level	Note
4514Code	1292
4515Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4516Level	Warning
4517Code	1292
4518Message	Truncated incorrect time value: '839:59:59'
4519SELECT
4520CAST(ADDTIME(TIME'00:00:00', 8395959) AS SIGNED) AS ci,
4521CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
4522CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
4523CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
4524CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
4525CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
4526CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
4527CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
4528CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
4529ci	8385959
4530c0	8385959
4531c1	8385959.0
4532c2	8385959.00
4533c3	8385959.000
4534c4	8385959.0000
4535c5	8385959.00000
4536c6	8385959.000000
4537c7	8385959.0000000
4538Warnings:
4539Level	Warning
4540Code	1292
4541Message	Truncated incorrect time value: '839:59:59'
4542Level	Warning
4543Code	1292
4544Message	Truncated incorrect time value: '839:59:59'
4545Level	Warning
4546Code	1292
4547Message	Truncated incorrect time value: '839:59:59'
4548Level	Warning
4549Code	1292
4550Message	Truncated incorrect time value: '839:59:59'
4551Level	Warning
4552Code	1292
4553Message	Truncated incorrect time value: '839:59:59'
4554Level	Warning
4555Code	1292
4556Message	Truncated incorrect time value: '839:59:59'
4557Level	Warning
4558Code	1292
4559Message	Truncated incorrect time value: '839:59:59'
4560Level	Warning
4561Code	1292
4562Message	Truncated incorrect time value: '839:59:59'
4563Level	Warning
4564Code	1292
4565Message	Truncated incorrect time value: '839:59:59'
4566SELECT
4567ADDTIME(TIME'00:00:00', 8395959) AS ci,
4568ADDTIME(TIME'00:00:00', 8395959)+0 AS c0,
4569ADDTIME(TIME'00:00:00', 8395959)+0.0 AS c1,
4570ADDTIME(TIME'00:00:00', 8395959)+0.00 AS c2,
4571ADDTIME(TIME'00:00:00', 8395959)+0.000 AS c3,
4572ADDTIME(TIME'00:00:00', 8395959)+0.0000 AS c4,
4573ADDTIME(TIME'00:00:00', 8395959)+0.00000 AS c5,
4574ADDTIME(TIME'00:00:00', 8395959)+0.000000 AS c6,
4575ADDTIME(TIME'00:00:00', 8395959)+0.0000000 AS c7;
4576ci	838:59:59
4577c0	8385959
4578c1	8385959.0
4579c2	8385959.00
4580c3	8385959.000
4581c4	8385959.0000
4582c5	8385959.00000
4583c6	8385959.000000
4584c7	8385959.0000000
4585Warnings:
4586Level	Warning
4587Code	1292
4588Message	Truncated incorrect time value: '839:59:59'
4589Level	Warning
4590Code	1292
4591Message	Truncated incorrect time value: '839:59:59'
4592Level	Warning
4593Code	1292
4594Message	Truncated incorrect time value: '839:59:59'
4595Level	Warning
4596Code	1292
4597Message	Truncated incorrect time value: '839:59:59'
4598Level	Warning
4599Code	1292
4600Message	Truncated incorrect time value: '839:59:59'
4601Level	Warning
4602Code	1292
4603Message	Truncated incorrect time value: '839:59:59'
4604Level	Warning
4605Code	1292
4606Message	Truncated incorrect time value: '839:59:59'
4607Level	Warning
4608Code	1292
4609Message	Truncated incorrect time value: '839:59:59'
4610Level	Warning
4611Code	1292
4612Message	Truncated incorrect time value: '839:59:59'
4613# ADDTIME(time,string)
4614SELECT
4615ADDTIME(TIME'00:00:00', '839:59:59') AS c0,
4616ADDTIME(TIME'00:00:00', '839:59:59.0') AS c1,
4617ADDTIME(TIME'00:00:00', '839:59:59.00') AS c2,
4618ADDTIME(TIME'00:00:00', '839:59:59.000') AS c3,
4619ADDTIME(TIME'00:00:00', '839:59:59.0000') AS c4,
4620ADDTIME(TIME'00:00:00', '839:59:59.00000') AS c5,
4621ADDTIME(TIME'00:00:00', '839:59:59.000000') AS c6,
4622ADDTIME(TIME'00:00:00', '839:59:59.0000000') AS c7;
4623c0	838:59:59
4624c1	838:59:59.9
4625c2	838:59:59.99
4626c3	838:59:59.999
4627c4	838:59:59.9999
4628c5	838:59:59.99999
4629c6	838:59:59.999999
4630c7	838:59:59.999999
4631Warnings:
4632Level	Warning
4633Code	1292
4634Message	Truncated incorrect time value: '839:59:59'
4635Level	Warning
4636Code	1292
4637Message	Truncated incorrect time value: '839:59:59'
4638Level	Warning
4639Code	1292
4640Message	Truncated incorrect time value: '839:59:59'
4641Level	Warning
4642Code	1292
4643Message	Truncated incorrect time value: '839:59:59'
4644Level	Warning
4645Code	1292
4646Message	Truncated incorrect time value: '839:59:59'
4647Level	Warning
4648Code	1292
4649Message	Truncated incorrect time value: '839:59:59'
4650Level	Warning
4651Code	1292
4652Message	Truncated incorrect time value: '839:59:59'
4653Level	Note
4654Code	1292
4655Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
4656Level	Warning
4657Code	1292
4658Message	Truncated incorrect time value: '839:59:59'
4659SELECT
4660MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59')) AS c0,
4661MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0')) AS c1,
4662MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00')) AS c2,
4663MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000')) AS c3,
4664MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000')) AS c4,
4665MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00000')) AS c5,
4666MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000000')) AS c6,
4667MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000000')) AS c7;
4668c0	0
4669c1	900000
4670c2	990000
4671c3	999000
4672c4	999900
4673c5	999990
4674c6	999999
4675c7	999999
4676Warnings:
4677Level	Warning
4678Code	1292
4679Message	Truncated incorrect time value: '839:59:59'
4680Level	Warning
4681Code	1292
4682Message	Truncated incorrect time value: '839:59:59'
4683Level	Warning
4684Code	1292
4685Message	Truncated incorrect time value: '839:59:59'
4686Level	Warning
4687Code	1292
4688Message	Truncated incorrect time value: '839:59:59'
4689Level	Warning
4690Code	1292
4691Message	Truncated incorrect time value: '839:59:59'
4692Level	Warning
4693Code	1292
4694Message	Truncated incorrect time value: '839:59:59'
4695Level	Warning
4696Code	1292
4697Message	Truncated incorrect time value: '839:59:59'
4698Level	Note
4699Code	1292
4700Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
4701Level	Warning
4702Code	1292
4703Message	Truncated incorrect time value: '839:59:59'
4704SELECT
4705CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS SIGNED) AS ci,
4706CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
4707CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
4708CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
4709CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
4710CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
4711CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
4712CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
4713CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
4714ci	8385959
4715c0	8385959
4716c1	8385959.0
4717c2	8385959.00
4718c3	8385959.000
4719c4	8385959.0000
4720c5	8385959.00000
4721c6	8385959.000000
4722c7	8385959.0000000
4723Warnings:
4724Level	Warning
4725Code	1292
4726Message	Truncated incorrect time value: '839:59:59'
4727Level	Warning
4728Code	1292
4729Message	Truncated incorrect time value: '839:59:59'
4730Level	Warning
4731Code	1292
4732Message	Truncated incorrect time value: '839:59:59'
4733Level	Warning
4734Code	1292
4735Message	Truncated incorrect time value: '839:59:59'
4736Level	Warning
4737Code	1292
4738Message	Truncated incorrect time value: '839:59:59'
4739Level	Warning
4740Code	1292
4741Message	Truncated incorrect time value: '839:59:59'
4742Level	Warning
4743Code	1292
4744Message	Truncated incorrect time value: '839:59:59'
4745Level	Warning
4746Code	1292
4747Message	Truncated incorrect time value: '839:59:59'
4748Level	Warning
4749Code	1292
4750Message	Truncated incorrect time value: '839:59:59'
4751SELECT
4752ADDTIME(TIME'00:00:00', '839:59:59') AS ci,
4753ADDTIME(TIME'00:00:00', '839:59:59')+0 AS c0,
4754ADDTIME(TIME'00:00:00', '839:59:59')+0.0 AS c1,
4755ADDTIME(TIME'00:00:00', '839:59:59')+0.00 AS c2,
4756ADDTIME(TIME'00:00:00', '839:59:59')+0.000 AS c3,
4757ADDTIME(TIME'00:00:00', '839:59:59')+0.0000 AS c4,
4758ADDTIME(TIME'00:00:00', '839:59:59')+0.00000 AS c5,
4759ADDTIME(TIME'00:00:00', '839:59:59')+0.000000 AS c6,
4760ADDTIME(TIME'00:00:00', '839:59:59')+0.0000000 AS c7;
4761ci	838:59:59
4762c0	8385959
4763c1	8385959.0
4764c2	8385959.00
4765c3	8385959.000
4766c4	8385959.0000
4767c5	8385959.00000
4768c6	8385959.000000
4769c7	8385959.0000000
4770Warnings:
4771Level	Warning
4772Code	1292
4773Message	Truncated incorrect time value: '839:59:59'
4774Level	Warning
4775Code	1292
4776Message	Truncated incorrect time value: '839:59:59'
4777Level	Warning
4778Code	1292
4779Message	Truncated incorrect time value: '839:59:59'
4780Level	Warning
4781Code	1292
4782Message	Truncated incorrect time value: '839:59:59'
4783Level	Warning
4784Code	1292
4785Message	Truncated incorrect time value: '839:59:59'
4786Level	Warning
4787Code	1292
4788Message	Truncated incorrect time value: '839:59:59'
4789Level	Warning
4790Code	1292
4791Message	Truncated incorrect time value: '839:59:59'
4792Level	Warning
4793Code	1292
4794Message	Truncated incorrect time value: '839:59:59'
4795Level	Warning
4796Code	1292
4797Message	Truncated incorrect time value: '839:59:59'
4798# ADDTIME(int,int)
4799SELECT
4800ADDTIME(0, 8395959) AS c,
4801MICROSECOND(ADDTIME(0, 8395959)) AS cm,
4802CAST(ADDTIME(0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
4803CAST(ADDTIME(0, 8395959) AS DECIMAL(30,0)) AS cd300;
4804c	838:59:59
4805cm	0
4806cs_fixme_mdev_17384	838
4807cd300	8385959
4808Warnings:
4809Level	Warning
4810Code	1292
4811Message	Truncated incorrect time value: '839:59:59'
4812Level	Warning
4813Code	1292
4814Message	Truncated incorrect time value: '839:59:59'
4815Level	Warning
4816Code	1292
4817Message	Truncated incorrect time value: '839:59:59'
4818Level	Warning
4819Code	1292
4820Message	Truncated incorrect INTEGER value: '838:59:59'
4821Level	Warning
4822Code	1292
4823Message	Truncated incorrect time value: '839:59:59'
4824SELECT
4825ADDTIME(20010101000000, 8395959) AS c,
4826MICROSECOND(ADDTIME(20010101000000, 8395959)) AS cm,
4827CAST(ADDTIME(20010101000000, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
4828CAST(ADDTIME(20010101000000, 8395959) AS DECIMAL(30,0)) AS cd300;
4829c	2001-02-04 23:59:59
4830cm	0
4831cs_fixme_mdev_17384	2001
4832cd300	20010204235959
4833Warnings:
4834Level	Warning
4835Code	1292
4836Message	Truncated incorrect INTEGER value: '2001-02-04 23:59:59'
4837# ADDTIME(decimal,int)
4838# 8385960 in cd300 is correct: addtime returns '838:59:59.9'
4839# which is further *rounded* to a decimals(30,0)
4840SELECT
4841ADDTIME(0.0, 8395959) AS c,
4842MICROSECOND(ADDTIME(0.0, 8395959)) AS cm,
4843CAST(ADDTIME(0.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
4844CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS cd300;
4845c	838:59:59.9
4846cm	900000
4847cs_fixme_mdev_17384	838
4848cd300	8385960
4849Warnings:
4850Level	Warning
4851Code	1292
4852Message	Truncated incorrect time value: '839:59:59'
4853Level	Warning
4854Code	1292
4855Message	Truncated incorrect time value: '839:59:59'
4856Level	Warning
4857Code	1292
4858Message	Truncated incorrect time value: '839:59:59'
4859Level	Warning
4860Code	1292
4861Message	Truncated incorrect INTEGER value: '838:59:59.9'
4862Level	Warning
4863Code	1292
4864Message	Truncated incorrect time value: '839:59:59'
4865SELECT
4866ADDTIME(20010101000000.0, 8395959) AS c,
4867MICROSECOND(ADDTIME(20010101000000.0, 8395959)) AS cm,
4868CAST(ADDTIME(20010101000000.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
4869CAST(ADDTIME(20010101000000.0, 8395959) AS DECIMAL(30,0)) AS cd300;
4870c	2001-02-04 23:59:59.0
4871cm	0
4872cs_fixme_mdev_17384	2001
4873cd300	20010204235959
4874Warnings:
4875Level	Warning
4876Code	1292
4877Message	Truncated incorrect INTEGER value: '2001-02-04 23:59:59.0'
4878# ADDTIME(decimal,decimal)
4879SELECT
4880ADDTIME(0.0, 8395959.0) AS c1,
4881ADDTIME(0.0, 8395959.00) AS c2,
4882ADDTIME(0.0, 8395959.000) AS c3,
4883ADDTIME(0.0, 8395959.0000) AS c4,
4884ADDTIME(0.0, 8395959.00000) AS c5,
4885ADDTIME(0.0, 8395959.000000) AS c6,
4886ADDTIME(0.0, 8395959.0000000) AS c7;
4887c1	838:59:59.9
4888c2	838:59:59.99
4889c3	838:59:59.999
4890c4	838:59:59.9999
4891c5	838:59:59.99999
4892c6	838:59:59.999999
4893c7	838:59:59.999999
4894Warnings:
4895Level	Warning
4896Code	1292
4897Message	Truncated incorrect time value: '839:59:59'
4898Level	Warning
4899Code	1292
4900Message	Truncated incorrect time value: '839:59:59'
4901Level	Warning
4902Code	1292
4903Message	Truncated incorrect time value: '839:59:59'
4904Level	Warning
4905Code	1292
4906Message	Truncated incorrect time value: '839:59:59'
4907Level	Warning
4908Code	1292
4909Message	Truncated incorrect time value: '839:59:59'
4910Level	Warning
4911Code	1292
4912Message	Truncated incorrect time value: '839:59:59'
4913Level	Note
4914Code	1292
4915Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4916Level	Warning
4917Code	1292
4918Message	Truncated incorrect time value: '839:59:59'
4919SELECT
4920MICROSECOND(ADDTIME(0.0, 8395959.0)) AS c1,
4921MICROSECOND(ADDTIME(0.0, 8395959.00)) AS c2,
4922MICROSECOND(ADDTIME(0.0, 8395959.000)) AS c3,
4923MICROSECOND(ADDTIME(0.0, 8395959.0000)) AS c4,
4924MICROSECOND(ADDTIME(0.0, 8395959.00000)) AS c5,
4925MICROSECOND(ADDTIME(0.0, 8395959.000000)) AS c6,
4926MICROSECOND(ADDTIME(0.0, 8395959.0000000)) AS c7;
4927c1	900000
4928c2	990000
4929c3	999000
4930c4	999900
4931c5	999990
4932c6	999999
4933c7	999999
4934Warnings:
4935Level	Warning
4936Code	1292
4937Message	Truncated incorrect time value: '839:59:59'
4938Level	Warning
4939Code	1292
4940Message	Truncated incorrect time value: '839:59:59'
4941Level	Warning
4942Code	1292
4943Message	Truncated incorrect time value: '839:59:59'
4944Level	Warning
4945Code	1292
4946Message	Truncated incorrect time value: '839:59:59'
4947Level	Warning
4948Code	1292
4949Message	Truncated incorrect time value: '839:59:59'
4950Level	Warning
4951Code	1292
4952Message	Truncated incorrect time value: '839:59:59'
4953Level	Note
4954Code	1292
4955Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
4956Level	Warning
4957Code	1292
4958Message	Truncated incorrect time value: '839:59:59'
4959# 8385960 in c1 is correct: addtime returns '838:59:59.9'
4960# which is further *rounded* to a decimals(30,0)
4961SELECT
4962CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS c0,
4963CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,1)) AS c1,
4964CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,2)) AS c2,
4965CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,3)) AS c3,
4966CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,4)) AS c4,
4967CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,5)) AS c5,
4968CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,6)) AS c6,
4969CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,7)) AS c7;
4970c0	8385960
4971c1	8385959.9
4972c2	8385959.90
4973c3	8385959.900
4974c4	8385959.9000
4975c5	8385959.90000
4976c6	8385959.900000
4977c7	8385959.9000000
4978Warnings:
4979Level	Warning
4980Code	1292
4981Message	Truncated incorrect time value: '839:59:59'
4982Level	Warning
4983Code	1292
4984Message	Truncated incorrect time value: '839:59:59'
4985Level	Warning
4986Code	1292
4987Message	Truncated incorrect time value: '839:59:59'
4988Level	Warning
4989Code	1292
4990Message	Truncated incorrect time value: '839:59:59'
4991Level	Warning
4992Code	1292
4993Message	Truncated incorrect time value: '839:59:59'
4994Level	Warning
4995Code	1292
4996Message	Truncated incorrect time value: '839:59:59'
4997Level	Warning
4998Code	1292
4999Message	Truncated incorrect time value: '839:59:59'
5000Level	Warning
5001Code	1292
5002Message	Truncated incorrect time value: '839:59:59'
5003SELECT
5004ADDTIME(0.0, 8395959)+0 AS c0,
5005ADDTIME(0.0, 8395959)+0.0 AS c1,
5006ADDTIME(0.0, 8395959)+0.00 AS c2,
5007ADDTIME(0.0, 8395959)+0.000 AS c3,
5008ADDTIME(0.0, 8395959)+0.0000 AS c4,
5009ADDTIME(0.0, 8395959)+0.00000 AS c5,
5010ADDTIME(0.0, 8395959)+0.000000 AS c6,
5011ADDTIME(0.0, 8395959)+0.0000000 AS c7;
5012c0	8385959.9
5013c1	8385959.9
5014c2	8385959.90
5015c3	8385959.900
5016c4	8385959.9000
5017c5	8385959.90000
5018c6	8385959.900000
5019c7	8385959.9000000
5020Warnings:
5021Level	Warning
5022Code	1292
5023Message	Truncated incorrect time value: '839:59:59'
5024Level	Warning
5025Code	1292
5026Message	Truncated incorrect time value: '839:59:59'
5027Level	Warning
5028Code	1292
5029Message	Truncated incorrect time value: '839:59:59'
5030Level	Warning
5031Code	1292
5032Message	Truncated incorrect time value: '839:59:59'
5033Level	Warning
5034Code	1292
5035Message	Truncated incorrect time value: '839:59:59'
5036Level	Warning
5037Code	1292
5038Message	Truncated incorrect time value: '839:59:59'
5039Level	Warning
5040Code	1292
5041Message	Truncated incorrect time value: '839:59:59'
5042Level	Warning
5043Code	1292
5044Message	Truncated incorrect time value: '839:59:59'
5045# TIMESTAMP(string,decimal)
5046SELECT
5047TIMESTAMP('2001-01-01', 8395959) AS ci,
5048TIMESTAMP('2001-01-01', 8395959.0) AS c1,
5049TIMESTAMP('2001-01-01', 8395959.00) AS c2,
5050TIMESTAMP('2001-01-01', 8395959.000) AS c3,
5051TIMESTAMP('2001-01-01', 8395959.0000) AS c4,
5052TIMESTAMP('2001-01-01', 8395959.00000) AS c5,
5053TIMESTAMP('2001-01-01', 8395959.000000) AS c6,
5054TIMESTAMP('2001-01-01', 8395959.0000000) AS c7;
5055ci	2001-02-04 23:59:59
5056c1	2001-02-04 23:59:59.0
5057c2	2001-02-04 23:59:59.00
5058c3	2001-02-04 23:59:59.000
5059c4	2001-02-04 23:59:59.0000
5060c5	2001-02-04 23:59:59.00000
5061c6	2001-02-04 23:59:59.000000
5062c7	2001-02-04 23:59:59.000000
5063Warnings:
5064Level	Note
5065Code	1292
5066Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
5067SELECT
5068MICROSECOND(TIMESTAMP('2001-01-01', 8395959)) AS ci,
5069MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0)) AS c1,
5070MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00)) AS c2,
5071MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000)) AS c3,
5072MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000)) AS c4,
5073MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00000)) AS c5,
5074MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000000)) AS c6,
5075MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000000)) AS c7;
5076ci	0
5077c1	0
5078c2	0
5079c3	0
5080c4	0
5081c5	0
5082c6	0
5083c7	0
5084Warnings:
5085Level	Note
5086Code	1292
5087Message	Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
5088SELECT
5089CAST(TIMESTAMP('2001-01-01', 8395959) AS SIGNED) AS ci,
5090CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,0)) AS c0,
5091CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,1)) AS c1,
5092CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,2)) AS c2,
5093CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,3)) AS c3,
5094CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,4)) AS c4,
5095CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,5)) AS c5,
5096CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,6)) AS c6;
5097ci	20010204235959
5098c0	20010204235959
5099c1	20010204235959.0
5100c2	20010204235959.00
5101c3	20010204235959.000
5102c4	20010204235959.0000
5103c5	20010204235959.00000
5104c6	20010204235959.000000
5105SELECT
5106TIMESTAMP('2001-01-01', 8395959) AS ci,
5107TIMESTAMP('2001-01-01', 8395959)+0 AS c0,
5108TIMESTAMP('2001-01-01', 8395959)+0.0 AS c1,
5109TIMESTAMP('2001-01-01', 8395959)+0.00 AS c2,
5110TIMESTAMP('2001-01-01', 8395959)+0.000 AS c3,
5111TIMESTAMP('2001-01-01', 8395959)+0.0000 AS c4,
5112TIMESTAMP('2001-01-01', 8395959)+0.00000 AS c5,
5113TIMESTAMP('2001-01-01', 8395959)+0.000000 AS c6,
5114TIMESTAMP('2001-01-01', 8395959)+0.0000000 AS c7;
5115ci	2001-02-04 23:59:59
5116c0	20010204235959
5117c1	20010204235959.0
5118c2	20010204235959.00
5119c3	20010204235959.000
5120c4	20010204235959.0000
5121c5	20010204235959.00000
5122c6	20010204235959.000000
5123c7	20010204235959.0000000
5124# TIMESTAMP(string,string)
5125SELECT
5126TIMESTAMP('2001-01-01', '839:59:59') AS ci,
5127TIMESTAMP('2001-01-01', '839:59:59.0') AS c1,
5128TIMESTAMP('2001-01-01', '839:59:59.00') AS c2,
5129TIMESTAMP('2001-01-01', '839:59:59.000') AS c3,
5130TIMESTAMP('2001-01-01', '839:59:59.0000') AS c4,
5131TIMESTAMP('2001-01-01', '839:59:59.00000') AS c5,
5132TIMESTAMP('2001-01-01', '839:59:59.000000') AS c6,
5133TIMESTAMP('2001-01-01', '839:59:59.0000000') AS c7;
5134ci	2001-02-04 23:59:59
5135c1	2001-02-04 23:59:59.0
5136c2	2001-02-04 23:59:59.00
5137c3	2001-02-04 23:59:59.000
5138c4	2001-02-04 23:59:59.0000
5139c5	2001-02-04 23:59:59.00000
5140c6	2001-02-04 23:59:59.000000
5141c7	2001-02-04 23:59:59.000000
5142Warnings:
5143Level	Note
5144Code	1292
5145Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
5146SELECT
5147MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59')) AS ci,
5148MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0')) AS c1,
5149MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00')) AS c2,
5150MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000')) AS c3,
5151MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000')) AS c4,
5152MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00000')) AS c5,
5153MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000000')) AS c6,
5154MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000000')) AS c7;
5155ci	0
5156c1	0
5157c2	0
5158c3	0
5159c4	0
5160c5	0
5161c6	0
5162c7	0
5163Warnings:
5164Level	Note
5165Code	1292
5166Message	Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
5167SELECT
5168CAST(TIMESTAMP('2001-01-01', '839:59:59') AS SIGNED) AS ci,
5169CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,0)) AS c0,
5170CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,1)) AS c1,
5171CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,2)) AS c2,
5172CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,3)) AS c3,
5173CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,4)) AS c4,
5174CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,5)) AS c5,
5175CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,6)) AS c6;
5176ci	20010204235959
5177c0	20010204235959
5178c1	20010204235959.0
5179c2	20010204235959.00
5180c3	20010204235959.000
5181c4	20010204235959.0000
5182c5	20010204235959.00000
5183c6	20010204235959.000000
5184SELECT
5185TIMESTAMP('2001-01-01', '839:59:59') AS ci,
5186TIMESTAMP('2001-01-01', '839:59:59')+0 AS c0,
5187TIMESTAMP('2001-01-01', '839:59:59')+0.0 AS c1,
5188TIMESTAMP('2001-01-01', '839:59:59')+0.00 AS c2,
5189TIMESTAMP('2001-01-01', '839:59:59')+0.000 AS c3,
5190TIMESTAMP('2001-01-01', '839:59:59')+0.0000 AS c4,
5191TIMESTAMP('2001-01-01', '839:59:59')+0.00000 AS c5,
5192TIMESTAMP('2001-01-01', '839:59:59')+0.000000 AS c6,
5193TIMESTAMP('2001-01-01', '839:59:59')+0.0000000 AS c7;
5194ci	2001-02-04 23:59:59
5195c0	20010204235959
5196c1	20010204235959.0
5197c2	20010204235959.00
5198c3	20010204235959.000
5199c4	20010204235959.0000
5200c5	20010204235959.00000
5201c6	20010204235959.000000
5202c7	20010204235959.0000000
5203# Corner cases for TIMESTAMP(timestamp,xxx)
5204# HOUR is outside of supported INTERVAL DAYS TO SECONDS range
5205# Expect NULL with INTERVAL warnings
5206CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
5207INSERT INTO t1 VALUES ('4294967296:00:00', '178956970 16:00:00');
5208INSERT INTO t1 VALUES ('4294967295:59:59', '178956970 15:59:59');
5209INSERT INTO t1 VALUES ('4294967294:59:59', '178956970 14:59:59');
5210INSERT INTO t1 VALUES ('87649416:00:00', '3652059 00:00:00');
5211SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
5212ta	tb
5213NULL	NULL
5214NULL	NULL
5215NULL	NULL
5216NULL	NULL
5217Warnings:
5218Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '4294967296:00:00'
5219Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '178956970 16:00:00'
5220Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5221Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '178956970 15:59:59'
5222Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '4294967294:59:59'
5223Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '178956970 14:59:59'
5224Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '87649416:00:00'
5225Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '3652059 00:00:00'
5226DROP TABLE t1;
5227CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
5228INSERT INTO t1 VALUES ('-4294967296:00:00', '-178956970 16:00:00');
5229INSERT INTO t1 VALUES ('-4294967295:59:59', '-178956970 15:59:59');
5230INSERT INTO t1 VALUES ('-4294967294:59:59', '-178956970 14:59:59');
5231INSERT INTO t1 VALUES ('-87649416:00:00', '-3652059 00:00:00');
5232SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
5233ta	tb
5234NULL	NULL
5235NULL	NULL
5236NULL	NULL
5237NULL	NULL
5238Warnings:
5239Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-4294967296:00:00'
5240Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-178956970 16:00:00'
5241Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-4294967295:59:59'
5242Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-178956970 15:59:59'
5243Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-4294967294:59:59'
5244Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-178956970 14:59:59'
5245Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-87649416:00:00'
5246Warning	1292	Incorrect INTERVAL DAY TO SECOND value: '-3652059 00:00:00'
5247DROP TABLE t1;
5248# HOUR is OK
5249# Expect max or near-max DATETIME value + no INTERVAL warnings
5250CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
5251INSERT INTO t1 VALUES ('87649415:59:59.999999', '3652058 23:59:59.999999');
5252INSERT INTO t1 VALUES ('87649415:59:59', '3652058 23:59:59');
5253SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
5254ta	tb
52559999-12-31 23:59:59.999999	9999-12-31 23:59:59.999999
52569999-12-31 23:59:59.000000	9999-12-31 23:59:59.000000
5257DROP TABLE t1;
5258# HOUR is OK
5259# Expect near '0001-01-01 00:00:00' DATETIME value + no INTERVAL warnings
5260CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
5261INSERT INTO t1 VALUES ('-87649415:59:59.999999', '-3652058 23:59:59.999999');
5262INSERT INTO t1 VALUES ('-87649415:59:59', '-3652058 23:59:59');
5263SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
5264ta	tb
5265NULL	0001-01-01 00:00:00.000000
52660001-01-01 00:00:00.000000	0001-01-01 00:00:00.999999
5267DROP TABLE t1;
5268# HOUR is OK
5269# Expect NULL on datetime arithmetic overflow + no INTERVAL warnings
5270CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
5271INSERT INTO t1 VALUES ('-00:00:00.000001', '-0 00:00:00.000001');
5272SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
5273ta	tb
5274NULL	NULL
5275DROP TABLE t1;
5276# Corner cases for ADDTIME(timestamp,xxx)
5277# HOUR is outside of UINT_MAX32 range
5278# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5279SELECT
5280ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959) AS ci,
5281ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0 AS c0,
5282ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0 AS c1,
5283ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00 AS c2,
5284ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000 AS c3,
5285ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000 AS c4,
5286ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00000 AS c5,
5287ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000000 AS c6,
5288ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000000 AS c7;
5289ci	NULL
5290c0	NULL
5291c1	NULL
5292c2	NULL
5293c3	NULL
5294c4	NULL
5295c5	NULL
5296c6	NULL
5297c7	NULL
5298Warnings:
5299Level	Warning
5300Code	1292
5301Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5302Level	Warning
5303Code	1292
5304Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5305Level	Warning
5306Code	1292
5307Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5308Level	Warning
5309Code	1292
5310Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5311Level	Warning
5312Code	1292
5313Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5314Level	Warning
5315Code	1292
5316Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5317Level	Warning
5318Code	1292
5319Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5320Level	Warning
5321Code	1292
5322Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5323Level	Warning
5324Code	1292
5325Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5326SELECT
5327ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59') AS ci,
5328ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0 AS c0,
5329ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0 AS c1,
5330ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00 AS c2,
5331ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000 AS c3,
5332ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000 AS c4,
5333ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00000 AS c5,
5334ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000000 AS c6,
5335ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000000 AS c7;
5336ci	NULL
5337c0	NULL
5338c1	NULL
5339c2	NULL
5340c3	NULL
5341c4	NULL
5342c5	NULL
5343c6	NULL
5344c7	NULL
5345Warnings:
5346Level	Warning
5347Code	1292
5348Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5349Level	Warning
5350Code	1292
5351Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5352Level	Warning
5353Code	1292
5354Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5355Level	Warning
5356Code	1292
5357Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5358Level	Warning
5359Code	1292
5360Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5361Level	Warning
5362Code	1292
5363Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5364Level	Warning
5365Code	1292
5366Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5367Level	Warning
5368Code	1292
5369Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5370Level	Warning
5371Code	1292
5372Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5373# HOUR UINT_MAX32
5374# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5375SELECT
5376ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959) AS ci,
5377ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0 AS c0,
5378ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0 AS c1,
5379ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00 AS c2,
5380ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000 AS c3,
5381ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000 AS c4,
5382ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00000 AS c5,
5383ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000000 AS c6,
5384ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000000 AS c7;
5385ci	NULL
5386c0	NULL
5387c1	NULL
5388c2	NULL
5389c3	NULL
5390c4	NULL
5391c5	NULL
5392c6	NULL
5393c7	NULL
5394Warnings:
5395Level	Warning
5396Code	1292
5397Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5398Level	Warning
5399Code	1292
5400Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5401Level	Warning
5402Code	1292
5403Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5404Level	Warning
5405Code	1292
5406Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5407Level	Warning
5408Code	1292
5409Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5410Level	Warning
5411Code	1292
5412Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5413Level	Warning
5414Code	1292
5415Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5416Level	Warning
5417Code	1292
5418Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5419Level	Warning
5420Code	1292
5421Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5422SELECT
5423ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59') AS ci,
5424ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0 AS c0,
5425ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0 AS c1,
5426ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00 AS c2,
5427ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000 AS c3,
5428ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000 AS c4,
5429ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00000 AS c5,
5430ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000000 AS c6,
5431ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000000 AS c7;
5432ci	NULL
5433c0	NULL
5434c1	NULL
5435c2	NULL
5436c3	NULL
5437c4	NULL
5438c5	NULL
5439c6	NULL
5440c7	NULL
5441Warnings:
5442Level	Warning
5443Code	1292
5444Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5445Level	Warning
5446Code	1292
5447Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5448Level	Warning
5449Code	1292
5450Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5451Level	Warning
5452Code	1292
5453Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5454Level	Warning
5455Code	1292
5456Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5457Level	Warning
5458Code	1292
5459Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5460Level	Warning
5461Code	1292
5462Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5463Level	Warning
5464Code	1292
5465Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5466Level	Warning
5467Code	1292
5468Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5469# HOUR is max_useful_hour()+1
5470# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5471SELECT
5472ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959) AS ci,
5473ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0 AS c0,
5474ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0 AS c1,
5475ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00 AS c2,
5476ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000 AS c3,
5477ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000 AS c4,
5478ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00000 AS c5,
5479ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000000 AS c6,
5480ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000000 AS c7;
5481ci	NULL
5482c0	NULL
5483c1	NULL
5484c2	NULL
5485c3	NULL
5486c4	NULL
5487c5	NULL
5488c6	NULL
5489c7	NULL
5490Warnings:
5491Level	Warning
5492Code	1292
5493Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5494Level	Warning
5495Code	1292
5496Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5497Level	Warning
5498Code	1292
5499Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5500Level	Warning
5501Code	1292
5502Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5503Level	Warning
5504Code	1292
5505Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5506Level	Warning
5507Code	1292
5508Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5509Level	Warning
5510Code	1292
5511Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5512Level	Warning
5513Code	1292
5514Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5515Level	Warning
5516Code	1292
5517Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5518SELECT
5519ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59') AS ci,
5520ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0 AS c0,
5521ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0 AS c1,
5522ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00 AS c2,
5523ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000 AS c3,
5524ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000 AS c4,
5525ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00000 AS c5,
5526ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000000 AS c6,
5527ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000000 AS c7;
5528ci	NULL
5529c0	NULL
5530c1	NULL
5531c2	NULL
5532c3	NULL
5533c4	NULL
5534c5	NULL
5535c6	NULL
5536c7	NULL
5537Warnings:
5538Level	Warning
5539Code	1292
5540Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5541Level	Warning
5542Code	1292
5543Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5544Level	Warning
5545Code	1292
5546Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5547Level	Warning
5548Code	1292
5549Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5550Level	Warning
5551Code	1292
5552Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5553Level	Warning
5554Code	1292
5555Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5556Level	Warning
5557Code	1292
5558Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5559Level	Warning
5560Code	1292
5561Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5562Level	Warning
5563Code	1292
5564Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5565# HOUR is max_useful_hour()
5566# Expect NULL (calc_time_diff overflows ) + no INTERVAL warnings
5567SELECT
5568ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959) AS ci,
5569ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0 AS c0,
5570ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0 AS c1,
5571ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00 AS c2,
5572ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000 AS c3,
5573ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
5574ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
5575ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
5576ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
5577ci	NULL
5578c0	NULL
5579c1	NULL
5580c2	NULL
5581c3	NULL
5582c4	NULL
5583c5	NULL
5584c6	NULL
5585c7	NULL
5586SELECT
5587ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59') AS ci,
5588ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
5589ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
5590ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
5591ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
5592ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
5593ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
5594ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
5595ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
5596ci	NULL
5597c0	NULL
5598c1	NULL
5599c2	NULL
5600c3	NULL
5601c4	NULL
5602c5	NULL
5603c6	NULL
5604c7	NULL
5605# HOUR is max_useful_hour()
5606# Expect non-NULL + no warnings
5607SELECT
5608ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959) AS ci,
5609ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0 AS c0,
5610ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0 AS c1,
5611ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00 AS c2,
5612ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000 AS c3,
5613ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
5614ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
5615ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
5616ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
5617ci	9999-12-31 23:59:59
5618c0	99991231235959
5619c1	99991231235959.0
5620c2	99991231235959.00
5621c3	99991231235959.000
5622c4	99991231235959.0000
5623c5	99991231235959.00000
5624c6	99991231235959.000000
5625c7	99991231235959.0000000
5626SELECT
5627ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59') AS ci,
5628ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
5629ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
5630ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
5631ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
5632ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
5633ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
5634ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
5635ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
5636ci	9999-12-31 23:59:59
5637c0	99991231235959
5638c1	99991231235959.0
5639c2	99991231235959.00
5640c3	99991231235959.000
5641c4	99991231235959.0000
5642c5	99991231235959.00000
5643c6	99991231235959.000000
5644c7	99991231235959.0000000
5645# Corner cases for ADDTIME(time,xxx)
5646# HOUR outside of UINT32 range
5647# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5648SELECT
5649ADDTIME(TIME'00:00:00', 42949672965959) AS ci,
5650ADDTIME(TIME'00:00:00', 42949672965959)+0 AS c0,
5651ADDTIME(TIME'00:00:00', 42949672965959)+0.0 AS c1,
5652ADDTIME(TIME'00:00:00', 42949672965959)+0.00 AS c2,
5653ADDTIME(TIME'00:00:00', 42949672965959)+0.000 AS c3,
5654ADDTIME(TIME'00:00:00', 42949672965959)+0.0000 AS c4,
5655ADDTIME(TIME'00:00:00', 42949672965959)+0.00000 AS c5,
5656ADDTIME(TIME'00:00:00', 42949672965959)+0.000000 AS c6,
5657ADDTIME(TIME'00:00:00', 42949672965959)+0.0000000 AS c7;
5658ci	NULL
5659c0	NULL
5660c1	NULL
5661c2	NULL
5662c3	NULL
5663c4	NULL
5664c5	NULL
5665c6	NULL
5666c7	NULL
5667Warnings:
5668Level	Warning
5669Code	1292
5670Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5671Level	Warning
5672Code	1292
5673Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5674Level	Warning
5675Code	1292
5676Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5677Level	Warning
5678Code	1292
5679Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5680Level	Warning
5681Code	1292
5682Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5683Level	Warning
5684Code	1292
5685Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5686Level	Warning
5687Code	1292
5688Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5689Level	Warning
5690Code	1292
5691Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5692Level	Warning
5693Code	1292
5694Message	Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
5695SELECT
5696ADDTIME(TIME'00:00:00', '4294967296:59:59') AS ci,
5697ADDTIME(TIME'00:00:00', '4294967296:59:59')+0 AS c0,
5698ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0 AS c1,
5699ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00 AS c2,
5700ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000 AS c3,
5701ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000 AS c4,
5702ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00000 AS c5,
5703ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000000 AS c6,
5704ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000000 AS c7;
5705ci	NULL
5706c0	NULL
5707c1	NULL
5708c2	NULL
5709c3	NULL
5710c4	NULL
5711c5	NULL
5712c6	NULL
5713c7	NULL
5714Warnings:
5715Level	Warning
5716Code	1292
5717Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5718Level	Warning
5719Code	1292
5720Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5721Level	Warning
5722Code	1292
5723Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5724Level	Warning
5725Code	1292
5726Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5727Level	Warning
5728Code	1292
5729Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5730Level	Warning
5731Code	1292
5732Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5733Level	Warning
5734Code	1292
5735Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5736Level	Warning
5737Code	1292
5738Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5739Level	Warning
5740Code	1292
5741Message	Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
5742# HOUR is UINT_MAX32 (outside of INTERVAL DAY TO SECOND range)
5743# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5744SELECT
5745ADDTIME(TIME'00:00:00', 42949672955959) AS ci,
5746ADDTIME(TIME'00:00:00', 42949672955959)+0 AS c0,
5747ADDTIME(TIME'00:00:00', 42949672955959)+0.0 AS c1,
5748ADDTIME(TIME'00:00:00', 42949672955959)+0.00 AS c2,
5749ADDTIME(TIME'00:00:00', 42949672955959)+0.000 AS c3,
5750ADDTIME(TIME'00:00:00', 42949672955959)+0.0000 AS c4,
5751ADDTIME(TIME'00:00:00', 42949672955959)+0.00000 AS c5,
5752ADDTIME(TIME'00:00:00', 42949672955959)+0.000000 AS c6,
5753ADDTIME(TIME'00:00:00', 42949672955959)+0.0000000 AS c7;
5754ci	NULL
5755c0	NULL
5756c1	NULL
5757c2	NULL
5758c3	NULL
5759c4	NULL
5760c5	NULL
5761c6	NULL
5762c7	NULL
5763Warnings:
5764Level	Warning
5765Code	1292
5766Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5767Level	Warning
5768Code	1292
5769Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5770Level	Warning
5771Code	1292
5772Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5773Level	Warning
5774Code	1292
5775Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5776Level	Warning
5777Code	1292
5778Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5779Level	Warning
5780Code	1292
5781Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5782Level	Warning
5783Code	1292
5784Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5785Level	Warning
5786Code	1292
5787Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5788Level	Warning
5789Code	1292
5790Message	Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
5791SELECT
5792ADDTIME(TIME'00:00:00', '4294967295:59:59') AS ci,
5793ADDTIME(TIME'00:00:00', '4294967295:59:59')+0 AS c0,
5794ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0 AS c1,
5795ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00 AS c2,
5796ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000 AS c3,
5797ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0000 AS c4,
5798ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00000 AS c5,
5799ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000000 AS c6,
5800ADDTIME(TIME'00:00:00', '4294967295;00:00')+0.0000000 AS c7;
5801ci	NULL
5802c0	NULL
5803c1	NULL
5804c2	NULL
5805c3	NULL
5806c4	NULL
5807c5	NULL
5808c6	NULL
5809c7	NULL
5810Warnings:
5811Level	Warning
5812Code	1292
5813Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5814Level	Warning
5815Code	1292
5816Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5817Level	Warning
5818Code	1292
5819Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5820Level	Warning
5821Code	1292
5822Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5823Level	Warning
5824Code	1292
5825Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5826Level	Warning
5827Code	1292
5828Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5829Level	Warning
5830Code	1292
5831Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5832Level	Warning
5833Code	1292
5834Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
5835Level	Warning
5836Code	1292
5837Message	Incorrect INTERVAL DAY TO SECOND value: '4294967295;00:00'
5838# HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
5839# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5840SELECT
5841ADDTIME(TIME'00:00:00', 876494165959) AS ci,
5842ADDTIME(TIME'00:00:00', 876494165959)+0 AS c0,
5843ADDTIME(TIME'00:00:00', 876494165959)+0.0 AS c1,
5844ADDTIME(TIME'00:00:00', 876494165959)+0.00 AS c2,
5845ADDTIME(TIME'00:00:00', 876494165959)+0.000 AS c3,
5846ADDTIME(TIME'00:00:00', 876494165959)+0.0000 AS c4,
5847ADDTIME(TIME'00:00:00', 876494165959)+0.00000 AS c5,
5848ADDTIME(TIME'00:00:00', 876494165959)+0.000000 AS c6,
5849ADDTIME(TIME'00:00:00', 876494165959)+0.0000000 AS c7;
5850ci	NULL
5851c0	NULL
5852c1	NULL
5853c2	NULL
5854c3	NULL
5855c4	NULL
5856c5	NULL
5857c6	NULL
5858c7	NULL
5859Warnings:
5860Level	Warning
5861Code	1292
5862Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5863Level	Warning
5864Code	1292
5865Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5866Level	Warning
5867Code	1292
5868Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5869Level	Warning
5870Code	1292
5871Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5872Level	Warning
5873Code	1292
5874Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5875Level	Warning
5876Code	1292
5877Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5878Level	Warning
5879Code	1292
5880Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5881Level	Warning
5882Code	1292
5883Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5884Level	Warning
5885Code	1292
5886Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5887SELECT
5888ADDTIME(TIME'00:00:00', '87649416:59:59') AS ci,
5889ADDTIME(TIME'00:00:00', '87649416:59:59')+0 AS c0,
5890ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0 AS c1,
5891ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00 AS c2,
5892ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000 AS c3,
5893ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000 AS c4,
5894ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00000 AS c5,
5895ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000000 AS c6,
5896ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000000 AS c7;
5897ci	NULL
5898c0	NULL
5899c1	NULL
5900c2	NULL
5901c3	NULL
5902c4	NULL
5903c5	NULL
5904c6	NULL
5905c7	NULL
5906Warnings:
5907Level	Warning
5908Code	1292
5909Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5910Level	Warning
5911Code	1292
5912Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5913Level	Warning
5914Code	1292
5915Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5916Level	Warning
5917Code	1292
5918Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5919Level	Warning
5920Code	1292
5921Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5922Level	Warning
5923Code	1292
5924Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5925Level	Warning
5926Code	1292
5927Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5928Level	Warning
5929Code	1292
5930Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5931Level	Warning
5932Code	1292
5933Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5934# HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
5935# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
5936SELECT
5937ADDTIME(TIME'-838:59:59', 876494165959) AS ci,
5938ADDTIME(TIME'-838:59:59.9', 876494165959) AS c1,
5939ADDTIME(TIME'-838:59:59.99', 876494165959) AS c2,
5940ADDTIME(TIME'-838:59:59.999', 876494165959) AS c3,
5941ADDTIME(TIME'-838:59:59.9999', 876494165959) AS c4,
5942ADDTIME(TIME'-838:59:59.99999', 876494165959) AS c5,
5943ADDTIME(TIME'-838:59:59.999999', 876494165959) AS c6;
5944ci	NULL
5945c1	NULL
5946c2	NULL
5947c3	NULL
5948c4	NULL
5949c5	NULL
5950c6	NULL
5951Warnings:
5952Level	Warning
5953Code	1292
5954Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5955Level	Warning
5956Code	1292
5957Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5958Level	Warning
5959Code	1292
5960Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5961Level	Warning
5962Code	1292
5963Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5964Level	Warning
5965Code	1292
5966Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5967Level	Warning
5968Code	1292
5969Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5970Level	Warning
5971Code	1292
5972Message	Incorrect INTERVAL DAY TO SECOND value: '876494165959'
5973SELECT
5974ADDTIME(TIME'-838:59:59', '87649416:59:59') AS ci,
5975ADDTIME(TIME'-838:59:59.9', '87649416:59:59') AS c1,
5976ADDTIME(TIME'-838:59:59.99', '87649416:59:59') AS c2,
5977ADDTIME(TIME'-838:59:59.999', '87649416:59:59') AS c3,
5978ADDTIME(TIME'-838:59:59.9999', '87649416:59:59') AS c4,
5979ADDTIME(TIME'-838:59:59.99999', '87649416:59:59') AS c5,
5980ADDTIME(TIME'-838:59:59.999999', '87649416:59:59') AS c6;
5981ci	NULL
5982c1	NULL
5983c2	NULL
5984c3	NULL
5985c4	NULL
5986c5	NULL
5987c6	NULL
5988Warnings:
5989Level	Warning
5990Code	1292
5991Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5992Level	Warning
5993Code	1292
5994Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5995Level	Warning
5996Code	1292
5997Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
5998Level	Warning
5999Code	1292
6000Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
6001Level	Warning
6002Code	1292
6003Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
6004Level	Warning
6005Code	1292
6006Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
6007Level	Warning
6008Code	1292
6009Message	Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
6010SELECT
6011ADDTIME(TIME'-838:59:59.9999999', '87649416:59:59') AS c7;
6012c7	NULL
6013# HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
6014# Expect max TIME(0) + zero fraction + TIME warnings + no INTEVAL warnings
6015SELECT
6016ADDTIME(TIME'00:00:00', 876494155959) AS ci,
6017ADDTIME(TIME'00:00:00', 876494155959)+0 AS c0,
6018ADDTIME(TIME'00:00:00', 876494155959)+0.0 AS c1,
6019ADDTIME(TIME'00:00:00', 876494155959)+0.00 AS c2,
6020ADDTIME(TIME'00:00:00', 876494155959)+0.000 AS c3,
6021ADDTIME(TIME'00:00:00', 876494155959)+0.0000 AS c4,
6022ADDTIME(TIME'00:00:00', 876494155959)+0.00000 AS c5,
6023ADDTIME(TIME'00:00:00', 876494155959)+0.000000 AS c6,
6024ADDTIME(TIME'00:00:00', 876494155959)+0.0000000 AS c7;
6025ci	838:59:59
6026c0	8385959
6027c1	8385959.0
6028c2	8385959.00
6029c3	8385959.000
6030c4	8385959.0000
6031c5	8385959.00000
6032c6	8385959.000000
6033c7	8385959.0000000
6034Warnings:
6035Level	Warning
6036Code	1292
6037Message	Truncated incorrect time value: '87649415:59:59'
6038Level	Warning
6039Code	1292
6040Message	Truncated incorrect time value: '87649415:59:59'
6041Level	Warning
6042Code	1292
6043Message	Truncated incorrect time value: '87649415:59:59'
6044Level	Warning
6045Code	1292
6046Message	Truncated incorrect time value: '87649415:59:59'
6047Level	Warning
6048Code	1292
6049Message	Truncated incorrect time value: '87649415:59:59'
6050Level	Warning
6051Code	1292
6052Message	Truncated incorrect time value: '87649415:59:59'
6053Level	Warning
6054Code	1292
6055Message	Truncated incorrect time value: '87649415:59:59'
6056Level	Warning
6057Code	1292
6058Message	Truncated incorrect time value: '87649415:59:59'
6059Level	Warning
6060Code	1292
6061Message	Truncated incorrect time value: '87649415:59:59'
6062SELECT
6063ADDTIME(TIME'00:00:00', '87649415:59:59') AS ci,
6064ADDTIME(TIME'00:00:00', '87649415:59:59')+0 AS c0,
6065ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0 AS c1,
6066ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00 AS c2,
6067ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000 AS c3,
6068ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000 AS c4,
6069ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00000 AS c5,
6070ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000000 AS c6,
6071ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000000 AS c7;
6072ci	838:59:59
6073c0	8385959
6074c1	8385959.0
6075c2	8385959.00
6076c3	8385959.000
6077c4	8385959.0000
6078c5	8385959.00000
6079c6	8385959.000000
6080c7	8385959.0000000
6081Warnings:
6082Level	Warning
6083Code	1292
6084Message	Truncated incorrect time value: '87649415:59:59'
6085Level	Warning
6086Code	1292
6087Message	Truncated incorrect time value: '87649415:59:59'
6088Level	Warning
6089Code	1292
6090Message	Truncated incorrect time value: '87649415:59:59'
6091Level	Warning
6092Code	1292
6093Message	Truncated incorrect time value: '87649415:59:59'
6094Level	Warning
6095Code	1292
6096Message	Truncated incorrect time value: '87649415:59:59'
6097Level	Warning
6098Code	1292
6099Message	Truncated incorrect time value: '87649415:59:59'
6100Level	Warning
6101Code	1292
6102Message	Truncated incorrect time value: '87649415:59:59'
6103Level	Warning
6104Code	1292
6105Message	Truncated incorrect time value: '87649415:59:59'
6106Level	Warning
6107Code	1292
6108Message	Truncated incorrect time value: '87649415:59:59'
6109# HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
6110# Expect max TIME(N) + TIME warnings + no INTERVAL warnings
6111SELECT
6112ADDTIME(TIME'-838:59:59', 876494155959) AS ci,
6113ADDTIME(TIME'-838:59:59.9', 876494155959) AS c1,
6114ADDTIME(TIME'-838:59:59.99', 876494155959) AS c2,
6115ADDTIME(TIME'-838:59:59.999', 876494155959) AS c3,
6116ADDTIME(TIME'-838:59:59.9999', 876494155959) AS c4,
6117ADDTIME(TIME'-838:59:59.99999', 876494155959) AS c5,
6118ADDTIME(TIME'-838:59:59.999999', 876494155959) AS c6;
6119ci	838:59:59
6120c1	838:59:59.9
6121c2	838:59:59.99
6122c3	838:59:59.999
6123c4	838:59:59.9999
6124c5	838:59:59.99999
6125c6	838:59:59.999999
6126Warnings:
6127Level	Warning
6128Code	1292
6129Message	Truncated incorrect time value: '87648577:00:00'
6130Level	Warning
6131Code	1292
6132Message	Truncated incorrect time value: '87648576:59:59.100000'
6133Level	Warning
6134Code	1292
6135Message	Truncated incorrect time value: '87648576:59:59.010000'
6136Level	Warning
6137Code	1292
6138Message	Truncated incorrect time value: '87648576:59:59.001000'
6139Level	Warning
6140Code	1292
6141Message	Truncated incorrect time value: '87648576:59:59.000100'
6142Level	Warning
6143Code	1292
6144Message	Truncated incorrect time value: '87648576:59:59.000010'
6145Level	Warning
6146Code	1292
6147Message	Truncated incorrect time value: '87648576:59:59.000001'
6148SELECT
6149ADDTIME(TIME'-838:59:59', '87649415:59:59') AS ci,
6150ADDTIME(TIME'-838:59:59.9', '87649415:59:59') AS c1,
6151ADDTIME(TIME'-838:59:59.99', '87649415:59:59') AS c2,
6152ADDTIME(TIME'-838:59:59.999', '87649415:59:59') AS c3,
6153ADDTIME(TIME'-838:59:59.9999', '87649415:59:59') AS c4,
6154ADDTIME(TIME'-838:59:59.99999', '87649415:59:59') AS c5,
6155ADDTIME(TIME'-838:59:59.999999', '87649415:59:59') AS c6;
6156ci	838:59:59
6157c1	838:59:59.9
6158c2	838:59:59.99
6159c3	838:59:59.999
6160c4	838:59:59.9999
6161c5	838:59:59.99999
6162c6	838:59:59.999999
6163Warnings:
6164Level	Warning
6165Code	1292
6166Message	Truncated incorrect time value: '87648577:00:00'
6167Level	Warning
6168Code	1292
6169Message	Truncated incorrect time value: '87648576:59:59.100000'
6170Level	Warning
6171Code	1292
6172Message	Truncated incorrect time value: '87648576:59:59.010000'
6173Level	Warning
6174Code	1292
6175Message	Truncated incorrect time value: '87648576:59:59.001000'
6176Level	Warning
6177Code	1292
6178Message	Truncated incorrect time value: '87648576:59:59.000100'
6179Level	Warning
6180Code	1292
6181Message	Truncated incorrect time value: '87648576:59:59.000010'
6182Level	Warning
6183Code	1292
6184Message	Truncated incorrect time value: '87648576:59:59.000001'
6185SELECT
6186ADDTIME(TIME'-838:59:59.9999999', '87649415:59:59') AS c7;
6187c7	838:59:59.999999
6188#
6189# MDEV-17400 The result of TIME('42949672965959-01') depends on architecture
6190#
6191SELECT TIME('42949672955959-01'), TIME('42949672965959-01');
6192TIME('42949672955959-01')	TIME('42949672965959-01')
6193NULL	NULL
6194Warnings:
6195Warning	1292	Incorrect time value: '42949672955959-01'
6196Warning	1292	Incorrect time value: '42949672965959-01'
6197SELECT TIME('18446744073709551615-01'),  TIME('18446744073709551616-01');
6198TIME('18446744073709551615-01')	TIME('18446744073709551616-01')
6199NULL	NULL
6200Warnings:
6201Warning	1292	Incorrect time value: '18446744073709551615-01'
6202Warning	1292	Incorrect time value: '18446744073709551616-01'
6203#
6204# MDEV-17434 EXTRACT(DAY FROM negative_time) returns wrong result
6205#
6206CREATE TABLE t1 (a TIME(6));
6207INSERT INTO t1 VALUES ('-24:10:10.10');
6208SELECT
6209EXTRACT(MINUTE FROM a),
6210EXTRACT(SECOND FROM a),
6211EXTRACT(MICROSECOND FROM a),
6212EXTRACT(DAY FROM a),
6213EXTRACT(DAY_HOUR FROM a),
6214EXTRACT(DAY_MINUTE FROM a),
6215EXTRACT(DAY_SECOND FROM a),
6216EXTRACT(DAY_MICROSECOND FROM a)
6217FROM t1;
6218EXTRACT(MINUTE FROM a)	EXTRACT(SECOND FROM a)	EXTRACT(MICROSECOND FROM a)	EXTRACT(DAY FROM a)	EXTRACT(DAY_HOUR FROM a)	EXTRACT(DAY_MINUTE FROM a)	EXTRACT(DAY_SECOND FROM a)	EXTRACT(DAY_MICROSECOND FROM a)
6219-10	-10	-100000	-1	-100	-10010	-1001010	-1001010100000
6220CREATE TABLE t2 AS
6221SELECT
6222EXTRACT(MINUTE FROM a),
6223EXTRACT(SECOND FROM a),
6224EXTRACT(MICROSECOND FROM a),
6225EXTRACT(DAY FROM a),
6226EXTRACT(DAY_HOUR FROM a),
6227EXTRACT(DAY_MINUTE FROM a),
6228EXTRACT(DAY_SECOND FROM a),
6229EXTRACT(DAY_MICROSECOND FROM a)
6230FROM t1;
6231SHOW CREATE TABLE t2;
6232Table	Create Table
6233t2	CREATE TABLE `t2` (
6234  `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL,
6235  `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL,
6236  `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL,
6237  `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
6238  `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
6239  `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
6240  `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
6241  `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL
6242) ENGINE=MyISAM DEFAULT CHARSET=latin1
6243DROP TABLE t2;
6244DROP TABLE t1;
6245#
6246# MDEV-17478 Wrong result for TIME('+100:20:30')
6247#
6248SELECT TIME('+100:20:30');
6249TIME('+100:20:30')
6250100:20:30
6251#
6252# MDEV-17477 Wrong result for TIME('-2001-01-01 10:20:30')
6253#
6254SELECT TIME('-2001-01-01 10:20:30');
6255TIME('-2001-01-01 10:20:30')
6256NULL
6257Warnings:
6258Warning	1292	Incorrect time value: '-2001-01-01 10:20:30'
6259SELECT TIME('2001-01-01') AS c1, TIME('2001-01-01  ') AS c2;
6260c1	c2
626100:20:01	00:20:01
6262Warnings:
6263Warning	1292	Truncated incorrect time value: '2001-01-01'
6264Warning	1292	Truncated incorrect time value: '2001-01-01  '
6265SELECT TIME('0001:01:01 '), TIME('0001:01:01  ');
6266TIME('0001:01:01 ')	TIME('0001:01:01  ')
626701:01:01	01:01:01
6268SELECT TIME('1 2'), TIME('1 2 ');
6269TIME('1 2')	TIME('1 2 ')
627000:00:01	00:00:01
6271Warnings:
6272Warning	1292	Truncated incorrect time value: '1 2'
6273Warning	1292	Truncated incorrect time value: '1 2 '
6274SELECT TIME('2001-01-01T'), TIME('2001-01-01T ');
6275TIME('2001-01-01T')	TIME('2001-01-01T ')
627600:00:00	00:00:00
6277SELECT TIME('901-01-01T1'), TIME('901-01-01T10');
6278TIME('901-01-01T1')	TIME('901-01-01T10')
627901:00:00	10:00:00
6280SELECT TIME('091-01-01T1'), TIME('091-01-01T10');
6281TIME('091-01-01T1')	TIME('091-01-01T10')
628201:00:00	10:00:00
6283SELECT TIME('0001:01:01x'), TIME('0001:01:01xx');
6284TIME('0001:01:01x')	TIME('0001:01:01xx')
628501:01:01	01:01:01
6286Warnings:
6287Warning	1292	Truncated incorrect time value: '0001:01:01x'
6288Warning	1292	Truncated incorrect time value: '0001:01:01xx'
6289SELECT TIME('0001:01:01.'), TIME('0001:01:01..');
6290TIME('0001:01:01.')	TIME('0001:01:01..')
629101:01:01	01:01:01
6292Warnings:
6293Warning	1292	Truncated incorrect time value: '0001:01:01..'
6294SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
6295TIME('0001:01:01-')	TIME('0001:01:01--')
629601:01:01	01:01:01
6297Warnings:
6298Warning	1292	Truncated incorrect time value: '0001:01:01-'
6299Warning	1292	Truncated incorrect time value: '0001:01:01--'
6300SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
6301TIME('0001:01:01-')	TIME('0001:01:01--')
630201:01:01	01:01:01
6303Warnings:
6304Warning	1292	Truncated incorrect time value: '0001:01:01-'
6305Warning	1292	Truncated incorrect time value: '0001:01:01--'
6306SELECT TIME('-xxx'), TIME('-xxxxxxxxxxxxxxxxxxxx');
6307TIME('-xxx')	TIME('-xxxxxxxxxxxxxxxxxxxx')
6308NULL	NULL
6309Warnings:
6310Warning	1292	Incorrect time value: '-xxx'
6311Warning	1292	Incorrect time value: '-xxxxxxxxxxxxxxxxxxxx'
6312SELECT TIME('-      '), TIME('-                         ');
6313TIME('-      ')	TIME('-                         ')
6314NULL	NULL
6315Warnings:
6316Warning	1292	Incorrect time value: '-      '
6317Warning	1292	Incorrect time value: '-                         '
6318SELECT TIME('-'), TIME('-');
6319TIME('-')	TIME('-')
6320NULL	NULL
6321Warnings:
6322Warning	1292	Incorrect time value: '-'
6323Warning	1292	Incorrect time value: '-'
6324SELECT TIME('1-1-1 1:1:1'), TIME('1-1-1 1:1:1.0');
6325TIME('1-1-1 1:1:1')	TIME('1-1-1 1:1:1.0')
632601:01:01	01:01:01.0
6327SELECT TIME('1-1-1 1:2:3'), TIME('1-1-1 1:2:3.0');
6328TIME('1-1-1 1:2:3')	TIME('1-1-1 1:2:3.0')
632901:02:03	01:02:03.0
6330SELECT
6331CAST('20050326112233 garbage' as datetime),
6332CAST('20050326 garbage' as date),
6333CAST('50326 garbage' as time);
6334CAST('20050326112233 garbage' as datetime)	CAST('20050326 garbage' as date)	CAST('50326 garbage' as time)
63352005-03-26 11:22:33	2005-03-26	05:03:26
6336Warnings:
6337Warning	1292	Truncated incorrect datetime value: '20050326112233 garbage'
6338Warning	1292	Truncated incorrect date value: '20050326 garbage'
6339Warning	1292	Truncated incorrect time value: '50326 garbage'
6340SELECT TIME('- 01:00:00'), TIME('- 1 01:00:00');
6341TIME('- 01:00:00')	TIME('- 1 01:00:00')
6342-01:00:00	-25:00:00
6343#
6344# MDEV-17854 Assertion `decimals <= 6' failed in my_time_fraction_remainder on SELECT with NULLIF and FROM_UNIXTIME on incorrect time
6345#
6346SET time_zone='+00:00';
6347SELECT NULLIF(FROM_UNIXTIME('foo'), '2012-12-12 21:10:14');
6348NULLIF(FROM_UNIXTIME('foo'), '2012-12-12 21:10:14')
63491970-01-01 00:00:00
6350Warnings:
6351Warning	1292	Truncated incorrect DECIMAL value: 'foo'
6352Warning	1292	Truncated incorrect DECIMAL value: 'foo'
6353SET time_zone=DEFAULT;
6354#
6355# MDEV-18402 Assertion `sec.sec() <= 59' failed in Item_func_maketime::get_date
6356#
6357SELECT MAKETIME('01', '01', LEAST( -100, NULL ));
6358MAKETIME('01', '01', LEAST( -100, NULL ))
6359NULL
6360SELECT CONCAT(MAKETIME('01', '01', LEAST( -100, NULL )));
6361CONCAT(MAKETIME('01', '01', LEAST( -100, NULL )))
6362NULL
6363#
6364# MDEV-19774 Assertion `sec.se c() <= 0x7FFFFFFFL' failed in Item_func_from_unixtime::get_date
6365#
6366SELECT FROM_UNIXTIME(LEAST(3696610869, NULL));
6367FROM_UNIXTIME(LEAST(3696610869, NULL))
6368NULL
6369