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
|
# === Purpose ===
#
# This test validate that replication works when the source has a GIPK
# and the replica does not.
#
# ==== Requirements ====
#
# R1. If the source contains a GIPK, replication toa replica with no GIPK
# should work seamlessly.
#
# === Implementation ====
#
# 1. Enable the generation of GIPKs in the source
# Create a table with no primary key
# 2. Create the same table on the replica
# 3. Insert some values on the table
# Check they are replicated correctly
# 4. Update and delete rows in the table
# Check changes are replicated correctly
# 5. Cleanup
#
# === References ===
#
# Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
#
--source include/master-slave.inc
--echo
--echo ##################################################
--echo # 1. Enable the generation of GIPKs in the source
--echo # Create a table with no primary key
--source include/rpl_connection_master.inc
# Set at the session level, so no restore needed for MTR
SET SESSION sql_generate_invisible_primary_key = ON;
--source include/disable_binlog.inc
CREATE TABLE t1(f1 INT, f2 INT);
--source include/restore_binlog.inc
--let $column_count= `SELECT COUNT(*) FROM information_schema.columns WHERE table_name='t1';`
--let $assert_text= The table contains 3 columns
--let $assert_cond= $column_count = 3
--source include/assert.inc
--let $pk_count= `SELECT COUNT(*) FROM information_schema.columns WHERE table_name='t1' and column_name='my_row_id';`
--let $assert_text= The table contains a generated invisilble primary key
--let $assert_cond= $pk_count = 1
--source include/assert.inc
--echo
--echo ##################################################
--echo # 2. Create the same table on the replica
--source include/rpl_connection_slave.inc
CREATE TABLE t1(f1 INT, f2 INT);
--echo
--echo ##################################################
--echo # 3. Insert some values on the table
--echo # Check they are replicated correctly
--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES (1, 10);
INSERT INTO t1 VALUES (5, 50);
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $row_count= `SELECT COUNT(*) FROM t1;`
--let $assert_text= The table t1 contains the 2 inserted rows
--let $assert_cond= $row_count = 2
--source include/assert.inc
--echo
--echo ##################################################
--echo # 4. Update and delete rows in the table
--echo # Check changes are replicated correctly
--source include/rpl_connection_master.inc
UPDATE t1 SET t1.f2 = 100 WHERE t1.f1=5;
DELETE FROM t1 WHERE t1.f1=1;
--source include/sync_slave_sql_with_master.inc
--let $row_count= `SELECT COUNT(*) FROM t1;`
--let $assert_text= The table t1 contains 1 row
--let $assert_cond= $row_count = 1
--source include/assert.inc
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE t1.f2 = 100 AND t1.f1 = 5;`
--let $assert_text= The table t1 was updated
--let $assert_cond= $row_count = 1
--source include/assert.inc
--echo
--echo ##################################################
--echo # 5. Cleanup
--source include/rpl_connection_master.inc
SET SESSION sql_generate_invisible_primary_key = OFF;
DROP TABLE t1;
--source include/rpl_end.inc
|