summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb-lock.test
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-10-20 16:24:28 +0300
committerunknown <monty@mysql.com>2004-10-20 16:24:28 +0300
commit560d7bcdd0c80551b7844b3669be503113c91ddf (patch)
treef3f6e81dac72352598beb9c21f116d2ef7f9c3ef /mysql-test/t/innodb-lock.test
parent7bdb93aa7e8b2c4d003f68635af8e1cbe757f6e6 (diff)
parentec8779e95a46b3dfff492196ad004cb2716df3c3 (diff)
downloadmariadb-git-560d7bcdd0c80551b7844b3669be503113c91ddf.tar.gz
Merge with 4.0
BitKeeper/etc/logging_ok: auto-union Docs/Support/texi2html: Auto merged innobase/trx/trx0rec.c: Auto merged libmysql/libmysql.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/t/innodb-lock.test: Auto merged mysys/thr_lock.c: Auto merged sql/ha_innodb.cc: Auto merged sql/lock.cc: Auto merged sql/sql_acl.cc: Keep old code
Diffstat (limited to 'mysql-test/t/innodb-lock.test')
-rw-r--r--mysql-test/t/innodb-lock.test57
1 files changed, 56 insertions, 1 deletions
diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test
index 33baec32549..2bbbac82ad5 100644
--- a/mysql-test/t/innodb-lock.test
+++ b/mysql-test/t/innodb-lock.test
@@ -1,5 +1,15 @@
-- source include/have_innodb.inc
+#
+# Check and select innodb lock type
+#
+
+select @@innodb_table_locks;
+
+#
+# Testing of explicit table locks with enforced table locks
+#
+
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
@@ -8,9 +18,11 @@ drop table if exists t1;
--enable_warnings
#
-# Testing of explicit table locks
+# Testing of explicit table locks with enforced table locks
#
+set @@innodb_table_locks=1;
+
connection con1;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
@@ -41,3 +53,46 @@ select * from t1;
commit;
drop table t1;
+
+#
+# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
+#
+
+set @@innodb_table_locks=0;
+
+create table t1 (id integer primary key, x integer) engine=INNODB;
+insert into t1 values(0, 0),(1,1),(2,2);
+commit;
+SELECT * from t1 where id = 0 FOR UPDATE;
+
+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;
+
+connection con1;
+
+# This will be locked by MySQL
+--send
+update t1 set x=10 where id = 2;
+--sleep 2
+
+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;
+unlock tables;
+
+connection con1;
+reap;
+commit;
+select * from t1;
+drop table t1;