Commit a22c69b2 authored by Tor Didriksen's avatar Tor Didriksen

Backport from next-mr-bugfixing of tor.didriksen@sun.com-20100106140051-3j2iuag63eltsr2e

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.
parent f512cb4e
......@@ -82,5 +82,24 @@ 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()
ENDS NOW() + INTERVAL 11 MONTH
ON COMPLETION PRESERVE
DO
INSERT INTO t1 VALUES (1);
DROP TABLE t1;
DROP EVENT e1;
DROP EVENT e2;
DROP DATABASE events_test;
SET GLOBAL event_scheduler=@event_scheduler;
......@@ -108,6 +108,32 @@ 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()
ENDS NOW() + INTERVAL 11 MONTH
ON COMPLETION PRESERVE
DO
INSERT INTO t1 VALUES (1);
DROP TABLE t1;
DROP EVENT e1;
DROP EVENT e2;
DROP DATABASE events_test;
SET GLOBAL event_scheduler=@event_scheduler;
......
......@@ -834,8 +834,9 @@ bool get_next_time(const Time_zone *time_zone, my_time_t *next,
}
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment