List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:April 27 2011 7:55am
Subject:bzr commit into mysql-trunk branch (sergey.glukhov:3327)
View as plain text  
#At file:///home/gluh/MySQL/mysql-trunk/ based on revid:marc.alff@stripped

 3327 Sergey Glukhov	2011-04-27 [merge]
      5.5 -> trunk merge
     @ mysql-test/r/func_time.result
        5.5 -> trunk merge
     @ mysql-test/t/func_time.test
        5.5 -> trunk merge
     @ sql-common/my_time.c
        5.5 -> trunk merge
     @ sql/item_timefunc.cc
        5.5 -> trunk merge

    modified:
      mysql-test/r/func_time.result
      mysql-test/t/func_time.test
      sql-common/my_time.c
      sql/item_timefunc.cc
=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2011-03-30 07:42:03 +0000
+++ b/mysql-test/r/func_time.result	2011-04-27 07:55:04 +0000
@@ -1377,6 +1377,18 @@ NULL
 SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
 ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR)
 NULL
+#
+# Bug#11889186  60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
+#
+SELECT DATE_FORMAT('0000-00-11', '%W');
+DATE_FORMAT('0000-00-11', '%W')
+NULL
+SELECT DATE_FORMAT('0000-00-11', '%a');
+DATE_FORMAT('0000-00-11', '%a')
+NULL
+SELECT DATE_FORMAT('0000-00-11', '%w');
+DATE_FORMAT('0000-00-11', '%w')
+NULL
 End of 5.1 tests
 #
 # BUG#43578 "MyISAM&Maria gives wrong rows with range access

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2011-03-30 07:42:03 +0000
+++ b/mysql-test/t/func_time.test	2011-04-27 07:55:04 +0000
@@ -894,6 +894,14 @@ SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBA
 
 SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
 
+--echo #
+--echo # Bug#11889186  60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
+--echo #
+
+SELECT DATE_FORMAT('0000-00-11', '%W');
+SELECT DATE_FORMAT('0000-00-11', '%a');
+SELECT DATE_FORMAT('0000-00-11', '%w');
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'sql-common/my_time.c'
--- a/sql-common/my_time.c	2011-02-02 18:13:28 +0000
+++ b/sql-common/my_time.c	2011-04-27 07:46:23 +0000
@@ -772,7 +772,7 @@ long calc_daynr(uint year,uint month,uin
   int y= year;                                  /* may be < 0 temporarily */
   DBUG_ENTER("calc_daynr");
 
-  if (y == 0 && month == 0 && day == 0)
+  if (y == 0 && month == 0)
     DBUG_RETURN(0);				/* Skip errors */
   /* Cast to int to be able to handle month == 0 */
   delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day);
@@ -783,6 +783,7 @@ long calc_daynr(uint year,uint month,uin
   temp=(int) ((y/100+1)*3)/4;
   DBUG_PRINT("exit",("year: %d  month: %d  day: %d -> daynr: %ld",
 		     y+(month <= 2),month,day,delsum+y/4-temp));
+  DBUG_ASSERT(delsum+(int) y/4-temp > 0);
   DBUG_RETURN(delsum+(int) y/4-temp);
 } /* calc_daynr */
 

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2011-03-28 13:38:03 +0000
+++ b/sql/item_timefunc.cc	2011-04-27 07:55:04 +0000
@@ -665,7 +665,7 @@ bool make_date_time(DATE_TIME_FORMAT *fo
                     system_charset_info);
         break;
       case 'W':
-        if (type == MYSQL_TIMESTAMP_TIME)
+        if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
           return 1;
         weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
                               l_time->day),0);
@@ -674,7 +674,7 @@ bool make_date_time(DATE_TIME_FORMAT *fo
                     system_charset_info);
         break;
       case 'a':
-        if (type == MYSQL_TIMESTAMP_TIME)
+        if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
           return 1;
         weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
                              l_time->day),0);
@@ -833,7 +833,7 @@ bool make_date_time(DATE_TIME_FORMAT *fo
       }
       break;
       case 'w':
-	if (type == MYSQL_TIMESTAMP_TIME)
+	if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
 	  return 1;
 	weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
 					l_time->day),1);

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-trunk branch (sergey.glukhov:3327) Sergey Glukhov27 Apr