diff options
Diffstat (limited to 'sql/event_data_objects.cc')
| -rw-r--r-- | sql/event_data_objects.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 86a710f87c6..db056a9f08e 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -479,14 +479,24 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) uint not_used; if (!starts_null) { - table->field[ET_FIELD_STARTS]->get_date(&time, TIME_NO_ZERO_DATE); + /* + The expected data type for these columns in mysql.events: + starts, ends, execute_at, last_executed + is DATETIME. No nanosecond truncation should normally be needed, + unless the DBA changes them, e.g. to VARCHAR, DECIMAL, etc. + For this unexpected case let's use the default round mode, + according to the current session settings. + */ + table->field[ET_FIELD_STARTS]->get_date(&time, TIME_NO_ZERO_DATE | + thd->temporal_round_mode()); starts= my_tz_OFFSET0->TIME_to_gmt_sec(&time,¬_used); } ends_null= table->field[ET_FIELD_ENDS]->is_null(); if (!ends_null) { - table->field[ET_FIELD_ENDS]->get_date(&time, TIME_NO_ZERO_DATE); + table->field[ET_FIELD_ENDS]->get_date(&time, TIME_NO_ZERO_DATE | + thd->temporal_round_mode()); ends= my_tz_OFFSET0->TIME_to_gmt_sec(&time,¬_used); } @@ -502,8 +512,8 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) DBUG_ASSERT(!(starts_null && ends_null && !expression && execute_at_null)); if (!expression && !execute_at_null) { - if (table->field[ET_FIELD_EXECUTE_AT]->get_date(&time, - TIME_NO_ZERO_DATE)) + if (table->field[ET_FIELD_EXECUTE_AT]->get_date(&time, TIME_NO_ZERO_DATE | + thd->temporal_round_mode())) DBUG_RETURN(TRUE); execute_at= my_tz_OFFSET0->TIME_to_gmt_sec(&time,¬_used); } @@ -535,8 +545,8 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table) if (!table->field[ET_FIELD_LAST_EXECUTED]->is_null()) { - table->field[ET_FIELD_LAST_EXECUTED]->get_date(&time, - TIME_NO_ZERO_DATE); + table->field[ET_FIELD_LAST_EXECUTED]->get_date(&time, TIME_NO_ZERO_DATE | + thd->temporal_round_mode()); last_executed= my_tz_OFFSET0->TIME_to_gmt_sec(&time,¬_used); } @@ -654,7 +664,7 @@ my_time_t add_interval(MYSQL_TIME *ltime, const Time_zone *time_zone, interval_type scale, INTERVAL interval) { - if (date_add_interval(ltime, scale, interval)) + if (date_add_interval(current_thd, ltime, scale, interval)) return 0; uint not_used; @@ -758,8 +768,8 @@ bool get_next_time(const Time_zone *time_zone, my_time_t *next, if (seconds) { - longlong seconds_diff; - long microsec_diff; + ulonglong seconds_diff; + ulong microsec_diff; bool negative= calc_time_diff(&local_now, &local_start, 1, &seconds_diff, µsec_diff); if (!negative) |
