~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_row_img_sanity.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  Description
 
3
#  ===========
 
4
#
 
5
#  This test case checks whether binlog files contain Before and After
 
6
#  image values as expected. Configuration is done using the
 
7
#  --binlog-row-image variable.
 
8
#
 
9
#  How it works
 
10
#  ============
 
11
#
 
12
#  The test case is implemented such that master and slave basically
 
13
#  hold the same table but sometimes differ in indexes, number of
 
14
#  columns and data types constraints (autoinc or NOT NULL). Then some
 
15
#  statements are executed and the output of mysqlbinlog is parsed for
 
16
#  the given event to check if the columns in the before and after
 
17
#  image match expectations according to the binlog-row-image value on
 
18
#  master and on slave.
 
19
#
 
20
#  See also WL#5096.
 
21
#
 
22
-- source include/master-slave.inc
 
23
-- source include/have_binlog_format_row.inc
 
24
 
 
25
-- connection slave
 
26
call mtr.add_suppression("Slave: Can\'t find record in \'t\' Error_code: 1032");
 
27
call mtr.add_suppression("Slave SQL: .*Could not execute Update_rows event on table test.t; Can.t find record in .t.* Error_code: 1032");
 
28
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
 
29
 
 
30
-- connection master
 
31
 
 
32
## assertion: check that default value for binlog-row-image == 'FULL'
 
33
SHOW VARIABLES LIKE 'binlog_row_image';
 
34
 
 
35
## save original 
 
36
-- connection master
 
37
SET @old_binlog_row_image= @@binlog_row_image;
 
38
-- connection slave
 
39
SET @old_binlog_row_image= @@binlog_row_image;
 
40
-- connection master
 
41
 
 
42
-- echo #####################################################
 
43
-- echo # basic assertion that binlog_row_image='FULL' is the
 
44
-- echo # default 
 
45
-- echo #####################################################
 
46
 
 
47
-- connection master
 
48
-- let $row_img_set=master:FULL:N,slave:FULL:Y
 
49
-- source include/rpl_row_img_set.inc
 
50
 
 
51
CREATE TABLE t (c1 int, c2 int, c3 blob, primary key(c1));
 
52
 
 
53
-- let $row_img_query= INSERT INTO t(c1,c3) VALUES (1, 'a')
 
54
-- let $row_img_expected_master= | 1:1 2:NULL 3:'a'
 
55
-- let $row_img_expected_slave = | 1:1 2:NULL 3:'a'
 
56
-- source include/rpl_row_img_parts_master_slave.inc
 
57
 
 
58
-- let $row_img_query= UPDATE t SET c1=2 WHERE c1=1;
 
59
-- let $row_img_expected_master= 1:1 2:NULL 3:'a' | 1:2 2:NULL 3:'a'
 
60
-- let $row_img_expected_slave = 1:1 2:NULL 3:'a' | 1:2 2:NULL 3:'a'
 
61
-- source include/rpl_row_img_parts_master_slave.inc
 
62
 
 
63
-- let $row_img_query= DELETE FROM t;
 
64
-- let $row_img_expected_master= 1:2 2:NULL 3:'a' |
 
65
-- let $row_img_expected_slave = 1:2 2:NULL 3:'a' |
 
66
-- source include/rpl_row_img_parts_master_slave.inc
 
67
 
 
68
DROP TABLE t;
 
69
-- sync_slave_with_master
 
70
 
 
71
#
 
72
# Assertions: combines img_types with different index types. 
 
73
#             The checks that rows are logged with expected
 
74
#             image contents, depending on the img_type.
 
75
#
 
76
 
 
77
-- connection master
 
78
SET @img_types= 'MINIMAL NOBLOB FULL';
 
79
while (`SELECT HEX(@img_types) != HEX('')`)
 
