mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / rpl / t / rpl_row_sp009.test
blob2f05a55e6f8340fd2990e94a6d1cc1d35f663078
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 #############################################################################
11 # Includes
12 -- source include/have_binlog_format_row.inc
13 -- source include/master-slave.inc
16 # Begin clean up test section
17 connection master;
18 --disable_warnings
19 DROP PROCEDURE IF EXISTS test.p1;
20 DROP TABLE IF EXISTS test.t1;
21 DROP TABLE IF EXISTS test.t2;
24 # Begin test section 1 
25 CREATE TABLE test.t1 (a INT, PRIMARY KEY(a));
26 INSERT INTO test.t1 VALUES (1),(2),(3),(4);
27 CREATE TABLE test.t2 (a INT, PRIMARY KEY(a));
29 delimiter |;
30 CREATE PROCEDURE test.p1 (arg1 CHAR(1))
31 BEGIN
32   DECLARE b, c INT;
33   IF arg1 = 'a' THEN
34     BEGIN
35       DECLARE cur1 CURSOR FOR SELECT A FROM test.t1 WHERE a % 2;
36       DECLARE continue handler for not found set b = 1;
37       SET b = 0;
38       OPEN cur1;
39       c1_repeat: REPEAT
40         FETCH cur1 INTO c;
41         IF (b = 1) THEN
42           LEAVE c1_repeat;
43         END IF;
45         INSERT INTO test.t2 VALUES (c);
46         UNTIL b = 1
47       END REPEAT;
48       CLOSE cur1;
49     END;
50   END IF;
51   IF arg1 = 'b' THEN
52     BEGIN
53       DECLARE cur2 CURSOR FOR SELECT a FROM test.t1 WHERE NOT a % 2;
54       DECLARE continue handler for not found set b = 1;
55       SET b = 0;
56       OPEN cur2;
57       c2_repeat: REPEAT
58         FETCH cur2 INTO c;
59         IF (b = 1) THEN
60           LEAVE c2_repeat;
61         END IF;
63         INSERT INTO test.t2 VALUES (c);
64         UNTIL b = 1
65       END REPEAT;
66       CLOSE cur2;
67     END;
68   END IF;
69 END|
70 delimiter ;|
72 CALL test.p1('a');
73 SELECT * FROM test.t2 ORDER BY a;
74 save_master_pos;
75 connection slave;
76 sync_with_master;
77 SELECT * FROM test.t2 ORDER BY a;
78 connection master;
79 truncate test.t2;
81 # this next call fails, but should not
82 call test.p1('b');
83 select * from test.t2 ORDER BY a;
84 save_master_pos;
85 connection slave;
86 sync_with_master;
87 SELECT * FROM test.t2 ORDER BY a;
89 connection master;
90 truncate test.t2;
91 SELECT * FROM test.t2 ORDER BY a;
92 save_master_pos;
93 connection slave;
94 sync_with_master;
95 SELECT * FROM test.t2 ORDER BY a;
97 # Cleanup
98 connection master;
99 #show binlog events;
100 DROP PROCEDURE test.p1;
101 DROP TABLE test.t1;
102 DROP TABLE test.t2;
103 sync_slave_with_master;
105 # End of 5.0 test case
106 --source include/rpl_end.inc