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