List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:January 17 2012 9:25am
Subject:bzr push into mysql-trunk branch (alexander.barkov:3737 to 3738) Bug#13545236
View as plain text  
 3738 Alexander Barkov	2012-01-17
      BUG#13545236 - ASSERT IN SEC_SINCE_EPOCH
      
      Problem:
      WL#946 introduced a new methid Item_cache_datetime::get_date().
      It did not execute check_date(), so in some cases it started
      to return non-NULL result when instead of expected NULL.
      
      Before WL#946 the generic Item::get_date() was used,
      which executes check_date() inside str_to_datetime_with_warn().
      
      Fix:
      adding check_date() in the new method, to reproduce the pre-WL#946 behaviour.
      
      modified:
            mysql-test/r/func_time.result
            mysql-test/t/func_time.test
            sql/item.cc

    modified:
      mysql-test/r/func_time.result
      mysql-test/t/func_time.test
      sql/item.cc
 3737 Nirbhay Choubey	2012-01-17 [merge]
      Null-merge from mysql-5.5.

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2012-01-13 08:36:43 +0000
+++ b/mysql-test/r/func_time.result	2012-01-17 08:23:57 +0000
@@ -1512,6 +1512,40 @@ drop table t1;
 # Start of 5.6 tests
 #
 #
+# BUG#13545236 - ASSERT IN SEC_SINCE_EPOCH
+#
+CREATE TABLE t1 (a TIME NOT NULL);
+INSERT INTO t1 VALUES ('04:39:24');
+INSERT INTO t1 VALUES ('00:20:09');
+SELECT a FROM t1
+WHERE CONVERT_TZ(TIMESTAMPADD(YEAR , a, TIMESTAMP('0000-00-00')),
+'+00:00','+00:00');
+a
+SELECT a FROM t1
+WHERE CONVERT_TZ(TIMESTAMPADD(YEAR, a, DATE('0000-00-00')),
+'+00:00','+00:00');
+a
+DROP TABLE t1;
+CREATE TABLE t1 (a TIME);
+INSERT INTO t1 VALUES ('00:00:00');
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, TIMESTAMP('0000-00-01')) IS NULL;
+a
+00:00:00
+Warnings:
+Warning	1292	Incorrect datetime value: '0000-00-01'
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, TIMESTAMP'0000-00-01 00:00:00') IS NULL;
+a
+00:00:00
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, DATE('0000-00-01')) IS NULL;
+a
+00:00:00
+Warnings:
+Warning	1292	Incorrect datetime value: '0000-00-01'
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, DATE'0000-00-01') IS NULL;
+a
+00:00:00
+DROP TABLE t1;
+#
 # BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP 
 # Part2 (5.6)
 CREATE TABLE t1 (a VARCHAR(32) NOT NULL);

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2012-01-13 08:36:43 +0000
+++ b/mysql-test/t/func_time.test	2012-01-17 08:23:57 +0000
@@ -1005,6 +1005,27 @@ drop table t1;
 --echo #
 
 --echo #
+--echo # BUG#13545236 - ASSERT IN SEC_SINCE_EPOCH
+--echo #
+CREATE TABLE t1 (a TIME NOT NULL);
+INSERT INTO t1 VALUES ('04:39:24');
+INSERT INTO t1 VALUES ('00:20:09');
+SELECT a FROM t1
+WHERE CONVERT_TZ(TIMESTAMPADD(YEAR , a, TIMESTAMP('0000-00-00')),
+                 '+00:00','+00:00');
+SELECT a FROM t1
+WHERE CONVERT_TZ(TIMESTAMPADD(YEAR, a, DATE('0000-00-00')),
+                 '+00:00','+00:00');
+DROP TABLE t1;
+CREATE TABLE t1 (a TIME);
+INSERT INTO t1 VALUES ('00:00:00');
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, TIMESTAMP('0000-00-01')) IS NULL;
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, TIMESTAMP'0000-00-01 00:00:00') IS NULL;
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, DATE('0000-00-01')) IS NULL;
+SELECT * FROM t1 WHERE TIMESTAMPDIFF(MONTH, a, DATE'0000-00-01') IS NULL;
+DROP TABLE t1;
+
+--echo #
 --echo # BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP 
 --echo # Part2 (5.6)
 CREATE TABLE t1 (a VARCHAR(32) NOT NULL);

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2012-01-13 13:03:00 +0000
+++ b/sql/item.cc	2012-01-17 08:23:57 +0000
@@ -8507,12 +8507,18 @@ bool Item_cache_datetime::get_date(MYSQL
       return false;
     }
   case MYSQL_TYPE_DATE:
-    TIME_from_longlong_date_packed(ltime, int_value);
-    return false;
+    {
+      int warnings= 0;
+      TIME_from_longlong_date_packed(ltime, int_value);
+      return check_date(ltime, non_zero_date(ltime), fuzzydate, &warnings);
+    }
   case MYSQL_TYPE_DATETIME:
   case MYSQL_TYPE_TIMESTAMP:
-    TIME_from_longlong_datetime_packed(ltime, int_value);
-    return false;
+    {
+      int warnings= 0;
+      TIME_from_longlong_datetime_packed(ltime, int_value);
+      return check_date(ltime, non_zero_date(ltime), fuzzydate, &warnings);
+    }
   default:
     DBUG_ASSERT(0);
   }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3737 to 3738) Bug#13545236Alexander Barkov17 Jan