List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 19 2010 8:25am
Subject:bzr commit into mysql-5.1-bugteam branch (tor.didriksen:3387)
View as plain text  
#At file:///export/home/didrik/mysqldev51/5.1-bugteam-bug50087/ based on revid:sergey.glukhov@stripped

 3387 Tor Didriksen	2010-05-19
      Backport from next-mr-bugfixing of tor.didriksen@stripped
      
      Bug #50087 Interval arithmetic for Event_queue_element is not portable.
      
      Subtraction of two unsigned months yielded a (very large) positive value.
      Conversion of this to a signed value was not necessarily well defined.
                    
      Solution: do the subtraction on signed values.
      
      Added some more tests, since the original test case would only fail in january.
     @ mysql-test/r/events_scheduling.result
        Add test cases.
     @ mysql-test/t/events_scheduling.test
        Add test cases.
     @ sql/event_data_objects.cc
        Convert month to signed before doing the subtraction.

    modified:
      mysql-test/r/events_scheduling.result
      mysql-test/t/events_scheduling.test
      sql/event_data_objects.cc
=== modified file 'mysql-test/r/events_scheduling.result'
--- a/mysql-test/r/events_scheduling.result	2008-12-16 18:09:09 +0000
+++ b/mysql-test/r/events_scheduling.result	2010-05-19 08:25:23 +0000
@@ -82,5 +82,101 @@ DROP TABLE table_1;
 DROP TABLE table_2;
 DROP TABLE table_3;
 DROP TABLE table_4;
+
+Bug #50087 Interval arithmetic for Event_queue_element is not portable.
+
+CREATE TABLE t1(a int);
+CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 1 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 2 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e3 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 3 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e4 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 4 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e5 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 5 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e6 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 6 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e7 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 7 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e8 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 8 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e9 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 9 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e10 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 10 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e11 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 11 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e12 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 12 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+CREATE EVENT e13 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW()
+ENDS NOW() + INTERVAL 11 MONTH
+ON COMPLETION PRESERVE
+DO
+INSERT INTO t1 VALUES (1);
+DROP TABLE t1;
+DROP EVENT e1;
+DROP EVENT e2;
+DROP EVENT e3;
+DROP EVENT e4;
+DROP EVENT e5;
+DROP EVENT e6;
+DROP EVENT e7;
+DROP EVENT e8;
+DROP EVENT e9;
+DROP EVENT e10;
+DROP EVENT e11;
+DROP EVENT e12;
+DROP EVENT e13;
 DROP DATABASE events_test;
 SET GLOBAL event_scheduler=@event_scheduler;

=== modified file 'mysql-test/t/events_scheduling.test'
--- a/mysql-test/t/events_scheduling.test	2008-12-16 18:09:09 +0000
+++ b/mysql-test/t/events_scheduling.test	2010-05-19 08:25:23 +0000
@@ -108,6 +108,120 @@ DROP TABLE table_1;
 DROP TABLE table_2;
 DROP TABLE table_3;
 DROP TABLE table_4;
+
+-- echo
+-- echo Bug #50087 Interval arithmetic for Event_queue_element is not portable.
+-- echo
+
+CREATE TABLE t1(a int);
+
+CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 1 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 2 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e3 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 3 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e4 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 4 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e5 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 5 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e6 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 6 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e7 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 7 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e8 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 8 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e9 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 9 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e10 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 10 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e11 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 11 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e12 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW() - INTERVAL 12 MONTH
+ENDS NOW() + INTERVAL 2 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+CREATE EVENT e13 ON SCHEDULE EVERY 1 MONTH
+STARTS NOW()
+ENDS NOW() + INTERVAL 11 MONTH
+ON COMPLETION PRESERVE
+DO
+  INSERT INTO t1 VALUES (1);
+
+DROP TABLE t1;
+DROP EVENT e1;
+DROP EVENT e2;
+DROP EVENT e3;
+DROP EVENT e4;
+DROP EVENT e5;
+DROP EVENT e6;
+DROP EVENT e7;
+DROP EVENT e8;
+DROP EVENT e9;
+DROP EVENT e10;
+DROP EVENT e11;
+DROP EVENT e12;
+DROP EVENT e13;
+
+
 DROP DATABASE events_test;
 SET GLOBAL event_scheduler=@event_scheduler;
 

=== modified file 'sql/event_data_objects.cc'
--- a/sql/event_data_objects.cc	2010-01-19 09:03:40 +0000
+++ b/sql/event_data_objects.cc	2010-05-19 08:25:23 +0000
@@ -834,8 +834,9 @@ bool get_next_time(const Time_zone *time
   }
   else
   {
-    long diff_months= (long) (local_now.year - local_start.year)*12 +
-                      (local_now.month - local_start.month);
+    long diff_months= ((long) local_now.year - (long) local_start.year)*12 +
+                      ((long) local_now.month - (long) local_start.month);
+
     /*
       Unlike for seconds above, the formula below returns the interval
       that, when added to the local_start, will give the time in the


Attachment: [text/bzr-bundle] bzr/tor.didriksen@sun.com-20100519082523-dgtycxek1jfxtodf.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (tor.didriksen:3387) Tor Didriksen19 May