80
{
 
81
  -- disable_query_log
 
82
  let $img_type= `SELECT SUBSTRING_INDEX(@img_types, ' ', 1)`;
 
83
  -- let $row_img_set=master:$img_type:N,slave:$img_type:Y
 
84
  -- source include/rpl_row_img_set.inc
 
85
 
 
86
  SET @index_types= 'UK-NOT-NULL PK UK K NONE';
 
87
  while (`SELECT HEX(@index_types) != HEX('')`)
 
88
  {
 
89
    -- disable_query_log
 
90
    let $index_type= `SELECT SUBSTRING_INDEX(@index_types, ' ', 1)`;
 
91
    -- enable_query_log
 
92
 
 
93
    -- echo ITERATIONS: row_img: $img_type, indexes: $index_type
 
94
 
 
95
    -- source include/rpl_reset.inc
 
96
    -- connection master
 
97
 
 
98
    # create the table
 
99
    -- echo CREATING TABLE IN $CURRENT_CONNECTION WITH INDEX '$index_type'
 
100
 
 
101
    if (`SELECT HEX('$index_type') = HEX('NONE')`)
 
102
    {
 
103
      CREATE TABLE t (c1 int, c2 int, c3 blob);
 
104
    }
 
105
 
 
106
    if (`SELECT HEX('$index_type') = HEX('K')`)
 
107
    {
 
108
      CREATE TABLE t (c1 int, c2 int, c3 blob, key(c1));
 
109
    }
 
110
 
 
111
    if (`SELECT HEX('$index_type') = HEX('UK')`)
 
112
    {
 
113
      CREATE TABLE t (c1 int, c2 int, c3 blob, unique key(c1));
 
114
    }
 
115
 
 
116
    if (`SELECT HEX('$index_type') = HEX('PK')`)
 
117
    {
 
118
      CREATE TABLE t (c1 int, c2 int, c3 blob, primary key(c1));
 
119
    }
 
120
 
 
121
    if (`SELECT HEX('$index_type') = HEX('UK-NOT-NULL')`)
 
122
    {
 
123
      CREATE TABLE t (c1 int NOT NULL, c2 int, c3 blob, unique key(c1));
 
124
    }
 
125
 
 
126
    -- sync_slave_with_master
 
127
    -- connection master
 
128
 
 
129
    # Issue some statements
 
130
 
 
131
    -- let $row_img_query= INSERT INTO t VALUES (1,2,"a")
 
132
    -- let $row_img_expected_master= | 1:1 2:2 3:'a'
 
133
    -- let $row_img_expected_slave = | 1:1 2:2 3:'a'
 
134
    -- source include/rpl_row_img_parts_master_slave.inc
 
135
 
 
136
    -- let $row_img_query= INSERT INTO t(c1,c3) VALUES (10,"a")
 
137
    if (`SELECT @@binlog_row_image = "FULL" or @@binlog_row_image = "NOBLOB"`)
 
138
    {
 
139
      -- let $row_img_expected_master= | 1:10 2:NULL 3:'a'
 
140
    }
 
141
    if  (`SELECT @@binlog_row_image = "MINIMAL"`)
 
142
    {
 
143
      -- let $row_img_expected_master= | 1:10 3:'a'
 
144
    }
 
145
    -- let $row_img_expected_slave= $row_img_expected_master
 
146
    -- source include/rpl_row_img_parts_master_slave.inc
 
147
 
 
148
    # we need to test insert delayed to check if the thread handling
 
149
    # the delayed inserts also marks the correct write set (it has its
 
150
    # own sort of table object).
 
151
    -- let $row_img_query= INSERT DELAYED INTO t(c1,c3) VALUES (100,"a")
 
152
    if (`SELECT @@binlog_row_image = "FULL" or @@binlog_row_image = "NOBLOB"`)
 
153
    {
 
154
      -- let $row_img_expected_master= | 1:100 2:NULL 3:'a'
 
155
    }
 
156
    if  (`SELECT @@binlog_row_image = "MINIMAL"`)
 
157
    { 
 
158
      -- let $row_img_expected_master= | 1:100 3:'a'
 
159
    }
 
160
    -- let $row_img_expected_slave= $row_img_expected_master
 
161
    -- source include/rpl_row_img_parts_master_slave.inc
 
162
 
 
163
    -- let $row_img_query= INSERT INTO t(c1) VALUES (1000)
 
164
    if (`SELECT @@binlog_row_image = "FULL"`)
 
165
    {
 
166
      -- let $row_img_expected_master= | 1:1000 2:NULL 3:NULL
 
167
    } 
 
168
    if  (`SELECT @@binlog_row_image = "NOBLOB"`)
 
169
    { 
 
170
      -- let $row_img_expected_master= | 1:1000 2:NULL
 
171
    }
 
172
    if  (`SELECT @@binlog_row_image = "MINIMAL"`)
 
173
    { 
 
174
      -- let $row_img_expected_master= | 1:1000
 
175
    }
 
176
    -- let $row_img_expected_slave= $row_img_expected_master
 
177
    -- source include/rpl_row_img_parts_master_slave.inc
 
178
 
 
179
    -- let $row_img_query= INSERT DELAYED INTO t(c1) VALUES (10000)
 
180
    if (`SELECT @@binlog_row_image = "FULL"`)
 
181
    {
 
182
      -- let $row_img_expected_master= | 1:10000 2:NULL 3:NULL
 
183
    } 
 
184
    if  (`SELECT @@binlog_row_image = "NOBLOB"`)
 
185
    { 
 
186
      -- let $row_img_expected_master= | 1:10000 2:NULL
 
187
    }
 
188
    if  (`SELECT @@binlog_row_image = "MINIMAL"`)
 
189
    { 
 
190
      -- let $row_img_expected_master= | 1:10000
 
191
    }
 
192
    -- let $row_img_expected_slave= $row_img_expected_master
 
193
    -- source include/rpl_row_img_parts_master_slave.inc
 
194
 
 
195
    -- let $row_img_query= UPDATE t SET c1=2 WHERE c1=1
 
196
    if (`SELECT @@binlog_row_image = "FULL" OR (SELECT '$index_type' IN ('NONE', 'K', 'UK'))`)
 
197
    {
 
198
      -- let $bi= 1:1 2:2 3:'a'
 
199
    }
 
200
 
 
201
    # noblob with pk + uk not nullable
 
202
    if (`SELECT @@binlog_row_image = "NOBLOB" AND (SELECT '$index_type' IN ('PK', 'UK-NOT-NULL'))`)
 
203
    {
 
204
      -- let $bi= 1:1 2:2
 
205
    }
 
206
 
 
207
    if (`SELECT @@binlog_row_image = "MINIMAL" AND (SELECT '$index_type' IN ('PK', 'UK-NOT-NULL'))`)
 
208
    {
 
209
      -- let $bi= 1:1
 
210
    }
 
211
 
 
212
    if (`SELECT @@binlog_row_image = "FULL"`)
 
213
    {
 
214
      -- let $ai= 1:2 2:2 3:'a'
 
215
    }
 
216
 
 
217
    if (`SELECT @@binlog_row_image = "NOBLOB"`)
 
218
    {
 
219
      -- let $ai= 1:2 2:2
 
220
    }
 
221
 
 
222
    if (`SELECT @@binlog_row_image = "MINIMAL"`)
 
223
    {
 
224
      -- let $ai= 1:2
 
225
    }
 
226
    -- let $row_img_expected_master= $bi | $ai
 
227
    -- let $row_img_expected_slave = $bi | $ai
 
228
    -- let $ai=
 
229
    -- let $bi=
 
230
    -- source include/rpl_row_img_parts_master_slave.inc
 
231
 
 
232
    -- let $row_img_query= DELETE FROM t WHERE c2=2
 
233
    # no key, simple key or unique key nullable
 
234
    if (`SELECT @@binlog_row_image = "FULL" OR (SELECT '$index_type' IN ('NONE', 'K', 'UK'))`)
 
235
    {
 
236
      -- let $row_img_expected_master= 1:2 2:2 3:'a' |
 
237
    }
 
238
 
 
239
    # noblob with pk + uk not nullable
 
240
    if (`SELECT @@binlog_row_image = "NOBLOB" AND (SELECT '$index_type' IN ('PK', 'UK-NOT-NULL'))`)
 
241
    {
 
242
      -- let $row_img_expected_master= 1:2 2:2 |
 
243
    }
 
244
 
 
245
    if (`SELECT @@binlog_row_image = "MINIMAL" AND (SELECT '$index_type' IN ('PK', 'UK-NOT-NULL'))`)
 
246
    {
 
247
      -- let $row_img_expected_master= 1:2 |
 
248
    }
 
249
    -- let $row_img_expected_slave= $row_img_expected_master
 
250
    -- source include/rpl_row_img_parts_master_slave.inc
 
251
 
 
252
    DROP TABLE t;
 
253
 
 
254
    -- sync_slave_with_master
 
255
 
 
256
    -- disable_query_log
 
257
    -- connection master
 
258
    -- eval SET @index_types= LTRIM(SUBSTRING(@index_types, LENGTH('$index_type') + 1))
 
259
    -- enable_query_log
 
260
 
 
261
  }
 
262
 
 
263
  -- disable_query_log
 
264
  -- connection master
 
265
  -- eval SET @img_types= LTRIM(SUBSTRING(@img_types, LENGTH('$img_type') + 1))
 
266
  -- enable_query_log
 
267
}
 
