| 1 |
# === Purpose === |
| 2 |
# |
| 3 |
# This test checks that replication and auto increment logic still works if the |
| 4 |
# source has an extra GIPK, and the replica (not having a GIPK) has an extra |
| 5 |
# AUTO_INCREMENT column to the right |
| 6 |
# |
| 7 |
# ==== Requirements ==== |
| 8 |
# |
| 9 |
# R1. Extra auto increment columns on the replica are not affected by GIPKS on source tables. |
| 10 |
# |
| 11 |
# === Implementation ==== |
| 12 |
# |
| 13 |
# 1. Enable the generation of GIPKs in the source |
| 14 |
# With the binary log temporarily disabled, create table t1 |
| 15 |
# Create the same table on the replica with an extra auto inc column at the end |
| 16 |
# 2. Add 3 rows to the table on the source |
| 17 |
# Check the generated values on the replica are the expected |
| 18 |
# 3. Update/Delete rows on the source |
| 19 |
# 4. Cleanup |
| 20 |
# |
| 21 |
# === References === |
| 22 |
# |
| 23 |
# Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key |
| 24 |
# |
| 25 |
|
| 26 |
--source include/have_binlog_format_row.inc |
| 27 |
# This test needs --binlog-row-image = full |
| 28 |
--let $option_name = binlog_row_image |
| 29 |
--let $option_value = 'full' |
| 30 |
--source include/only_with_option.inc |
| 31 |
--source include/master-slave.inc |
| 32 |
|
| 33 |
--echo |
| 34 |
--echo ################################################## |
| 35 |
--echo # 1. Enable the generation of GIPKs in the source |
| 36 |
--echo # With the binary log temporarily disabled, create table t1 |
| 37 |
--echo # Create the same table on the replica with an extra auto inc column at the end |
| 38 |
|
| 39 |
--source include/rpl_connection_slave.inc |
| 40 |
|
| 41 |
CREATE TABLE t1(f1 INT, f2 INT, extra_column INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (extra_column)); |
| 42 |
|
| 43 |
--source include/rpl_connection_master.inc |
| 44 |
|
| 45 |
# Set at the session level, so no restore needed for MTR |
| 46 |
SET SESSION sql_generate_invisible_primary_key = ON; |
| 47 |
|
| 48 |
--source include/disable_binlog.inc |
| 49 |
CREATE TABLE t1(f1 INT, f2 INT); |
| 50 |
--source include/restore_binlog.inc |
| 51 |
|
| 52 |
SET SESSION sql_generate_invisible_primary_key = OFF; |
| 53 |
|
| 54 |
--echo |
| 55 |
--echo ################################################## |
| 56 |
--echo # 2. Add 3 rows to the table on the source |
| 57 |
--echo # Check the generated values on the replica are the expected |
| 58 |
|
| 59 |
--source include/rpl_connection_slave.inc |
| 60 |
|
| 61 |
--let $sysvars_to_save = [ "GLOBAL.replica_parallel_workers" ] |
| 62 |
--source include/save_sysvars.inc |
| 63 |
|
| 64 |
# Make the applier deterministic by having only 1 thread |
| 65 |
--source include/stop_slave_sql.inc |
| 66 |
SET @@GLOBAL.replica_parallel_workers= 1; |
| 67 |
--source include/start_slave_sql.inc |
| 68 |
|
| 69 |
--source include/rpl_connection_master.inc |
| 70 |
|
| 71 |
INSERT INTO t1 VALUES (1, 1); |
| 72 |
|
| 73 |
INSERT INTO t1 VALUES (2, 2); |
| 74 |
|
| 75 |
INSERT INTO t1 VALUES (3, 3); |
| 76 |
|
| 77 |
--source include/sync_slave_sql_with_master.inc |
| 78 |
|
| 79 |
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE f1 = 1 AND f2 = 1 AND extra_column = 1;` |
| 80 |
--let $assert_text= The table contains a row with generated key 1 |
| 81 |
--let $assert_cond= $row_count = 1 |
| 82 |
--source include/assert.inc |
| 83 |
|
| 84 |
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE f1 = 2 AND f2 = 2 AND extra_column = 2;` |
| 85 |
--let $assert_text= The table contains a row with generated key 2 |
| 86 |
--let $assert_cond= $row_count = 1 |
| 87 |
--source include/assert.inc |
| 88 |
|
| 89 |
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE f1 = 3 AND f2 = 3 AND extra_column = 3;` |
| 90 |
--let $assert_text= The table contains a row with generated key 3 |
| 91 |
--let $assert_cond= $row_count = 1 |
| 92 |
--source include/assert.inc |
| 93 |
|
| 94 |
--echo |
| 95 |
--echo ################################################## |
| 96 |
--echo # 3. Update/Delete rows on the source |
| 97 |
|
| 98 |
--source include/rpl_connection_master.inc |
| 99 |
|
| 100 |
UPDATE t1 SET t1.f2 = 60 WHERE t1.f1=2; |
| 101 |
|
| 102 |
DELETE FROM t1 WHERE t1.f1=1; |
| 103 |
|
| 104 |
--source include/sync_slave_sql_with_master.inc |
| 105 |
|
| 106 |
--source include/rpl_connection_slave.inc |
| 107 |
|
| 108 |
--let $row_count= `SELECT COUNT(*) FROM t1;` |
| 109 |
--let $assert_text= The table contains 2 rows |
| 110 |
--let $assert_cond= $row_count = 2 |
| 111 |
--source include/assert.inc |
| 112 |
|
| 113 |
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE f1 = 2 AND f2 = 60 AND extra_column = 2;` |
| 114 |
--let $assert_text= The table contains a row with generated key 2 |
| 115 |
--let $assert_cond= $row_count = 1 |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE f1 = 3 AND f2 = 3 AND extra_column = 3;` |
| 119 |
--let $assert_text= The table contains a row with generated key 3 |
| 120 |
--let $assert_cond= $row_count = 1 |
| 121 |
--source include/assert.inc |
| 122 |
|
| 123 |
--echo |
| 124 |
--echo ################################################## |
| 125 |
--echo # 4. Cleanup |
| 126 |
|
| 127 |
--disable_warnings |
| 128 |
--source include/restore_sysvars.inc |
| 129 |
--enable_warnings |
| 130 |
|
| 131 |
--source include/rpl_connection_master.inc |
| 132 |
|
| 133 |
DROP TABLE t1; |
| 134 |
|
| 135 |
--source include/rpl_end.inc |