~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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