~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Basic tests of row-level logging
 
3
#
 
4
 
 
5
#
 
6
# First we test tables with only an index.
 
7
#
 
8
 
 
9
eval CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)$extra_index_t1) ENGINE = $type ;
 
10
SELECT * FROM t1;
 
11
sync_slave_with_master;
 
12
SELECT * FROM t1;
 
13
 
 
14
# Testing insert
 
15
connection master;
 
16
INSERT INTO t1 VALUES ('A','B'), ('X','Y'), ('X','X');
 
17
INSERT INTO t1 VALUES ('A','C'), ('X','Z'), ('A','A');
 
18
SELECT * FROM t1 ORDER BY C1,C2;
 
19
sync_slave_with_master;
 
20
SELECT * FROM t1 ORDER BY C1,C2;
 
21
 
 
22
# Testing delete
 
23
# Observe that are several rows having the value for the index but only one
 
24
# should be deleted.
 
25
connection master;
 
26
DELETE FROM t1 WHERE C1 = C2;
 
27
SELECT * FROM t1 ORDER BY C1,C2;
 
28
sync_slave_with_master;
 
29
SELECT * FROM t1 ORDER BY C1,C2;
 
30
 
 
31
#
 
32
# Testing update.
 
33
# Note that we have a condition on a column that is not part of the index for
 
34
# the table. The right row should be updated nevertheless.
 
35
#
 
36
connection master;
 
37
UPDATE t1 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
 
38
SELECT * FROM t1 ORDER BY C1,C2;
 
39
sync_slave_with_master;
 
40
SELECT * FROM t1 ORDER BY C1,C2;
 
41
 
 
42
# Testing update with a condition that does not match any rows, but
 
43
# which has a match for the index.
 
44
connection master;
 
45
UPDATE t1 SET c2 = 'Q' WHERE c1 = 'A' AND c2 = 'N';
 
46
SELECT * FROM t1 ORDER BY c1,c2;
 
47
sync_slave_with_master;
 
48
SELECT * FROM t1 ORDER BY c1,c2;
 
49
 
 
50
#
 
51
# Testing table with primary key
 
52
#
 
53
connection master;
 
54
eval CREATE TABLE t2 (c1 INT, c12 char(1), c2 INT, PRIMARY KEY (c1)) ENGINE = $type ;
 
55
INSERT INTO t2
 
56
  VALUES (1,'A',2),  (2,'A',4),  (3,'A',9),  (4,'A',15), (5,'A',25),
 
57
         (6,'A',35), (7,'A',50), (8,'A',64), (9,'A',81);
 
58
SELECT * FROM t2 ORDER BY c1,c2;
 
59
SELECT * FROM t2 WHERE c2 = c1 * c1 ORDER BY c1,c2;
 
60
sync_slave_with_master;
 
61
SELECT * FROM t2 ORDER BY c1,c2;
 
62
SELECT * FROM t2 WHERE c2 = c1 * c1 ORDER BY c1,c2;
 
63
 
 
64
connection master;
 
65
UPDATE t2 SET c2 = c1*c1 WHERE c2 != c1*c1;
 
66
SELECT * FROM t2 WHERE c2 = c1 * c1 ORDER BY c1,c2;
 
67
sync_slave_with_master;
 
68
SELECT * FROM t2 WHERE c2 = c1 * c1 ORDER BY c1,c2;
 
69
 
 
70
# Testing update with a condition that does not match any rows, but
 
71
# which has a match for the primary key.
 
72
connection master;
 
73
UPDATE t2 SET c12 = 'Q' WHERE c1 = 1 AND c2 = 999;
 
74
SELECT * FROM t2 ORDER BY c1,c2;
 
75
sync_slave_with_master;
 
76
SELECT * FROM t2 ORDER BY c1,c2;
 
77
 
 
78
connection master;
 
79
DELETE FROM t2 WHERE c1 % 4 = 0;
 
80
SELECT * FROM t2 ORDER BY c1,c2;
 
81
sync_slave_with_master;
 
82
SELECT * FROM t2 ORDER BY c1,c2;
 
83
 
 
84
connection master;
 
85
UPDATE t2 SET c12='X';
 
86
 
 
87
#
 
88
# Testing table with a multi-column primary key.
 
89
#
 