268
 
 
269
### Some more scenarios
 
270
###  These relate to different constraints on PKE and its impact 
 
271
###  on logged images. Further description is inline.
 
272
 
 
273
-- connection master
 
274
SET @img_types= 'MINIMAL NOBLOB FULL';
 
275
while (`SELECT HEX(@img_types) != HEX('')`)
 
276
{
 
277
  -- disable_query_log
 
278
  let $img_type= `SELECT SUBSTRING_INDEX(@img_types, ' ', 1)`;
 
279
  -- let $row_img_set=master:$img_type:N,slave:$img_type:Y
 
280
  -- source include/rpl_row_img_set.inc
 
281
 
 
282
  -- echo ITERATIONS: row_img: $img_type
 
283
 
 
284
  -- source include/rpl_reset.inc
 
285
  -- connection master
 
286
 
 
287
  # ASSERTIONS:
 
288
  # UPDATE (MINIMAL,NOBLOB,FULL)
 
289
  #  - on slave, columns that are not in master's BI but are in slave's
 
290
  #    PKE are in slave's BI
 
291
 
 
292
  -- connection master
 
293
  SET SQL_LOG_BIN=0;
 
294
  CREATE TABLE t (a INT);
 
295
  SET SQL_LOG_BIN=1;
 
296
 
 
297
  -- connection slave
 
298
  SET SQL_LOG_BIN=0;
 
299
  CREATE TABLE t (a INT, b INT DEFAULT 1000);
 
300
  SET SQL_LOG_BIN=1;
 
301
 
 
302
  -- connection master
 
303
  INSERT INTO t VALUES (1);
 
304
  -- sync_slave_with_master
 
305
  -- connection master
 
306
 
 
307
  -- let $row_img_query= UPDATE t SET a=2 WHERE a=1;
 
308
  #   1. columns that are set to default value are in AI
 
309
  -- let $row_img_expected_master= 1:1 | 1:2
 
310
  if (`SELECT @@binlog_row_image = "NOBLOB" OR (SELECT @@binlog_row_image = "FULL")`)
 
311
  {
 
312
    -- let $row_img_expected_slave = 1:1 2:1000 | 1:2 2:1000
 
313
  }
 
314
  if (`SELECT @@binlog_row_image = "MINIMAL"`)
 
315
  {
 
316
    -- let $row_img_expected_slave = 1:1 2:1000 | 1:2
 
317
  }
 
318
  -- source include/rpl_row_img_parts_master_slave.inc
 
319
 
 
320
  -- connection master
 
321
  DROP TABLE IF EXISTS t;
 
322
  -- sync_slave_with_master
 
323
 
 
324
  -- source include/rpl_reset.inc
 
325
 
 
326
  -- connection master
 
327
  if (`SELECT @@binlog_row_image = "MINIMAL"`)
 
328
  {
 
329
    -- echo ####### MINIMAL PARTICULAR SCENARIO ######
 
330
  
 
331
    # ASSERTIONS: 
 
332
    #   INSERT/MINIMAL
 
333
    #      1. columns that are set to default value are in AI
 
334
    #
 
335
    #    UPDATE/MINIMAL:
 
336
    #      2. columns that are set to the same value are in AI
 
337
    #      3. columns that are not in WHERE clause but in PKE are in BI
 
338
    #      4. on slave, columns that are not in master's BI but are in slave's
 
339
    #         PKE are in slave's BI
 
340
    #    
 
341
    #    DELETE/MINIMAL:
 
342
    #      5. on slave, columns that are in master's BI but not in slave's PKE are
 
343
    #         not in slave's BI
 
344
    #      6. columns that are NOT NULL UK but not in PK are not in BI
 
345
    #
 
346
    -- connection master
 
347
    SET SQL_LOG_BIN=0;
 
348
    CREATE TABLE t (c1 INT PRIMARY KEY, c2 INT DEFAULT 100, c3 INT);
 
349
    SET SQL_LOG_BIN=1;
 
350
 
 
351
    -- connection slave
 
352
    SET SQL_LOG_BIN=0;
 
353
    CREATE TABLE t (c1 INT NOT NULL UNIQUE KEY, c2 INT DEFAULT 100, c3 INT, c4 INT, PRIMARY KEY(c2,c3));
 
354
 
 
355
    -- let $row_img_query= INSERT INTO t VALUES (1, 100, 1);
 
356
    #   1. columns that are set to default value are in AI
 
357
    -- let $row_img_expected_master= | 1:1 2:100 3:1
 
358
    -- let $row_img_expected_slave = | 1:1 2:100 3:1
 
359
    -- source include/rpl_row_img_parts_master_slave.inc
 
360
 
 
361
    -- let $row_img_query= UPDATE t SET c2=100, c3=1000 WHERE c2=100;
 
362
    #   2. columns that are set to the same value are in AI
 
363
    #   3. columns that are not in WHERE clause but in PKE are in BI
 
364
    #   4. on slave, columns that are not in master's BI but are in slave's PKE are in slave's BI
 
365
    -- let $row_img_expected_master= 1:1 | 2:100 3:1000
 
366
    -- let $row_img_expected_slave = 2:100 3:1 | 2:100 3:1000
 
367
    -- source include/rpl_row_img_parts_master_slave.inc
 
368
 
 
369
    -- let $row_img_query= DELETE FROM t WHERE c1=1
 
370
    # asserts:
 
371
    #   5. on slave, columns that are not in master's BI but are in slave's PKE are in slave's BI
 
372
    #   6. columns that are NOT NULL UK but not in PK are not in BI
 
373
    -- let $row_img_expected_master= 1:1 |
 
374
    -- let $row_img_expected_slave= 2:100 3:1000 | 
 
375
    -- source include/rpl_row_img_parts_master_slave.inc
 
376
 
 
377
    -- connection master
 
378
    DROP TABLE t;
 
379
    -- sync_slave_with_master
 
380
 
 
381
    -- echo ####### MINIMAL OTHER PARTICULAR SCENARIO ######
 
382
  
 
383
    # ASSERTIONS: 
 
384
    #    UPDATE/MINIMAL:
 
385
    #      1. all columns needed to identify a row are in BI; as the
 
386
    #      index is not unique, this means all columns of the table
 
387
    #      2. columns that are in SET changed are in AI
 
388
    #      3. columns that are not in SET are not in AI
 
389
    #      4. table on slave has the same definition as table on
 
390
    #      master, so points 1-2-3 apply to images in the slave's
 
391
    #      binlog too.
 
392
    #
 
393
    -- connection master
 
394
    CREATE TABLE t (c1 INT NOT NULL, c2 INT NOT NULL, KEY (c1));
 
395
    INSERT INTO t VALUES (30,40);
 
396
 
 
397
    -- connection slave
 
398
 
 
399
    -- let $row_img_query= UPDATE t SET c2=100 ORDER BY c1;
 
400
    #   1. all columns needed to identify a row are in BI
 
401
    #   2. columns that are in SET changed are in AI
 
402
    #   3. columns that are not in SET are not in AI
 
403
    #   4. slave is as master as tables' definitions are identical
 
404
    -- let $row_img_expected_master= 1:30 2:40 | 2:100
 
405
    -- let $row_img_expected_slave = 1:30 2:40 | 2:100
 
406
    -- source include/rpl_row_img_parts_master_slave.inc
 
407
 
 
408
    -- connection master
 
409
    DROP TABLE t;
 
410
    -- sync_slave_with_master
 
411
  }
 
412
 
 
413
  if (`SELECT @@binlog_row_image = "NOBLOB"`)
 
414
  {
 
415
    -- echo ####### NOBLOB PARTICULAR SCENARIO ######
 
416
 
 
417
    #    ASSERTIONS: 
 
418
    #    INSERT/NOBLOB:
 
419
    #      1 non-blob columns that are set to default value are in AI
 
420
    #    
 
421
    #    UPDATE/NOBLOB:
 
422
    #      2 non-blob columns that are set to default value are in AI
 
423
    #      3 blob columns that are set to default value are in AI
 
424
    #      4 blob columns that are in WHERE clause but not in PKE are not in BI
 
425
    #      5 blob columns that are in NON-NULL UK but not in PK are not in BI
 
426
    #      6 on slave, blob columns that are in master's BI clause but not in
 
427
    #        slave's PKE are not in BI
 
428
    #
 
429
    #    DELETE
 
430
    #      7 non-blob columns that are not in WHERE clause but in PKE are in BI
 
431
    #      8 blob columns that are used in WHERE clause but not in PKE are not
 
432
    #        in BI
 
433
    #      9 blob columns that are NOT NULL UK but not in PK are not in BI
 
434
    #     10 on slave, blob columns that are in master's BI but not in slave's PKE
 
435
    #        are not in slave's BI
 
436
 
 
437
    -- connection master
 
438
    SET SQL_LOG_BIN=0;
 
439
    CREATE TABLE t (c1 INT, c2 BLOB, c3 INT DEFAULT 1000, c4 BLOB NOT NULL, c5 INT, UNIQUE KEY(c4(512)), PRIMARY KEy(c1, c2(512)));
 
440
    SET SQL_LOG_BIN=1;
 
441
 
 
442
    -- connection slave
 
443
    SET SQL_LOG_BIN=0;
 
444
    CREATE TABLE t (c1 INT PRIMARY KEY, c2 BLOB, c3 INT DEFAULT 1000, c4 BLOB, c5 INT);
 
445
    SET SQL_LOG_BIN=1;
 
446
 
 
447
    -- connection master
 
448
    -- let $row_img_query= INSERT INTO t VALUES (1,'aaa', 1000, 'bbb', 1)
 
449
    #   1. non-blob columns that are set to default value are in AI
 
450
    -- let $row_img_expected_master= | 1:1 2:'aaa' 3:1000 4:'bbb' 5:1
 
451
    -- let $row_img_expected_slave = | 1:1 2:'aaa' 3:1000 4:'bbb' 5:1
 
452
    -- source include/rpl_row_img_parts_master_slave.inc
 
453
 
 
454
    -- connection master
 
455
    -- let $row_img_query= UPDATE t SET c2='aaa', c3=1000, c5=10000 WHERE c1=1 AND c4='bbb'
 
456
    # asserts that:
 
457
    #  2. non-blob columns that are set to default value are in AI
 
458
    #  3. blob columns that are set to default value are in AI
 
459
    #  4. blob columns that are in WHERE clause but not in PKE are not in BI
 
460
    #  5. blob columns that are in NON-NULL UK but not in PK are not in BI
 
461
    #  6. on slave, blob columns that are in master's BI clause but not in
 
462
    #     slave's PKE are not in BI
 
463
    -- let $row_img_expected_master= 1:1 2:'aaa' 3:1000 5:1 | 1:1 2:'aaa' 3:1000 5:10000
 
464
    -- let $row_img_expected_slave = 1:1 3:1000 5:1 | 1:1 2:'aaa' 3:1000 5:10000
 
465
    -- source include/rpl_row_img_parts_master_slave.inc
 
466
 
 
467
    -- connection master
 
468
    -- let $row_img_query= DELETE FROM t WHERE c1=1 AND c4='bbb'
 
469
    # asserts that:
 
470
    #   7. non-blob columns that are not in WHERE clause but in PKE are in BI
 
471
    #   8. blob columns that are used in WHERE clause but not in PKE are not n BI
 
472
    #   9. blob columns that are NOT NULL UK but not in PK are not in BI
 
473
    #  10. on slave, blob columns that are in master's BI but not in slave's PKE are not in slave's BI
 
474
    -- let $row_img_expected_master= 1:1 2:'aaa' 3:1000 5:10000 | 
 
475
    -- let $row_img_expected_slave = 1:1 3:1000 5:10000 | 
 
476
    -- source include/rpl_row_img_parts_master_slave.inc
 
477
 
 
478
    -- connection master
 
479
    DROP TABLE t;
 
480
    -- sync_slave_with_master
 
481
 
 
482
  }
 
483
 
 
484
  -- disable_query_log
 
485
  -- connection master
 
486
  -- eval SET @img_types= LTRIM(SUBSTRING(@img_types, LENGTH('$img_type') + 1))
 
487
  -- enable_query_log
 
488
}
 
