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
|
stop slave;
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;
start slave;
DROP PROCEDURE IF EXISTS test.p1;
DROP PROCEDURE IF EXISTS test.p2;
DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1(a INT,PRIMARY KEY(a))ENGINE=INNODB;
CREATE PROCEDURE test.p1()
BEGIN
INSERT INTO test.t1 VALUES (4);
SELECT get_lock("test", 100);
UPDATE test.t1 set a=a+4 WHERE a=4;
END|
CREATE PROCEDURE test.p2()
BEGIN
UPDATE test.t1 SET a=a+1;
END|
SELECT get_lock("test", 200);
get_lock("test", 200)
1
CALL test.p1();
CALL test.p2();
SELECT release_lock("test");
release_lock("test")
1
SELECT * FROM test.t1;
a
5
SELECT * FROM test.t1;
a
5
DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1(a INT,PRIMARY KEY(a))ENGINE=INNODB;
CALL test.p2();
CALL test.p1();
get_lock("test", 100)
0
SELECT * FROM test.t1;
a
8
SELECT * FROM test.t1;
a
8
DROP PROCEDURE IF EXISTS test.p1;
DROP PROCEDURE IF EXISTS test.p2;
DROP TABLE IF EXISTS test.t1;
|