1
by brian
clean slate |
1 |
stop slave; |
2 |
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
3 |
reset master; |
|
4 |
reset slave; |
|
5 |
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
6 |
start slave; |
|
7 |
USE test; |
|
8 |
DROP VIEW IF EXISTS v1,v11; |
|
9 |
DROP TABLE IF EXISTS t1,t2,t3,t11,t12,t13; |
|
10 |
DROP PROCEDURE IF EXISTS p1; |
|
11 |
DROP PROCEDURE IF EXISTS p11; |
|
12 |
DROP FUNCTION IF EXISTS f1; |
|
13 |
DROP FUNCTION IF EXISTS f2; |
|
14 |
DROP EVENT IF EXISTS e1; |
|
15 |
DROP EVENT IF EXISTS e11; |
|
16 |
||
17 |
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, c VARCHAR(64)) ENGINE=myisam; |
|
18 |
INSERT INTO t1 VALUES (1,1,'1'); |
|
19 |
INSERT INTO t1 VALUES (2,2,UUID()); |
|
20 |
CREATE TABLE t2 (a INT UNIQUE, b INT, c VARCHAR(64)) ENGINE=myisam; |
|
21 |
INSERT INTO t2 VALUES (1,1,'1'); |
|
22 |
INSERT INTO t2 VALUES (2,2,UUID()); |
|
23 |
CREATE TABLE t11 (a INT NOT NULL PRIMARY KEY, b INT, c VARCHAR(64)) ENGINE=innodb; |
|
24 |
INSERT INTO t11 VALUES (1,1,'1'); |
|
25 |
INSERT INTO t11 VALUES (2,2,UUID()); |
|
26 |
CREATE TABLE t12 (a INT UNIQUE, b INT, c VARCHAR(64)) ENGINE=innodb; |
|
27 |
INSERT INTO t12 VALUES (1,1,'1'); |
|
28 |
INSERT INTO t12 VALUES (2,2,UUID()); |
|
29 |
||
30 |
CREATE VIEW v1 AS SELECT * FROM t1; |
|
31 |
CREATE VIEW v11 AS SELECT * FROM t11; |
|
32 |
CREATE TRIGGER t1_tr1 BEFORE INSERT ON t1 FOR EACH ROW |
|
33 |
BEGIN
|
|
34 |
INSERT INTO t2 VALUES (NEW.a, NEW.b, NEW.c); |
|
35 |
INSERT INTO t3 VALUES (NEW.a, NEW.b, NEW.c); |
|
36 |
END| |
|
37 |
CREATE TRIGGER t1_tr2 BEFORE UPDATE ON t1 FOR EACH ROW |
|
38 |
BEGIN
|
|
39 |
UPDATE t2 SET c = ''; |
|
40 |
UPDATE t3 SET c = ''; |
|
41 |
END| |
|
42 |
CREATE TRIGGER t11_tr1 BEFORE INSERT ON t11 FOR EACH ROW |
|
43 |
BEGIN
|
|
44 |
INSERT INTO t12 VALUES (NEW.a, NEW.b, NEW.c); |
|
45 |
INSERT INTO t13 VALUES (NEW.a, NEW.b, NEW.c); |
|
46 |
END| |
|
47 |
CREATE TRIGGER t11_tr2 BEFORE UPDATE ON t11 FOR EACH ROW |
|
48 |
BEGIN
|
|
49 |
UPDATE t12 SET c = ''; |
|
50 |
UPDATE t13 SET c = ''; |
|
51 |
END| |
|
52 |
CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO |
|
53 |
BEGIN
|
|
54 |
ALTER EVENT e1 DISABLE; |
|
55 |
CALL p1(10, ''); |
|
56 |
END| |
|
57 |
CREATE EVENT e11 ON SCHEDULE EVERY 1 SECOND DISABLE DO |
|
58 |
BEGIN
|
|
59 |
ALTER EVENT e11 DISABLE; |
|
60 |
CALL p11(10, ''); |
|
61 |
END| |
|
62 |
CREATE FUNCTION f1 (x INT) RETURNS VARCHAR(64) |
|
63 |
BEGIN
|
|
64 |
IF x > 5 THEN |
|
65 |
RETURN UUID(); |
|
66 |
END IF; |
|
67 |
RETURN ''; |
|
68 |
END| |
|
69 |
CREATE FUNCTION f2 (x INT) RETURNS VARCHAR(64) |
|
70 |
BEGIN
|
|
71 |
RETURN f1(x); |
|
72 |
END| |
|
73 |
CREATE PROCEDURE p1 (IN x INT, IN y VARCHAR(64)) |
|
74 |
BEGIN
|
|
75 |
INSERT IGNORE INTO t1 VALUES (x,x,y); |
|
76 |
END| |
|
77 |
CREATE PROCEDURE p11 (IN x INT, IN y VARCHAR(64)) |
|
78 |
BEGIN
|
|
79 |
INSERT IGNORE INTO t11 VALUES (x,x,y); |
|
80 |
END| |
|
81 |
||
82 |
CREATE TABLE t3 SELECT * FROM v1; |
|
83 |
INSERT INTO t1 VALUES (3,3,''); |
|
84 |
UPDATE t1 SET c='2' WHERE a = 1; |
|
85 |
INSERT INTO t1 VALUES(4,4,f1(4)); |
|
86 |
INSERT INTO t1 VALUES (100,100,''); |
|
87 |
CALL p1(5, UUID()); |
|
88 |
INSERT INTO t1 VALUES (101,101,''); |
|
89 |
INSERT INTO t1 VALUES(6,6,f1(6)); |
|
90 |
INSERT INTO t1 VALUES (102,102,''); |
|
91 |
INSERT INTO t1 VALUES(7,7,f2(7)); |
|
92 |
INSERT INTO t1 VALUES (103,103,''); |
|
93 |
||
94 |
CREATE TABLE t13 SELECT * FROM v11; |
|
95 |
INSERT INTO t11 VALUES (3,3,''); |
|
96 |
UPDATE t11 SET c='2' WHERE a = 1; |
|
97 |
INSERT INTO t11 VALUES(4,4,f1(4)); |
|
98 |
INSERT INTO t11 VALUES (100,100,''); |
|
99 |
CALL p11(5, UUID()); |
|
100 |
INSERT INTO t11 VALUES (101,101,''); |
|
101 |
INSERT INTO t11 VALUES(6,6,f1(6)); |
|
102 |
INSERT INTO t11 VALUES (102,102,''); |
|
103 |
INSERT INTO t11 VALUES(7,7,f2(7)); |
|
104 |
INSERT INTO t11 VALUES (103,103,''); |
|
105 |
||
106 |
SET GLOBAL EVENT_SCHEDULER = on; |
|
107 |
ALTER EVENT e1 ENABLE; |
|
108 |
ALTER EVENT e11 ENABLE; |
|
109 |
SET GLOBAL EVENT_SCHEDULER = off; |
|
110 |
||
111 |
SHOW TABLES LIKE 't%'; |
|
112 |
Tables_in_test (t%) |
|
113 |
t1
|
|
114 |
t11
|
|
115 |
t12
|
|
116 |
t13
|
|
117 |
t2
|
|
118 |
t3
|
|
119 |
SELECT table_name FROM information_schema.views WHERE table_schema='test'; |
|
120 |
table_name
|
|
121 |
v1
|
|
122 |
v11
|
|
123 |
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; |
|
124 |
trigger_name event_manipulation event_object_table |
|
125 |
t11_tr1 INSERT t11 |
|
126 |
t11_tr2 UPDATE t11 |
|
127 |
t1_tr1 INSERT t1 |
|
128 |
t1_tr2 UPDATE t1 |
|
129 |
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; |
|
130 |
routine_type routine_name |
|
131 |
FUNCTION f1 |
|
132 |
FUNCTION f2 |
|
133 |
PROCEDURE p1 |
|
134 |
PROCEDURE p11 |
|
135 |
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; |
|
136 |
event_name status |
|
137 |
e1 DISABLED |
|
138 |
e11 DISABLED |
|
139 |
||
140 |
SELECT COUNT(*) FROM t1; |
|
141 |
COUNT(*) |
|
142 |
12
|
|
143 |
SELECT a,b FROM t1 ORDER BY a; |
|
144 |
a b |
|
145 |
1 1 |
|
146 |
2 2 |
|
147 |
3 3 |
|
148 |
4 4 |
|
149 |
5 5 |
|
150 |
6 6 |
|
151 |
7 7 |
|
152 |
10 10 |
|
153 |
100 100 |
|
154 |
101 101 |
|
155 |
102 102 |
|
156 |
103 103 |
|
157 |
SELECT COUNT(*) FROM t2; |
|
158 |
COUNT(*) |
|
159 |
12
|
|
160 |
SELECT a,b FROM t2 ORDER BY a; |
|
161 |
a b |
|
162 |
1 1 |
|
163 |
2 2 |
|
164 |
3 3 |
|
165 |
4 4 |
|
166 |
5 5 |
|
167 |
6 6 |
|
168 |
7 7 |
|
169 |
10 10 |
|
170 |
100 100 |
|
171 |
101 101 |
|
172 |
102 102 |
|
173 |
103 103 |
|
174 |
SELECT COUNT(*) FROM t3; |
|
175 |
COUNT(*) |
|
176 |
12
|
|
177 |
SELECT a,b FROM t3 ORDER BY a; |
|
178 |
a b |
|
179 |
1 1 |
|
180 |
2 2 |
|
181 |
3 3 |
|
182 |
4 4 |
|
183 |
5 5 |
|
184 |
6 6 |
|
185 |
7 7 |
|
186 |
10 10 |
|
187 |
100 100 |
|
188 |
101 101 |
|
189 |
102 102 |
|
190 |
103 103 |
|
191 |
SELECT a,b FROM v1 ORDER BY a; |
|
192 |
a b |
|
193 |
1 1 |
|
194 |
2 2 |
|
195 |
3 3 |
|
196 |
4 4 |
|
197 |
5 5 |
|
198 |
6 6 |
|
199 |
7 7 |
|
200 |
10 10 |
|
201 |
100 100 |
|
202 |
101 101 |
|
203 |
102 102 |
|
204 |
103 103 |
|
205 |
SELECT COUNT(*) FROM t11; |
|
206 |
COUNT(*) |
|
207 |
12
|
|
208 |
SELECT a,b FROM t11 ORDER BY a; |
|
209 |
a b |
|
210 |
1 1 |
|
211 |
2 2 |
|
212 |
3 3 |
|
213 |
4 4 |
|
214 |
5 5 |
|
215 |
6 6 |
|
216 |
7 7 |
|
217 |
10 10 |
|
218 |
100 100 |
|
219 |
101 101 |
|
220 |
102 102 |
|
221 |
103 103 |
|
222 |
SELECT COUNT(*) FROM t12; |
|
223 |
COUNT(*) |
|
224 |
12
|
|
225 |
SELECT a,b FROM t12 ORDER BY a; |
|
226 |
a b |
|
227 |
1 1 |
|
228 |
2 2 |
|
229 |
3 3 |
|
230 |
4 4 |
|
231 |
5 5 |
|
232 |
6 6 |
|
233 |
7 7 |
|
234 |
10 10 |
|
235 |
100 100 |
|
236 |
101 101 |
|
237 |
102 102 |
|
238 |
103 103 |
|
239 |
SELECT COUNT(*) FROM t13; |
|
240 |
COUNT(*) |
|
241 |
12
|
|
242 |
SELECT a,b FROM t13 ORDER BY a; |
|
243 |
a b |
|
244 |
1 1 |
|
245 |
2 2 |
|
246 |
3 3 |
|
247 |
4 4 |
|
248 |
5 5 |
|
249 |
6 6 |
|
250 |
7 7 |
|
251 |
10 10 |
|
252 |
100 100 |
|
253 |
101 101 |
|
254 |
102 102 |
|
255 |
103 103 |
|
256 |
SELECT a,b FROM v11 ORDER BY a; |
|
257 |
a b |
|
258 |
1 1 |
|
259 |
2 2 |
|
260 |
3 3 |
|
261 |
4 4 |
|
262 |
5 5 |
|
263 |
6 6 |
|
264 |
7 7 |
|
265 |
10 10 |
|
266 |
100 100 |
|
267 |
101 101 |
|
268 |
102 102 |
|
269 |
103 103 |
|
270 |
||
271 |
SHOW TABLES LIKE 't%'; |
|
272 |
Tables_in_test (t%) |
|
273 |
t1
|
|
274 |
t11
|
|
275 |
t12
|
|
276 |
t13
|
|
277 |
t2
|
|
278 |
t3
|
|
279 |
SELECT table_name FROM information_schema.views WHERE table_schema='test'; |
|
280 |
table_name
|
|
281 |
v1
|
|
282 |
v11
|
|
283 |
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; |
|
284 |
trigger_name event_manipulation event_object_table |
|
285 |
t11_tr1 INSERT t11 |
|
286 |
t11_tr2 UPDATE t11 |
|
287 |
t1_tr1 INSERT t1 |
|
288 |
t1_tr2 UPDATE t1 |
|
289 |
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; |
|
290 |
routine_type routine_name |
|
291 |
FUNCTION f1 |
|
292 |
FUNCTION f2 |
|
293 |
PROCEDURE p1 |
|
294 |
PROCEDURE p11 |
|
295 |
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; |
|
296 |
event_name status |
|
297 |
e1 SLAVESIDE_DISABLED |
|
298 |
e11 SLAVESIDE_DISABLED |
|
299 |
||
300 |
SELECT COUNT(*) FROM t1; |
|
301 |
COUNT(*) |
|
302 |
12
|
|
303 |
SELECT a,b FROM t1 ORDER BY a; |
|
304 |
a b |
|
305 |
1 1 |
|
306 |
2 2 |
|
307 |
3 3 |
|
308 |
4 4 |
|
309 |
5 5 |
|
310 |
6 6 |
|
311 |
7 7 |
|
312 |
10 10 |
|
313 |
100 100 |
|
314 |
101 101 |
|
315 |
102 102 |
|
316 |
103 103 |
|
317 |
SELECT COUNT(*) FROM t2; |
|
318 |
COUNT(*) |
|
319 |
12
|
|
320 |
SELECT a,b FROM t2 ORDER BY a; |
|
321 |
a b |
|
322 |
1 1 |
|
323 |
2 2 |
|
324 |
3 3 |
|
325 |
4 4 |
|
326 |
5 5 |
|
327 |
6 6 |
|
328 |
7 7 |
|
329 |
10 10 |
|
330 |
100 100 |
|
331 |
101 101 |
|
332 |
102 102 |
|
333 |
103 103 |
|
334 |
SELECT COUNT(*) FROM t3; |
|
335 |
COUNT(*) |
|
336 |
12
|
|
337 |
SELECT a,b FROM t3 ORDER BY a; |
|
338 |
a b |
|
339 |
1 1 |
|
340 |
2 2 |
|
341 |
3 3 |
|
342 |
4 4 |
|
343 |
5 5 |
|
344 |
6 6 |
|
345 |
7 7 |
|
346 |
10 10 |
|
347 |
100 100 |
|
348 |
101 101 |
|
349 |
102 102 |
|
350 |
103 103 |
|
351 |
SELECT a,b FROM v1 ORDER BY a; |
|
352 |
a b |
|
353 |
1 1 |
|
354 |
2 2 |
|
355 |
3 3 |
|
356 |
4 4 |
|
357 |
5 5 |
|
358 |
6 6 |
|
359 |
7 7 |
|
360 |
10 10 |
|
361 |
100 100 |
|
362 |
101 101 |
|
363 |
102 102 |
|
364 |
103 103 |
|
365 |
SELECT COUNT(*) FROM t11; |
|
366 |
COUNT(*) |
|
367 |
12
|
|
368 |
SELECT a,b FROM t11 ORDER BY a; |
|
369 |
a b |
|
370 |
1 1 |
|
371 |
2 2 |
|
372 |
3 3 |
|
373 |
4 4 |
|
374 |
5 5 |
|
375 |
6 6 |
|
376 |
7 7 |
|
377 |
10 10 |
|
378 |
100 100 |
|
379 |
101 101 |
|
380 |
102 102 |
|
381 |
103 103 |
|
382 |
SELECT COUNT(*) FROM t12; |
|
383 |
COUNT(*) |
|
384 |
12
|
|
385 |
SELECT a,b FROM t12 ORDER BY a; |
|
386 |
a b |
|
387 |
1 1 |
|
388 |
2 2 |
|
389 |
3 3 |
|
390 |
4 4 |
|
391 |
5 5 |
|
392 |
6 6 |
|
393 |
7 7 |
|
394 |
10 10 |
|
395 |
100 100 |
|
396 |
101 101 |
|
397 |
102 102 |
|
398 |
103 103 |
|
399 |
SELECT COUNT(*) FROM t13; |
|
400 |
COUNT(*) |
|
401 |
12
|
|
402 |
SELECT a,b FROM t13 ORDER BY a; |
|
403 |
a b |
|
404 |
1 1 |
|
405 |
2 2 |
|
406 |
3 3 |
|
407 |
4 4 |
|
408 |
5 5 |
|
409 |
6 6 |
|
410 |
7 7 |
|
411 |
10 10 |
|
412 |
100 100 |
|
413 |
101 101 |
|
414 |
102 102 |
|
415 |
103 103 |
|
416 |
SELECT a,b FROM v11 ORDER BY a; |
|
417 |
a b |
|
418 |
1 1 |
|
419 |
2 2 |
|
420 |
3 3 |
|
421 |
4 4 |
|
422 |
5 5 |
|
423 |
6 6 |
|
424 |
7 7 |
|
425 |
10 10 |
|
426 |
100 100 |
|
427 |
101 101 |
|
428 |
102 102 |
|
429 |
103 103 |
|
430 |
||
431 |
UPDATE t1 SET c=''; |
|
432 |
UPDATE t2 SET c=''; |
|
433 |
UPDATE t3 SET c=''; |
|
434 |
UPDATE t11 SET c=''; |
|
435 |
UPDATE t12 SET c=''; |
|
436 |
UPDATE t13 SET c=''; |
|
437 |
ALTER TABLE t3 ORDER BY a; |
|
438 |
ALTER TABLE t13 ORDER BY a; |
|
439 |
||
440 |
||
441 |
||
442 |
DROP VIEW IF EXISTS v1,v11; |
|
443 |
DROP TABLE IF EXISTS t1,t2,t3,t11,t12,t13; |
|
444 |
DROP PROCEDURE IF EXISTS p1; |
|
445 |
DROP PROCEDURE IF EXISTS p11; |
|
446 |
DROP FUNCTION IF EXISTS f1; |
|
447 |
DROP FUNCTION IF EXISTS f2; |
|
448 |
DROP EVENT IF EXISTS e1; |
|
449 |
DROP EVENT IF EXISTS e11; |