489
 
 
490
-- echo ################## SPECIAL CASES #########################
 
491
 
 
492
-- source include/rpl_reset.inc
 
493
-- connection master
 
494
-- let $row_img_set=master:NOBLOB:N,slave:NOBLOB:Y
 
495
-- source include/rpl_row_img_set.inc
 
496
 
 
497
-- echo ###################################
 
498
-- echo # PK (contains blob)
 
499
-- echo ###################################
 
500
 
 
501
-- connection master
 
502
 
 
503
CREATE TABLE t (c1 int, c2 int, c3 blob, primary key(c1,c3(512)));
 
504
 
 
505
-- let $row_img_query= INSERT INTO t VALUES (1,2,"a")
 
506
-- let $row_img_expected_master= | 1:1 2:2 3:'a'
 
507
-- let $row_img_expected_slave = | 1:1 2:2 3:'a'
 
508
-- source include/rpl_row_img_parts_master_slave.inc
 
509
 
 
510
-- let $row_img_query= INSERT INTO t(c1,c3) VALUES (10,"a")
 
511
-- let $row_img_expected_master= | 1:10 2:NULL 3:'a'
 
512
-- let $row_img_expected_slave = | 1:10 2:NULL 3:'a'
 
513
-- source include/rpl_row_img_parts_master_slave.inc
 