90
connection master;
 
91
eval CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1), pk1 INT, C3 CHAR(1), pk2 INT, PRIMARY KEY (pk1,pk2)) ENGINE = $type ;
 
92
 
 
93
INSERT INTO t3 VALUES ('A','B',1,'B',1), ('X','Y',2,'B',1), ('X','X',3,'B',1);
 
94
INSERT INTO t3 VALUES ('A','C',1,'B',2), ('X','Z',2,'B',2), ('A','A',3,'B',2);
 
95
SELECT * FROM t3 ORDER BY C1,C2;
 
96
sync_slave_with_master;
 
97
SELECT * FROM t3 ORDER BY C1,C2;
 
98
 
 
99
connection master;
 
100
DELETE FROM t3 WHERE C1 = C2;
 
101
SELECT * FROM t3 ORDER BY C1,C2;
 
102
sync_slave_with_master;
 
103
SELECT * FROM t3 ORDER BY C1,C2;
 
104
 
 
105
connection master;
 
106
UPDATE t3 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
 
107
SELECT * FROM t3 ORDER BY C1,C2;
 
108
sync_slave_with_master;
 
109
SELECT * FROM t3 ORDER BY C1,C2;
 
110
 
 
111
#
 
112
# Testing table without index or primary key
 
113
#
 
114
connection master;
 
115
eval CREATE TABLE t6 (C1 CHAR(1), C2 CHAR(1), C3 INT$extra_index_t6) ENGINE = $type;
 
116
 
 
117
# Testing insert
 
118
INSERT INTO t6 VALUES ('A','B',1), ('X','Y',2), ('X','X',3);
 
119
INSERT INTO t6 VALUES ('A','C',4), ('X','Z',5), ('A','A',6);
 
120
SELECT * FROM t6 ORDER BY C3;
 
121
sync_slave_with_master;
 
122
SELECT * FROM t6 ORDER BY C3;
 
123
 
 
124
# Testing delete
 
125
# Observe that are several rows having the value for the index but only one
 
126
# should be deleted.
 
127
connection master;
 
128
DELETE FROM t6 WHERE C1 = C2;
 
129
SELECT * FROM t6 ORDER BY C3;
 
130
sync_slave_with_master;
 
131
SELECT * FROM t6 ORDER BY C3;
 
132
 
 
133
#
 
134
# Testing update.
 
135
# Note that we have a condition on a column that is not part of the index for
 
136
# the table. The right row should be updated nevertheless.
 
137
#
 
138
connection master;
 
139
UPDATE t6 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
 
140
SELECT * FROM t6 ORDER BY C3;
 
141
sync_slave_with_master;
 
142
SELECT * FROM t6 ORDER BY C3;
 
143
 
 
144
# now mixing the 3 tables without begin/commit
 
145
connection master;
 
146
eval CREATE TABLE t5 (C1 CHAR(1), C2 CHAR(1), C3 INT PRIMARY KEY) ENGINE = $type ;
 
147
INSERT INTO t5 VALUES ('A','B',1), ('X','Y',2), ('X','X',3);
 
148
INSERT INTO t5 VALUES ('A','C',4), ('X','Z',5), ('A','A',6);
 
149
 
 
150
UPDATE t5,t2,t3 SET t5.C2='Q', t2.c12='R', t3.C3 ='S' WHERE t5.C1 = t2.c12 AND t5.C1 = t3.C1;
 
151
SELECT * FROM t5,t2,t3 WHERE t5.C2='Q' AND t2.c12='R' AND t3.C3 ='S' ORDER BY t5.C3,t2.c1,t3.pk1,t3.pk2;
 
152
sync_slave_with_master;
 
153
SELECT * FROM t5,t2,t3 WHERE t5.C2='Q' AND t2.c12='R' AND t3.C3 ='S' ORDER BY t5.C3,t2.c1,t3.pk1,t3.pk2;
 
154
 
 
155
#
 
156
# Testing special column types
 
157
#
 
158
 
 
159
connection master;
 
160
eval CREATE TABLE t4 (C1 CHAR(1) PRIMARY KEY, B1 BIT(1), B2 BIT(1) NOT NULL DEFAULT 0, C2 CHAR(1) NOT NULL DEFAULT 'A') ENGINE = $type ;
 
