MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:May 15 2009 8:16am
Subject:bzr commit into mysql-5.0-bugteam branch (Alexey.Kopytov:2741)
Bug#44792
View as plain text  
#At file:///Users/kaa/src/bzr/bugteam/bug44792/my50-bug44792/ based on revid:pstoev@stripped

 2741 Alexey Kopytov	2009-05-15
      Bug #44792: valgrind warning when casting from time to time 
       
      Field_time::get_time() did not initialize some members of 
      MYSQL_TIME which led to valgrind warnings when those members 
      were accessed in Protocol_simple::store_time(). 
       
      It is unlikely that this bug could result in wrong data 
      being returned, since Field_time::get_time() initializes the 
      'day' member of MYSQL_TIME to 0, so the value of 'day' 
      in Protocol_simple::store_time() would be 0 regardless 
      of the values for 'year' and 'month'.
      modified:
        mysql-test/r/type_time.result
        mysql-test/t/type_time.test
        sql/field.cc

per-file messages:
  mysql-test/r/type_time.result
    Added a test case for bug #44792.
  mysql-test/t/type_time.test
    Added a test case for bug #44792.
  sql/field.cc
    Field_time::get_time() did not initialize some members of 
    MYSQL_TIME which led to valgrind warnings when those members 
    were accessed in Protocol_simple::store_time().
=== modified file 'mysql-test/r/type_time.result'
--- a/mysql-test/r/type_time.result	2007-07-15 17:51:36 +0000
+++ b/mysql-test/r/type_time.result	2009-05-15 08:16:00 +0000
@@ -128,3 +128,13 @@ SELECT sum(f3) FROM t1 where f2='2007-07
 sum(f3)
 3
 drop table t1;
+#
+# Bug #44792: valgrind warning when casting from time to time
+#
+CREATE TABLE t1 (c TIME);
+INSERT INTO t1 VALUES ('0:00:00');
+SELECT CAST(c AS TIME) FROM t1;
+CAST(c AS TIME)
+00:00:00
+DROP TABLE t1;
+End of 5.0 tests

=== modified file 'mysql-test/t/type_time.test'
--- a/mysql-test/t/type_time.test	2007-07-15 17:51:36 +0000
+++ b/mysql-test/t/type_time.test	2009-05-15 08:16:00 +0000
@@ -77,3 +77,16 @@ insert into t1 values('2007-07-02', 1);
 insert into t1 values('2007-07-02', 2);
 SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2;
 drop table t1;
+
+
+--echo #
+--echo # Bug #44792: valgrind warning when casting from time to time
+--echo #
+
+CREATE TABLE t1 (c TIME);
+INSERT INTO t1 VALUES ('0:00:00');
+SELECT CAST(c AS TIME) FROM t1;
+DROP TABLE t1;
+
+
+--echo End of 5.0 tests

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2009-04-09 09:19:31 +0000
+++ b/sql/field.cc	2009-05-15 08:16:00 +0000
@@ -4877,7 +4877,7 @@ bool Field_time::get_time(MYSQL_TIME *lt
     ltime->neg= 1;
     tmp=-tmp;
   }
-  ltime->day= 0;
+  ltime->year= ltime->month= ltime->day= 0;
   ltime->hour=   (int) (tmp/10000);
   tmp-=ltime->hour*10000;
   ltime->minute= (int) tmp/100;

Thread
bzr commit into mysql-5.0-bugteam branch (Alexey.Kopytov:2741)Bug#44792Alexey Kopytov15 May