summaryrefslogtreecommitdiff
path: root/sql/event_data_objects.cc
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@sun.com>2010-01-06 15:00:51 +0100
committerTor Didriksen <tor.didriksen@sun.com>2010-01-06 15:00:51 +0100
commita0f701ec171cbf02960ae014eefa5fef09a33ffe (patch)
tree5f822cbd6e51a3152056d59856647d0bd896774d /sql/event_data_objects.cc
parentf471d82bb546ffb2fb57a43dc882150b306317f6 (diff)
downloadmariadb-git-a0f701ec171cbf02960ae014eefa5fef09a33ffe.tar.gz
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.
Diffstat (limited to 'sql/event_data_objects.cc')
-rw-r--r--sql/event_data_objects.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index b2bbd340e14..7562e8d8207 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -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