List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:March 30 2011 7:00am
Subject:bzr commit into mysql-5.1 branch (sergey.glukhov:3642) Bug#11766126
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1/ based on revid:jon.hauglid@stripped

 3642 Sergey Glukhov	2011-03-30
      Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
      Valgrind warning happens because null values check happens too late
      in Item_func_month::val_str(after result string calculation).The fix
      is to check null value before result string calculation.
     @ mysql-test/r/func_time.result
        test case
     @ mysql-test/t/func_time.test
        test case
     @ sql/item_timefunc.h
        check null value before result string calculation.

    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	2011-03-28 13:27:44 +0000
+++ b/mysql-test/r/func_time.result	2011-03-30 07:00:41 +0000
@@ -1393,4 +1393,10 @@ SET GLOBAL SQL_MODE=DEFAULT;
 SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
 FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1)
 NULL
+#
+# Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+#
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025))
+NULL
 End of 5.1 tests

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2011-03-28 13:27:44 +0000
+++ b/mysql-test/t/func_time.test	2011-03-30 07:00:41 +0000
@@ -901,4 +901,10 @@ SET GLOBAL SQL_MODE=DEFAULT;
 
 SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
 
+--echo #
+--echo # Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+--echo #
+
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+
 --echo End of 5.1 tests

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2011-02-22 21:03:32 +0000
+++ b/sql/item_timefunc.h	2011-03-30 07:00:41 +0000
@@ -106,8 +106,11 @@ public:
   { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
   String *val_str(String *str) 
   {
-    str->set(val_int(), &my_charset_bin);
-    return null_value ? 0 : str;
+    longlong nr= val_int();
+    if (null_value)
+      return 0;
+    str->set(nr, &my_charset_bin);
+    return str;
   }
   const char *func_name() const { return "month"; }
   enum Item_result result_type () const { return INT_RESULT; }


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20110330070041-8sniyg6fdtrfxlq7.bundle
Thread
bzr commit into mysql-5.1 branch (sergey.glukhov:3642) Bug#11766126Sergey Glukhov30 Mar