mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
cace147c63
the parsing. Next step will be to refactor of usage of Event_timed during Events::create_event() and Events::update_event(). Disallow: - CREATE EVENT ... DO CREATE EVENT ...; - ALTER EVENT ... DO CREATE EVENT ...; - CREATE EVENT ... DO ALTER EVENT DO ....; - CREATE PROCEDURE ... BEGIN CREATE EVENT ... END| Allowed: - CREATE EVENT ... DO DROP EVENT yyy; - CREATE EVENT ... DO ALTER EVENT yyy; (the nested ALTER EVENT can have anything but DO clause) - ALTER EVENT ... DO ALTER EVENT yyy; (the nested ALTER EVENT can have anything but DO clause) - ALTER EVENT ... DO DROP EVENT yyy; - CREATE PROCEDURE ... BEGIN ALTER EVENT ... END| (the nested ALTER EVENT can have anything but DO clause) - CREATE PROCEDURE ... BEGIN DROP EVENT ... END| mysql-test/r/events.result: update results mysql-test/r/events_bugs.result: update results mysql-test/t/events.test: use number as error, mysql-test-run does not like the name. will come back to this later, now it's enough to pass the test. disable nested events / events in SP, when the nested event has a body. If no body is provided, namely DROP EVENT or ALTER that changes the characteristics, then these are allowed. mysql-test/t/events_bugs.test: use number as error, mysql-test-run does not like the name. will come back to this later, now it's enough to pass the test. disable nested events / events in SP, when the nested event has a body. If no body is provided, namely DROP EVENT or ALTER that changes the characteristics, then these are allowed. sql/share/errmsg.txt: new message sql/sql_yacc.yy: refactor CREATE EVENT parsing to fit into the structure CREATE DEFINER=xxx EVENT The actual definer part is not used, but parsed, for now. Disable nested CREATE EVENTS, CREATE EVENT inside CREATE PROCEDURE. And an event DDL with body inside an ALTER. This stops the following : - CREATE EVENT ... DO CREATE EVENT ...; - ALTER EVENT ... DO CREATE EVENT ...; - CREATE EVENT ... DO ALTER EVENT DO ....; - CREATE PROCEDURE ... BEGIN CREATE EVENT ... END| This allows: - CREATE EVENT ... DO DROP EVENT yyy; - CREATE EVENT ... DO ALTER EVENT yyy; (the nested ALTER EVENT can have anything but DO clause) - ALTER EVENT ... DO ALTER EVENT yyy; (the nested ALTER EVENT can have anything but DO clause) - ALTER EVENT ... DO DROP EVENT yyy; - CREATE PROCEDURE ... BEGIN ALTER EVENT ... END| (the nested ALTER EVENT can have anything but DO clause) - CREATE PROCEDURE ... BEGIN DROP EVENT ... END|
401 lines
20 KiB
Text
401 lines
20 KiB
Text
create database if not exists events_test;
|
||
use events_test;
|
||
CREATE USER pauline@localhost;
|
||
CREATE DATABASE db_x;
|
||
GRANT EVENT ON db_x.* TO pauline@localhost;
|
||
USE db_x;
|
||
CREATE TABLE x_table(a int);
|
||
CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x;
|
||
CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
|
||
SHOW DATABASES LIKE 'db_x';
|
||
Database (db_x)
|
||
db_x
|
||
SET GLOBAL event_scheduler=1;
|
||
SHOW DATABASES LIKE 'db_x';
|
||
Database (db_x)
|
||
db_x
|
||
SHOW TABLES FROM db_x;
|
||
Tables_in_db_x
|
||
x_table
|
||
SET GLOBAL event_scheduler=2;
|
||
DROP EVENT e_x1;
|
||
DROP EVENT e_x2;
|
||
DROP DATABASE db_x;
|
||
DROP USER pauline@localhost;
|
||
USE events_test;
|
||
SET GLOBAL event_scheduler=2;
|
||
drop event if exists event1;
|
||
Warnings:
|
||
Note 1305 Event event1 does not exist
|
||
create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end;
|
||
alter event event1 rename to event2 enable;
|
||
alter event event2 disable;
|
||
alter event event2 enable;
|
||
alter event event2 on completion not preserve;
|
||
alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__
|
||
alter event event3 rename to event2;
|
||
drop event event2;
|
||
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
|
||
drop event event2;
|
||
CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
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';
|
||
starts IS NULL ends IS NULL comment
|
||
0 1
|
||
ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
|
||
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
|
||
1 1
|
||
ALTER EVENT event_starts_test COMMENT "non-empty comment";
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
|
||
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
|
||
1 1 non-empty comment
|
||
ALTER EVENT event_starts_test COMMENT "";
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
|
||
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
|
||
1 1
|
||
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;
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
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';
|
||
starts IS NULL ends IS NULL comment
|
||
0 0
|
||
ALTER EVENT event_starts_test COMMENT "non-empty comment";
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
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';
|
||
starts IS NULL ends IS NULL comment
|
||
0 0 non-empty comment
|
||
ALTER EVENT event_starts_test COMMENT "";
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
|
||
DROP EVENT event_starts_test;
|
||
create table test_nested(a int);
|
||
create event e_43 on schedule every 1 second do set @a = 5;
|
||
set global event_scheduler = 1;
|
||
alter event e_43 do alter event e_43 do set @a = 4;
|
||
ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
|
||
alter event e_43 do
|
||
begin
|
||
alter event e_43 on schedule every 5 minute;
|
||
insert into test_nested values(1);
|
||
end|
|
||
set global event_scheduler = 1;
|
||
select db, name, body, status, interval_field, interval_value from mysql.event;
|
||
db name body status interval_field interval_value
|
||
events_test e_43 begin
|
||
alter event e_43 on schedule every 5 minute;
|
||
insert into test_nested values(1);
|
||
end ENABLED MINUTE 5
|
||
drop event e_43;
|
||
drop table test_nested;
|
||
"Let's check whether we can use non-qualified names"
|
||
create table non_qualif(a int);
|
||
create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
|
||
select * from non_qualif;
|
||
a
|
||
800219
|
||
drop event non_qualif_ev;
|
||
drop table non_qualif;
|
||
set global event_scheduler = 2;
|
||
create table t_event3 (a int, b float);
|
||
drop event if exists event3;
|
||
Warnings:
|
||
Note 1305 Event event3 does not exist
|
||
create event event3 on schedule every 50 + 10 minute starts date_add("20100101", interval 5 minute) ends date_add("20151010", interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand());
|
||
select count(*) from t_event3;
|
||
count(*)
|
||
0
|
||
drop event event3;
|
||
drop table t_event3;
|
||
set names utf8;
|
||
CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1;
|
||
SHOW CREATE EVENT root6;
|
||
Event sql_mode Create Event
|
||
root6 CREATE EVENT `root6` ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1
|
||
create event root7 on schedule every 2 year do select 1;
|
||
SHOW CREATE EVENT root7;
|
||
Event sql_mode Create Event
|
||
root7 CREATE EVENT `root7` ON SCHEDULE EVERY 2 YEAR ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root8 on schedule every '2:5' year_month do select 1;
|
||
SHOW CREATE EVENT root8;
|
||
Event sql_mode Create Event
|
||
root8 CREATE EVENT `root8` ON SCHEDULE EVERY '2-5' YEAR_MONTH ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root8_1 on schedule every '2:15' year_month do select 1;
|
||
SHOW CREATE EVENT root8_1;
|
||
Event sql_mode Create Event
|
||
root8_1 CREATE EVENT `root8_1` ON SCHEDULE EVERY '3-3' YEAR_MONTH ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1;
|
||
SHOW CREATE EVENT root9;
|
||
Event sql_mode Create Event
|
||
root9 CREATE EVENT `root9` ON SCHEDULE EVERY 2 WEEK ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' DO select 1
|
||
create event root10 on schedule every '20:5' day_hour do select 1;
|
||
SHOW CREATE EVENT root10;
|
||
Event sql_mode Create Event
|
||
root10 CREATE EVENT `root10` ON SCHEDULE EVERY '20 5' DAY_HOUR ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root11 on schedule every '20:25' day_hour do select 1;
|
||
SHOW CREATE EVENT root11;
|
||
Event sql_mode Create Event
|
||
root11 CREATE EVENT `root11` ON SCHEDULE EVERY '21 1' DAY_HOUR ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root12 on schedule every '20:25' hour_minute do select 1;
|
||
SHOW CREATE EVENT root12;
|
||
Event sql_mode Create Event
|
||
root12 CREATE EVENT `root12` ON SCHEDULE EVERY '20:25' HOUR_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root13 on schedule every '25:25' hour_minute do select 1;
|
||
SHOW CREATE EVENT root13;
|
||
Event sql_mode Create Event
|
||
root13 CREATE EVENT `root13` ON SCHEDULE EVERY '25:25' HOUR_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root13_1 on schedule every '11:65' hour_minute do select 1;
|
||
SHOW CREATE EVENT root13_1;
|
||
Event sql_mode Create Event
|
||
root13_1 CREATE EVENT `root13_1` ON SCHEDULE EVERY '12:5' HOUR_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root14 on schedule every '35:35' minute_second do select 1;
|
||
SHOW CREATE EVENT root14;
|
||
Event sql_mode Create Event
|
||
root14 CREATE EVENT `root14` ON SCHEDULE EVERY '35:35' MINUTE_SECOND ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root15 on schedule every '35:66' minute_second do select 1;
|
||
SHOW CREATE EVENT root15;
|
||
Event sql_mode Create Event
|
||
root15 CREATE EVENT `root15` ON SCHEDULE EVERY '36:6' MINUTE_SECOND ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root16 on schedule every '35:56' day_minute do select 1;
|
||
SHOW CREATE EVENT root16;
|
||
Event sql_mode Create Event
|
||
root16 CREATE EVENT `root16` ON SCHEDULE EVERY '1 11:56' DAY_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root17 on schedule every '35:12:45' day_minute do select 1;
|
||
SHOW CREATE EVENT root17;
|
||
Event sql_mode Create Event
|
||
root17 CREATE EVENT `root17` ON SCHEDULE EVERY '35 12:45' DAY_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root17_1 on schedule every '35:25:65' day_minute do select 1;
|
||
SHOW CREATE EVENT root17_1;
|
||
Event sql_mode Create Event
|
||
root17_1 CREATE EVENT `root17_1` ON SCHEDULE EVERY '36 2:5' DAY_MINUTE ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root18 on schedule every '35:12:45' hour_second do select 1;
|
||
SHOW CREATE EVENT root18;
|
||
Event sql_mode Create Event
|
||
root18 CREATE EVENT `root18` ON SCHEDULE EVERY '35:12:45' HOUR_SECOND ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root19 on schedule every '15:59:85' hour_second do select 1;
|
||
SHOW CREATE EVENT root19;
|
||
Event sql_mode Create Event
|
||
root19 CREATE EVENT `root19` ON SCHEDULE EVERY '16:0:25' HOUR_SECOND ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
create event root20 on schedule every '50:20:12:45' day_second do select 1;
|
||
SHOW CREATE EVENT root20;
|
||
Event sql_mode Create Event
|
||
root20 CREATE EVENT `root20` ON SCHEDULE EVERY '50 20:12:45' DAY_SECOND ON COMPLETION NOT PRESERVE ENABLE DO select 1
|
||
set names cp1251;
|
||
create event <20><><EFBFBD><EFBFBD>21 on schedule every '50:23:59:95' day_second COMMENT '<27><><EFBFBD><EFBFBD> <20> 1251 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' do select 1;
|
||
SHOW CREATE EVENT <20><><EFBFBD><EFBFBD>21;
|
||
Event sql_mode Create Event
|
||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>21 CREATE EVENT `<60><><EFBFBD><EFBFBD>21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND ON COMPLETION NOT PRESERVE ENABLE COMMENT '<27><><EFBFBD><EFBFBD> <20> 1251 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' DO select 1
|
||
insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND");
|
||
show create event root22;
|
||
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
|
||
SHOW EVENTS;
|
||
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
|
||
drop event root22;
|
||
drop event root6;
|
||
drop event root7;
|
||
drop event root8;
|
||
drop event root8_1;
|
||
drop event root9;
|
||
drop event root10;
|
||
drop event root11;
|
||
drop event root12;
|
||
drop event root13;
|
||
drop event root13_1;
|
||
drop event root14;
|
||
drop event root15;
|
||
drop event root16;
|
||
drop event root17;
|
||
drop event root17_1;
|
||
drop event root18;
|
||
drop event root19;
|
||
drop event root20;
|
||
drop event <20><><EFBFBD><EFBFBD>21;
|
||
set names latin1;
|
||
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED
|
||
ALTER TABLE mysql.event ADD dummy INT FIRST;
|
||
SHOW EVENTS;
|
||
ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 17. Table probably corrupted
|
||
ALTER TABLE mysql.event DROP dummy, ADD dummy2 VARCHAR(64) FIRST;
|
||
SHOW EVENTS;
|
||
ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 17. Table probably corrupted
|
||
ALTER TABLE mysql.event DROP dummy2;
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED
|
||
CREATE TABLE event_like LIKE mysql.event;
|
||
INSERT INTO event_like SELECT * FROM mysql.event;
|
||
ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default '';
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log.
|
||
ALTER TABLE mysql.event MODIFY db char(20) character set utf8 collate utf8_bin default '';
|
||
SHOW CREATE TABLE mysql.event;
|
||
Table Create Table
|
||
event CREATE TABLE `event` (
|
||
`db` char(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||
`name` char(64) NOT NULL DEFAULT '',
|
||
`body` longblob NOT NULL,
|
||
`definer` char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||
`execute_at` datetime DEFAULT NULL,
|
||
`interval_value` int(11) DEFAULT NULL,
|
||
`interval_field` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') DEFAULT NULL,
|
||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||
`last_executed` datetime DEFAULT NULL,
|
||
`starts` datetime DEFAULT NULL,
|
||
`ends` datetime DEFAULT NULL,
|
||
`status` enum('ENABLED','DISABLED') NOT NULL DEFAULT 'ENABLED',
|
||
`on_completion` enum('DROP','PRESERVE') NOT NULL DEFAULT 'DROP',
|
||
`sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') NOT NULL DEFAULT '',
|
||
`comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||
PRIMARY KEY (`db`,`name`)
|
||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log.
|
||
ALTER TABLE mysql.event MODIFY db char(64) character set utf8 collate utf8_bin default '';
|
||
"This should work"
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED
|
||
ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default '';
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log.
|
||
ALTER TABLE mysql.event MODIFY db varchar(64) character set utf8 collate utf8_bin default '';
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log.
|
||
ALTER TABLE mysql.event DROP comment, DROP starts;
|
||
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
|
||
ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 14. Table probably corrupted
|
||
DROP TABLE mysql.event;
|
||
CREATE TABLE mysql.event like event_like;
|
||
INSERT INTO mysql.event SELECT * FROM event_like;
|
||
DROP TABLE event_like;
|
||
SHOW EVENTS;
|
||
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
|
||
events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED
|
||
DROP EVENT intact_check;
|
||
create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5;
|
||
select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event;
|
||
db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion
|
||
events_test e_26 set @a = 5 root@localhost 2017-01-01 00:00:00 DROP
|
||
drop event e_26;
|
||
create event e_26 on schedule at NULL disabled do set @a = 5;
|
||
ERROR HY000: Incorrect AT value: 'NULL'
|
||
create event e_26 on schedule at 'definitely not a datetime' disabled do set @a = 5;
|
||
ERROR HY000: Incorrect AT value: 'definitely not a datetime'
|
||
set names utf8;
|
||
create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
|
||
drop event задачка;
|
||
set event_scheduler=2;
|
||
ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
|
||
set global event_scheduler=3;
|
||
ERROR 42000: Variable 'event_scheduler' can't be set to the value of '3'
|
||
"DISABLE the scheduler. Testing that it does not work when the variable is 0"
|
||
set global event_scheduler=2;
|
||
select definer, name, db from mysql.event;
|
||
definer name db
|
||
select get_lock("test_lock1", 20);
|
||
get_lock("test_lock1", 20)
|
||
1
|
||
create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
|
||
"Should return 1 row"
|
||
select definer, name, db from mysql.event;
|
||
definer name db
|
||
root@localhost закачка events_test
|
||
"Should be only 1 process"
|
||
select /*1*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Connect Suspended NULL
|
||
select release_lock("test_lock1");
|
||
release_lock("test_lock1")
|
||
1
|
||
drop event закачка;
|
||
"Should have 0 events"
|
||
select count(*) from mysql.event;
|
||
count(*)
|
||
0
|
||
"ENABLE the scheduler and get a lock"
|
||
set global event_scheduler=1;
|
||
select get_lock("test_lock2", 20);
|
||
get_lock("test_lock2", 20)
|
||
1
|
||
"Create an event which tries to acquire a mutex. The event locks on the mutex"
|
||
create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
|
||
"Let some time pass to the event starts"
|
||
"Should have only 2 processes: the scheduler and the locked event"
|
||
select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Connect Sleeping NULL
|
||
root localhost events_test Connect User lock select get_lock("test_lock2", 20)
|
||
"Release the mutex, the event worker should finish."
|
||
"Release the mutex, the event worker should finish."
|
||
select release_lock("test_lock2");
|
||
release_lock("test_lock2")
|
||
1
|
||
drop event закачка;
|
||
set global event_scheduler=1;
|
||
select get_lock("test_lock2_1", 20);
|
||
get_lock("test_lock2_1", 20)
|
||
1
|
||
create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
|
||
"Should have only 3 processes: the scheduler, our conn and the locked event"
|
||
select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Connect Sleeping NULL
|
||
root localhost events_test Connect User lock select get_lock("test_lock2_1", 20)
|
||
set global event_scheduler=2;
|
||
"Should have only our process now:"
|
||
select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
|
||
user host db command state info
|
||
event_scheduler localhost NULL Connect Suspended NULL
|
||
root localhost events_test Connect User lock select get_lock("test_lock2_1", 20)
|
||
drop event закачка21;
|
||
create table t_16 (s1 int);
|
||
create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5;
|
||
ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
|
||
drop table t_16;
|
||
create event white_space
|
||
on schedule every 10 hour
|
||
disable
|
||
do
|
||
select 1;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 1
|
||
drop event white_space;
|
||
create event white_space on schedule every 10 hour disable do
|
||
select 2;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 2
|
||
drop event white_space;
|
||
create event white_space on schedule every 10 hour disable do select 3;
|
||
select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
|
||
event_schema event_name definer event_definition
|
||
events_test white_space root@localhost select 3
|
||
drop event white_space;
|
||
create event e1 on schedule every 1 year do set @a = 5;
|
||
create table t1 (s1 int);
|
||
create trigger t1_ai after insert on t1 for each row show create event e1;
|
||
ERROR 0A000: Not allowed to return a result set from a trigger
|
||
drop table t1;
|
||
drop event e1;
|
||
drop database events_test;
|