161
 
 
162
INSERT INTO t4 SET C1 = 1;
 
163
SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1;
 
164
sync_slave_with_master;
 
165
SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1;
 
166
 
 
167
#
 
168
# Testing conflicting operations
 
169
#
 
170
connection master;
 
171
eval CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = $type ;
 
172
sync_slave_with_master;
 
173
--echo --- on slave: original values ---
 
174
INSERT INTO t7 VALUES (1,3), (2,6), (3,9);
 
175
SELECT * FROM t7 ORDER BY C1;
 
176
 
 
177
# since bug#31552/31609 idempotency is not default any longer. In order
 
178
# the preceeding test INSERT INTO t7 to pass the mode is switched
 
179
# temprorarily
 
180
set @@global.slave_exec_mode= 'IDEMPOTENT';
 
181
 
 
182
connection master;
 
183
--echo --- on master: new values inserted ---
 
184
INSERT INTO t7 VALUES (1,2), (2,4), (3,6);
 
185
SELECT * FROM t7 ORDER BY C1;
 
186
sync_slave_with_master;
 
187
 
 
188
set @@global.slave_exec_mode= default;
 
189
--echo --- on slave: old values should be overwritten by replicated values ---
 
190
SELECT * FROM t7 ORDER BY C1;
 
191
 
 
192
#
 
193
# A more complicated test where the table has several keys and we are
 
194
# causing a conflict for a key that is not "last".
 
195
#
 
196
connection master;
 
197
--echo --- on master ---
 
198
eval CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $type ;
 
199
 
 
200
# First we make sure that the constraints are correctly set.
 
201
INSERT INTO t8 VALUES (99,99,99);
 
202
--error ER_DUP_ENTRY
 
203
INSERT INTO t8 VALUES (99,22,33);
 
204
--error ER_DUP_ENTRY
 
205
INSERT INTO t8 VALUES (11,99,33);
 
206
--error ER_DUP_ENTRY
 
207
INSERT INTO t8 VALUES (11,22,99);
 
208
SELECT * FROM t8 ORDER BY a;
 
209
 
 
210
sync_slave_with_master;
 
211
--echo --- on slave ---
 
212
SELECT * FROM t8 ORDER BY a;
 
213
INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9);
 
214
SELECT * FROM t8 ORDER BY a;
 
215
 
 
216
# since bug#31552/31609 idempotency is not default any longer. In order
 
217
# the preceeding test INSERT INTO t8 to pass the mode is switched
 
218
# temprorarily
 
219
set @@global.slave_exec_mode= 'IDEMPOTENT';
 
220
 
 
221
connection master;
 
222
--echo --- on master ---
 
223
# We insert a row that will cause conflict on the primary key but not
 
224
# on the other keys.
 
225
INSERT INTO t8 VALUES (2,4,8);
 
226
sync_slave_with_master;
 
227
set @@global.slave_exec_mode= default;
 
228
 
 
229
--echo --- on slave ---
 
230
SELECT * FROM t8 ORDER BY a;
 
231
 
 
232
# BUG#31552: Replication breaks when deleting rows from out-of-sync
 
233
#            table without PK
 
234
 
 
235
--echo **** Test for BUG#31552 ****
 
236
 
 
237
--echo **** On Master ****
 
238
# Clean up t1 so that we can use it.
 
239
connection master;
 
240
DELETE FROM t1;
 
241
sync_slave_with_master;
 
242
 
 
243
# Just to get a clean binary log
 
244
source include/reset_master_and_slave.inc;
 
245
 
 
246
--echo **** On Master ****
 
247
connection master;
 
248
INSERT INTO t1 VALUES ('K','K'), ('L','L'), ('M','M');
 
249
--echo **** On Master ****
 
250
sync_slave_with_master;
 
251
# since bug#31552/31609 idempotency is not default any longer. In order
 
252
# the following test DELETE FROM t1 to pass the mode is switched
 
253
# temprorarily
 
254
set @@global.slave_exec_mode= 'IDEMPOTENT';
 
255
DELETE FROM t1 WHERE C1 = 'L';
 
256
 
 
257
connection master;
 
258
DELETE FROM t1;
 
259
query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
 
260
sync_slave_with_master;
 
261
set @@global.slave_exec_mode= default;
 
262
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
263
disable_query_log;
 
