| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# The purpose of this test script is to test the behavior of |
| 4 |
# INSERT/UPDATE/DELETE with a partitioned table and a non partitioned |
| 5 |
# table. |
| 6 |
# |
| 7 |
# ==== Requirements ==== |
| 8 |
# |
| 9 |
# R1. partition_id written to the binary log when there is partitioning |
| 10 |
# and no sub-partitioning shall range from 0 to (N-1) for a table with |
| 11 |
# N partitions. |
| 12 |
# R2. partition_id written to the binary log when there is subpartitioning |
| 13 |
# shall range from 0 to (M x N - 1) where M is the number of partition and |
| 14 |
# N is the number of subpartition. |
| 15 |
# R3. Statements that modify multiple rows of the same partition/subpartition |
| 16 |
# shall generate only one event. |
| 17 |
# R4. Statements that modify multiple rows of different partitions/subpartition |
| 18 |
# shall generate multiple events, one for every row that moves from one |
| 19 |
# partition to another. |
| 20 |
# R5. partition_id shall be read and written in endian-independent way |
| 21 |
# R6. partition_id shall not be written to the binary log when there is |
| 22 |
# no partitioning. |
| 23 |
# R7. It shall be possible to have both partition_id and ndb_extra_row_info in |
| 24 |
# same event. |
| 25 |
# |
| 26 |
# ==== Implementation ==== |
| 27 |
# |
| 28 |
# Create a table with partitions(RANGE), and test for (R1), (R3) and (R4) |
| 29 |
# Create a table with partitions(RANGE), with more than one byte(partitions >=128) partitions, and test for (R5) |
| 30 |
# Create a table with partitions(RANGE) and sub_partitions(KEY), and test for (R2)-(R4) |
| 31 |
# Create a table without partition and test for (R6) |
| 32 |
# Sync with slave successfully |
| 33 |
# Drop the tables created |
| 34 |
# Create a table with partitions and INSERT a row which has both partition |
| 35 |
# and ndb_extra_row_info (R7) |
| 36 |
# Test PARTIAL_UPDATE_EVENT on a partitioned table |
| 37 |
# |
| 38 |
# ==== References ==== |
| 39 |
# |
| 40 |
# Bug#32358736:PARSING INCORRECTLY EXTRA ROW INFO OF BINLOG |
| 41 |
# Bug#28712618:INSERT/UPDATE/DELETE WITH MULTIPLE ROWS IN SAME PARTITION CREATE MULTIPLE EVENT |
| 42 |
# WL#12168:Add Partition Information into the Binary Log |
| 43 |
# |
| 44 |
|
| 45 |
--source include/have_debug.inc |
| 46 |
--source include/have_binlog_format_row.inc |
| 47 |
--source include/master-slave.inc |
| 48 |
# mysqlbinlog should be debug compiled. |
| 49 |
--source include/mysqlbinlog_have_debug.inc |
| 50 |
|
| 51 |
--echo #####1.Verifying the value of partition_id written to the binary log ##### |
| 52 |
|
| 53 |
--let $iteration = 1 |
| 54 |
|
| 55 |
while ($iteration <= 2) |
| 56 |
{ |
| 57 |
if ($iteration == 1) |
| 58 |
{ |
| 59 |
CREATE TABLE employees (store_id INT NOT NULL) PARTITION BY RANGE (store_id) |
| 60 |
( PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20), PARTITION p2 VALUES LESS THAN (30)); |
| 61 |
} |
| 62 |
|
| 63 |
if ($iteration == 2) |
| 64 |
{ |
| 65 |
CREATE TABLE employees (store_id INT NOT NULL); |
| 66 |
ALTER TABLE employees PARTITION BY RANGE (store_id) ( PARTITION p0 VALUES LESS THAN (10), |
| 67 |
PARTITION p1 VALUES LESS THAN (20), |
| 68 |
PARTITION p2 VALUES LESS THAN (30)); |
| 69 |
} |
| 70 |
|
| 71 |
--source include/save_binlog_position.inc |
| 72 |
INSERT INTO employees VALUES(22); |
| 73 |
# Check if the partition_id is correctly logged for this event. |
| 74 |
# It is stored in the third partition so the partition_id should be 2 |
| 75 |
--let $expected_partition_id = 2 |
| 76 |
--source suite/rpl/include/rpl_partition_info.inc |
| 77 |
|
| 78 |
ALTER TABLE employees ADD PARTITION (PARTITION p3 VALUES LESS THAN (40)); |
| 79 |
--source include/save_binlog_position.inc |
| 80 |
INSERT INTO employees VALUES(38); |
| 81 |
|
| 82 |
# Check if the partition_id is correctly logged for this event. |
| 83 |
# It is stored in the third partition so the partition_id should be 3 |
| 84 |
--let $expected_partition_id = 3 |
| 85 |
--source suite/rpl/include/rpl_partition_info.inc |
| 86 |
|
| 87 |
--source include/save_binlog_position.inc |
| 88 |
UPDATE employees SET store_id = 39 WHERE store_id = 38; |
| 89 |
|
| 90 |
# Check if the old and new partition_id is correctly logged for this event. |
| 91 |
# It is stored in the third partition before and after UPDATE so both |
| 92 |
# partition_id should be 3 |
| 93 |
--let $partition_id= 3 3 |
| 94 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 95 |
|
| 96 |
--source include/save_binlog_position.inc |
| 97 |
UPDATE employees SET store_id = 28 WHERE store_id = 39; |
| 98 |
|
| 99 |
# Check if the old and new partition_id is correctly logged for this event. |
| 100 |
# It is stored in the third partition before and in second after UPDATE so, |
| 101 |
# the old partition_id is 3 and new partition_id should be 2 |
| 102 |
--let $partition_id= 3 2 |
| 103 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 104 |
|
| 105 |
--echo #####2.INSERT, UPDATE, DELETE in a partitioned table affecting same and multiple partition ##### |
| 106 |
--echo #####3.Verifying the number of events created when executing statements affecting same and multiple partitions ##### |
| 107 |
--echo -----INSERT----- |
| 108 |
|
| 109 |
# Test that only one Write_rows_event is logged |
| 110 |
--source include/save_binlog_position.inc |
| 111 |
INSERT INTO employees VALUES(4), (5); |
| 112 |
|
| 113 |
--let $dont_print_pattern= 1 |
| 114 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # !Commit |
| 115 |
--source include/assert_binlog_events.inc |
| 116 |
|
| 117 |
# Check if the partition_id is correctly logged for this event. |
| 118 |
--let $expected_partition_id= 0 |
| 119 |
--source suite/rpl/include/rpl_partition_info.inc |
| 120 |
|
| 121 |
# Test that two Write_rows_events are logged |
| 122 |
--source include/save_binlog_position.inc |
| 123 |
INSERT INTO employees VALUES(7), (15); |
| 124 |
|
| 125 |
--let $event_sequence =!Gtid_or_anon # !Begin # Table_map # Write_rows # Write_rows # !Commit |
| 126 |
--source include/assert_binlog_events.inc |
| 127 |
|
| 128 |
# Check if the partition_id is correctly logged for this event. |
| 129 |
--let $expected_partition_id= 0;1 |
| 130 |
--source suite/rpl/include/rpl_partition_info.inc |
| 131 |
|
| 132 |
--echo -----UPDATE----- |
| 133 |
|
| 134 |
# Test that one Update_rows_events are logged |
| 135 |
--source include/save_binlog_position.inc |
| 136 |
UPDATE employees SET store_id = 9 WHERE store_id < 6; |
| 137 |
|
| 138 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # !Commit |
| 139 |
--source include/assert_binlog_events.inc |
| 140 |
|
| 141 |
# Check if the partition_id is correctly logged for this event. |
| 142 |
--let $partition_id = 0 0 |
| 143 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 144 |
|
| 145 |
# Test that two Update_rows_events are logged |
| 146 |
# different source_partition_id but same target_partition_id |
| 147 |
--source include/save_binlog_position.inc |
| 148 |
UPDATE employees SET store_id = 12 WHERE store_id < 25 AND store_id > 10; |
| 149 |
|
| 150 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # Update_rows # !Commit |
| 151 |
--source include/assert_binlog_events.inc |
| 152 |
|
| 153 |
# Check if the partition_id is correctly logged for this event. |
| 154 |
--let $partition_id = 1 1;2 1 |
| 155 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 156 |
|
| 157 |
# Test that two Update_rows_events are logged |
| 158 |
# same source_partition_id but different target_partition_id |
| 159 |
--source include/save_binlog_position.inc |
| 160 |
UPDATE employees SET store_id = store_id + 2 WHERE store_id < 10; |
| 161 |
|
| 162 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # Update_rows # !Commit |
| 163 |
--source include/assert_binlog_events.inc |
| 164 |
|
| 165 |
# Check if the partition_id is correctly logged for this event. |
| 166 |
--let $partition_id = 0 1;0 0 |
| 167 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 168 |
|
| 169 |
--echo -----DELETE----- |
| 170 |
|
| 171 |
# Test that single Delete_rows_events are logged |
| 172 |
--source include/save_binlog_position.inc |
| 173 |
DELETE FROM employees where store_id < 10; |
| 174 |
|
| 175 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Delete_rows # !Commit |
| 176 |
--source include/assert_binlog_events.inc |
| 177 |
|
| 178 |
# Check if the partition_id is correctly logged for this event. |
| 179 |
--let $expected_partition_id= 0 |
| 180 |
--source suite/rpl/include/rpl_partition_info.inc |
| 181 |
|
| 182 |
# Test that two Delete_rows_events are logged |
| 183 |
--source include/save_binlog_position.inc |
| 184 |
DELETE FROM employees where store_id < 40; |
| 185 |
|
| 186 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Delete_rows # Delete_rows # !Commit |
| 187 |
--source include/assert_binlog_events.inc |
| 188 |
|
| 189 |
# Check if the partition_id is correctly logged for this event. |
| 190 |
--let $expected_partition_id= 1;2 |
| 191 |
--source suite/rpl/include/rpl_partition_info.inc |
| 192 |
|
| 193 |
--inc $iteration |
| 194 |
|
| 195 |
DROP TABLE employees; |
| 196 |
} |
| 197 |
--echo #####4.Verifying the value of partition_id written to the binary log in case of table with more than 128 partitions###### |
| 198 |
CREATE TABLE tp ( |
| 199 |
id INT primary key |
| 200 |
) |
| 201 |
PARTITION BY RANGE( id ) ( |
| 202 |
PARTITION p0 VALUES LESS THAN (0), PARTITION p1 VALUES LESS THAN (1), |
| 203 |
PARTITION p2 VALUES LESS THAN (2), PARTITION p3 VALUES LESS THAN (3), |
| 204 |
PARTITION p4 VALUES LESS THAN (4), PARTITION p5 VALUES LESS THAN (5), |
| 205 |
PARTITION p6 VALUES LESS THAN (6), PARTITION p7 VALUES LESS THAN (7), |
| 206 |
PARTITION p8 VALUES LESS THAN (8), PARTITION p9 VALUES LESS THAN (9), |
| 207 |
PARTITION p10 VALUES LESS THAN (10), PARTITION p11 VALUES LESS THAN (11), |
| 208 |
PARTITION p12 VALUES LESS THAN (12), PARTITION p13 VALUES LESS THAN (13), |
| 209 |
PARTITION p14 VALUES LESS THAN (14), PARTITION p15 VALUES LESS THAN (15), |
| 210 |
PARTITION p16 VALUES LESS THAN (16), PARTITION p17 VALUES LESS THAN (17), |
| 211 |
PARTITION p18 VALUES LESS THAN (18), PARTITION p19 VALUES LESS THAN (19), |
| 212 |
PARTITION p20 VALUES LESS THAN (20), PARTITION p21 VALUES LESS THAN (21), |
| 213 |
PARTITION p22 VALUES LESS THAN (22), PARTITION p23 VALUES LESS THAN (23), |
| 214 |
PARTITION p24 VALUES LESS THAN (24), PARTITION p25 VALUES LESS THAN (25), |
| 215 |
PARTITION p26 VALUES LESS THAN (26), PARTITION p27 VALUES LESS THAN (27), |
| 216 |
PARTITION p28 VALUES LESS THAN (28), PARTITION p29 VALUES LESS THAN (29), |
| 217 |
PARTITION p30 VALUES LESS THAN (30), PARTITION p31 VALUES LESS THAN (31), |
| 218 |
PARTITION p32 VALUES LESS THAN (32), PARTITION p33 VALUES LESS THAN (33), |
| 219 |
PARTITION p34 VALUES LESS THAN (34), PARTITION p35 VALUES LESS THAN (35), |
| 220 |
PARTITION p36 VALUES LESS THAN (36), PARTITION p37 VALUES LESS THAN (37), |
| 221 |
PARTITION p38 VALUES LESS THAN (38), PARTITION p39 VALUES LESS THAN (39), |
| 222 |
PARTITION p40 VALUES LESS THAN (40), PARTITION p41 VALUES LESS THAN (41), |
| 223 |
PARTITION p42 VALUES LESS THAN (42), PARTITION p43 VALUES LESS THAN (43), |
| 224 |
PARTITION p44 VALUES LESS THAN (44), PARTITION p45 VALUES LESS THAN (45), |
| 225 |
PARTITION p46 VALUES LESS THAN (46), PARTITION p47 VALUES LESS THAN (47), |
| 226 |
PARTITION p48 VALUES LESS THAN (48), PARTITION p49 VALUES LESS THAN (49), |
| 227 |
PARTITION p50 VALUES LESS THAN (50), PARTITION p51 VALUES LESS THAN (51), |
| 228 |
PARTITION p52 VALUES LESS THAN (52), PARTITION p53 VALUES LESS THAN (53), |
| 229 |
PARTITION p54 VALUES LESS THAN (54), PARTITION p55 VALUES LESS THAN (55), |
| 230 |
PARTITION p56 VALUES LESS THAN (56), PARTITION p57 VALUES LESS THAN (57), |
| 231 |
PARTITION p58 VALUES LESS THAN (58), PARTITION p59 VALUES LESS THAN (59), |
| 232 |
PARTITION p60 VALUES LESS THAN (60), PARTITION p61 VALUES LESS THAN (61), |
| 233 |
PARTITION p62 VALUES LESS THAN (62), PARTITION p63 VALUES LESS THAN (63), |
| 234 |
PARTITION p64 VALUES LESS THAN (64), PARTITION p65 VALUES LESS THAN (65), |
| 235 |
PARTITION p66 VALUES LESS THAN (66), PARTITION p67 VALUES LESS THAN (67), |
| 236 |
PARTITION p68 VALUES LESS THAN (68), PARTITION p69 VALUES LESS THAN (69), |
| 237 |
PARTITION p70 VALUES LESS THAN (70), PARTITION p71 VALUES LESS THAN (71), |
| 238 |
PARTITION p72 VALUES LESS THAN (72), PARTITION p73 VALUES LESS THAN (73), |
| 239 |
PARTITION p74 VALUES LESS THAN (74), PARTITION p75 VALUES LESS THAN (75), |
| 240 |
PARTITION p76 VALUES LESS THAN (76), PARTITION p77 VALUES LESS THAN (77), |
| 241 |
PARTITION p78 VALUES LESS THAN (78), PARTITION p79 VALUES LESS THAN (79), |
| 242 |
PARTITION p80 VALUES LESS THAN (80), PARTITION p81 VALUES LESS THAN (81), |
| 243 |
PARTITION p82 VALUES LESS THAN (82), PARTITION p83 VALUES LESS THAN (83), |
| 244 |
PARTITION p84 VALUES LESS THAN (84), PARTITION p85 VALUES LESS THAN (85), |
| 245 |
PARTITION p86 VALUES LESS THAN (86), PARTITION p87 VALUES LESS THAN (87), |
| 246 |
PARTITION p88 VALUES LESS THAN (88), PARTITION p89 VALUES LESS THAN (89), |
| 247 |
PARTITION p90 VALUES LESS THAN (90), PARTITION p91 VALUES LESS THAN (91), |
| 248 |
PARTITION p92 VALUES LESS THAN (92), PARTITION p93 VALUES LESS THAN (93), |
| 249 |
PARTITION p94 VALUES LESS THAN (94), PARTITION p95 VALUES LESS THAN (95), |
| 250 |
PARTITION p96 VALUES LESS THAN (96), PARTITION p97 VALUES LESS THAN (97), |
| 251 |
PARTITION p98 VALUES LESS THAN (98), PARTITION p99 VALUES LESS THAN (99), |
| 252 |
PARTITION p100 VALUES LESS THAN (100), PARTITION p101 VALUES LESS THAN (101), |
| 253 |
PARTITION p102 VALUES LESS THAN (102), PARTITION p103 VALUES LESS THAN (103), |
| 254 |
PARTITION p104 VALUES LESS THAN (104), PARTITION p105 VALUES LESS THAN (105), |
| 255 |
PARTITION p106 VALUES LESS THAN (106), PARTITION p107 VALUES LESS THAN (107), |
| 256 |
PARTITION p108 VALUES LESS THAN (108), PARTITION p109 VALUES LESS THAN (109), |
| 257 |
PARTITION p110 VALUES LESS THAN (110), PARTITION p111 VALUES LESS THAN (111), |
| 258 |
PARTITION p112 VALUES LESS THAN (112), PARTITION p113 VALUES LESS THAN (113), |
| 259 |
PARTITION p114 VALUES LESS THAN (114), PARTITION p115 VALUES LESS THAN (115), |
| 260 |
PARTITION p116 VALUES LESS THAN (116), PARTITION p117 VALUES LESS THAN (117), |
| 261 |
PARTITION p118 VALUES LESS THAN (118), PARTITION p119 VALUES LESS THAN (119), |
| 262 |
PARTITION p120 VALUES LESS THAN (120), PARTITION p121 VALUES LESS THAN (121), |
| 263 |
PARTITION p122 VALUES LESS THAN (122), PARTITION p123 VALUES LESS THAN (123), |
| 264 |
PARTITION p124 VALUES LESS THAN (124), PARTITION p125 VALUES LESS THAN (125), |
| 265 |
PARTITION p126 VALUES LESS THAN (126), PARTITION p127 VALUES LESS THAN (127), |
| 266 |
PARTITION p128 VALUES LESS THAN (128), PARTITION p129 VALUES LESS THAN (129)); |
| 267 |
|
| 268 |
--source include/save_binlog_position.inc |
| 269 |
INSERT INTO tp VALUES(126), (127), (128); |
| 270 |
# Check if the partition_id is correctly logged for this event. |
| 271 |
--let $expected_partition_id = 127;128;129 |
| 272 |
--source suite/rpl/include/rpl_partition_info.inc |
| 273 |
|
| 274 |
--echo #####5.Verifying the value of partition_id written to the binary log in case of sub-partitions###### |
| 275 |
|
| 276 |
CREATE TABLE sp(id INT, age INT) PARTITION BY RANGE(age) SUBPARTITION BY KEY(id) ( |
| 277 |
PARTITION p0 VALUES LESS THAN (30) (SUBPARTITION p0a, SUBPARTITION p0b), |
| 278 |
PARTITION p1 VALUES LESS THAN (60) (SUBPARTITION p1a, SUBPARTITION p1b)); |
| 279 |
|
| 280 |
--source include/save_binlog_position.inc |
| 281 |
INSERT INTO sp VALUES(101, 31); |
| 282 |
|
| 283 |
# Check if the partition_id is correctly logged for this event. |
| 284 |
--let $expected_partition_id = 2 |
| 285 |
--source suite/rpl/include/rpl_partition_info.inc |
| 286 |
|
| 287 |
--source include/save_binlog_position.inc |
| 288 |
INSERT INTO sp VALUES (102, 32); |
| 289 |
|
| 290 |
# Check if the partition_id is correctly logged for this event. |
| 291 |
--let $expected_partition_id = 3 |
| 292 |
--source suite/rpl/include/rpl_partition_info.inc |
| 293 |
|
| 294 |
--echo #####6.INSERTS, UPDATES, DELETES in a partitioned table affecting same and multiple sub_partition ##### |
| 295 |
--echo #####7.Verifying the number of events created when executing statements affecting single and multiple sub_partitions ##### |
| 296 |
|
| 297 |
--echo -----INSERT----- |
| 298 |
|
| 299 |
# A single statement writing multiple rows in the same partition |
| 300 |
# and sub_partition should generate just one row event. |
| 301 |
--source include/save_binlog_position.inc |
| 302 |
INSERT INTO sp VALUES(103, 31), (105, 32); |
| 303 |
|
| 304 |
# Test that only one Write_rows_event is logged |
| 305 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # !Commit |
| 306 |
--source include/assert_binlog_events.inc |
| 307 |
|
| 308 |
# Check if the partition_id is correctly logged for this event. |
| 309 |
--let $expected_partition_id = 2 |
| 310 |
--source suite/rpl/include/rpl_partition_info.inc |
| 311 |
|
| 312 |
# A single statement writing multiple rows in the same partition |
| 313 |
# but different sub_partition should generate more than one rows event . |
| 314 |
--source include/save_binlog_position.inc |
| 315 |
INSERT INTO sp VALUES(104, 32), (105, 32); |
| 316 |
|
| 317 |
# Test that two Write_rows_event is logged |
| 318 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # Write_rows # !Commit |
| 319 |
--source include/assert_binlog_events.inc |
| 320 |
|
| 321 |
# Check if the partition_id is correctly logged for this event. |
| 322 |
--let $expected_partition_id = 3;2 |
| 323 |
--source suite/rpl/include/rpl_partition_info.inc |
| 324 |
|
| 325 |
--echo -----UPDATE----- |
| 326 |
|
| 327 |
# A single statement writing multiple rows in the same partition |
| 328 |
# and sub_partition should generate just one row event. |
| 329 |
--source include/save_binlog_position.inc |
| 330 |
UPDATE sp set age=31 where id = 102 or id=104; |
| 331 |
|
| 332 |
# Test that only one Update_rows_event is logged |
| 333 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # !Commit |
| 334 |
--source include/assert_binlog_events.inc |
| 335 |
|
| 336 |
# Check if the old and new partition_id is correctly logged for this event. |
| 337 |
--let $partition_id= 3 3 |
| 338 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 339 |
|
| 340 |
# A single statement writing multiple rows in the same partition |
| 341 |
# but different sub_partition should generate more than one rows event . |
| 342 |
--source include/save_binlog_position.inc |
| 343 |
UPDATE sp set age=29 where id = 102 or id=103; |
| 344 |
|
| 345 |
# Test that two Update_rows_event is logged |
| 346 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # Update_rows # !Commit |
| 347 |
--source include/assert_binlog_events.inc |
| 348 |
|
| 349 |
# Check if the old and new partition_id is correctly logged for this event. |
| 350 |
--let $partition_id = 2 0;3 1 |
| 351 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 352 |
|
| 353 |
--echo -----DELETE----- |
| 354 |
|
| 355 |
# A single statement writing multiple rows in the same partition |
| 356 |
# and sub_partition should generate just one row event. |
| 357 |
--source include/save_binlog_position.inc |
| 358 |
DELETE FROM sp where id = 101 or id=105; |
| 359 |
|
| 360 |
# Test that only one Delete_rows_event is logged |
| 361 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Delete_rows # !Commit |
| 362 |
--source include/assert_binlog_events.inc |
| 363 |
|
| 364 |
# Check if the partition_id is correctly logged for this event. |
| 365 |
--let $expected_partition_id = 2 |
| 366 |
--source suite/rpl/include/rpl_partition_info.inc |
| 367 |
|
| 368 |
# A single statement writing multiple rows in the same partition |
| 369 |
# but different sub_partition should generate more than one rows event . |
| 370 |
--source include/save_binlog_position.inc |
| 371 |
DELETE FROM sp where id = 102 or id=103; |
| 372 |
|
| 373 |
# Test that two Delete_rows_event is logged |
| 374 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Delete_rows # Delete_rows # !Commit |
| 375 |
--source include/assert_binlog_events.inc |
| 376 |
|
| 377 |
# Check if the partition_id is correctly logged for this event. |
| 378 |
--let $expected_partition_id = 0;1 |
| 379 |
--source suite/rpl/include/rpl_partition_info.inc |
| 380 |
|
| 381 |
--echo #####8.INSERT, UPDATE, DELETE in a table with no partition ##### |
| 382 |
--echo #####9.Verifying the number of events created when executing the above statements ##### |
| 383 |
|
| 384 |
CREATE TABLE t(s int, x int); |
| 385 |
INSERT INTO t VALUES (11, 2); |
| 386 |
INSERT INTO t VALUES (13, 4); |
| 387 |
|
| 388 |
--echo -----INSERT----- |
| 389 |
|
| 390 |
# Test that only one Write_rows_event is logged |
| 391 |
--source include/save_binlog_position.inc |
| 392 |
INSERT INTO t VALUES (10, 1), (11, 20); |
| 393 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # !Commit |
| 394 |
--source include/assert_binlog_events.inc |
| 395 |
|
| 396 |
--echo -----UPDATE----- |
| 397 |
# Test that only one Update_rows_event is logged |
| 398 |
--source include/save_binlog_position.inc |
| 399 |
UPDATE t SET s= 7 WHERE x > 3; |
| 400 |
|
| 401 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows # !Commit |
| 402 |
--source include/assert_binlog_events.inc |
| 403 |
|
| 404 |
--echo -----DELETE------ |
| 405 |
# Test that only one Delete_rows_event is logged |
| 406 |
--source include/save_binlog_position.inc |
| 407 |
DELETE from t where x < 4; |
| 408 |
|
| 409 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Delete_rows # !Commit |
| 410 |
--source include/assert_binlog_events.inc |
| 411 |
|
| 412 |
--echo #####10.Sync with slave and check if all the tables are replicated correctly##### |
| 413 |
|
| 414 |
--source include/sync_slave_sql_with_master.inc |
| 415 |
|
| 416 |
let $diff_tables= master:tp, slave:tp; |
| 417 |
--source include/diff_tables.inc |
| 418 |
|
| 419 |
let $diff_tables= master:t, slave:t; |
| 420 |
--source include/diff_tables.inc |
| 421 |
|
| 422 |
let $diff_tables= master:sp, slave:sp; |
| 423 |
--source include/diff_tables.inc |
| 424 |
|
| 425 |
# Cleanup |
| 426 |
connection master; |
| 427 |
DROP TABLE tp; |
| 428 |
DROP TABLE t; |
| 429 |
DROP TABLE sp; |
| 430 |
|
| 431 |
--echo #####11.INSERT in a table which has both partition info and ndb_info ##### |
| 432 |
|
| 433 |
# Set the debug points to be used for creating ndb_info |
| 434 |
# |
| 435 |
connection slave; |
| 436 |
--let $debug_point_silent= 1 |
| 437 |
--let $debug_point= extra_row_ndb_info_check |
| 438 |
--source include/add_debug_point.inc |
| 439 |
connection master; |
| 440 |
--let $debug_point= extra_row_ndb_info_set_3 |
| 441 |
--source include/add_debug_point.inc |
| 442 |
|
| 443 |
CREATE TABLE t1 (store_id INT NOT NULL) PARTITION BY RANGE (store_id) ( PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20)); |
| 444 |
|
| 445 |
--source include/save_binlog_position.inc |
| 446 |
INSERT INTO t1 VALUES (1), (11), (15); |
| 447 |
|
| 448 |
# Test that three Write_rows_event is logged |
| 449 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # Write_rows # Write_rows # !Commit |
| 450 |
--source include/assert_binlog_events.inc |
| 451 |
|
| 452 |
# Check if the partition_id is correctly logged for this event. |
| 453 |
--let $expected_partition_id = 0;1 |
| 454 |
--source suite/rpl/include/rpl_partition_info.inc |
| 455 |
|
| 456 |
# needed for mysqlbinlog_only_decoded_rows |
| 457 |
--source include/have_grep.inc |
| 458 |
--let mysqlbinlog_only_decoded_rows =1 |
| 459 |
--source include/mysqlbinlog.inc |
| 460 |
|
| 461 |
# Cleanup |
| 462 |
|
| 463 |
--source include/sync_slave_sql_with_master.inc |
| 464 |
--let $debug_point= extra_row_ndb_info_check |
| 465 |
--source include/remove_debug_point.inc |
| 466 |
connection master; |
| 467 |
--let $debug_point= extra_row_ndb_info_set_3 |
| 468 |
--source include/remove_debug_point.inc |
| 469 |
|
| 470 |
--echo #####12.Test partial JSON Update ##### |
| 471 |
SET @@SESSION.BINLOG_ROW_VALUE_OPTIONS= PARTIAL_JSON; |
| 472 |
|
| 473 |
--source include/save_binlog_position.inc |
| 474 |
UPDATE t1 SET store_id = 8 WHERE store_id = 11; |
| 475 |
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Update_rows_partial # !Commit |
| 476 |
--source include/assert_binlog_events.inc |
| 477 |
|
| 478 |
--let $partition_id = 1 0 |
| 479 |
--source suite/rpl/include/rpl_partition_info_update.inc |
| 480 |
|
| 481 |
# Verify that we get the expected error when trying to print ndb_info with a length < 2 |
| 482 |
# mysqlbinlog should be debug compiled. |
| 483 |
--source include/mysqlbinlog_have_debug.inc |
| 484 |
|
| 485 |
--source include/save_binlog_position.inc |
| 486 |
INSERT INTO t1 VALUES (2); |
| 487 |
|
| 488 |
--exec $MYSQL_BINLOG -#d,simulate_error_in_ndb_info_print --force-if-open --start-position=$binlog_position -vv $binlog_fullpath > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_partition_1.binlog |
| 489 |
|
| 490 |
--let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_partition_1.binlog |
| 491 |
--let $assert_select= The number of extra_row_ndb_info is smaller than the minimum acceptable value |
| 492 |
--let $assert_match= |
| 493 |
--let $assert_count= 1 |
| 494 |
--let $assert_text= The error block is working fine for ndb_info print. |
| 495 |
--source include/assert_grep.inc |
| 496 |
|
| 497 |
DROP TABLE t1; |
| 498 |
|
| 499 |
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_partition_1.binlog |
| 500 |
RESET MASTER; |
| 501 |
--source include/rpl_end.inc |