List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:February 2 2011 6:14pm
Subject:bzr commit into mysql-5.5 branch (Georgi.Kodinov:3298)
View as plain text  
#At file:///Users/kgeorge/mysql/work/B55755-5.5/ based on revid:dmitry.lenev@stripped

 3298 Georgi Kodinov	2011-02-02 [merge]
      merge

    modified:
      config.h.cmake
      configure.cmake
      include/my_time.h
      mysql-test/r/func_time.result
      mysql-test/t/func_time.test
      mysql-test/t/variables.test
      sql-common/my_time.c
      sql/mysqld.cc
      sql/sql_class.h
      sql/sys_vars.cc
=== modified file 'config.h.cmake'
--- a/config.h.cmake	2011-01-04 10:23:45 +0000
+++ b/config.h.cmake	2011-02-02 18:13:28 +0000
@@ -614,4 +614,9 @@
 #define PROTOCOL_VERSION 10
 
 
+/* time_t related defines */
+
+#cmakedefine SIZEOF_TIME_T @SIZEOF_TIME_T@
+#cmakedefine TIME_T_UNSIGNED @TIME_T_UNSIGNED@
+
 #endif

=== modified file 'configure.cmake'
--- a/configure.cmake	2010-12-21 12:00:26 +0000
+++ b/configure.cmake	2011-02-02 18:13:28 +0000
@@ -574,6 +574,7 @@ MY_CHECK_TYPE_SIZE(uint32 UINT32)
 MY_CHECK_TYPE_SIZE(u_int32_t U_INT32_T)
 MY_CHECK_TYPE_SIZE(int64 INT64)
 MY_CHECK_TYPE_SIZE(uint64 UINT64)