264
eval SELECT "$last_error" AS Last_SQL_Error;
 
265
enable_query_log;
 
266
query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
 
267
 
 
268
# BUG#37076: TIMESTAMP/DATETIME values are not replicated correctly
 
269
#            between machines with mixed endiannes
 
270
#            (regression test)
 
271
 
 
272
--echo **** Test for BUG#37076 ****
 
273
--echo **** On Master ****
 
274
connection master;
 
275
DROP TABLE IF EXISTS t1;
 
276
CREATE TABLE t1 (a TIMESTAMP, b DATETIME, c DATE);
 
277
INSERT INTO t1 VALUES(
 
278
  '2005-11-14 01:01:01', '2005-11-14 01:01:02', '2005-11-14');
 
279
 
 
280
--echo **** On Slave ****
 
281
sync_slave_with_master slave;
 
282
SELECT * FROM t1;
 
283
 
 
284
#
 
285
# cleanup
 
286
#
 
287
 
 
288
connection master;
 
289
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
 
290
sync_slave_with_master;
 
291
 
 
292
#
 
293
# BUG#37426: RBR breaks for CHAR() UTF8 fields > 85 chars
 
294
#
 
295
 
 
296
# We have 4 combinations to test with respect to the field length
 
297
# (i.e., the number of bytes) of the CHAR fields:
 
298
#
 
299
# 1. Replicating from CHAR<256 to CHAR<256 
 
300
# 2. Replicating from CHAR<256 to CHAR>255
 
301
# 3. Replicating from CHAR>255 to CHAR<256
 
302
# 4. Replicating from CHAR>255 to CHAR>255
 
303
 
 
304
# We also make a special case of using the max size of a field on the
 
305
# master, i.e. CHAR(255) in UTF-8, giving another three cases.
 
306
#
 
307
# 5. Replicating UTF-8 CHAR(255) to CHAR(<256)
 
308
# 6. Replicating UTF-8 CHAR(255) to CHAR(>255)
 
309
# 7. Replicating UTF-8 CHAR(255) to CHAR(255) UTF-8
 
310
 
 
311
connection master;
 
312
eval CREATE TABLE t1 (i INT NOT NULL,
 
313
                      c CHAR(16) CHARACTER SET utf8 NOT NULL,
 
314
                      j INT NOT NULL) ENGINE = $type ;
 
315
 
 
316
eval CREATE TABLE t2 (i INT NOT NULL,
 
317
                      c CHAR(16) CHARACTER SET utf8 NOT NULL,
 
318
                      j INT NOT NULL) ENGINE = $type ;
 
319
 
 
320
sync_slave_with_master;
 
321
ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;
 
322
 
 
323
connection master;
 
324
eval CREATE TABLE t3 (i INT NOT NULL,
 
325
                      c CHAR(128) CHARACTER SET utf8 NOT NULL,
 
326
                      j INT NOT NULL) ENGINE = $type ;
 
327
sync_slave_with_master;
 
328
ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;
 
329
 
 
330
connection master;
 
331
eval CREATE TABLE t4 (i INT NOT NULL,
 
332
                      c CHAR(128) CHARACTER SET utf8 NOT NULL,
 
333
                      j INT NOT NULL) ENGINE = $type ;
 
334
 
 
335
eval CREATE TABLE t5 (i INT NOT NULL,
 
336
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
 
337
                      j INT NOT NULL) ENGINE = $type ;
 
338
sync_slave_with_master;
 
339
ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;
 
340
 
 
341
connection master;
 
342
eval CREATE TABLE t6 (i INT NOT NULL,
 
343
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
 
344
                      j INT NOT NULL) ENGINE = $type ;
 
345
sync_slave_with_master;
 
346
ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;
 
347
 
 
348
connection master;
 
349
eval CREATE TABLE t7 (i INT NOT NULL,
 
350
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
 
351
                      j INT NOT NULL) ENGINE = $type ;
 
352
 
 
353
--echo [expecting slave to replicate correctly]
 
354
connection master;
 
355
INSERT INTO t1 VALUES (1, "", 1);
 
356
INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2);
 
357
sync_slave_with_master;
 
358
 
 
359
let $diff_table_1=master:test.t1;
 
360
let $diff_table_2=slave:test.t1;
 
