From: Date: June 27 2006 5:34pm Subject: bk commit into 4.1 tree (kroki:1.2519) BUG#12356 List-Archive: http://lists.mysql.com/commits/8326 X-Bug: 12356 Message-Id: <200606271534.k5RFY6WQ008740@moonlight.intranet> Below is the list of changes that have just been committed into a local 4.1 repository of tomash. When tomash does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2519 06/06/27 19:33:59 kroki@stripped +5 -0 Dec. 31st, 9999 is still a valid date, only starting with Jan 1st 10000 things become invalid (Bug #12356) sql/item_timefunc.cc 1.103 06/06/27 19:33:53 kroki@stripped +6 -5 Dec. 31st, 9999 is still a valid date, only starting with Jan 1st 10000 things become invalid (Bug #12356) mysql-test/t/func_time.test 1.37 06/06/27 19:33:53 kroki@stripped +6 -0 test cases for date range edge cases added mysql-test/t/func_sapdb.test 1.9 06/06/27 19:33:53 kroki@stripped +2 -0 test cases for date range edge cases added mysql-test/r/func_time.result 1.42 06/06/27 19:33:53 kroki@stripped +6 -0 test cases for date range edge cases added mysql-test/r/func_sapdb.result 1.10 06/06/27 19:33:53 kroki@stripped +6 -0 test cases for date range edge cases added # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: kroki # Host: moonlight.intranet # Root: /home/tomash/src/mysql_ab/mysql-4.1-bug12356 --- 1.102/sql/item_timefunc.cc 2006-06-17 02:07:09 +04:00 +++ 1.103/sql/item_timefunc.cc 2006-06-27 19:33:53 +04:00 @@ -27,6 +27,7 @@ /* TODO: Move month and days to language files */ +/* Day number for Dec 31st, 9999 */ #define MAX_DAY_NUMBER 3652424L static const char *month_names[]= @@ -401,7 +402,7 @@ if (yearday > 0) { uint days= calc_daynr(l_time->year,1,1) + yearday - 1; - if (days <= 0 || days >= MAX_DAY_NUMBER) + if (days <= 0 || days > MAX_DAY_NUMBER) goto err; get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day); } @@ -447,7 +448,7 @@ (weekday - 1); } - if (days <= 0 || days >= MAX_DAY_NUMBER) + if (days <= 0 || days > MAX_DAY_NUMBER) goto err; get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day); } @@ -1931,7 +1932,7 @@ ltime->hour= (uint) (sec/3600); daynr= calc_daynr(ltime->year,ltime->month,1) + days; /* Day number from year 0 to 9999-12-31 */ - if ((ulonglong) daynr >= MAX_DAY_NUMBER) + if ((ulonglong) daynr > MAX_DAY_NUMBER) goto null_date; get_date_from_daynr((long) daynr, <ime->year, <ime->month, <ime->day); @@ -1941,7 +1942,7 @@ period= (calc_daynr(ltime->year,ltime->month,ltime->day) + sign * (long) interval.day); /* Daynumber from year 0 to 9999-12-31 */ - if ((ulong) period >= MAX_DAY_NUMBER) + if ((ulong) period > MAX_DAY_NUMBER) goto null_date; get_date_from_daynr((long) period,<ime->year,<ime->month,<ime->day); break; @@ -2412,7 +2413,7 @@ days= calc_daynr(yearnr,1,1) + daynr - 1; /* Day number from year 0 to 9999-12-31 */ - if (days >= 0 && days < MAX_DAY_NUMBER) + if (days >= 0 && days <= MAX_DAY_NUMBER) { null_value=0; get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day); --- 1.9/mysql-test/r/func_sapdb.result 2005-11-01 13:59:53 +03:00 +++ 1.10/mysql-test/r/func_sapdb.result 2006-06-27 19:33:53 +04:00 @@ -71,6 +71,12 @@ select makedate(1997,0); makedate(1997,0) NULL +select makedate(9999,365); +makedate(9999,365) +9999-12-31 +select makedate(9999,366); +makedate(9999,366) +NULL select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002"); addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002") 1998-01-02 01:01:01.000001 --- 1.8/mysql-test/t/func_sapdb.test 2005-07-28 04:21:42 +04:00 +++ 1.9/mysql-test/t/func_sapdb.test 2006-06-27 19:33:53 +04:00 @@ -37,6 +37,8 @@ select makedate(1997,1); select makedate(1997,0); +select makedate(9999,365); +select makedate(9999,366); #Time functions --- 1.41/mysql-test/r/func_time.result 2006-06-19 12:03:24 +04:00 +++ 1.42/mysql-test/r/func_time.result 2006-06-27 19:33:53 +04:00 @@ -352,6 +352,12 @@ select extract(MONTH FROM "2001-02-00"); extract(MONTH FROM "2001-02-00") 2 +SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE); +DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE) +9999-12-31 00:00:00 +SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE); +DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE) +9999-12-31 00:00:00 SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND; "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND 1968-01-20 03:14:08 --- 1.36/mysql-test/t/func_time.test 2006-06-19 12:03:24 +04:00 +++ 1.37/mysql-test/t/func_time.test 2006-06-27 19:33:53 +04:00 @@ -140,6 +140,12 @@ select extract(MONTH FROM "2001-02-00"); # +# MySQL Bugs: #12356: DATE_SUB or DATE_ADD incorrectly returns null +# +SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE); +SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE); + +# # Test big intervals (Bug #3498) # SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;