MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:May 28 2010 7:29am
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3399)
Bug#53942
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:sergey.glukhov@stripped

 3399 Sergey Glukhov	2010-05-28
      Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values
      Field_time::get_date method does not initialize MYSQL_TIME::time_type field.
      The fix is to init this field.
     @ mysql-test/r/type_time.result
        test case
     @ mysql-test/t/type_time.test
        test case
     @ sql/field.cc
        --init MYSQL_TIME::time_type field in Field_time::get_date method
        --removed duplicated code in Field_time::get_time method

    modified:
      mysql-test/r/type_time.result
      mysql-test/t/type_time.test
      sql/field.cc
=== modified file 'mysql-test/r/type_time.result'
--- a/mysql-test/r/type_time.result	2009-05-15 08:42:57 +0000
+++ b/mysql-test/r/type_time.result	2010-05-28 07:28:59 +0000
@@ -137,4 +137,13 @@ SELECT CAST(c AS TIME) FROM t1;
 CAST(c AS TIME)
 00:00:00
 DROP TABLE t1;
+#
+# Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values
+#
+CREATE TABLE t1(f1 TIME);
+INSERT INTO t1 VALUES ('23:38:57');
+SELECT TIMESTAMP(f1,'1') FROM t1;
+TIMESTAMP(f1,'1')
+NULL
+DROP TABLE t1;
 End of 5.0 tests

=== modified file 'mysql-test/t/type_time.test'
--- a/mysql-test/t/type_time.test	2009-05-15 08:16:00 +0000
+++ b/mysql-test/t/type_time.test	2010-05-28 07:28:59 +0000
@@ -88,5 +88,13 @@ INSERT INTO t1 VALUES ('0:00:00');
 SELECT CAST(c AS TIME) FROM t1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values
+--echo #
+
+CREATE TABLE t1(f1 TIME);
+INSERT INTO t1 VALUES ('23:38:57');
+SELECT TIMESTAMP(f1,'1') FROM t1;
+DROP TABLE t1;
 
 --echo End of 5.0 tests

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-04-25 11:06:40 +0000
+++ b/sql/field.cc	2010-05-28 07:28:59 +0000
@@ -5334,27 +5334,14 @@ bool Field_time::get_date(MYSQL_TIME *lt
   ltime->minute=   tmp/100;
   ltime->second= tmp % 100;
   ltime->year= ltime->month= ltime->day= ltime->second_part= 0;
+  ltime->time_type= MYSQL_TIMESTAMP_TIME;
   return 0;
 }
 
 
 bool Field_time::get_time(MYSQL_TIME *ltime)
 {
-  long tmp=(long) sint3korr(ptr);
-  ltime->neg=0;
-  if (tmp < 0)
-  {
-    ltime->neg= 1;
-    tmp=-tmp;
-  }
-  ltime->year= ltime->month= ltime->day= 0;
-  ltime->hour=   (int) (tmp/10000);
-  tmp-=ltime->hour*10000;
-  ltime->minute= (int) tmp/100;
-  ltime->second= (int) tmp % 100;
-  ltime->second_part=0;
-  ltime->time_type= MYSQL_TIMESTAMP_TIME;
-  return 0;
+  return Field_time::get_date(ltime, TIME_FUZZY_DATE);
 }
 
 


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100528072859-2cpg7yd3yoqdxv6d.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3399)Bug#53942Sergey Glukhov28 May
  • Re: bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3399)Bug#53942Gleb Shchepa28 May