361
source include/diff_tables.inc;
 
362
 
 
363
--echo [expecting slave to replicate correctly]
 
364
connection master;
 
365
INSERT INTO t2 VALUES (1, "", 1);
 
366
INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2);
 
367
sync_slave_with_master;
 
368
 
 
369
let $diff_table_1=master:test.t2;
 
370
let $diff_table_2=slave:test.t2;
 
371
source include/diff_tables.inc;
 
372
 
 
373
--echo [expecting slave to stop]
 
374
connection master;
 
375
INSERT INTO t3 VALUES (1, "", 1);
 
376
INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2);
 
377
 
 
378
connection slave;
 
379
source include/wait_for_slave_sql_to_stop.inc;
 
380
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
381
disable_query_log;
 
382
eval SELECT "$last_error" AS Last_SQL_Error;
 
383
enable_query_log;
 
384
connection master;
 
385
RESET MASTER;
 
386
connection slave;
 
387
STOP SLAVE;
 
388
RESET SLAVE;
 
389
START SLAVE;
 
390
source include/wait_for_slave_to_start.inc;
 
391
 
 
392
--echo [expecting slave to replicate correctly]
 
393
connection master;
 
394
INSERT INTO t4 VALUES (1, "", 1);
 
395
INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2);
 
396
sync_slave_with_master;
 
397
 
 
398
let $diff_table_1=master:test.t4;
 
399
let $diff_table_2=slave:test.t4;
 
400
source include/diff_tables.inc;
 
401
 
 
402
--echo [expecting slave to stop]
 
403
connection master;
 
404
INSERT INTO t5 VALUES (1, "", 1);
 
405
INSERT INTO t5 VALUES (2, repeat(_utf8'a', 255), 2);
 
406
 
 
407
connection slave;
 
408
source include/wait_for_slave_sql_to_stop.inc;
 
409
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
410
disable_query_log;
 
411
eval SELECT "$last_error" AS Last_SQL_Error;
 
412
enable_query_log;
 
413
connection master;
 
414
RESET MASTER;
 
415
connection slave;
 
416
STOP SLAVE;
 
417
RESET SLAVE;
 
418
START SLAVE;
 
419
source include/wait_for_slave_to_start.inc;
 
420
 
 
421
--echo [expecting slave to stop]
 
422
connection master;
 
423
INSERT INTO t6 VALUES (1, "", 1);
 
424
INSERT INTO t6 VALUES (2, repeat(_utf8'a', 255), 2);
 
425
 
 
426
connection slave;
 
427
source include/wait_for_slave_sql_to_stop.inc;
 
428
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
429
disable_query_log;
 
430
eval SELECT "$last_error" AS Last_SQL_Error;
 
431
enable_query_log;
 
432
connection master;
 
433
RESET MASTER;
 
434
connection slave;
 
435
STOP SLAVE;
 
436
RESET SLAVE;
 
437
START SLAVE;
 
438
source include/wait_for_slave_to_start.inc;
 
439
 
 
440
--echo [expecting slave to replicate correctly]
 
441
connection master;
 
442
INSERT INTO t7 VALUES (1, "", 1);
 
443
INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2);
 
444
sync_slave_with_master;
 
445
 
 
446
let $diff_table_1=master:test.t7;
 
447
let $diff_table_2=slave:test.t7;
 
448
source include/diff_tables.inc;
 
449
 
 
450
connection master;
 
451
drop table t1, t2, t3, t4, t5, t6, t7;
 
452
sync_slave_with_master;
 
453
 
 
454
#
 
455
# BUG#32709: Assertion failed: trx_data->empty(), file .\log.cc, line 1293
 
456
#
 
457
 
 
458
connection master;
 
459
eval CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=$type;
 
460
 
 
461
INSERT INTO t1 VALUES (1), (2), (3);
 
462
--error ER_DUP_ENTRY
 
463
UPDATE t1 SET a = 10;
 
464
INSERT INTO t1 VALUES (4);
 
465
sync_slave_with_master;
 
466
 
 
467
let $diff_table_1=master:test.t1;
 
468
let $diff_table_2=slave:test.t1;
 
469
source include/diff_tables.inc;
 
470
 
 
471
connection master;
 
472
drop table t1;
 
473
sync_slave_with_master;
 
