MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tatiana A. Nurnberg Date:October 1 2008 1:29pm
Subject:bzr commit into mysql-5.0-bugteam branch (azundris:2685) Bug#37553
View as plain text  
#At file:///home/tnurnberg/forest/37553/50-37553/

 2685 Tatiana A. Nurnberg	2008-10-01
      Bug#37553: MySql Error Compare TimeDiff & Time
      
      some calculations lost the sign of negative time values
modified:
  mysql-test/r/cast.result
  mysql-test/r/func_sapdb.result
  mysql-test/t/cast.test
  mysql-test/t/func_sapdb.test
  sql/item_cmpfunc.cc
  sql/item_timefunc.h
  sql/my_decimal.cc

per-file messages:
  mysql-test/r/cast.result
    show that converting time to DECIMAL no longer drops sign
  mysql-test/r/func_sapdb.result
    show that time-related comparisons work with negative
    time values now
  mysql-test/t/cast.test
    show that converting time to DECIMAL no longer drops sign
  mysql-test/t/func_sapdb.test
    show that time-related comparisons work with negative
    time values now
  sql/item_cmpfunc.cc
    use signed rather than unsigned types in comparison
  sql/item_timefunc.h
    let time-related functions do signed comparisons --
    the file-comments pretended we were doing that all along, anyway
  sql/my_decimal.cc
    heed sign when converting time to my_decimal;
    times may actually be negative!
=== modified file 'mysql-test/r/cast.result'
--- a/mysql-test/r/cast.result	2007-12-20 07:35:52 +0000
+++ b/mysql-test/r/cast.result	2008-10-01 13:29:25 +0000
@@ -438,4 +438,7 @@ SECOND(NULL);
 HOUR(NULL)	MINUTE(NULL)	SECOND(NULL)
 NULL	NULL	NULL
 DROP TABLE t1;
+SELECT CAST(time('-73:42:12') AS DECIMAL);
+CAST(time('-73:42:12') AS DECIMAL)
+-734212
 End of 5.0 tests

=== modified file 'mysql-test/r/func_sapdb.result'
--- a/mysql-test/r/func_sapdb.result	2007-10-23 13:51:43 +0000
+++ b/mysql-test/r/func_sapdb.result	2008-10-01 13:29:25 +0000
@@ -256,3 +256,12 @@ a
 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
 str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
 2003-01-02 10:11:12.001200
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10'),time('00:00:00');
+timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')	time('00:00:00')
+-24:00:00	00:00:00
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')>time('00:00:00');
+timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')>time('00:00:00')
+0
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00');
+timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00')
+1

=== modified file 'mysql-test/t/cast.test'
--- a/mysql-test/t/cast.test	2007-12-20 07:35:52 +0000
+++ b/mysql-test/t/cast.test	2008-10-01 13:29:25 +0000
@@ -268,4 +268,11 @@ SELECT HOUR(NULL),
        SECOND(NULL);
 DROP TABLE t1;
 
+#
+# Bug#37553: MySql Error Compare TimeDiff & Time
+#
+
+# show that conversion to DECIMAL no longer drops sign
+SELECT CAST(time('-73:42:12') AS DECIMAL);
+
 --echo End of 5.0 tests

=== modified file 'mysql-test/t/func_sapdb.test'
--- a/mysql-test/t/func_sapdb.test	2007-10-12 09:46:48 +0000
+++ b/mysql-test/t/func_sapdb.test	2008-10-01 13:29:25 +0000
@@ -135,3 +135,18 @@ select str_to_date("2003-01-02 10:11:12.
 --enable_ps_protocol
 
 # End of 4.1 tests
+
+
+
+#
+# Bug#37553: MySql Error Compare TimeDiff & Time
+#
+
+# calculations involving negative time values ignored sign
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10'),time('00:00:00');
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')>time('00:00:00');
+select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00');
+
+
+
+# End of 5.0 tests

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2008-09-09 15:05:27 +0000
+++ b/sql/item_cmpfunc.cc	2008-10-01 13:29:25 +0000
@@ -979,7 +979,7 @@ get_datetime_value(THD *thd, Item ***ite
 int Arg_comparator::compare_datetime()
 {
   bool a_is_null, b_is_null;
-  ulonglong a_value, b_value;
+  longlong a_value, b_value;
 
   /* Get DATE/DATETIME/TIME value of the 'a' item. */
   a_value= (*get_value_func)(thd, &a, &a_cache, *b, &a_is_null);

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2008-01-07 16:55:05 +0000
+++ b/sql/item_timefunc.h	2008-10-01 13:29:25 +0000
@@ -408,6 +408,7 @@ public:
   {
     return save_time_in_field(field);
   }
+  bool result_as_longlong() { return TRUE; }
 };
 
 

=== modified file 'sql/my_decimal.cc'
--- a/sql/my_decimal.cc	2007-10-05 07:38:57 +0000
+++ b/sql/my_decimal.cc	2008-10-01 13:29:25 +0000
@@ -216,7 +216,7 @@ my_decimal *date2my_decimal(MYSQL_TIME *
   date = (ltime->year*100L + ltime->month)*100L + ltime->day;
   if (ltime->time_type > MYSQL_TIMESTAMP_DATE)
     date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
-  if (int2my_decimal(E_DEC_FATAL_ERROR, date, FALSE, dec))
+  if (int2my_decimal(E_DEC_FATAL_ERROR, ltime->neg ? -date : date, FALSE, dec))
     return dec;
   if (ltime->second_part)
   {

Thread
bzr commit into mysql-5.0-bugteam branch (azundris:2685) Bug#37553Tatiana A. Nurnberg2 Oct