1
by brian
clean slate |
1 |
-- connect (con1,localhost,root,,) |
2 |
-- connect (con2,localhost,root,,) |
|
3 |
||
4 |
-- connection con1 |
|
5 |
SET autocommit=0; |
|
6 |
SELECT * FROM t1 FOR UPDATE; |
|
7 |
-- if ($con1_extra_sql_present) { |
|
8 |
-- eval $con1_extra_sql |
|
9 |
-- } |
|
10 |
||
11 |
-- connection con2 |
|
12 |
SET autocommit=0; |
|
13 |
SELECT * FROM t2 FOR UPDATE; |
|
14 |
-- if ($con2_extra_sql_present) { |
|
15 |
-- eval $con2_extra_sql |
|
16 |
-- } |
|
17 |
||
18 |
-- if ($con1_should_be_rolledback) { |
|
19 |
-- connection con1 |
|
20 |
-- send |
|
21 |
INSERT INTO t2 VALUES (0); |
|
22 |
||
23 |
-- connection con2 |
|
24 |
INSERT INTO t1 VALUES (0); |
|
25 |
ROLLBACK; |
|
26 |
||
27 |
-- connection con1 |
|
28 |
-- error ER_LOCK_DEADLOCK |
|
29 |
-- reap |
|
30 |
-- } |
|
31 |
# else |
|
32 |
-- if (!$con1_should_be_rolledback) { |
|
33 |
-- connection con2 |
|
34 |
-- send |
|
35 |
INSERT INTO t1 VALUES (0); |
|
36 |
||
37 |
-- connection con1 |
|
38 |
INSERT INTO t2 VALUES (0); |
|
39 |
ROLLBACK; |
|
40 |
||
41 |
-- connection con2 |
|
42 |
-- error ER_LOCK_DEADLOCK |
|
43 |
-- reap |
|
44 |
-- } |
|
45 |
||
46 |
-- connection default |
|
47 |
||
48 |
DELETE FROM t5_nontrans; |
|
49 |
||
50 |
-- disconnect con1 |
|
51 |
-- disconnect con2 |