514
 
 
515
-- let $row_img_query= INSERT DELAYED INTO t(c1,c3) VALUES (100,"a")
 
516
-- let $row_img_expected_master= | 1:100 2:NULL 3:'a'
 
517
-- let $row_img_expected_slave = | 1:100 2:NULL 3:'a'
 
518
-- source include/rpl_row_img_parts_master_slave.inc
 
519
 
 
520
-- let $row_img_query= INSERT INTO t(c1) VALUES (1000)
 
521
-- let $row_img_expected_master= | 1:1000 2:NULL
 
522
-- let $row_img_expected_slave = | 1:1000 2:NULL
 
523
-- source include/rpl_row_img_parts_master_slave.inc
 
524
 
 
525
-- let $row_img_query= INSERT DELAYED INTO t(c1) VALUES (10000)
 
526
-- let $row_img_expected_master= | 1:10000 2:NULL
 
527
-- let $row_img_expected_slave = | 1:10000 2:NULL
 
528
-- source include/rpl_row_img_parts_master_slave.inc
 
529
 
 
530
-- let $row_img_query= UPDATE t SET c1=2 WHERE c1=1
 
531
-- let $row_img_expected_master= 1:1 2:2 3:'a' | 1:2 2:2
 
532
-- let $row_img_expected_slave = 1:1 2:2 3:'a' | 1:2 2:2
 
