MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:May 31 2010 9:25am
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3402)
Bug#53942
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:mattias.jonsson@stripped

 3402 Sergey Glukhov	2010-05-31
      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
        --use Field_time::get_time in Field_time::get_date
        --removed duplicated code in Field_time::get_date 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-31 09:25:11 +0000
@@ -138,3 +138,13 @@ CAST(c AS TIME)
 00:00:00
 DROP TABLE t1;
 End of 5.0 tests
+#
+# 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.1 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-31 09:25:11 +0000
@@ -88,5 +88,15 @@ INSERT INTO t1 VALUES ('0:00:00');
 SELECT CAST(c AS TIME) FROM t1;
 DROP TABLE t1;
 
-
 --echo End of 5.0 tests
+
+--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.1 tests

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-04-25 11:06:40 +0000
+++ b/sql/field.cc	2010-05-31 09:25:11 +0000
@@ -5312,7 +5312,6 @@ String *Field_time::val_str(String *val_
  
 bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
 {
-  long tmp;
   THD *thd= table ? table->in_use : current_thd;
   if (!(fuzzydate & TIME_FUZZY_DATE))
   {
@@ -5322,19 +5321,7 @@ bool Field_time::get_date(MYSQL_TIME *lt
                         thd->row_count);
     return 1;
   }
-  tmp=(long) sint3korr(ptr);
-  ltime->neg=0;
-  if (tmp < 0)
-  {
-    ltime->neg= 1;
-    tmp=-tmp;
-  }
-  ltime->hour=tmp/10000;
-  tmp-=ltime->hour*10000;
-  ltime->minute=   tmp/100;
-  ltime->second= tmp % 100;
-  ltime->year= ltime->month= ltime->day= ltime->second_part= 0;
-  return 0;
+  return Field_time::get_time(ltime);
 }
 
 


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100531092511-sbm69fz2tko1rdz3.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3402)Bug#53942Sergey Glukhov31 May