mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
select @@innodb_table_locks;
|
||||
@@innodb_table_locks
|
||||
1
|
||||
drop table if exists t1;
|
||||
set @@innodb_table_locks=1;
|
||||
create table t1 (id integer, x integer) engine=INNODB;
|
||||
insert into t1 values(0, 0);
|
||||
set autocommit=0;
|
||||
@ -20,3 +24,33 @@ id x
|
||||
0 2
|
||||
commit;
|
||||
drop table t1;
|
||||
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;
|
||||
id x
|
||||
0 0
|
||||
set autocommit=0;
|
||||
set @@innodb_table_locks=0;
|
||||
lock table t1 write;
|
||||
update t1 set x=10 where id = 2;
|
||||
SELECT * from t1 where id = 2;
|
||||
id x
|
||||
2 2
|
||||
UPDATE t1 set x=3 where id = 2;
|
||||
commit;
|
||||
SELECT * from t1;
|
||||
id x
|
||||
0 0
|
||||
1 1
|
||||
2 3
|
||||
commit;
|
||||
unlock tables;
|
||||
commit;
|
||||
select * from t1;
|
||||
id x
|
||||
0 0
|
||||
1 1
|
||||
2 10
|
||||
drop table t1;
|
||||
|
13
mysql-test/r/rpl_commit_after_flush.result
Normal file
13
mysql-test/r/rpl_commit_after_flush.result
Normal file
@ -0,0 +1,13 @@
|
||||
slave stop;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
slave start;
|
||||
create table t1 (a int) type=innodb;
|
||||
begin;
|
||||
insert into t1 values(1);
|
||||
flush tables with read lock;
|
||||
commit;
|
||||
unlock tables;
|
||||
drop table t1;
|
1
mysql-test/t/innodb-lock-master.opt
Normal file
1
mysql-test/t/innodb-lock-master.opt
Normal file
@ -0,0 +1 @@
|
||||
--innodb-table-lock=1
|
@ -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;
|
||||
|
17
mysql-test/t/rpl_commit_after_flush.test
Normal file
17
mysql-test/t/rpl_commit_after_flush.test
Normal file
@ -0,0 +1,17 @@
|
||||
source include/master-slave.inc;
|
||||
source include/have_innodb.inc;
|
||||
create table t1 (a int) type=innodb;
|
||||
begin;
|
||||
insert into t1 values(1);
|
||||
flush tables with read lock;
|
||||
commit;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
# cleanup
|
||||
connection master;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
Reference in New Issue
Block a user