~vadim-tk/percona-server/percona-galera-5.1.57-0.8.1

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_row_sp002.test

  • Committer: root
  • Date: 2011-07-28 00:14:23 UTC
  • Revision ID: root@r815.office.percona.com-20110728001423-6pw0v4b7r0dkbsr4
Ported to Galera 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#############################################################################
 
2
# This test is being created to test out the non deterministic items with   #
 
3
# row based replication.                                                    #
 
4
#############################################################################
 
5
# Test: Contains two stored procedures test one that insert data into tables#
 
6
#        and use the LAST_INSERTED_ID() on tables with FOREIGN KEY(a)       #
 
7
#        REFERENCES ON DELETE CASCADE. This test also has a delete sp that  #
 
8
#        should cause a delete cascade.                                     #
 
9
#       The second test has a sp that will either insert rows or delete from#
 
10
#        the table depending on the CASE outcome. The test uses this SP in a#
 
11
#        transaction first rolling back and then commiting,                 #
 
12
#############################################################################
 
13
 
 
14
 
 
15
 
 
16
# Includes
 
17
-- source include/have_binlog_format_row.inc
 
18
-- source include/master-slave.inc
 
19
 
 
20
 
 
21
# Begin test section 1
 
22
 
 
23
eval CREATE TABLE test.t1 (a INT AUTO_INCREMENT KEY, t CHAR(6)) ENGINE=$engine_type;
 
24
eval CREATE TABLE test.t2 (a INT AUTO_INCREMENT KEY, f INT, FOREIGN KEY(a) REFERENCES test.t1(a) ON DELETE CASCADE) ENGINE=$engine_type;
 
25
 
 
26
delimiter |;
 
27
create procedure test.p1(IN i CHAR(6))
 
28
begin
 
29
 INSERT INTO test.t1 (t) VALUES (i);
 
30
 INSERT INTO test.t2 VALUES (NULL,LAST_INSERT_ID());
 
31
end|
 
32
create procedure test.p2(IN i INT)
 
33
begin
 
34
 DELETE FROM test.t1 where a < i;
 
35
end|
 
36
delimiter ;|
 
37
 
 
38
let $message=< -- test 1 call p1 -- >;
 
39
--source include/show_msg.inc
 
40
SET FOREIGN_KEY_CHECKS=1;
 
41
call test.p1('texas');
 
42
call test.p1('Live');
 
43
call test.p1('next');
 
44
call test.p1('to');
 
45
call test.p1('OK');
 
46
call test.p1('MySQL');
 
47
 
 
48
let $message=< -- test 1 select master after p1 -- >;
 
49
--source include/show_msg.inc
 
50
 
 
51
SELECT * FROM test.t1;
 
52
SELECT * FROM test.t2;
 
53
 
 
54
let $message=< -- test 1 select slave after p1 -- >;
 
55
--source include/show_msg.inc
 
56
sync_slave_with_master;
 
57
SELECT * FROM test.t1;
 
58
SELECT * FROM test.t2;
 
59
 
 
60
let $message=< -- test 1 call p2 & select master -- >;
 
61
--source include/show_msg.inc
 
62
connection master;
 
63
call test.p2(4);
 
64
SELECT * FROM test.t1;
 
65
SELECT * FROM test.t2;
 
66
 
 
67
let $message=< -- test 1 select slave after p2 -- >;
 
68
--source include/show_msg.inc
 
69
sync_slave_with_master;
 
70
SELECT * FROM test.t1;
 
71
SELECT * FROM test.t2;
 
72
 
 
73
connection master;
 
74
#show binlog events;
 
75
let $message=< -- End test 1 Begin test 2 -- >;
 
76
--source include/show_msg.inc
 
77
# End test 1 Begin test 2
 
78
 
 
79
--disable_warnings
 
80
SET FOREIGN_KEY_CHECKS=0;
 
81
DROP PROCEDURE IF EXISTS test.p1;
 
82
DROP PROCEDURE IF EXISTS test.p2;
 
83
DROP TABLE IF EXISTS test.t1;
 
84
DROP TABLE IF EXISTS test.t2;
 
85
--enable_warnings
 
86
# End of cleanup
 
87
 
 
88
eval CREATE TABLE test.t1 (a INT, t CHAR(6), PRIMARY KEY(a)) ENGINE=$engine_type;
 
89
eval CREATE TABLE test.t2 (a INT, f INT, FOREIGN KEY(a) REFERENCES test.t1(a) ON UPDATE CASCADE, PRIMARY KEY(a)) ENGINE=$engine_type;
 
