2007-05-28 22:20:22 +03:00
|
|
|
create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB;
|
|
|
|
create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM;
|
|
|
|
create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB;
|
|
|
|
select get_lock("a", 20);
|
|
|
|
get_lock("a", 20)
|
|
|
|
1
|
|
|
|
reset master;
|
2007-05-30 10:56:18 +03:00
|
|
|
insert into t2 values (null, null), (null, get_lock("a", 10));
|
2007-05-30 00:22:24 +03:00
|
|
|
select @result /* must be zero either way */;
|
|
|
|
@result
|
|
|
|
0
|
2007-11-06 13:53:26 +02:00
|
|
|
select RELEASE_LOCK("a");
|
|
|
|
RELEASE_LOCK("a")
|
|
|
|
1
|
2007-10-29 15:20:59 +02:00
|
|
|
delete from t1;
|
|
|
|
delete from t2;
|
|
|
|
insert into t1 values (1,1),(2,2);
|
|
|
|
begin;
|
|
|
|
update t1 set b=11 where a=2;
|
2007-11-06 20:31:40 +02:00
|
|
|
begin;
|
2007-10-29 15:20:59 +02:00
|
|
|
update t1 set b=b+10;
|
|
|
|
kill query ID;
|
|
|
|
rollback;
|
2007-11-06 20:31:40 +02:00
|
|
|
rollback;
|
2007-11-06 13:53:26 +02:00
|
|
|
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
|
2007-10-29 15:20:59 +02:00
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 2
|
|
|
|
begin;
|
|
|
|
delete from t1 where a=2;
|
2007-11-06 20:31:40 +02:00
|
|
|
begin;
|
2007-10-29 15:20:59 +02:00
|
|
|
delete from t1 where a=2;
|
|
|
|
kill query ID;
|
|
|
|
rollback;
|
2007-11-06 20:31:40 +02:00
|
|
|
rollback;
|
2007-11-06 13:53:26 +02:00
|
|
|
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
|
2007-10-29 15:20:59 +02:00
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 2
|
|
|
|
drop table if exists t4;
|
|
|
|
create table t4 (a int, b int) engine=innodb;
|
|
|
|
insert into t4 values (3, 3);
|
|
|
|
begin;
|
|
|
|
insert into t1 values (3, 3);
|
|
|
|
begin;
|
|
|
|
insert into t1 select * from t4 for update;
|
|
|
|
kill query ID;
|
|
|
|
rollback;
|
|
|
|
rollback;
|
|
|
|
select * from t1 /* must be the same as before (1,1),(2,2) */;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 2
|
|
|
|
drop table t4;
|
2007-05-28 22:20:22 +03:00
|
|
|
drop table t1,t2,t3;
|
2007-10-29 15:20:59 +02:00
|
|
|
end of the tests
|