533
-- source include/rpl_row_img_parts_master_slave.inc
 
534
 
 
535
-- let $row_img_query= DELETE FROM t WHERE c2=2
 
536
-- let $row_img_expected_master= 1:2 2:2 3:'a' | 
 
537
-- let $row_img_expected_slave = 1:2 2:2 3:'a' | 
 
538
-- source include/rpl_row_img_parts_master_slave.inc
 
539
 
 
540
DROP TABLE t;
 
541
 
 
542
-- sync_slave_with_master
 
543
 
 
544
-- echo ###################################
 
545
-- echo # PK (does not contain blob, but blob is updated)
 
546
-- echo ###################################
 
547
 
 
548
-- source include/rpl_reset.inc
 
549
-- connection master
 
550
 
 
551
CREATE TABLE t (c1 int, c2 int, c3 blob, primary key(c1,c2));
 
552
 
 
553
-- let $row_img_query= INSERT INTO t VALUES (1,2,"a")
 
554
-- let $row_img_expected_master= | 1:1 2:2 3:'a'
 
555
-- let $row_img_expected_slave = | 1:1 2:2 3:'a'
 
556
-- source include/rpl_row_img_parts_master_slave.inc
 
557
 
 
558
-- let $row_img_query= INSERT INTO t(c1,c3) VALUES (10,"a")
 
559
-- let $row_img_expected_master= | 1:10 2:0 3:'a'
 
560
-- let $row_img_expected_slave = | 1:10 2:0 3:'a'
 
561
-- source include/rpl_row_img_parts_master_slave.inc
 
562
 
 
563
-- let $row_img_query= INSERT DELAYED INTO t(c1,c3) VALUES (100,"a")
 
564
-- let $row_img_expected_master= | 1:100 2:0 3:'a'
 
565
-- let $row_img_expected_slave = | 1:100 2:0 3:'a'
 
566
-- source include/rpl_row_img_parts_master_slave.inc
 
567
 
 
568
-- let $row_img_query= INSERT INTO t(c1) VALUES (1000)
 
569
-- let $row_img_expected_master= | 1:1000 2:0
 
570
-- let $row_img_expected_slave = | 1:1000 2:0
 
571
-- source include/rpl_row_img_parts_master_slave.inc
 
572
 
 
573
-- let $row_img_query= INSERT DELAYED INTO t(c1) VALUES (10000)
 
574
-- let $row_img_expected_master= | 1:10000 2:0
 
575
-- let $row_img_expected_slave = | 1:10000 2:0
 
576
-- source include/rpl_row_img_parts_master_slave.inc
 
577
 
 
578
-- let $row_img_query= UPDATE t SET c3='b' WHERE c1=1
 
579
-- let $row_img_expected_master= 1:1 2:2 | 1:1 2:2 3:'b'
 
580
-- let $row_img_expected_slave = 1:1 2:2 | 1:1 2:2 3:'b'
 
581
-- source include/rpl_row_img_parts_master_slave.inc
 
582
 
 
583
-- let $row_img_query= DELETE FROM t WHERE c2=2
 
584
-- let $row_img_expected_master= 1:1 2:2 | 
 
585
-- let $row_img_expected_slave = 1:1 2:2 | 
 
586
-- source include/rpl_row_img_parts_master_slave.inc
 
587
 
 
588
DROP TABLE t;
 
589
-- sync_slave_with_master
 
590
 
 
591
-- echo ###################################
 
592
-- echo # AUTOINC columns
 
593
-- echo ###################################
 
594
 
 
595
-- source include/rpl_reset.inc
 
596
-- connection master
 
597
-- let $row_img_set=master:MINIMAL:N,slave:MINIMAL:Y
 
598
-- source include/rpl_row_img_set.inc
 
599
 
 
600
CREATE TABLE t (c1 int NOT NULL AUTO_INCREMENT, c2 int, c3 blob, primary key(c1,c2));
 
