# Establish connection con1 (user=root)
# Establish connection con2 (user=root)
# Establish connection con3 (user=root)
# Switch to connection con1
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) ENGINE=innodb;
BEGIN;
INSERT INTO t1 VALUES(1);
# Switch to connection con2
FLUSH TABLES WITH READ LOCK;
SELECT * FROM t1;
a
# Switch to connection con1
COMMIT;
# Switch to connection con2
SELECT * FROM t1;
a
UNLOCK TABLES;
# Switch to connection con1
# Switch to connection con1
BEGIN;
SELECT * FROM t1 FOR UPDATE;
a
1
# Switch to connection con2
BEGIN;
SELECT * FROM t1 FOR UPDATE;
# Switch to connection con3
FLUSH TABLES WITH READ LOCK;
# Switch to connection con1
COMMIT;
# Switch to connection con2
a
1
# Switch to connection con3
UNLOCK TABLES;
# Switch to connection con2
COMMIT;
# Switch to connection con1
BEGIN;
INSERT INTO t1 VALUES(10);
FLUSH TABLES WITH READ LOCK;
COMMIT;
UNLOCK TABLES;
# Switch to connection con2
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
BEGIN;
SELECT * FROM t1;
a
1
10
SHOW CREATE DATABASE test;
Database	Create Database
test	CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
DROP TABLE t1;
# Switch to connection default and close connections con1, con2, con3