90
 
 
91
delimiter |;
 
92
CREATE PROCEDURE  test.p1(IN nm INT, IN ch CHAR(6))
 
93
BEGIN
 
94
 INSERT INTO test.t1 (a,t) VALUES (nm, ch);
 
95
 INSERT INTO test.t2 VALUES (nm, LAST_INSERT_ID());
 
96
END|
 
97
CREATE PROCEDURE test.p2(IN i INT)
 
98
BEGIN
 
99
 UPDATE test.t1 SET a = i*10 WHERE a = i;
 
100
END|
 
101
delimiter ;|
 
102
SET FOREIGN_KEY_CHECKS=1;
 
103
CALL test.p1(1,'texas');
 
104
CALL test.p1(2,'Live');
 
105
CALL test.p1(3,'next');
 
106
CALL test.p1(4,'to');
 
107
CALL test.p1(5,'OK');
 
108
CALL test.p1(6,'MySQL');
 
109
 
 
110
let $message=< -- test 2 select Master after p1 -- >;
 
111
--source include/show_msg.inc
 
112
SELECT * FROM test.t1;
 
113
SELECT * FROM test.t2;
 
114
 
 
115
let $message=< -- test 2 select Slave after p1 -- >;
 
116
--source include/show_msg.inc
 
117
sync_slave_with_master;
 
118
SELECT * FROM test.t1;
 
119
SELECT * FROM test.t2;
 
120
 
 
121
let $message=< -- test 2 call p2 & select Master -- >;
 
122
--source include/show_msg.inc
 
123
connection master;
 
124
CALL test.p2(2);
 
125
CALL test.p2(4);
 
126
CALL test.p2(6);
 
127
SELECT * FROM test.t1;
 
128
SELECT * FROM test.t2;
 
129
 
 
130
let $message=< -- test 1 select Slave after p2 -- >;
 
131
--source include/show_msg.inc
 
132
sync_slave_with_master;
 
133
SELECT * FROM test.t1;
 
134
SELECT * FROM test.t2;
 
135
 
 
136
connection master;
 
137
#show binlog events;
 
138
let $message=< -- End test 2 Begin test 3 -- >;
 
139
--source include/show_msg.inc
 
140
# End test 2 begin test 3
 
141
 
 
142
eval CREATE TABLE test.t3 (a INT AUTO_INCREMENT KEY, t CHAR(6))ENGINE=$engine_type;
 
143
 
 
144
delimiter |;
 
145
CREATE PROCEDURE test.p3(IN n INT)
 
146
begin
 
147
CASE n
 
148
WHEN 2 THEN
 
149
 DELETE from test.t3; 
 
150
ELSE
 
151
 INSERT INTO test.t3 VALUES (NULL,'NONE');
 
152
END CASE;
 
153
end|
 
154
delimiter ;|
 
155
 
 
156
SET AUTOCOMMIT=0;
 
157
START TRANSACTION;
 
158
 
 
159
-- disable_query_log
 
160
-- disable_result_log
 
161
let $n=50;
 
162
while ($n)
 
163
{
 
164
  eval call test.p3($n);
 
165
  dec $n;
 
166
}
 
167
-- enable_result_log
 
168
-- enable_query_log
 
169
 
 
170
ROLLBACK;
 
171
select * from test.t3;
 
172
sync_slave_with_master;
 
173
select * from test.t3;
 
174
 
 
175
connection master;
 
176
START TRANSACTION;
 
177
 
 
178
-- disable_query_log
 
179
-- disable_result_log
 
180
let $n=50;
 
181
while ($n)
 
182
{
 
183
  eval call test.p3($n);
 
184
  dec $n;
 
185
}
 
186
-- enable_result_log
 
187
-- enable_query_log
 
188
 
 
189
COMMIT;
 
190
select * from test.t3;
 
191
sync_slave_with_master;
 
192
select * from test.t3;
 
193
 
 
194
connection master;
 
195
#show binlog events from 1627;
 
196
 
 
197
 
 
198
# First lets cleanup
 
199
SET AUTOCOMMIT=1;
 
200
SET FOREIGN_KEY_CHECKS=0;
 
201
DROP PROCEDURE test.p3;
 
202
DROP PROCEDURE test.p1;
 
203
DROP PROCEDURE test.p2;
 
204
DROP TABLE test.t1;
 
205
DROP TABLE test.t2;
 
206
DROP TABLE test.t3;
 
207
 
 
208
# End of 5.0 test case
 
209
--source include/rpl_end.inc