601
 
 
602
-- let $row_img_query= INSERT INTO t(c2) VALUES (2)
 
603
-- let $row_img_expected_master= | 1:1 2:2
 
604
-- let $row_img_expected_slave = | 1:1 2:2
 
605
-- source include/rpl_row_img_parts_master_slave.inc
 
606
 
 
607
DROP TABLE t;
 
608
-- sync_slave_with_master
 
609
 
 
610
-- echo ##################################################################
 
611
-- echo # Test that slave does not write more columns than the ones it has 
 
612
-- echo ##################################################################
 
613
 
 
614
-- source include/rpl_reset.inc
 
615
-- connection master
 
616
-- let $row_img_set=master:MINIMAL:N,slave:MINIMAL:Y
 
617
-- source include/rpl_row_img_set.inc
 
618
 
 
619
SET SQL_LOG_BIN=0;
 
620
CREATE TABLE t (c1 int NOT NULL AUTO_INCREMENT, c2 int, c3 blob, primary key(c1,c2));
 
621
SET SQL_LOG_BIN=1;
 
622
 
 
623
-- connection slave
 
624
CREATE TABLE t (c1 int, c2 int, primary key(c1));
 
625
 
 
626
-- connection master
 
627
 
 
628
-- let $row_img_query= INSERT INTO t(c2,c3) VALUES (2,'aaaaa')
 
629
-- let $row_img_expected_master= | 1:1 2:2 3:'aaaaa'
 
630
-- let $row_img_expected_slave = | 1:1 2:2
 
631
-- source include/rpl_row_img_parts_master_slave.inc
 
632
 
 
633
-- let $row_img_query= UPDATE t SET c2=3, c3='bbbbb' WHERE c2=2
 
634
-- let $row_img_expected_master= 1:1 2:2 | 2:3 3:'bbbbb'
 
635
-- let $row_img_expected_slave = 1:1 | 2:3
 
636
-- source include/rpl_row_img_parts_master_slave.inc
 
637
 
 
638
DROP TABLE t;
 
639
-- sync_slave_with_master
 
640
 
 
641
-- echo ##################################################################
 
642
-- echo # Test that slave fills default columns in its own columns
 
643
-- echo ##################################################################
 
644
 
 
645
-- source include/rpl_reset.inc
 
646
-- connection master
 
647
-- let $row_img_set=master:FULL:N,slave:FULL:Y
 
648
-- source include/rpl_row_img_set.inc
 
649
 
 
650
SET SQL_LOG_BIN=0;
 
651
CREATE TABLE t (c1 int, c2 int);
 
652
SET SQL_LOG_BIN=1;
 
653
 
 
654
-- connection slave
 
655
CREATE TABLE t (c1 int, c2 int, c3 int DEFAULT 2005);
 
656
 
 
657
-- connection master
 
658
 
 
659
-- let $row_img_query= INSERT INTO t(c1) VALUES (1)
 
660
-- let $row_img_expected_master= | 1:1 2:NULL
 
661
-- let $row_img_expected_slave = | 1:1 2:NULL 3:2005
 
662
-- source include/rpl_row_img_parts_master_slave.inc
 
663
 
 
664
-- let $row_img_query= INSERT INTO t(c1) VALUES (2)
 
665
-- let $row_img_expected_master= | 1:2 2:NULL
 
666
-- let $row_img_expected_slave = | 1:2 2:NULL 3:2005
 
667
-- source include/rpl_row_img_parts_master_slave.inc
 
668
 
 
669
-- connection slave
 
670
SELECT * FROM t;
 
671
-- connection master
 
672
SELECT * FROM t;
 
673
 
 
674
DROP TABLE t;
 
675
-- sync_slave_with_master
 
676
 
 
677
-- echo ##################################################################
 
678
-- echo # Test that slave uses partial BI when master contains more columns
 
679
-- echo ##################################################################
 
680
 
 
681
-- source include/rpl_reset.inc
 
682
-- connection master
 
683
-- let $row_img_set=master:MINIMAL:N,slave:MINIMAL:Y
 
684
-- source include/rpl_row_img_set.inc
 
685
 
 
686
 
 
687
SET SQL_LOG_BIN=0;
 
688
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, primary key(c1, c3), unique key(c1));
 
689
SET SQL_LOG_BIN=1;
 
690
 
 
691
-- connection slave
 
692
CREATE TABLE t (c1 int NOT NULL, c2 int, unique key(c1));
 
693
 
 
694
-- connection master
 
695
 
 
696
-- let $row_img_query= INSERT INTO t VALUES (1, 2, 3)
 
697
-- let $row_img_expected_master= | 1:1 2:2 3:3
 
698
-- let $row_img_expected_slave = | 1:1 2:2
 
699
-- source include/rpl_row_img_parts_master_slave.inc
 
700
 
 
701
-- let $row_img_query= UPDATE t SET c2= 4 WHERE c1=1
 
702
-- let $row_img_expected_master= 1:1 3:3 | 2:4
 
703
-- let $row_img_expected_slave = 1:1 | 2:4
 
704
-- source include/rpl_row_img_parts_master_slave.inc
 
705
 
 
706
-- connection slave
 
707
SELECT * FROM t;
 
708
-- connection master
 
709
SELECT * FROM t;
 
710
 
 
711
DROP TABLE t;
 
712
-- sync_slave_with_master
 
