Debian Codegraph @

mysql-test/suite/rpl/t/rpl_gipk_on_source_only.test

raw
1 # === Purpose ===
2 #
3 # This test validate that replication works when the source has a GIPK
4 # and the replica does not.
5 #
6 # ==== Requirements ====
7 #
8 # R1. If the source contains a GIPK, replication toa replica with no GIPK
9 # should work seamlessly.
10 #
11 # === Implementation ====
12 #
13 # 1. Enable the generation of GIPKs in the source
14 # Create a table with no primary key
15 # 2. Create the same table on the replica
16 # 3. Insert some values on the table
17 # Check they are replicated correctly
18 # 4. Update and delete rows in the table
19 # Check changes are replicated correctly
20 # 5. Cleanup
21 #
22 # === References ===
23 #
24 # Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
25 #
26
27 --source include/master-slave.inc
28
29 --echo
30 --echo ##################################################
31 --echo # 1. Enable the generation of GIPKs in the source
32 --echo # Create a table with no primary key
33
34 --source include/rpl_connection_master.inc
35
36 # Set at the session level, so no restore needed for MTR
37 SET SESSION sql_generate_invisible_primary_key = ON;
38
39 --source include/disable_binlog.inc
40 CREATE TABLE t1(f1 INT, f2 INT);
41 --source include/restore_binlog.inc
42
43 --let $column_count= `SELECT COUNT(*) FROM information_schema.columns WHERE table_name='t1';`
44 --let $assert_text= The table contains 3 columns
45 --let $assert_cond= $column_count = 3
46 --source include/assert.inc
47
48 --let $pk_count= `SELECT COUNT(*) FROM information_schema.columns WHERE table_name='t1' and column_name='my_row_id';`
49 --let $assert_text= The table contains a generated invisilble primary key
50 --let $assert_cond= $pk_count = 1
51 --source include/assert.inc
52
53 --echo
54 --echo ##################################################
55 --echo # 2. Create the same table on the replica
56
57 --source include/rpl_connection_slave.inc
58
59 CREATE TABLE t1(f1 INT, f2 INT);
60
61 --echo
62 --echo ##################################################
63 --echo # 3. Insert some values on the table
64 --echo # Check they are replicated correctly
65
66 --source include/rpl_connection_master.inc
67
68 INSERT INTO t1 VALUES (1, 10);
69 INSERT INTO t1 VALUES (5, 50);
70
71 --source include/sync_slave_sql_with_master.inc
72
73 --source include/rpl_connection_slave.inc
74
75 --let $row_count= `SELECT COUNT(*) FROM t1;`
76 --let $assert_text= The table t1 contains the 2 inserted rows
77 --let $assert_cond= $row_count = 2
78 --source include/assert.inc
79
80 --echo
81 --echo ##################################################
82 --echo # 4. Update and delete rows in the table
83 --echo # Check changes are replicated correctly
84
85 --source include/rpl_connection_master.inc
86
87 UPDATE t1 SET t1.f2 = 100 WHERE t1.f1=5;
88
89 DELETE FROM t1 WHERE t1.f1=1;
90
91 --source include/sync_slave_sql_with_master.inc
92
93 --let $row_count= `SELECT COUNT(*) FROM t1;`
94 --let $assert_text= The table t1 contains 1 row
95 --let $assert_cond= $row_count = 1
96 --source include/assert.inc
97
98 --let $row_count= `SELECT COUNT(*) FROM t1 WHERE t1.f2 = 100 AND t1.f1 = 5;`
99 --let $assert_text= The table t1 was updated
100 --let $assert_cond= $row_count = 1
101 --source include/assert.inc
102
103 --echo
104 --echo ##################################################
105 --echo # 5. Cleanup
106
107 --source include/rpl_connection_master.inc
108
109 SET SESSION sql_generate_invisible_primary_key = OFF;
110
111 DROP TABLE t1;
112
113 --source include/rpl_end.inc