Commit b934539d authored by unknown's avatar unknown

fix for bug#16537

(post-review pre-push changes)
coding style (mostly trailing spaces removed)


mysql-test/r/events.result:
  fix result file
sql/event.cc:
  - remove trailing spaces
  - add a missing initializer (gcc warning)
  - C++ to C comments
sql/event_executor.cc:
  - fix coding style (C++ to C comments, remove trailing spaces)
  - fix wrong indexing buggie not found till now (queue indexing is 0 based,
    not 1 based)
sql/event_timed.cc:
  - fix coding style
parent f6f52921
...@@ -40,7 +40,7 @@ drop event event2; ...@@ -40,7 +40,7 @@ drop event event2;
CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1; CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 10 INTERVAL_SECOND # # ENABLED events_test event_starts_test root@localhost RECURRING NULL 10 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment starts IS NULL ends IS NULL comment
0 1 0 1
...@@ -69,21 +69,21 @@ DROP EVENT event_starts_test; ...@@ -69,21 +69,21 @@ DROP EVENT event_starts_test;
CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2; CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 INTERVAL_SECOND # # ENABLED events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment starts IS NULL ends IS NULL comment
0 0 0 0
ALTER EVENT event_starts_test COMMENT "non-empty comment"; ALTER EVENT event_starts_test COMMENT "non-empty comment";
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 INTERVAL_SECOND # # ENABLED events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment starts IS NULL ends IS NULL comment
0 0 non-empty comment 0 0 non-empty comment
ALTER EVENT event_starts_test COMMENT ""; ALTER EVENT event_starts_test COMMENT "";
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 INTERVAL_SECOND # # ENABLED events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
DROP EVENT event_starts_test; DROP EVENT event_starts_test;
create event e_43 on schedule every 1 second do set @a = 5; create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1; set global event_scheduler = 1;
......
This diff is collapsed.
This diff is collapsed.
...@@ -116,7 +116,7 @@ event_timed::init_body(THD *thd) ...@@ -116,7 +116,7 @@ event_timed::init_body(THD *thd)
body_begin, thd->lex->ptr)); body_begin, thd->lex->ptr));
body.length= thd->lex->ptr - body_begin; body.length= thd->lex->ptr - body_begin;
// Trim nuls at the end /* Trim nuls at the end */
while (body.length && body_begin[body.length-1] == '\0') while (body.length && body_begin[body.length-1] == '\0')
body.length--; body.length--;
...@@ -161,13 +161,12 @@ event_timed::init_execute_at(THD *thd, Item *expr) ...@@ -161,13 +161,12 @@ event_timed::init_execute_at(THD *thd, Item *expr)
/* no starts and/or ends in case of execute_at */ /* no starts and/or ends in case of execute_at */
DBUG_PRINT("info", ("starts_null && ends_null should be 1 is %d", DBUG_PRINT("info", ("starts_null && ends_null should be 1 is %d",
(starts_null && ends_null))) (starts_null && ends_null)));
DBUG_ASSERT(starts_null && ends_null); DBUG_ASSERT(starts_null && ends_null);
// let's check whether time is in the past /* let's check whether time is in the past */
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,
(my_time_t) thd->query_start()); (my_time_t) thd->query_start());
if ((not_used= expr->get_date(&ltime, TIME_NO_ZERO_DATE))) if ((not_used= expr->get_date(&ltime, TIME_NO_ZERO_DATE)))
DBUG_RETURN(ER_WRONG_VALUE); DBUG_RETURN(ER_WRONG_VALUE);
...@@ -252,14 +251,14 @@ event_timed::init_interval(THD *thd, Item *expr, interval_type new_interval) ...@@ -252,14 +251,14 @@ event_timed::init_interval(THD *thd, Item *expr, interval_type new_interval)
case INTERVAL_DAY_MINUTE: case INTERVAL_DAY_MINUTE:
expression= (interval.day* 24 + interval.hour) * 60 + interval.minute; expression= (interval.day* 24 + interval.hour) * 60 + interval.minute;
break; break;
case INTERVAL_HOUR_SECOND: // day is anyway 0 case INTERVAL_HOUR_SECOND: /* day is anyway 0 */
case INTERVAL_DAY_SECOND: case INTERVAL_DAY_SECOND:
/* DAY_SECOND having problems because of leap seconds? */ /* DAY_SECOND having problems because of leap seconds? */
expression= ((interval.day* 24 + interval.hour) * 60 + interval.minute)*60 expression= ((interval.day* 24 + interval.hour) * 60 + interval.minute)*60
+ interval.second; + interval.second;
break; break;
case INTERVAL_MINUTE_MICROSECOND: // day and hour are 0 case INTERVAL_MINUTE_MICROSECOND: /* day and hour are 0 */
case INTERVAL_HOUR_MICROSECOND:// day is anyway 0 case INTERVAL_HOUR_MICROSECOND: /* day is anyway 0 */
case INTERVAL_DAY_MICROSECOND: case INTERVAL_DAY_MICROSECOND:
DBUG_RETURN(EVEX_MICROSECOND_UNSUP); DBUG_RETURN(EVEX_MICROSECOND_UNSUP);
expression= ((((interval.day*24) + interval.hour)*60+interval.minute)*60 + expression= ((((interval.day*24) + interval.hour)*60+interval.minute)*60 +
...@@ -398,7 +397,7 @@ event_timed::init_ends(THD *thd, Item *new_ends) ...@@ -398,7 +397,7 @@ event_timed::init_ends(THD *thd, Item *new_ends)
Check whether ENDS is not in the past. Check whether ENDS is not in the past.
*/ */
DBUG_PRINT("info", ("ENDS after NOW?")); DBUG_PRINT("info", ("ENDS after NOW?"));
my_tz_UTC->gmt_sec_to_TIME(&ltime_now, thd->query_start()); my_tz_UTC->gmt_sec_to_TIME(&ltime_now, thd->query_start());
if (my_time_compare(&ltime_now, &ltime) == 1) if (my_time_compare(&ltime_now, &ltime) == 1)
DBUG_RETURN(EVEX_BAD_PARAMS); DBUG_RETURN(EVEX_BAD_PARAMS);
...@@ -534,8 +533,8 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table) ...@@ -534,8 +533,8 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
et->definer_user.str= strmake_root(mem_root, et->definer.str, len); et->definer_user.str= strmake_root(mem_root, et->definer.str, len);
et->definer_user.length= len; et->definer_user.length= len;
len= et->definer.length - len - 1; //1 is because of @ len= et->definer.length - len - 1; //1 is because of @
et->definer_host.str= strmake_root(mem_root, ptr + 1, len);//1: because of @ et->definer_host.str= strmake_root(mem_root, ptr + 1, len);/* 1:because of @*/
et->definer_host.length= len; et->definer_host.length= len;
et->starts_null= table->field[EVEX_FIELD_STARTS]->is_null(); et->starts_null= table->field[EVEX_FIELD_STARTS]->is_null();
...@@ -597,20 +596,20 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table) ...@@ -597,20 +596,20 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
#endif #endif
last_executed_changed= false; last_executed_changed= false;
// ToDo : Andrey . Find a way not to allocate ptr on event_mem_root /* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
if ((ptr= get_field(mem_root, table->field[EVEX_FIELD_STATUS])) == NullS) if ((ptr= get_field(mem_root, table->field[EVEX_FIELD_STATUS])) == NullS)
goto error; goto error;
DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", et->name.str, ptr)); DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", et->name.str, ptr));
et->status= (ptr[0]=='E'? MYSQL_EVENT_ENABLED:MYSQL_EVENT_DISABLED); et->status= (ptr[0]=='E'? MYSQL_EVENT_ENABLED:MYSQL_EVENT_DISABLED);
// ToDo : Andrey . Find a way not to allocate ptr on event_mem_root /* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
if ((ptr= get_field(mem_root, if ((ptr= get_field(mem_root,
table->field[EVEX_FIELD_ON_COMPLETION])) == NullS) table->field[EVEX_FIELD_ON_COMPLETION])) == NullS)
goto error; goto error;
et->on_completion= (ptr[0]=='D'? MYSQL_EVENT_ON_COMPLETION_DROP: et->on_completion= (ptr[0]=='D'? MYSQL_EVENT_ON_COMPLETION_DROP:
MYSQL_EVENT_ON_COMPLETION_PRESERVE); MYSQL_EVENT_ON_COMPLETION_PRESERVE);
et->comment.str= get_field(mem_root, table->field[EVEX_FIELD_COMMENT]); et->comment.str= get_field(mem_root, table->field[EVEX_FIELD_COMMENT]);
if (et->comment.str != NullS) if (et->comment.str != NullS)
...@@ -796,7 +795,7 @@ event_timed::compute_next_execution_time() ...@@ -796,7 +795,7 @@ event_timed::compute_next_execution_time()
goto ret; goto ret;
} }
} }
if (!starts_null && !ends_null) if (!starts_null && !ends_null)
{ {
/* /*
...@@ -931,7 +930,7 @@ event_timed::mark_last_executed(THD *thd) ...@@ -931,7 +930,7 @@ event_timed::mark_last_executed(THD *thd)
thd->end_time(); thd->end_time();
my_tz_UTC->gmt_sec_to_TIME(&time_now, (my_time_t) thd->query_start()); my_tz_UTC->gmt_sec_to_TIME(&time_now, (my_time_t) thd->query_start());
last_executed= time_now; // was execute_at last_executed= time_now; /* was execute_at */
#ifdef ANDREY_0 #ifdef ANDREY_0
last_executed= execute_at; last_executed= execute_at;
#endif #endif
...@@ -1086,7 +1085,7 @@ event_timed::get_create_event(THD *thd, String *buf) ...@@ -1086,7 +1085,7 @@ event_timed::get_create_event(THD *thd, String *buf)
} }
else else
{ {
char dtime_buff[20*2+32];// +32 to make my_snprintf_{8bit|ucs2} happy char dtime_buff[20*2+32];/* +32 to make my_snprintf_{8bit|ucs2} happy */
buf->append(STRING_WITH_LEN("AT '")); buf->append(STRING_WITH_LEN("AT '"));
/* /*
Pass the buffer and the second param tells fills the buffer and Pass the buffer and the second param tells fills the buffer and
...@@ -1427,7 +1426,7 @@ extern pthread_attr_t connection_attrib; ...@@ -1427,7 +1426,7 @@ extern pthread_attr_t connection_attrib;
/* /*
Checks whether is possible and forks a thread. Passes self as argument. Checks whether is possible and forks a thread. Passes self as argument.
Returns Returns
EVENT_EXEC_STARTED - OK EVENT_EXEC_STARTED - OK
EVENT_EXEC_ALREADY_EXEC - Thread not forked, already working EVENT_EXEC_ALREADY_EXEC - Thread not forked, already working
...@@ -1498,7 +1497,6 @@ event_timed::spawn_thread_finish(THD *thd) ...@@ -1498,7 +1497,6 @@ event_timed::spawn_thread_finish(THD *thd)
Returns Returns
0 - ok 0 - ok
1 - not locked by this thread 1 - not locked by this thread
*/ */
...@@ -1524,5 +1522,5 @@ event_timed::spawn_unlock(THD *thd) ...@@ -1524,5 +1522,5 @@ event_timed::spawn_unlock(THD *thd)
} }
} }
VOID(pthread_mutex_unlock(&this->LOCK_running)); VOID(pthread_mutex_unlock(&this->LOCK_running));
return ret; return ret;
} }
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