+MY_CHECK_TYPE_SIZE(time_t TIME_T)
 SET (CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
 MY_CHECK_TYPE_SIZE(bool  BOOL)
 SET(CMAKE_EXTRA_INCLUDE_FILES)
@@ -593,6 +594,16 @@ ENDIF()
 # Code tests
 #
 
+# check whether time_t is unsigned
+CHECK_C_SOURCE_COMPILES("
+int main()
+{
+  int array[(((time_t)-1) > 0) ? 1 : -1];
+  return 0;
+}"
+TIME_T_UNSIGNED)
+
+
 CHECK_C_SOURCE_COMPILES("
 #ifdef _WIN32
 #include <winsock2.h>

=== modified file 'include/my_time.h'
--- a/include/my_time.h	2010-07-15 11:28:41 +0000
+++ b/include/my_time.h	2011-02-02 18:13:28 +0000
@@ -50,6 +50,19 @@ typedef long my_time_t;
 /* two-digit years < this are 20..; >= this are 19.. */
 #define YY_PART_YEAR	   70
 
+/*
+  check for valid times only if the range of time_t is greater than
+  the range of my_time_t
+*/
+#if SIZEOF_TIME_T > 4 || defined(TIME_T_UNSIGNED)
+# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
+    ((x) <= TIMESTAMP_MAX_VALUE && \
+     (x) >= TIMESTAMP_MIN_VALUE)
+#else
+# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
+    ((x) >= TIMESTAMP_MIN_VALUE)
+#endif
+
 /* Flags to str_to_datetime */
 #define TIME_FUZZY_DATE		1
 #define TIME_DATETIME_ONLY	2

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2010-12-17 11:11:34 +0000
+++ b/mysql-test/r/func_time.result	2011-02-02 18:13:28 +0000
@@ -1273,6 +1273,24 @@ date_add('1000-01-01 00:00:00', interval
 select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
 date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond)
 1000-01-01 00:00:01.020000
+#
+# Bug #52315 part 2 : utc_date() crashes when system time > year 2037
+#
+SET TIMESTAMP=-147490000;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483648;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483646;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483647;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=-1;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=1;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0;
 End of 5.0 tests
 select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
 date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2010-12-17 11:11:34 +0000
+++ b/mysql-test/t/func_time.test	2011-02-02 18:13:28 +0000
@@ -802,6 +802,24 @@ select LAST_DAY('2007-12-06 08:59:19.05'
 select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
 select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
 
+
+--echo #
+--echo # Bug #52315 part 2 : utc_date() crashes when system time > year 2037
+--echo #
+
+--disable_result_log
+SET TIMESTAMP=-147490000; SELECT UTC_TIMESTAMP();
+--error ER_WRONG_VALUE_FOR_VAR
+SET TIMESTAMP=2147483648; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483646; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483647; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=-1; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=1; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0;
+--enable_result_log
+
+
 --echo End of 5.0 tests
 
 #

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2010-11-25 03:50:16 +0000
+++ b/mysql-test/t/variables.test	2011-02-02 18:13:28 +0000
@@ -779,7 +779,7 @@ SET @@myisam_mmap_size= 500M;
 --echo # Bug #52315: utc_date() crashes when system time > year 2037
 --echo #
 
---error 0, ER_UNKNOWN_ERROR
+--error 0, ER_WRONG_VALUE_FOR_VAR
 SET TIMESTAMP=2*1024*1024*1024;
 --echo #Should not crash
 --disable_result_log

=== modified file 'sql-common/my_time.c'
--- a/sql-common/my_time.c	2010-11-04 13:18:27 +0000
+++ b/sql-common/my_time.c	2011-02-02 18:13:28 +0000
@@ -992,7 +992,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_sr
     with unsigned time_t tmp+= shift*86400L might result in a number,
     larger then TIMESTAMP_MAX_VALUE, so another check will work.
   */
-  if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
+  if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tmp))
     tmp= 0;
 
   return (my_time_t) tmp;

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-01-17 07:44:37 +0000
+++ b/sql/mysqld.cc	2011-02-02 18:13:28 +0000
@@ -3080,12 +3080,6 @@ static int init_common_variables()
 
   max_system_variables.pseudo_thread_id= (ulong)~0;
   server_start_time= flush_status_time= my_time(0);
-  /* TODO: remove this when my_time_t is 64 bit compatible */
-  if (server_start_time >= (time_t) MY_TIME_T_MAX)
-  {
-    sql_print_error("This MySQL server doesn't support dates later then 2038");
-    return 1;
-  }
 
   rpl_filter= new Rpl_filter;
   binlog_filter= new Rpl_filter;
@@ -3124,6 +3118,13 @@ static int init_common_variables()
   */
   mysql_bin_log.init_pthread_objects();
 
+  /* TODO: remove this when my_time_t is 64 bit compatible */
+  if (!IS_TIME_T_VALID_FOR_TIMESTAMP(server_start_time))
+  {
+    sql_print_error("This MySQL server doesn't support dates later then 2038");
+    return 1;
+  }
+
   if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
   {
     strmake(glob_hostname, STRING_WITH_LEN("localhost"));

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-12-29 00:26:31 +0000
+++ b/sql/sql_class.h	2011-02-02 18:13:28 +0000
@@ -2280,7 +2280,7 @@ public:
   /*TODO: this will be obsolete when we have support for 64 bit my_time_t */
   inline bool	is_valid_time() 
   { 
-    return (start_time < (time_t) MY_TIME_T_MAX); 
+    return (IS_TIME_T_VALID_FOR_TIMESTAMP(start_time));
   }
   void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
   ulonglong current_utime()  { return my_micro_time(); }

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-12-17 11:11:34 +0000
+++ b/sql/sys_vars.cc	2011-02-02 18:13:28 +0000
@@ -2430,17 +2430,17 @@ static ulonglong read_timestamp(THD *thd
 
 static bool check_timestamp(sys_var *self, THD *thd, set_var *var)
 {
-  time_t val;
+  longlong val;
 
   if (!var->value)
     return FALSE;
 
-  val= (time_t) var->save_result.ulonglong_value;
-  if (val < (time_t) MY_TIME_T_MIN || val > (time_t) MY_TIME_T_MAX)
+  val= (longlong) var->save_result.ulonglong_value;
+  if (val != 0 &&          // this is how you set the default value
+      (val < TIMESTAMP_MIN_VALUE || val > TIMESTAMP_MAX_VALUE))
   {
-    my_message(ER_UNKNOWN_ERROR, 
-               "This version of MySQL doesn't support dates later than 2038",
-               MYF(0));
+    char buf[64];
+    my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", llstr(val, buf));
     return TRUE;
   }
   return FALSE;

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-5.5 branch (Georgi.Kodinov:3298) Georgi Kodinov2 Feb