713
 
 
714
-- echo ##################################################################
 
715
-- echo # Test that if master has binlog_row_image=MINIMAL and slave has 
 
716
-- echo # NOBLOB or FULL, it will log the expected columns
 
717
-- echo ##################################################################
 
718
 
 
719
-- source include/rpl_reset.inc
 
720
-- connection master
 
721
-- let $row_img_set=master:MINIMAL:N,slave:FULL:Y
 
722
-- source include/rpl_row_img_set.inc
 
723
 
 
724
SET SQL_LOG_BIN=0;
 
725
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, primary key(c1));
 
726
SET SQL_LOG_BIN=1;
 
727
 
 
728
-- connection slave
 
729
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, c4 blob, unique key(c1));
 
730
 
 
731
-- connection master
 
732
-- let $row_img_query= INSERT INTO t VALUES (1, 2, 3)
 
733
-- let $row_img_expected_master= | 1:1 2:2 3:3
 
734
-- let $row_img_expected_slave = | 1:1 2:2 3:3 4:NULL
 
735
-- source include/rpl_row_img_parts_master_slave.inc
 
736
 
 
737
-- let $row_img_query= UPDATE t SET c2= 4 WHERE c1=1
 
738
-- let $row_img_expected_master=  1:1 | 2:4
 
739
-- let $row_img_expected_slave = 1:1 2:2 3:3 4:NULL | 1:1 2:4 3:3 4:NULL
 
740
-- source include/rpl_row_img_parts_master_slave.inc
 
741
 
 
742
-- let $row_img_query= DELETE FROM t WHERE c2=4
 
743
-- let $row_img_expected_master= 1:1 |
 
744
-- let $row_img_expected_slave = 1:1 2:4 3:3 4:NULL | 
 
745
-- source include/rpl_row_img_parts_master_slave.inc
 
746
 
 
747
DROP TABLE t;
 
748
-- sync_slave_with_master
 
749
 
 
750
-- source include/rpl_reset.inc
 
751
-- connection master
 
752
-- let $row_img_set=master:MINIMAL:N,slave:NOBLOB:Y
 
753
-- source include/rpl_row_img_set.inc
 
754
 
 
755
SET SQL_LOG_BIN=0;
 
756
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, primary key(c1));
 
757
SET SQL_LOG_BIN=1;
 
758
 
 
759
-- connection slave
 
760
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, c4 blob, unique key(c1));
 
761
 
 
762
-- connection master
 
763
-- let $row_img_query= INSERT INTO t VALUES (1, 2, 3)
 
764
-- let $row_img_expected_master= | 1:1 2:2 3:3
 
765
-- let $row_img_expected_slave = | 1:1 2:2 3:3
 
766
-- source include/rpl_row_img_parts_master_slave.inc
 
767
 
 
768
-- let $row_img_query= UPDATE t SET c2= 4 WHERE c1=1
 
769
-- let $row_img_expected_master= 1:1 | 2:4
 
770
-- let $row_img_expected_slave = 1:1 2:2 3:3 | 1:1 2:4 3:3
 
771
-- source include/rpl_row_img_parts_master_slave.inc
 
772
 
 
773
-- let $row_img_query= DELETE FROM t WHERE c2=4
 
774
-- let $row_img_expected_master= 1:1 |
 
775
-- let $row_img_expected_slave = 1:1 2:4 3:3 | 
 
776
-- source include/rpl_row_img_parts_master_slave.inc
 
777
 
 
778
DROP TABLE t;
 
779
-- sync_slave_with_master
 
780
 
 
781
-- echo ################################################################
 
782
-- echo # Test that the slave stop with error if no usable data is on BI
 
783
-- echo ################################################################
 
784
 
 
785
-- source include/rpl_reset.inc
 
786
-- connection master
 
787
-- let $row_img_set=master:MINIMAL:N,slave:NOBLOB:Y
 
788
-- source include/rpl_row_img_set.inc
 
789
 
 
790
SET SQL_LOG_BIN=0;
 
791
CREATE TABLE t (c1 int NOT NULL, c2 int, c3 int, primary key(c3));
 
792
SET SQL_LOG_BIN=1;
 
793
 
 
794
-- connection slave
 
795
CREATE TABLE t (c1 int NOT NULL, c2 int, primary key(c1));
 
796
 
 
797
-- connection master
 
798
 
 
799
INSERT INTO t VALUES (1,2,3);
 
800
UPDATE t SET c2=4 WHERE c2=2;
 
801
DROP TABLE t;
 
802
 
 
803
-- connection slave
 
804
# 1032==ER_KEY_NOT_FOUND (handler returns HA_ERR_END_OF_FILE)
 
805
let $slave_sql_errno= 1032;
 
806
source include/wait_for_slave_sql_error.inc;
 
807
DROP TABLE t;
 
808
--let $rpl_only_running_threads= 1
 
809
-- source include/rpl_reset.inc
 
810
 
 
811
## CLEAN UP
 
812
 
 
813
-- connection master
 
814
SET GLOBAL binlog_row_image= @old_binlog_row_image;
 
815
SET SESSION binlog_row_image= @old_binlog_row_image;
 
816
-- connection slave
 
817
SET GLOBAL binlog_row_image= @old_binlog_row_image;
 
818
SET SESSION binlog_row_image= @old_binlog_row_image;
 
819
 
 
820
--source include/rpl_end.inc