| 1 |
############################################################################# |
| 2 |
# Original Author: JBM # |
| 3 |
# Original Date: Aug/18/2005 # |
| 4 |
# Updated: 08/29/2005 removed sleeps and added master pos save and snyc # |
| 5 |
############################################################################# |
| 6 |
#TEST: Taken and modfied from http://bugs.mysql.com/bug.php?id=12168 # |
| 7 |
############################################################################# |
| 8 |
# 2006-02-08 By JBM : Added order by for ndb engine use |
| 9 |
############################################################################# |
| 10 |
|
| 11 |
# Includes |
| 12 |
-- source include/have_binlog_format_row.inc |
| 13 |
-- source include/set_privilege_checks_user_as_system_user.inc |
| 14 |
-- source include/master-slave.inc |
| 15 |
|
| 16 |
|
| 17 |
# Begin clean up test section |
| 18 |
connection master; |
| 19 |
|
| 20 |
# Begin test section 1 |
| 21 |
CREATE TABLE test.t1 (a INT, PRIMARY KEY(a)); |
| 22 |
INSERT INTO test.t1 VALUES (1),(2),(3),(4); |
| 23 |
CREATE TABLE test.t2 (a INT, PRIMARY KEY(a)); |
| 24 |
|
| 25 |
delimiter |; |
| 26 |
CREATE PROCEDURE test.p1 (arg1 CHAR(1)) |
| 27 |
BEGIN |
| 28 |
DECLARE b, c INT; |
| 29 |
IF arg1 = 'a' THEN |
| 30 |
BEGIN |
| 31 |
DECLARE cur1 CURSOR FOR SELECT A FROM test.t1 WHERE a % 2; |
| 32 |
DECLARE continue handler for not found set b = 1; |
| 33 |
SET b = 0; |
| 34 |
OPEN cur1; |
| 35 |
c1_repeat: REPEAT |
| 36 |
FETCH cur1 INTO c; |
| 37 |
IF (b = 1) THEN |
| 38 |
LEAVE c1_repeat; |
| 39 |
END IF; |
| 40 |
|
| 41 |
INSERT INTO test.t2 VALUES (c); |
| 42 |
UNTIL b = 1 |
| 43 |
END REPEAT; |
| 44 |
CLOSE cur1; |
| 45 |
END; |
| 46 |
END IF; |
| 47 |
IF arg1 = 'b' THEN |
| 48 |
BEGIN |
| 49 |
DECLARE cur2 CURSOR FOR SELECT a FROM test.t1 WHERE NOT a % 2; |
| 50 |
DECLARE continue handler for not found set b = 1; |
| 51 |
SET b = 0; |
| 52 |
OPEN cur2; |
| 53 |
c2_repeat: REPEAT |
| 54 |
FETCH cur2 INTO c; |
| 55 |
IF (b = 1) THEN |
| 56 |
LEAVE c2_repeat; |
| 57 |
END IF; |
| 58 |
|
| 59 |
INSERT INTO test.t2 VALUES (c); |
| 60 |
UNTIL b = 1 |
| 61 |
END REPEAT; |
| 62 |
CLOSE cur2; |
| 63 |
END; |
| 64 |
END IF; |
| 65 |
END| |
| 66 |
delimiter ;| |
| 67 |
|
| 68 |
CALL test.p1('a'); |
| 69 |
SELECT * FROM test.t2 ORDER BY a; |
| 70 |
--source include/sync_slave_sql_with_master.inc |
| 71 |
SELECT * FROM test.t2 ORDER BY a; |
| 72 |
connection master; |
| 73 |
truncate test.t2; |
| 74 |
|
| 75 |
# this next call fails, but should not |
| 76 |
call test.p1('b'); |
| 77 |
select * from test.t2 ORDER BY a; |
| 78 |
--source include/sync_slave_sql_with_master.inc |
| 79 |
SELECT * FROM test.t2 ORDER BY a; |
| 80 |
|
| 81 |
connection master; |
| 82 |
truncate test.t2; |
| 83 |
SELECT * FROM test.t2 ORDER BY a; |
| 84 |
--source include/sync_slave_sql_with_master.inc |
| 85 |
SELECT * FROM test.t2 ORDER BY a; |
| 86 |
|
| 87 |
# Cleanup |
| 88 |
connection master; |
| 89 |
#show binlog events; |
| 90 |
DROP PROCEDURE test.p1; |
| 91 |
DROP TABLE test.t1; |
| 92 |
DROP TABLE test.t2; |
| 93 |
--source include/sync_slave_sql_with_master.inc |
| 94 |
|
| 95 |
# End of 5.0 test case |
| 96 |
--source include/rpl_end.inc |