| 1 |
############################################################################# |
| 2 |
# Original Author: JBM # |
| 3 |
# Original Date: Aug/13/2005 Created from Bug 12335 # |
| 4 |
############################################################################# |
| 5 |
|
| 6 |
# Begin clean up test section |
| 7 |
connection master; |
| 8 |
--disable_warnings |
| 9 |
DROP PROCEDURE IF EXISTS test.p1; |
| 10 |
DROP PROCEDURE IF EXISTS test.p2; |
| 11 |
DROP TABLE IF EXISTS test.t1; |
| 12 |
--enable_warnings |
| 13 |
# End of cleanup |
| 14 |
|
| 15 |
# Begin test section 1 |
| 16 |
|
| 17 |
--disable_ps2_protocol |
| 18 |
eval CREATE TABLE test.t1(a INT,PRIMARY KEY(a))ENGINE=$engine_type; |
| 19 |
|
| 20 |
delimiter |; |
| 21 |
CREATE PROCEDURE test.p1() |
| 22 |
BEGIN |
| 23 |
INSERT INTO test.t1 VALUES (4); |
| 24 |
SELECT get_lock("test", 100); |
| 25 |
UPDATE test.t1 set a=a+4 WHERE a=4; |
| 26 |
END| |
| 27 |
CREATE PROCEDURE test.p2() |
| 28 |
BEGIN |
| 29 |
UPDATE test.t1 SET a=a+1; |
| 30 |
END| |
| 31 |
delimiter ;| |
| 32 |
|
| 33 |
SELECT get_lock("test", 200); |
| 34 |
|
| 35 |
connection master1; |
| 36 |
send CALL test.p1(); |
| 37 |
|
| 38 |
connection master; |
| 39 |
# Make sure that the call on master1 arrived at the get_lock. |
| 40 |
let $wait_condition= |
| 41 |
select count(*) = 1 from information_schema.processlist |
| 42 |
where state = 'User lock' and |
| 43 |
info = 'SELECT get_lock("test", 100)'; |
| 44 |
--source include/wait_condition.inc |
| 45 |
CALL test.p2(); |
| 46 |
SELECT release_lock("test"); |
| 47 |
|
| 48 |
connection master1; |
| 49 |
# Reap CALL test.p1() to ensure that it has fully completed |
| 50 |
# before doing any selects on test.t1. |
| 51 |
--reap |
| 52 |
# Release lock acquired by it. |
| 53 |
SELECT release_lock("test"); |
| 54 |
|
| 55 |
connection master; |
| 56 |
SELECT * FROM test.t1; |
| 57 |
sync_slave_with_master; |
| 58 |
connection slave; |
| 59 |
SELECT * FROM test.t1; |
| 60 |
|
| 61 |
connection master; |
| 62 |
DROP TABLE IF EXISTS test.t1; |
| 63 |
eval CREATE TABLE test.t1(a INT,PRIMARY KEY(a))ENGINE=$engine_type; |
| 64 |
CALL test.p2(); |
| 65 |
CALL test.p1(); |
| 66 |
SELECT release_lock("test"); |
| 67 |
SELECT * FROM test.t1; |
| 68 |
|
| 69 |
sync_slave_with_master; |
| 70 |
connection slave; |
| 71 |
SELECT * FROM test.t1; |
| 72 |
connection master; |
| 73 |
#show binlog events from 720; |
| 74 |
--enable_ps2_protocol |
| 75 |
|
| 76 |
DROP PROCEDURE IF EXISTS test.p1; |
| 77 |
DROP PROCEDURE IF EXISTS test.p2; |
| 78 |
DROP TABLE IF EXISTS test.t1; |
| 79 |
sync_slave_with_master; |
| 80 |
|
| 81 |
# End of 5.0 test case |