Commit 6dc3c042 authored by unknown's avatar unknown

Fix for bug#28666 CREATE EVENT ... EVERY 0 SECOND let server crash

A missing check for zero value of interval was added.


mysql-test/r/events_bugs.result:
  update result file
mysql-test/t/events_bugs.test:
  add test case for bug#28666 CREATE EVENT ... EVERY 0 SECOND let server crash
sql/event_data_objects.cc:
  add a missing check about zero value for interval
parent 813f9cb5
......@@ -528,4 +528,33 @@ DROP EVENT e3;
DROP EVENT e2;
DROP EVENT e1;
SET TIME_ZONE=@save_time_zone;
drop event if exists new_event;
CREATE EVENT new_event ON SCHEDULE EVERY 0 SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT 0) SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY "abcdef" SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY "0abcdef" SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY "a1bcdef" SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "abcdef" UNION SELECT "abcdef") SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "0abcdef") SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "a1bcdef") SECOND DO SELECT 1;
ERROR HY000: INTERVAL is either not positive or too big
CREATE EVENT new_event ON SCHEDULE AT "every day" DO SELECT 1;
ERROR HY000: Incorrect AT value: 'every day'
CREATE EVENT new_event ON SCHEDULE AT "0every day" DO SELECT 1;
ERROR HY000: Incorrect AT value: '0every day'
CREATE EVENT new_event ON SCHEDULE AT (SELECT "every day") DO SELECT 1;
ERROR HY000: Incorrect AT value: 'every day'
CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() DO SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STARTS NOW() DO SELECT 1' at line 1
CREATE EVENT new_event ON SCHEDULE AT NOW() ENDS NOW() DO SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ENDS NOW() DO SELECT 1' at line 1
CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() ENDS NOW() DO SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STARTS NOW() ENDS NOW() DO SELECT 1' at line 1
drop database events_test;
......@@ -610,6 +610,44 @@ DROP EVENT e1;
SET TIME_ZONE=@save_time_zone;
#
# START - BUG#28666 CREATE EVENT ... EVERY 0 SECOND let server crash
#
--disable_warnings
drop event if exists new_event;
--enable_warnings
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY 0 SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT 0) SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY "abcdef" SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY "0abcdef" SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY "a1bcdef" SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "abcdef" UNION SELECT "abcdef") SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "0abcdef") SECOND DO SELECT 1;
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "a1bcdef") SECOND DO SELECT 1;
--error ER_WRONG_VALUE
CREATE EVENT new_event ON SCHEDULE AT "every day" DO SELECT 1;
--error ER_WRONG_VALUE
CREATE EVENT new_event ON SCHEDULE AT "0every day" DO SELECT 1;
--error ER_WRONG_VALUE
CREATE EVENT new_event ON SCHEDULE AT (SELECT "every day") DO SELECT 1;
--error ER_PARSE_ERROR
CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() DO SELECT 1;
--error ER_PARSE_ERROR
CREATE EVENT new_event ON SCHEDULE AT NOW() ENDS NOW() DO SELECT 1;
--error ER_PARSE_ERROR
CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() ENDS NOW() DO SELECT 1;
#
# End of tests
#
......
......@@ -413,7 +413,8 @@ Event_parse_data::init_interval(THD *thd)
default:
;/* these are the microsec stuff */
}
if (interval_tmp.neg || expression > EVEX_MAX_INTERVAL_VALUE)
if (interval_tmp.neg || expression == 0 ||
expression > EVEX_MAX_INTERVAL_VALUE)
{
my_error(ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG, MYF(0));
DBUG_RETURN(EVEX_BAD_PARAMS);
......
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