summaryrefslogtreecommitdiff
path: root/mysql-test/t/bdb-deadlock.test
blob: 5ecfe592ce4ed764d8c5fcd0aa640adbb28601df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#

#-- source include/not_embedded.inc
-- source include/have_bdb.inc

connect (con1,localhost,root,,);
connect (con2,localhost,root,,);

drop table if exists t1,t2;
connection con1;
create table t1 (id integer, x integer) type=BDB;
create table t2 (id integer, x integer) type=BDB;
insert into t1 values(0, 0);
insert into t2 values(0, 0);
set autocommit=0;
update t1 set x = 1 where id = 0;

connection con2;
set autocommit=0;
update t2 set x = 1 where id = 0;

# The following query should hang because con1 is locking the page
--send
select x from t1 where id = 0;

connection con1;
# This should generate a deadlock as we are trying to access a locked row
--send
select x from t2 where id = 0;

connection con2;
--error 1213
reap;
commit;

connection con1;
reap;
commit;

connection con2;
select * from t1;
select * from t2;
commit;

connection con1;
select * from t1;
select * from t2;
commit;

drop table t1,t2;