diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 5b48e3ea14281b6c1ee9d5b7556377f7f75af5ce..ba3e5fa02892d060a593beb30ecc588a2d4cd559 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -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; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index b2c44da7f99dedba51846bd093bcb622cd5b4fc5..5bd8ae67fb13651e9904250a2230e27cd41e17a2 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.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 # diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 9394bdcdae514104cc947d3ce60911fff71a5528..86a8f264331fdf642e102193f9b5e3e0f78a561e 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -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);