MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:September 3 2010 12:14pm
Subject:bzr commit into mysql-5.1-bugteam branch (gshchepa:3498) Bug#52160
View as plain text  
#At file:///mnt/sda7/work/52160-5.1-bugteam/ based on revid:davi.arnaut@stripped

 3498 Gleb Shchepa	2010-09-03
      Bug #52160: crash and inconsistent results when grouping
                  by a function and column
      
      Grouping by the TIME_TO_SEC function result may cause a
      server crash or wrong results.
      
      TIME_TO_SEC() returns NULL if its argument is invalid (empty
      string for example). Thus its nullability depends not only
      on the nullability of its arguments but also on their values.
      Fixed by (overoptimistically) setting TIME_TO_SEC() to be
      nullable despite the nullability of its arguments.
     @ mysql-test/r/func_time.result
        Test case for bug #52160.
     @ mysql-test/t/func_time.test
        Test case for bug #52160.
     @ sql/item_timefunc.h
        Bug #52160: crash and inconsistent results when grouping
                    by a function and column
        
        Fixed by (overoptimistically) setting TIME_TO_SEC() to be
        nullable despite the nullability of its arguments.

    modified:
      mysql-test/r/func_time.result
      mysql-test/t/func_time.test
      sql/item_timefunc.h
=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2010-08-13 13:05:46 +0000
+++ b/mysql-test/r/func_time.result	2010-09-03 12:14:47 +0000
@@ -1343,4 +1343,18 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a
 1
 1
 DROP TABLE t1;
+#
+# Bug #52160: crash and inconsistent results when grouping
+#             by a function and column
+#
+CREATE TABLE t1(a CHAR(10) NOT NULL);
+INSERT INTO t1 VALUES (""),("");
+SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
+COUNT(*)
+2
+Warnings:
+Warning	1292	Truncated incorrect time value: ''
+Warning	1292	Truncated incorrect time value: ''
+Warning	1292	Truncated incorrect time value: ''
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2010-08-13 13:05:46 +0000
+++ b/mysql-test/t/func_time.test	2010-09-03 12:14:47 +0000
@@ -849,4 +849,14 @@ INSERT INTO t1 VALUES (0),(9.216e-096);
 SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #52160: crash and inconsistent results when grouping
+--echo #             by a function and column
+--echo #
+
+CREATE TABLE t1(a CHAR(10) NOT NULL);
+INSERT INTO t1 VALUES (""),("");
+SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2010-08-13 13:05:46 +0000
+++ b/sql/item_timefunc.h	2010-09-03 12:14:47 +0000
@@ -331,6 +331,7 @@ public:
   const char *func_name() const { return "time_to_sec"; }
   void fix_length_and_dec()
   {
+    maybe_null= TRUE;
     decimals=0;
     max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
   }


Attachment: [text/bzr-bundle] bzr/gshchepa@mysql.com-20100903121447-1x9anxawy0k6tkst.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (gshchepa:3498) Bug#52160Gleb Shchepa3 Sep