summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb-lock.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/innodb-lock.test')
-rw-r--r--mysql-test/t/innodb-lock.test49
1 files changed, 27 insertions, 22 deletions
diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test
index eacf7e562be..d2f630ccaba 100644
--- a/mysql-test/t/innodb-lock.test
+++ b/mysql-test/t/innodb-lock.test
@@ -56,9 +56,12 @@ commit;
drop table t1;
-#
-# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
-#
+--echo #
+--echo # Old lock method (where LOCK TABLE was ignored by InnoDB) no longer
+--echo # works due to fix for bugs #46272 "MySQL 5.4.4, new MDL: unnecessary
+--echo # deadlock" and bug #37346 "innodb does not detect deadlock between
+--echo # update and alter table".
+--echo #
set @@innodb_table_locks=0;
@@ -67,36 +70,38 @@ insert into t1 values(0, 0),(1,1),(2,2);
commit;
SELECT * from t1 where id = 0 FOR UPDATE;
+--echo # Connection 'con2'.
connection con2;
set autocommit=0;
set @@innodb_table_locks=0;
-# The following statement should work becase innodb doesn't check table locks
-lock table t1 write;
+--echo # The following statement should block because SQL-level lock
+--echo # is taken on t1 which will wait until concurrent transaction
+--echo # is commited.
+--echo # Sending:
+--send lock table t1 write;
+--echo # Connection 'con1'.
connection con1;
+--echo # Wait until LOCK TABLE is blocked on SQL-level lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table" and info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # We should be able to do UPDATEs and SELECTs within transaction.
+update t1 set x=1 where id = 0;
+select * from t1;
+--echo # Unblock LOCK TABLE.
+commit;
-# This will be locked by MySQL
---send
-update t1 set x=10 where id = 2;
---sleep 2
-
+--echo # Connection 'con2'.
connection con2;
-
-# Note that we will get a deadlock if we try to select any rows marked
-# for update by con1 !
-
-SELECT * from t1 where id = 2;
-UPDATE t1 set x=3 where id = 2;
-commit;
-SELECT * from t1;
-commit;
+--echo # Reap LOCK TABLE.
+--reap
unlock tables;
+--echo # Connection 'con1'.
connection con1;
-reap;
-commit;
-select * from t1;
drop table t1;
# End of 4.1 tests