1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
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.



mysql-test/r/events_scheduling.result:
  Add test case.
mysql-test/t/events_scheduling.test:
  Add test case.
sql/event_data_objects.cc:
  Convert month to signed before doing the subtraction.
This commit is contained in:
Tor Didriksen
2010-05-19 11:18:59 +02:00
parent 36be33b0ad
commit 5539f5ccf6
3 changed files with 48 additions and 2 deletions

View File

@ -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