File: rpl_gipk_on_source_only.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (113 lines) | stat: -rw-r--r-- 3,288 bytes parent folder | download
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