1
by brian
clean slate |
1 |
##################################################################
|
2 |
# Author: Giuseppe, Chuck Bell # |
|
3 |
# Date: 17-January-2007 # |
|
4 |
# Purpose: To test that event effects are replicated # |
|
5 |
# in both row based and statement based format # |
|
6 |
##################################################################
|
|
7 |
||
8 |
--disable_warnings |
|
9 |
DROP EVENT IF EXISTS test.justonce; |
|
10 |
drop table if exists t1,t2; |
|
11 |
--enable_warnings |
|
12 |
||
13 |
# first, we need a table to record something from an event |
|
14 |
||
15 |
eval CREATE TABLE `t1` ( |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
16 |
`id` INT(10) NOT NULL, |
1
by brian
clean slate |
17 |
`c` VARCHAR(50) NOT NULL, |
18 |
`ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
|
19 |
PRIMARY KEY (`id`) |
|
20 |
) ENGINE=$engine_type DEFAULT CHARSET=utf8; |
|
21 |
||
22 |
INSERT INTO t1 (id, c) VALUES (1, 'manually'); |
|
23 |
||
24 |
# We create the event so that it inserts exactly 1 row in the table |
|
25 |
# A recuring event is used so that we can be sure the event will |
|
26 |
# fire regardless of timing delays on the server. Otherwise, it is |
|
27 |
# possible for the event to timeout before it has inserted a row. |
|
28 |
--echo "Creating event test.justonce on the master" |
|
29 |
CREATE EVENT test.justonce ON SCHEDULE EVERY 2 SECOND DO |
|
30 |
INSERT IGNORE INTO t1 (id, c) VALUES (2, 'from justonce'); |
|
31 |
||
32 |
# Show the event is alive and present on master |
|
33 |
--echo "Checking event is active on master" |
|
34 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; |
|
35 |
||
36 |
# Wait until event has fired. We know this because t1 will contain |
|
37 |
# the row from the event. |
|
38 |
let $wait_condition= |
|
39 |
SELECT COUNT(*) = 1 FROM t1 WHERE c = 'from justonce'; |
|
40 |
--source include/wait_condition.inc |
|
41 |
||
42 |
# check that table t1 contains something |
|
43 |
--echo "Checking event data on the master" |
|
44 |
--enable_info |
|
45 |
--replace_column 3 TIMESTAMP |
|
46 |
SELECT * FROM t1 ORDER BY id; |
|
47 |
--disable_info |
|
48 |
||
49 |
sync_slave_with_master; |
|
50 |
||
51 |
--echo "Checking event data on the slave" |
|
52 |
--enable_info |
|
53 |
--replace_column 3 TIMESTAMP |
|
54 |
SELECT * FROM t1 ORDER BY id; |
|
55 |
--disable_info |
|
56 |
||
57 |
--echo "Checking event is inactive on slave" |
|
58 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; |
|
59 |
||
60 |
# Create an event on the slave and check to see what the originator is. |
|
61 |
--echo "Dropping event test.slave_once on the slave" |
|
62 |
--disable_warnings |
|
63 |
DROP EVENT IF EXISTS test.slave_once; |
|
64 |
--enable_warnings |
|
65 |
||
66 |
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO |
|
67 |
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once'); |
|
68 |
||
69 |
--echo "Checking event status on the slave for originator value = slave's server_id" |
|
70 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; |
|
71 |
||
72 |
--echo "Dropping event test.slave_once on the slave" |
|
73 |
--disable_warnings |
|
74 |
DROP EVENT IF EXISTS test.slave_once; |
|
75 |
--enable_warnings |
|
76 |
||
77 |
connection master; |
|
78 |
||
79 |
# BUG#20384 - disable events on slave |
|
80 |
--echo "Dropping event test.justonce on the master" |
|
81 |
--disable_warnings |
|
82 |
DROP EVENT IF EXISTS test.justonce; |
|
83 |
--enable_warnings |
|
84 |
||
85 |
--echo "Creating event test.er on the master" |
|
86 |
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO |
|
87 |
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er'); |
|
88 |
||
89 |
--echo "Checking event status on the master" |
|
90 |
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; |
|
91 |
||
92 |
sync_slave_with_master; |
|
93 |
||
94 |
--echo "Checking event status on the slave" |
|
95 |
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; |
|
96 |
||
97 |
connection master; |
|
98 |
--echo "Altering event test.er on the master" |
|
99 |
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO |
|
100 |
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er'); |
|
101 |
||
102 |
--echo "Checking event status on the master" |
|
103 |
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; |
|
104 |
||
105 |
sync_slave_with_master; |
|
106 |
||
107 |
--echo "Checking event status on the slave" |
|
108 |
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; |
|
109 |
||
110 |
connection master; |
|
111 |
--echo "Dropping event test.er on the master" |
|
112 |
DROP EVENT test.er; |
|
113 |
||
114 |
--echo "Checking event status on the master" |
|
115 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; |
|
116 |
||
117 |
--disable_info |
|
118 |
||
119 |
sync_slave_with_master; |
|
120 |
||
121 |
--echo "Checking event status on the slave" |
|
122 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; |
|
123 |
||
124 |
# test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status |
|
125 |
# on CREATE EVENT |
|
126 |
||
127 |
--echo "Creating event test.slave_terminate on the slave" |
|
128 |
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO |
|
129 |
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate'); |
|
130 |
||
131 |
--echo "Checking event status on the slave" |
|
132 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate'; |
|
133 |
||
134 |
--echo "Dropping event test.slave_terminate on the slave" |
|
135 |
DROP EVENT test.slave_terminate; |
|
136 |
||
137 |
--echo "Creating event test.slave_terminate with DISABLE ON SLAVE on the slave" |
|
138 |
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DISABLE ON SLAVE DO |
|
139 |
INSERT IGNORE INTO t1(c) VALUES (7, 'from slave_terminate'); |
|
140 |
||
141 |
--echo "Checking event status on the slave" |
|
142 |
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate'; |
|
143 |
||
144 |
--echo "Dropping event test.slave_terminate on the slave" |
|
145 |
DROP EVENT test.slave_terminate; |
|
146 |
||
147 |
--echo "Cleanup" |
|
148 |
connection master; |
|
149 |
DROP TABLE t1; |
|
150 |
sync_slave_with_master; |
|
151 |
connection master; |
|
152 |