1SET @old_binlog_format=@@binlog_format;
2SET GLOBAL binlog_format='MIXED';
3SET SESSION binlog_format='MIXED';
4SELECT @@binlog_format;
5@@binlog_format
6MIXED
7RESET MASTER;
8SHOW VARIABLES LIKE 'have_backup_locks';
9Variable_name	Value
10have_backup_locks	YES
11#-----------------------------------------------------------------------
12# Setup
13#-----------------------------------------------------------------------
14CREATE TABLE t_innodb(a INT NOT NULL, KEY (a)) ENGINE=InnoDB;
15CREATE TABLE t_myisam(a INT NOT NULL, KEY (a)) ENGINE=MyISAM;
16CREATE TABLE t_memory(a INT NOT NULL, KEY (a)) ENGINE=MEMORY;
17CREATE TABLE t_csv(a INT NOT NULL) ENGINE=CSV;
18CREATE TABLE t_blackhole(a INT NOT NULL, KEY (a)) ENGINE=BLACKHOLE;
19CREATE TABLE t_archive(a INT NOT NULL) ENGINE=ARCHIVE;
20CREATE VIEW v_innodb AS SELECT * FROM t_innodb;
21CREATE VIEW v_myisam AS SELECT * FROM t_myisam;
22CREATE VIEW v_memory AS SELECT * FROM t_memory;
23CREATE VIEW v_csv AS SELECT * FROM t_csv;
24CREATE VIEW v_blackhole AS SELECT * FROM t_blackhole;
25CREATE VIEW v_archive AS SELECT * FROM t_archive;
26#-----------------------------------------------------------------------
27# Single-threaded tests
28#-----------------------------------------------------------------------
29LOCK BINLOG FOR BACKUP;
30DELETE FROM t_innodb;
31INSERT INTO t_innodb VALUES(0);
32UPDATE t_innodb SET a = 1;
33REPLACE INTO t_innodb VALUES(1);
34SELECT * from t_innodb;
35a
361
371
38HANDLER t_innodb OPEN;
39HANDLER t_innodb READ a FIRST;
40a
411
42HANDLER t_innodb CLOSE;
43DELETE FROM t_myisam;
44INSERT INTO t_myisam VALUES(0);
45UPDATE t_myisam SET a = 1;
46REPLACE INTO t_myisam VALUES(1);
47SELECT * from t_myisam;
48a
491
501
51HANDLER t_myisam OPEN;
52HANDLER t_myisam READ a FIRST;
53a
541
55HANDLER t_myisam CLOSE;
56DELETE FROM t_memory;
57INSERT INTO t_memory VALUES(0);
58UPDATE t_memory SET a = 1;
59REPLACE INTO t_memory VALUES(1);
60SELECT * from t_memory;
61a
621
631
64DELETE FROM t_archive;
65INSERT INTO t_archive VALUES(0);
66SELECT * from t_archive;
67a
680
69DELETE FROM t_csv;
70INSERT INTO t_csv VALUES(0);
71UPDATE t_csv SET a = 1;
72REPLACE INTO t_csv VALUES(1);
73SELECT * from t_csv;
74a
751
761
77DELETE FROM t_blackhole;
78INSERT INTO t_blackhole VALUES(0);
79UPDATE t_blackhole SET a = 1;
80REPLACE INTO t_blackhole VALUES(1);
81SELECT * from t_blackhole;
82a
83CREATE TABLE tt_innodb(a INT NOT NULL) ENGINE=InnoDB;
84CREATE TABLE tt_myisam(a INT NOT NULL) ENGINE=MyISAM;
85CREATE TABLE tt_memory(a INT NOT NULL) ENGINE=MEMORY;
86CREATE TABLE tt_csv(a INT NOT NULL) ENGINE=CSV;
87CREATE TABLE tt_blackhole(a INT NOT NULL) ENGINE=BLACKHOLE;
88CREATE TABLE tt_archive(a INT NOT NULL) ENGINE=ARCHIVE;
89DROP TABLE tt_innodb;
90DROP TABLE tt_myisam;
91DROP TABLE tt_memory;
92DROP TABLE tt_csv;
93DROP TABLE tt_blackhole;
94DROP TABLE tt_archive;
95DROP TABLE non_existing;
96ERROR 42S02: Unknown table 'test.non_existing'
97TRUNCATE TABLE t_innodb;
98TRUNCATE TABLE t_myisam;
99TRUNCATE TABLE t_memory;
100TRUNCATE TABLE t_csv;
101TRUNCATE TABLE t_blackhole;
102RENAME TABLE t_innodb TO tmp, tmp TO t_innodb;
103RENAME TABLE t_myisam TO tmp, tmp TO t_myisam;
104RENAME TABLE t_memory TO tmp, tmp TO t_memory;
105RENAME TABLE t_csv TO tmp, tmp TO t_csv;
106RENAME TABLE t_blackhole TO tmp, tmp TO t_blackhole;
107RENAME TABLE t_archive TO tmp, tmp TO t_archive;
108ALTER TABLE t_innodb ADD COLUMN b CHAR(10) NOT NULL;
109ALTER TABLE t_innodb DROP COLUMN b;
110ALTER TABLE t_myisam ADD COLUMN b CHAR(10) NOT NULL;
111ALTER TABLE t_myisam DROP COLUMN b;
112ALTER TABLE t_memory ADD COLUMN b CHAR(10) NOT NULL;
113ALTER TABLE t_memory DROP COLUMN b;
114ALTER TABLE t_csv ADD COLUMN b CHAR(10) NOT NULL;
115ALTER TABLE t_csv DROP COLUMN b;
116ALTER TABLE t_blackhole ADD COLUMN b CHAR(10) NOT NULL;
117ALTER TABLE t_blackhole DROP COLUMN b;
118ALTER TABLE t_archive ADD COLUMN b CHAR(10) NOT NULL;
119ALTER TABLE t_archive DROP COLUMN b;
120ALTER TABLE t_innodb ADD KEY tmp (a);
121Warnings:
122Warning	1831	Duplicate index 'tmp' defined on the table 'test.t_innodb'. This is deprecated and will be disallowed in a future release.
123ALTER TABLE t_innodb DROP KEY tmp;
124ALTER TABLE t_myisam ADD KEY tmp (a);
125Warnings:
126Warning	1831	Duplicate index 'tmp' defined on the table 'test.t_myisam'. This is deprecated and will be disallowed in a future release.
127ALTER TABLE t_myisam DROP KEY tmp;
128ALTER TABLE t_memory ADD KEY tmp (a);
129Warnings:
130Warning	1831	Duplicate index 'tmp' defined on the table 'test.t_memory'. This is deprecated and will be disallowed in a future release.
131ALTER TABLE t_memory DROP KEY tmp;
132ALTER TABLE t_blackhole ADD KEY tmp (a);
133Warnings:
134Warning	1831	Duplicate index 'tmp' defined on the table 'test.t_blackhole'. This is deprecated and will be disallowed in a future release.
135ALTER TABLE t_blackhole DROP KEY tmp;
136CREATE DATABASE test1;
137DROP DATABASE test1;
138CREATE PROCEDURE p1()
139BEGIN
140SELECT 1;
141END|
142DROP PROCEDURE p1|
143CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
144BEGIN
145RETURN 1;
146END|
147DROP FUNCTION f1|
148CREATE VIEW v1 AS SELECT * FROM t_innodb;
149DROP VIEW v1;
150INSERT INTO v_innodb VALUES(1);
151INSERT INTO v_blackhole VALUES(1);
152INSERT INTO v_myisam VALUES(1);
153INSERT INTO v_csv VALUES(1);
154INSERT INTO v_memory VALUES(1);
155INSERT INTO v_archive VALUES(1);
156UNLOCK BINLOG;
157SELECT @@delay_key_write;
158@@delay_key_write
159ON
160SET GLOBAL delay_key_write=ALL;
161LOCK TABLES FOR BACKUP;
162ERROR HY000: The MySQL server is running with the delay_key_write=ALL option so it cannot execute this statement
163SET GLOBAL delay_key_write=default;
164SELECT @@delay_key_write;
165@@delay_key_write
166ON
167SET GLOBAL read_only=1;
168INSERT INTO t_innodb VALUES(0);
169INSERT INTO t_myisam VALUES(0);
170LOCK TABLES FOR BACKUP;
171INSERT INTO t_innodb VALUES(0);
172INSERT INTO t_myisam VALUES(0);
173ERROR HY000: Can't execute the query because you have a conflicting backup lock
174UNLOCK TABLES;
175INSERT INTO t_innodb VALUES(0);
176INSERT INTO t_myisam VALUES(0);
177SET GLOBAL read_only=0;
178LOCK TABLES FOR BACKUP;
179CREATE TEMPORARY TABLE tt_innodb(a INT NOT NULL) ENGINE=InnoDB;
180CREATE TEMPORARY TABLE tt_myisam(a INT NOT NULL) ENGINE=MyISAM;
181CREATE TEMPORARY TABLE tt_memory(a INT NOT NULL) ENGINE=MEMORY;
182CREATE TEMPORARY TABLE tt_csv(a INT NOT NULL) ENGINE=CSV;
183CREATE TEMPORARY TABLE tt_blackhole(a INT NOT NULL) ENGINE=BLACKHOLE;
184CREATE TEMPORARY TABLE tt_archive(a INT NOT NULL) ENGINE=ARCHIVE;
185INSERT INTO tt_innodb VALUES(5);
186INSERT INTO tt_myisam VALUES(5);
187INSERT INTO tt_memory VALUES(5);
188INSERT INTO tt_csv VALUES(5);
189INSERT INTO tt_blackhole VALUES(5);
190INSERT INTO tt_archive VALUES(5);
191LOCK BINLOG FOR BACKUP;
192START TRANSACTION;
193SELECT * FROM tt_archive;
194a
1955
196SELECT * FROM tt_blackhole;
197a
198SELECT * FROM tt_memory;
199a
2005
201SELECT * FROM tt_innodb;
202a
2035
204SELECT * FROM tt_myisam;
205a
2065
207INSERT INTO tt_innodb VALUES(6);
208INSERT INTO tt_myisam VALUES(6);
209INSERT INTO tt_memory VALUES(6);
210INSERT INTO tt_csv VALUES(6);
211INSERT INTO tt_blackhole VALUES(6);
212INSERT INTO tt_archive VALUES(6);
213COMMIT;
214SELECT * FROM tt_archive;
215a
2165
2176
218SELECT * FROM tt_blackhole;
219a
220SELECT * FROM tt_memory;
221a
2225
2236
224SELECT * FROM tt_innodb;
225a
2265
2276
228SELECT * FROM tt_myisam;
229a
2305
2316
232DROP TEMPORARY TABLE tt_innodb;
233DROP TEMPORARY TABLE tt_myisam;
234DROP TEMPORARY TABLE tt_memory;
235DROP TEMPORARY TABLE tt_csv;
236DROP TEMPORARY TABLE tt_blackhole;
237DROP TEMPORARY TABLE tt_archive;
238UNLOCK BINLOG;
239UNLOCK TABLES;
240SELECT @@log_bin;
241@@log_bin
2421
243LOCK BINLOG FOR BACKUP;
244INSERT INTO t_innodb VALUES(1);
245INSERT INTO t_myisam VALUES(1);
246UNLOCK BINLOG;
247SET @old_general_log = @@general_log;
248SET @old_slow_query_log = @@slow_query_log;
249SET @old_log_output = @@log_output;
250SET @old_long_query_time = @@SESSION.long_query_time;
251SET SESSION long_query_time = 0;
252SET GLOBAL log_output = 'TABLE';
253SET GLOBAL general_log = ON;
254SET GLOBAL slow_query_log = ON;
255LOCK TABLES FOR BACKUP;
256SELECT 1;
2571
2581
259LOCK BINLOG FOR BACKUP;
260SELECT 1;
2611
2621
263UNLOCK BINLOG;
264UNLOCK TABLES;
265SET SESSION long_query_time = @old_long_query_time;
266SET GLOBAL log_output = @old_log_output;
267SET GLOBAL slow_query_log = @old_slow_query_log;
268SET GLOBAL general_log = @old_general_log;
269#-----------------------------------------------------------------------
270# Multi-threaded tests
271#-----------------------------------------------------------------------
272# connection default
273CREATE USER user@localhost;
274GRANT ALL PRIVILEGES ON test.* TO user@localhost;
275LOCK TABLES FOR BACKUP;
276# connection con1
277SET SESSION lock_wait_timeout = 1;
278SET GLOBAL delay_key_write=ALL;
279ERROR HY000: Lock wait timeout exceeded; try restarting transaction
280SET SESSION lock_wait_timeout = DEFAULT;
281# connection default
282UNLOCK TABLES;
283# connection con2
284START TRANSACTION;
285INSERT INTO t_innodb VALUES(0);
286# connection default
287SET GLOBAL read_only=1;
288# connection con2
289COMMIT;
290ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
291INSERT INTO t_innodb VALUES(0);
292ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
293INSERT INTO t_myisam VALUES(0);
294ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
295# connection con1
296LOCK TABLES FOR BACKUP;
297# connection con2
298INSERT INTO t_innodb VALUES(0);
299ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
300INSERT INTO t_myisam VALUES(0);
301ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
302# connection default
303SET GLOBAL read_only=0;
304# connection con2
305SET SESSION lock_wait_timeout = 1;
306INSERT INTO t_innodb VALUES(0);
307INSERT INTO t_myisam VALUES(0);
308ERROR HY000: Lock wait timeout exceeded; try restarting transaction
309SET SESSION lock_wait_timeout = 0;
310Warnings:
311Warning	1292	Truncated incorrect lock_wait_timeout value: '0'
312# connection default
313SET GLOBAL read_only=1;
314# connection con2
315INSERT INTO t_innodb VALUES(0);
316ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
317INSERT INTO t_myisam VALUES(0);
318ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
319# connection con1
320UNLOCK TABLES;
321# connection con2
322INSERT INTO t_innodb VALUES(0);
323ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
324INSERT INTO t_myisam VALUES(0);
325ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
326# connection default
327SET GLOBAL read_only=0;
328# connection default
329LOCK TABLES FOR BACKUP;
330# connection con1
331CREATE TEMPORARY TABLE tt_innodb(a INT NOT NULL) ENGINE=InnoDB;
332CREATE TEMPORARY TABLE tt_myisam(a INT NOT NULL) ENGINE=MyISAM;
333CREATE TEMPORARY TABLE tt_memory(a INT NOT NULL) ENGINE=MEMORY;
334CREATE TEMPORARY TABLE tt_csv(a INT NOT NULL) ENGINE=CSV;
335CREATE TEMPORARY TABLE tt_blackhole(a INT NOT NULL) ENGINE=BLACKHOLE;
336CREATE TEMPORARY TABLE tt_archive(a INT NOT NULL) ENGINE=ARCHIVE;
337INSERT INTO tt_innodb VALUES(5);
338INSERT INTO tt_myisam VALUES(5);
339INSERT INTO tt_memory VALUES(5);
340INSERT INTO tt_csv VALUES(5);
341INSERT INTO tt_blackhole VALUES(5);
342INSERT INTO tt_archive VALUES(5);
343# connection default
344LOCK BINLOG FOR BACKUP;
345# connection con1
346SET SESSION lock_wait_timeout = 1;
347START TRANSACTION;
348INSERT INTO tt_myisam VALUES(6);
349INSERT INTO tt_innodb VALUES(6);
350SELECT * FROM tt_archive;
351a
3525
353SELECT * FROM tt_blackhole;
354a
355SELECT * FROM tt_memory;
356a
3575
358SELECT * FROM tt_innodb;
359a
3605
3616
362SELECT * FROM tt_myisam;
363a
3645
3656
366SELECT * FROM tt_csv;
367a
3685
369# connection default
370must_be_1
3711
372UNLOCK BINLOG;
373UNLOCK TABLES;
374# connection con1
375COMMIT;
376DROP TEMPORARY TABLE tt_innodb;
377DROP TEMPORARY TABLE tt_myisam;
378DROP TEMPORARY TABLE tt_memory;
379DROP TEMPORARY TABLE tt_csv;
380DROP TEMPORARY TABLE tt_blackhole;
381DROP TEMPORARY TABLE tt_archive;
382# connection default
383LOCK BINLOG FOR BACKUP;
384# connection con1
385SET SESSION lock_wait_timeout = 1;
386INSERT INTO t_innodb VALUES(1);
387ERROR HY000: Lock wait timeout exceeded; try restarting transaction
388INSERT INTO t_myisam VALUES(1);
389ERROR HY000: Lock wait timeout exceeded; try restarting transaction
390SET SESSION lock_wait_timeout = DEFAULT;
391# connection default
392must_be_1
3931
394UNLOCK BINLOG;
395# connection default
396LOCK BINLOG FOR BACKUP;
397# connection con1
398SET SESSION lock_wait_timeout = 1;
399DELETE FROM t_innodb;
400ERROR HY000: Lock wait timeout exceeded; try restarting transaction
401INSERT INTO t_innodb VALUES(0);
402ERROR HY000: Lock wait timeout exceeded; try restarting transaction
403UPDATE t_innodb SET a = 1;
404ERROR HY000: Lock wait timeout exceeded; try restarting transaction
405REPLACE INTO t_innodb VALUES(1);
406ERROR HY000: Lock wait timeout exceeded; try restarting transaction
407SELECT * from t_innodb;
408a
4090
4100
4110
4120
4131
4141
415HANDLER t_innodb OPEN;
416HANDLER t_innodb READ a FIRST;
417a
4180
419HANDLER t_innodb CLOSE;
420START TRANSACTION;
421SELECT * from t_innodb;
422a
4230
4240
4250
4260
4271
4281
429DELETE FROM t_innodb;
430INSERT INTO t_innodb VALUES(0);
431UPDATE t_innodb SET a = 1;
432REPLACE INTO t_innodb VALUES(1);
433COMMIT;
434ERROR HY000: Lock wait timeout exceeded; try restarting transaction
435SELECT * FROM t_innodb;
436a
4370
4380
4390
4400
4411
4421
443COMMIT;
444START TRANSACTION;
445INSERT INTO t_myisam VALUES(1);
446ERROR HY000: Lock wait timeout exceeded; try restarting transaction
447COMMIT;
448INSERT INTO t_myisam VALUES(0);
449ERROR HY000: Lock wait timeout exceeded; try restarting transaction
450UPDATE t_myisam SET a = 1;
451ERROR HY000: Lock wait timeout exceeded; try restarting transaction
452SELECT * FROM t_myisam;
453a
4541
4551
4561
4571
4581
4591
4601
461HANDLER t_myisam OPEN;
462HANDLER t_myisam READ a FIRST;
463a
4641
465HANDLER t_myisam CLOSE;
466DELETE FROM t_blackhole;
467ERROR HY000: Lock wait timeout exceeded; try restarting transaction
468INSERT INTO t_blackhole VALUES(0);
469ERROR HY000: Lock wait timeout exceeded; try restarting transaction
470UPDATE t_blackhole SET a = 1;
471ERROR HY000: Lock wait timeout exceeded; try restarting transaction
472REPLACE INTO t_blackhole VALUES(1);
473ERROR HY000: Lock wait timeout exceeded; try restarting transaction
474SELECT * FROM t_blackhole;
475a
476CREATE TABLE tt_innodb(a INT NOT NULL) ENGINE=InnoDB;
477ERROR HY000: Lock wait timeout exceeded; try restarting transaction
478DROP TABLE tt_innodb;
479ERROR HY000: Lock wait timeout exceeded; try restarting transaction
480DROP TABLE non_existing;
481ERROR 42S02: Unknown table 'test.non_existing'
482CREATE TABLE t_innodb(a INT NOT NULL) ENGINE=InnoDB;
483ERROR 42S01: Table 't_innodb' already exists
484TRUNCATE TABLE t_innodb;
485ERROR HY000: Lock wait timeout exceeded; try restarting transaction
486RENAME TABLE t_innodb TO tmp, tmp to t_innodb;
487ERROR HY000: Lock wait timeout exceeded; try restarting transaction
488ALTER TABLE t_innodb ADD COLUMN b CHAR(10);
489ERROR HY000: Lock wait timeout exceeded; try restarting transaction
490ALTER TABLE t_innodb ADD KEY (a);
491ERROR HY000: Lock wait timeout exceeded; try restarting transaction
492CREATE DATABASE test1;
493ERROR HY000: Lock wait timeout exceeded; try restarting transaction
494DROP DATABASE test1;
495ERROR HY000: Lock wait timeout exceeded; try restarting transaction
496CREATE PROCEDURE p1() SELECT 1;
497ERROR HY000: Lock wait timeout exceeded; try restarting transaction
498DROP PROCEDURE p1;
499ERROR HY000: Lock wait timeout exceeded; try restarting transaction
500CREATE VIEW v1 AS SELECT * FROM t_innodb;
501ERROR HY000: Lock wait timeout exceeded; try restarting transaction
502DROP VIEW v1;
503ERROR HY000: Lock wait timeout exceeded; try restarting transaction
504INSERT INTO v_innodb VALUES(1);
505ERROR HY000: Lock wait timeout exceeded; try restarting transaction
506# connection default
507must_be_1
5081
509UNLOCK BINLOG;
510# connection con1
511SHOW CREATE TABLE t_innodb;
512Table	Create Table
513t_innodb	CREATE TABLE `t_innodb` (
514  `a` int(11) NOT NULL,
515  `b` char(10) DEFAULT NULL,
516  KEY `a` (`a`),
517  KEY `a_2` (`a`)
518) ENGINE=InnoDB DEFAULT CHARSET=latin1
519DROP TABLE t_innodb;
520CREATE TABLE t_innodb(a INT NOT NULL) ENGINE=InnoDB;
521# connection default
522SET @old_general_log = @@general_log;
523SET @old_slow_query_log = @@slow_query_log;
524SET @old_log_output = @@log_output;
525SET GLOBAL log_output = 'TABLE';
526SET GLOBAL general_log = ON;
527SET GLOBAL slow_query_log = ON;
528LOCK BINLOG FOR BACKUP;
529# connection con1
530SET @old_long_query_time = @@SESSION.long_query_time;
531SET SESSION long_query_time = 0;
532SELECT 1;
5331
5341
535# connection default
536SELECT 1;
5371
5381
539# connection con1
540SET SESSION long_query_time = @old_long_query_time;
541# connection default
542must_be_1
5431
544UNLOCK BINLOG;
545SET GLOBAL log_output = @old_log_output;
546SET GLOBAL slow_query_log = @old_slow_query_log;
547SET GLOBAL general_log = @old_general_log;
548#-----------------------------------------------------------------------
549# Cleanup
550#-----------------------------------------------------------------------
551DROP USER user@localhost;
552DROP VIEW v_innodb, v_myisam, v_memory, v_csv, v_blackhole, v_archive;
553DROP TABLE t_innodb, t_myisam, t_memory, t_csv, t_blackhole, t_archive;
554SET GLOBAL binlog_format = @old_binlog_format;
555