474
 
 
475
#
 
476
# Bug #38230  Differences between master and slave after 
 
477
#             UPDATE or DELETE with LIMIT with pk
 
478
#
 
479
# the regression test verifies consistency via selecting
 
480
 
 
481
--disable_abort_on_error
 
482
 
 
483
--connection master
 
484
 
 
485
--disable_warnings
 
486
DROP TABLE IF EXISTS t1, t2;
 
487
--enable_warnings
 
488
 
 
489
eval CREATE TABLE t1 (
 
490
  `pk` int(11) NOT NULL AUTO_INCREMENT,
 
491
  `int_nokey` int(11) NOT NULL,
 
492
  `int_key` int(11) NOT NULL,
 
493
  `date_key` date NOT NULL,
 
494
  `date_nokey` date NOT NULL,
 
495
  `time_key` time NOT NULL,
 
496
  `time_nokey` time NOT NULL,
 
497
  `datetime_key` datetime NOT NULL,
 
498
  `datetime_nokey` datetime NOT NULL,
 
499
  `varchar_key` varchar(1) NOT NULL,
 
500
  `varchar_nokey` varchar(1) NOT NULL,
 
501
  PRIMARY KEY (`pk`),
 
502
  KEY `int_key` (`int_key`),
 
503
  KEY `date_key` (`date_key`),
 
504
  KEY `time_key` (`time_key`),
 
505
  KEY `datetime_key` (`datetime_key`),
 
506
  KEY `varchar_key` (`varchar_key`)
 
507
) ENGINE=$type;
 
