summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb_mysql.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-06-25 10:44:52 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-06-25 10:44:52 +0300
commit39459397cd8d5f2822b8931ef8127cecf0b9495e (patch)
tree39866def4322d9b8b545270cd6eec7aec27cd1c2 /mysql-test/t/innodb_mysql.test
parent8c353de9572b499c7905b0997740f9ac514c7e5a (diff)
downloadmariadb-git-39459397cd8d5f2822b8931ef8127cecf0b9495e.tar.gz
Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked
LOCK TABLES takes a list of tables to lock. It may lock several tables successfully and then encounter a tables that it can't lock, e.g. because it's locked. In such case it needs to undo the locks on the already locked tables. And it does that. But it has also notified the relevant table storage engine handlers that they should lock. The only reliable way to ensure that the table handlers will give up their locks is to end the transaction. This is what UNLOCK TABLE does : it ends the transaction if there were locked tables by LOCK tables. It is possible to end the transaction when the lock fails in LOCK TABLES because LOCK TABLES ends the transaction at its start already. Fixed by ending (again) the transaction when LOCK TABLES fails to lock a table. mysql-test/r/innodb_mysql.result: Bug #29154: test case mysql-test/t/innodb_mysql.test: Bug #29154: test case sql/sql_parse.cc: Bug #29154: end the trasaction at a failing LOCK TABLES so the handler can free its locks.
Diffstat (limited to 'mysql-test/t/innodb_mysql.test')
-rw-r--r--mysql-test/t/innodb_mysql.test35
1 files changed, 35 insertions, 0 deletions
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 0c53705cf71..25ba9a258ff 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -636,4 +636,39 @@ SELECT * FROM t3 WHERE a = 'uk';
DROP TABLE t1,t2,t3;
+
+#
+# Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked
+#
+
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+
+CONNECT (c1,localhost,root,,);
+CONNECT (c2,localhost,root,,);
+
+--echo switch to connection c1
+CONNECTION c1;
+SET AUTOCOMMIT=0;
+INSERT INTO t2 VALUES (1);
+
+--echo switch to connection c2
+CONNECTION c2;
+SET AUTOCOMMIT=0;
+--error ER_LOCK_WAIT_TIMEOUT
+LOCK TABLES t1 READ, t2 READ;
+
+--echo switch to connection c1
+CONNECTION c1;
+COMMIT;
+INSERT INTO t1 VALUES (1);
+
+--echo switch to connection default
+CONNECTION default;
+SET AUTOCOMMIT=default;
+DISCONNECT c1;
+DISCONNECT c2;
+DROP TABLE t1,t2;
+
+
--echo End of 5.0 tests