Debian Codegraph @

mysql-test/suite/binlog/t/binlog_mysqlbinlog_source_gipk_info.test

raw
1 # ==== Purpose ====
2 #
3 # This file contains test cases to validate the behavior of mysqlbinlog
4 # with the replication of GIPKs
5 #
6 # ==== Requirements ====
7 #
8 # R1: if the info is present, mysqlbinlog shall print stating if table maps contain GIPKs or not
9 # R2: Despite the value of binlog_row_metadata if a GIPK exists, full info on it is printed.
10 #
11 # ==== Implementation ====
12 #
13 # 1. Check the output of mysqlbinlog when the input file is a log
14 # from an old version server where GIPKs are not supported
15 # No info about GIPK should be present
16 # 2. Check the output of mysqlbinlog when the input files are logs
17 # created in a server version that supports GIPKs
18 # Info about GIPKs should be present
19 # 3. Check a binlog file containing the 2 tables above, but now with --print-table-metadata
20 # Even with binlog_row_metadata = minimal, data about the GIPK columns should be present
21 # 4. Check an equivalent binlog file but generated with binlog_row_metadata = full
22 # With --print-table-metadata the info should still be the same for GIPKs
23 # 5. Cleanup
24 #
25 # ==== Related Worklog ====
26 #
27 # WL#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
28 # Bug#34668313: Fix rpl_gipk_cross_version_schema_changes & binlog_mysqlbinlog_source_gipk_info
29 #
30
31 -- source include/have_binlog_format_row.inc
32
33 --echo
34 --echo ##################################################
35 --echo # 1. Check the output of mysqlbinlog when the input file is a log
36 --echo # from an old version server where GIPKs are not supported
37 --echo # No info about GIPK should be present
38
39 # The following binlog file was generated with the data:
40 #
41 # CREATE TABLE t1 (c1 BIGINT, c2 TEXT);
42 # INSERT INTO t1 VALUES (1,'1');
43
44
45 --let $input_binlog_file = $MYSQL_TEST_DIR/std_data/rpl_binlog_with_no_gipk_info.000001
46
47 --exec $MYSQL_BINLOG --force-if-open $input_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
48
49 --let $assert_text= Check the output contains no information GIPK
50 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
51 --let $assert_select = # has_generated_invisible_primary_key=0
52 --let $assert_count = 0
53 --source include/assert_grep.inc
54
55 --let $assert_text= Check the output contains no information GIPK
56 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
57 --let $assert_select = # has_generated_invisible_primary_key=1
58 --let $assert_count = 0
59 --source include/assert_grep.inc
60
61 --echo
62 --echo ##################################################
63 --echo # 2. Check the output of mysqlbinlog when the input files are logs
64 --echo # created in a server version that supports GIPKs
65 --echo # Info about GIPKs should be present
66
67 # The following binlog file was generated with the data:
68 #
69 # CREATE TABLE t1 (c1 BIGINT, c2 TEXT, PRIMARY KEY(c1));
70 # INSERT INTO t1 VALUES (1,'1');
71 #
72 # binlog_row_metadata = MINIMAL
73
74 --let $input_binlog_file = $MYSQL_TEST_DIR/std_data/rpl_binlog_with_gipk_info_no_gipk.000001
75
76 --exec $MYSQL_BINLOG --force-if-open $input_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_with_gipk_info.output
77
78 --let $assert_text= Check the output contains information about t1 not containing a GIPK
79 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_with_gipk_info.output
80 --let $assert_select = # has_generated_invisible_primary_key=0
81 --let $assert_count = 1
82 --source include/assert_grep.inc
83
84 # The following binlog file was generated with the data:
85 #
86 # SET SESSION sql_generate_invisible_primary_key = ON;
87 # CREATE TABLE t2(f1 INT, really_unique_column_name INT);
88 # SET SESSION sql_generate_invisible_primary_key = OFF;
89 # INSERT INTO t2 VALUES (1,'1');
90 #
91 # binlog_row_metadata = MINIMAL
92
93 --let $input_binlog_file = $MYSQL_TEST_DIR/std_data/rpl_binlog_with_gipk_info_with_gipk.000001
94
95 --exec $MYSQL_BINLOG --force-if-open $input_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_with_gipk_info.output
96
97 --let $assert_text= Check the output contains information about t2 containing a GIPK
98 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_with_gipk_info.output
99 --let $assert_select = # has_generated_invisible_primary_key=1
100 --let $assert_count = 1
101 --source include/assert_grep.inc
102
103 --echo
104 --echo ##################################################
105 --echo # 3. Check a binlog file containing the 2 tables above, but now with --print-table-metadata
106 --echo # Even with binlog_row_metadata = minimal, data about the GIPK columns should be present
107
108 # The following binlog file was generated with the data:
109 #
110 # CREATE TABLE t1 (c1 BIGINT, c2 TEXT, PRIMARY KEY(c1));
111 # INSERT INTO t1 VALUES (1,'1');
112 # SET SESSION sql_generate_invisible_primary_key = ON;
113 # CREATE TABLE t2(f1 INT, really_unique_column_name INT);
114 # SET SESSION sql_generate_invisible_primary_key = OFF;
115 # INSERT INTO t2 VALUES (1,'1');
116 #
117 # binlog_row_metadata = MINIMAL
118
119 --let $input_binlog_file = $MYSQL_TEST_DIR/std_data/rpl_binlog_with_gipk_info_minimal_metadata.000001
120
121 --exec $MYSQL_BINLOG --print-table-metadata --force-if-open $input_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
122
123 --let $assert_text= Check the output contains complete info about the GIPK column on t2
124 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
125 --let $assert_select = # Columns\(`my_row_id` BIGINT UNSIGNED NOT NULL INVISIBLE AUTO_INCREMENT
126 --let $assert_count = 1
127 --source include/assert_grep.inc
128
129 --let $assert_text= Check the output contains info about the GIPK being a PK on t2
130 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
131 --let $assert_select = # Primary Key\(my_row_id\)
132 --let $assert_count = 1
133 --source include/assert_grep.inc
134
135 --let $assert_text= Info about the column really_unique_column_name on t2 is only mentioned once on CREATE
136 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
137 --let $assert_select = really_unique_column_name
138 --let $assert_count = 1
139 --source include/assert_grep.inc
140
141 --let $assert_text= Check the output contains no info about c1 being a PK on t1
142 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
143 --let $assert_select = # Primary Key\(c1\)
144 --let $assert_count = 0
145 --source include/assert_grep.inc
146
147 --echo
148 --echo ##################################################
149 --echo # 4. Check an equivalent binlog file but generated with binlog_row_metadata = full
150 --echo # With --print-table-metadata the info should still be the same for GIPKs
151
152 # The following binlog file was generated with the data:
153 #
154 # CREATE TABLE t1 (c1 BIGINT, c2 TEXT, PRIMARY KEY(c1));
155 # INSERT INTO t1 VALUES (1,'1');
156 # SET SESSION sql_generate_invisible_primary_key = ON;
157 # CREATE TABLE t2(f1 INT, really_unique_column_name INT);
158 # SET SESSION sql_generate_invisible_primary_key = OFF;
159 # INSERT INTO t2 VALUES (1,'1');
160 #
161 # binlog_row_metadata = FULL
162
163 --let $input_binlog_file = $MYSQL_TEST_DIR/std_data/rpl_binlog_with_gipk_info_full_metadata.000001
164
165 --exec $MYSQL_BINLOG --print-table-metadata --force-if-open $input_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
166
167 --let $assert_text= Check the output contains complete info about the GIPK column on t2
168 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
169 --let $assert_select = # Columns\(`my_row_id` BIGINT UNSIGNED NOT NULL INVISIBLE AUTO_INCREMENT
170 --let $assert_count = 1
171 --source include/assert_grep.inc
172
173 --let $assert_text= Check the output contains info about the GIPK being a PK on t2
174 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
175 --let $assert_select = # Primary Key\(my_row_id\)
176 --let $assert_count = 1
177 --source include/assert_grep.inc
178
179 --let $assert_text= Info about the column really_unique_column_name on t2 is mentioned on CREATE and in the table map
180 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
181 --let $assert_select = really_unique_column_name
182 --let $assert_count = 2
183 --source include/assert_grep.inc
184
185 --let $assert_text= Check the output contains info about c1 being a PK on t1
186 --let $assert_file = $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output
187 --let $assert_select = # Primary Key\(c1\)
188 --let $assert_count = 1
189 --source include/assert_grep.inc
190
191 --echo
192 --echo ##################################################
193 --echo # 5. Cleanup
194
195 --remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_with_gipk_info.output
196 --remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_no_gipk_info.output