508
 
 
509
INSERT INTO t1 VALUES (1,8,5,'0000-00-00','0000-00-00','10:37:38','10:37:38','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),(2,0,9,'0000-00-00','0000-00-00','00:00:00','00:00:00','2007-10-14 00:00:00','2007-10-14 00:00:00','d','d');
 
510
 
 
511
eval CREATE TABLE t2 (
 
512
  `pk` int(11) NOT NULL AUTO_INCREMENT,
 
513
  `int_nokey` int(11) NOT NULL,
 
514
  `int_key` int(11) NOT NULL,
 
515
  `date_key` date NOT NULL,
 
516
  `date_nokey` date NOT NULL,
 
517
  `time_key` time NOT NULL,
 
518
  `time_nokey` time NOT NULL,
 
519
  `datetime_key` datetime NOT NULL,
 
520
  `datetime_nokey` datetime NOT NULL,
 
521
  `varchar_key` varchar(1) NOT NULL,
 
522
  `varchar_nokey` varchar(1) NOT NULL,
 
523
  PRIMARY KEY (`pk`),
 
524
  KEY `int_key` (`int_key`),
 
525
  KEY `date_key` (`date_key`),
 
526
  KEY `time_key` (`time_key`),
 
527
  KEY `datetime_key` (`datetime_key`),
 
528
  KEY `varchar_key` (`varchar_key`)
 
529
) ENGINE=$type;
 
530
 
 
531
INSERT INTO t2 VALUES (1,1,6,'2005-12-23','2005-12-23','02:24:28','02:24:28','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),(2,0,3,'2009-09-14','2009-09-14','00:00:00','00:00:00','2000-01-30 16:39:40','2000-01-30 16:39:40','q','q'),(3,0,3,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','c','c'),(4,1,6,'2007-03-29','2007-03-29','15:49:00','15:49:00','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),(5,4,0,'2002-12-04','2002-12-04','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),(6,9,0,'2005-01-28','2005-01-28','00:00:00','00:00:00','2001-05-18 00:00:00','2001-05-18 00:00:00','w','w'),(7,6,0,'0000-00-00','0000-00-00','06:57:25','06:57:25','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),(8,0,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','z','z'),(9,4,6,'2006-08-15','2006-08-15','00:00:00','00:00:00','2002-04-12 14:44:25','2002-04-12 14:44:25','j','j'),(10,0,5,'2006-12-20','2006-12-20','10:13:53','10:13:53','2008-07-22 00:00:00','2008-07-22 00:00:00','y','y'),(11,9,7,'0000-00-00','0000-00-00','00:00:00','00:00:00','2004-07-05 00:00:00','2004-07-05 00:00:00','{','{'),(12,4,3,'2007-01-26','2007-01-26','23:00:51','23:00:51','2001-05-16 00:00:00','2001-05-16 00:00:00','f','f'),(13,7,0,'2004-03-27','2004-03-27','00:00:00','00:00:00','2005-01-24 03:30:37','2005-01-24 03:30:37','',''),(14,6,0,'2006-07-26','2006-07-26','18:43:57','18:43:57','0000-00-00 00:00:00','0000-00-00 00:00:00','{','{'),(15,0,6,'2000-01-14','2000-01-14','00:00:00','00:00:00','2000-09-21 00:00:00','2000-09-21 00:00:00','o','o'),(16,9,8,'0000-00-00','0000-00-00','21:15:08','21:15:08','0000-00-00 00:00:00','0000-00-00 00:00:00','a','a'),(17,2,0,'2004-10-27','2004-10-27','00:00:00','00:00:00','2004-03-24 22:13:43','2004-03-24 22:13:43','',''),(18,7,4,'0000-00-00','0000-00-00','08:38:27','08:38:27','2002-03-18 19:51:44','2002-03-18 19:51:44','t','t'),(19,5,3,'2008-03-07','2008-03-07','03:29:07','03:29:07','2007-12-01 18:44:44','2007-12-01 18:44:44','t','t'),(20,0,0,'2002-04-09','2002-04-09','16:06:03','16:06:03','2009-04-22 00:00:00','2009-04-22 00:00:00','n','n');
 
532
 
 
533
DELETE FROM t2 WHERE `int_key` < 3 LIMIT 1;
 
534
UPDATE t1 SET `int_key` = 3 ORDER BY `pk` LIMIT 4;
 
535
DELETE FROM t2 WHERE `int_key` < 3 LIMIT 1;
 
536
DELETE FROM t2 WHERE `pk` < 6 LIMIT 1;
 
537
UPDATE t1 SET `int_key` = 6 ORDER BY `pk` LIMIT 3;
 
538
DELETE FROM t2 WHERE `pk` < 6 LIMIT 1;
 
539
UPDATE t1 SET `pk` = 6 ORDER BY `int_key` LIMIT 6;
 
540
DELETE FROM t2 WHERE `pk` < 7 LIMIT 1;
 
541
UPDATE t1 SET `int_key` = 4 ORDER BY `pk` LIMIT 6;
 
542
 
 
543
--sync_slave_with_master
 
544
--echo *** results: t2 must be consistent ****
 
545
 
 
546
let $diff_table_1=master:test.t2;
 
547
let $diff_table_2=master:test.t2;
 
548
source include/diff_tables.inc;
 
549
 
 
550
--connection master
 
551
DROP TABLE t1, t2;
 
552
 
 
553
--enable_abort_on_error
 
554
 
 
555
--echo EOF OF TESTS
 
556
 
 
557
#
 
558
# BUG#40004: Replication failure with no PK + no indexes
 
559
#
 
560
 
 
561
# The test cases are taken from the bug report. It is difficult to
 
562
# produce a test case that generates a HA_ERR_RECORD_DELETED, so we go
 
563
# with the test cases we have.
 
564
 
 
565
connection master;
 
566
 
 
567
eval CREATE TABLE t1 (a int) ENGINE=$type;
 
568
 
 
569
INSERT IGNORE INTO t1 VALUES (NULL);
 
570
INSERT INTO t1 ( a ) VALUES ( 0 );
 
571
INSERT INTO t1 ( a ) VALUES ( 9 );
 
572
INSERT INTO t1 ( a ) VALUES ( 2 );
 
573
INSERT INTO t1 ( a ) VALUES ( 9 );
 
574
INSERT INTO t1 ( a ) VALUES ( 5 );
 
575
 
 
576
UPDATE t1 SET a = 5 WHERE a = 9;
 
577
DELETE FROM t1 WHERE a < 6;
 
578
UPDATE t1 SET a = 9 WHERE a < 3;
 
579
INSERT INTO t1 ( a ) VALUES ( 3 );
 
580
UPDATE t1 SET a = 0 WHERE a < 4;
 
581
UPDATE t1 SET a = 8 WHERE a < 5;
 
582
 
 
583
sync_slave_with_master;
 
584
 
 
585
let $diff_table_1=master:test.t1;
 
586
let $diff_table_2=slave:test.t1;
 
587
source include/diff_tables.inc;
 
588
 
 
589
connection master;
 
590
drop table t1;
 
591
sync_slave_with_master;
 
592
 
 
593
#
 
594
# Bug #39752: Replication failure on RBR + MyISAM + no PK
 
595
#
 
596
 
 
597
# The test cases are taken from the bug report. It is difficult to
 
598
# produce a test case that generates a HA_ERR_RECORD_DELETED, so we go
 
599
# with the test cases we have.
 
600
 
 
601
connection master;
 
602
 
 
603
--disable_warnings
 
604
eval CREATE TABLE t1 (a bit) ENGINE=$type;
 
605
INSERT IGNORE INTO t1 VALUES (NULL);
 
606
INSERT INTO t1 ( a ) VALUES ( 0 );
 
607
UPDATE t1 SET a = 0 WHERE a = 1 LIMIT 3;
 
608
INSERT INTO t1 ( a ) VALUES ( 5 );
 
609
DELETE FROM t1 WHERE a < 2 LIMIT 4;
 
610
DELETE FROM t1 WHERE a < 9 LIMIT 4;
 
611
INSERT INTO t1 ( a ) VALUES ( 9 );
 
612
UPDATE t1 SET a = 8 WHERE a = 0 LIMIT 6;
 
613
INSERT INTO t1 ( a ) VALUES ( 8 );
 
614
UPDATE t1 SET a = 0 WHERE a < 6 LIMIT 0;
 
615
INSERT INTO t1 ( a ) VALUES ( 4 );
 
616
INSERT INTO t1 ( a ) VALUES ( 3 );
 
617
UPDATE t1 SET a = 0 WHERE a = 7 LIMIT 6;
 
618
DELETE FROM t1 WHERE a = 4 LIMIT 7;
 
619
UPDATE t1 SET a = 9 WHERE a < 2 LIMIT 9;
 
620
UPDATE t1 SET a = 0 WHERE a < 9 LIMIT 2;
 
621
DELETE FROM t1 WHERE a < 0 LIMIT 5;
 
622
INSERT INTO t1 ( a ) VALUES ( 5 );
 
623
UPDATE t1 SET a = 4 WHERE a < 6 LIMIT 4;
 
624
INSERT INTO t1 ( a ) VALUES ( 5 );
 
625
UPDATE t1 SET a = 9 WHERE a < 5 LIMIT 8;
 
626
DELETE FROM t1 WHERE a < 8 LIMIT 8;
 
627
INSERT INTO t1 ( a ) VALUES ( 6 );
 
628
DELETE FROM t1 WHERE a < 6 LIMIT 7;
 
629
UPDATE t1 SET a = 7 WHERE a = 3 LIMIT 7;
 
630
UPDATE t1 SET a = 8 WHERE a = 0 LIMIT 6;
 
631
INSERT INTO t1 ( a ) VALUES ( 7 );
 
632
DELETE FROM t1 WHERE a < 9 LIMIT 4;
 
633
INSERT INTO t1 ( a ) VALUES ( 7 );
 
634
INSERT INTO t1 ( a ) VALUES ( 6 );
 
635
UPDATE t1 SET a = 8 WHERE a = 3 LIMIT 4;
 
636
DELETE FROM t1 WHERE a = 2 LIMIT 9;
 
637
DELETE FROM t1 WHERE a = 1 LIMIT 4;
 
638
UPDATE t1 SET a = 4 WHERE a = 2 LIMIT 7;
 
639
INSERT INTO t1 ( a ) VALUES ( 0 );
 
640
DELETE FROM t1 WHERE a < 3 LIMIT 0;
 
641
UPDATE t1 SET a = 8 WHERE a = 5 LIMIT 2;
 
642
INSERT INTO t1 ( a ) VALUES ( 1 );
 
643
UPDATE t1 SET a = 9 WHERE a < 5 LIMIT 3;
 
644
--enable_warnings
 
645
 
 
646
sync_slave_with_master;
 
647
 
 
648
let $diff_table_1=master:test.t1;
 
649
let $diff_table_2=slave:test.t1;
 
650
source include/diff_tables.inc;
 
651
 
 
652
connection master;
 
653
drop table t1;
 
654
sync_slave_with_master;