2007-03-16 09:56:57 -04:00
|
|
|
set global event_scheduler=1;
|
|
|
|
stop slave;
|
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
|
|
reset master;
|
|
|
|
reset slave;
|
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
|
|
start slave;
|
|
|
|
set binlog_format=row;
|
2007-03-29 08:17:19 -04:00
|
|
|
DROP EVENT IF EXISTS test.justonce;
|
2007-03-16 09:56:57 -04:00
|
|
|
drop table if exists t1,t2;
|
|
|
|
CREATE TABLE `t1` (
|
2007-06-26 09:26:58 -04:00
|
|
|
`id` INT(10) UNSIGNED NOT NULL,
|
2007-03-16 09:56:57 -04:00
|
|
|
`c` VARCHAR(50) NOT NULL,
|
2007-03-30 11:08:19 -04:00
|
|
|
`ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
2007-03-16 09:56:57 -04:00
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT INTO t1 (id, c) VALUES (1, 'manually');
|
|
|
|
"Creating event test.justonce on the master"
|
|
|
|
CREATE EVENT test.justonce ON SCHEDULE EVERY 2 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1 (id, c) VALUES (2, 'from justonce');
|
|
|
|
"Checking event is active on master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
|
|
|
db name status originator
|
|
|
|
test justonce ENABLED 1
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event data on the master"
|
|
|
|
SELECT * FROM t1 ORDER BY id;
|
2007-03-16 09:56:57 -04:00
|
|
|
id c ts
|
|
|
|
1 manually TIMESTAMP
|
|
|
|
2 from justonce TIMESTAMP
|
|
|
|
affected rows: 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event data on the slave"
|
|
|
|
SELECT * FROM t1 ORDER BY id;
|
2007-03-16 09:56:57 -04:00
|
|
|
id c ts
|
|
|
|
1 manually TIMESTAMP
|
|
|
|
2 from justonce TIMESTAMP
|
|
|
|
affected rows: 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event is inactive on slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
test justonce SLAVESIDE_DISABLED 1
|
|
|
|
"Dropping event test.slave_once on the slave"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.slave_once;
|
|
|
|
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
|
|
|
|
"Checking event status on the slave for originator value = slave's server_id"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
|
|
|
test slave_once ENABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_once on the slave"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.slave_once;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.justonce on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.justonce;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.er on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
|
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er ENABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
|
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
|
|
|
|
"Altering event test.er on the master"
|
|
|
|
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
|
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er ENABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er')
|
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er')
|
|
|
|
"Dropping event test.er on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT test.er;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.slave_terminate on the slave"
|
|
|
|
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
|
|
|
|
"Checking event status on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
|
|
|
db name status originator
|
|
|
|
test slave_terminate ENABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_terminate on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
DROP EVENT test.slave_terminate;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.slave_terminate with DISABLE ON SLAVE on the slave"
|
|
|
|
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DISABLE ON SLAVE DO
|
|
|
|
INSERT IGNORE INTO t1(c) VALUES (7, 'from slave_terminate');
|
|
|
|
"Checking event status on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
|
|
|
db name status originator
|
|
|
|
test slave_terminate SLAVESIDE_DISABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_terminate on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
DROP EVENT test.slave_terminate;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Cleanup"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP TABLE t1;
|
|
|
|
set binlog_format=statement;
|
2007-03-29 08:17:19 -04:00
|
|
|
DROP EVENT IF EXISTS test.justonce;
|
2007-03-16 09:56:57 -04:00
|
|
|
drop table if exists t1,t2;
|
|
|
|
CREATE TABLE `t1` (
|
2007-06-26 09:26:58 -04:00
|
|
|
`id` INT(10) UNSIGNED NOT NULL,
|
2007-03-16 09:56:57 -04:00
|
|
|
`c` VARCHAR(50) NOT NULL,
|
2007-03-30 11:08:19 -04:00
|
|
|
`ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
2007-03-16 09:56:57 -04:00
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT INTO t1 (id, c) VALUES (1, 'manually');
|
|
|
|
"Creating event test.justonce on the master"
|
|
|
|
CREATE EVENT test.justonce ON SCHEDULE EVERY 2 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1 (id, c) VALUES (2, 'from justonce');
|
|
|
|
"Checking event is active on master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
|
|
|
db name status originator
|
|
|
|
test justonce ENABLED 1
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event data on the master"
|
|
|
|
SELECT * FROM t1 ORDER BY id;
|
2007-03-16 09:56:57 -04:00
|
|
|
id c ts
|
|
|
|
1 manually TIMESTAMP
|
|
|
|
2 from justonce TIMESTAMP
|
|
|
|
affected rows: 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event data on the slave"
|
|
|
|
SELECT * FROM t1 ORDER BY id;
|
2007-03-16 09:56:57 -04:00
|
|
|
id c ts
|
|
|
|
1 manually TIMESTAMP
|
|
|
|
2 from justonce TIMESTAMP
|
|
|
|
affected rows: 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event is inactive on slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
test justonce SLAVESIDE_DISABLED 1
|
|
|
|
"Dropping event test.slave_once on the slave"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.slave_once;
|
|
|
|
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
|
|
|
|
"Checking event status on the slave for originator value = slave's server_id"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
|
|
|
test slave_once ENABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_once on the slave"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.slave_once;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.justonce on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT IF EXISTS test.justonce;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.er on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
|
2007-06-26 09:26:58 -04:00
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
|
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er ENABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
|
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
|
|
|
|
"Altering event test.er on the master"
|
|
|
|
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
|
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er ENABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er')
|
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
|
|
|
db name status originator body
|
2007-06-26 09:26:58 -04:00
|
|
|
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er')
|
|
|
|
"Dropping event test.er on the master"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP EVENT test.er;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event status on the master"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
"Checking event status on the slave"
|
2007-03-29 08:17:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
2007-03-16 09:56:57 -04:00
|
|
|
db name status originator
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.slave_terminate on the slave"
|
|
|
|
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
|
|
|
|
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
|
|
|
|
"Checking event status on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
|
|
|
db name status originator
|
|
|
|
test slave_terminate ENABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_terminate on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
DROP EVENT test.slave_terminate;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Creating event test.slave_terminate with DISABLE ON SLAVE on the slave"
|
|
|
|
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DISABLE ON SLAVE DO
|
|
|
|
INSERT IGNORE INTO t1(c) VALUES (7, 'from slave_terminate');
|
|
|
|
"Checking event status on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
|
|
|
db name status originator
|
|
|
|
test slave_terminate SLAVESIDE_DISABLED 2
|
2007-06-26 09:26:58 -04:00
|
|
|
"Dropping event test.slave_terminate on the slave"
|
2007-03-30 11:08:19 -04:00
|
|
|
DROP EVENT test.slave_terminate;
|
2007-06-26 09:26:58 -04:00
|
|
|
"Cleanup"
|
2007-03-16 09:56:57 -04:00
|
|
|
DROP TABLE t1;
|
2007-06-13 16:24:21 -04:00
|
|
|
CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR
|
|
|
|
DO BEGIN
|
|
|
|
select * from t1;
|
|
|
|
END;|
|
|
|
|
ALTER EVENT event1 RENAME TO event2;
|
|
|
|
DROP EVENT event2;
|