Debian Codegraph @

mysql-test/suite/binlog_gtid/t/binlog_gtid_next_partially_failed_stmts.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that a partially failed statement saves its gtid into
4 # @@GLOBAL.GTID_EXECUTED and is binlogged when binlog is enabled.
5 #
6 # ==== Implementation ====
7 #
8 # 1) Execute a partially failed statement.
9 # 2) When binlog is enabled, verify that the partially failed statement
10 # saves its gtid into @@GLOBAL.GTID_EXECUTED if it is binlogged, or
11 # does not save its gtid into @@GLOBAL.GTID_EXECUTED if it is not
12 # binlogged.
13 # 3) Execute above two steps for all different types of statements.
14 #
15 # ==== References ====
16 #
17 # Bug#21686749 PARTIALLY FAILED DROP OR ACL STMT FAILS TO CONSUME GTID ON BINLOGLESS SLAVE
18 # See mysql-test/t/no_binlog_gtid_next_partially_failed_stmts.test
19 # See mysql-test/t/no_binlog_gtid_next_partially_failed_stmts_error.test
20 # See mysql-test/suite/binlog/t/binlog_gtid_next_partially_failed_grant.test
21 # See mysql-test/t/no_binlog_gtid_next_partially_failed_stmts_anonymous.test
22 #
23
24 # Test in this file is binlog format agnostic, thus no need
25 # to rerun it for every format.
26 --source include/have_binlog_format_row.inc
27
28 # Make sure the test is repeatable
29 RESET MASTER;
30
31 call mtr.add_suppression("Did not write failed .* into binary log while storing table level and column level grants in the privilege tables");
32
33 --let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
34
35 CREATE TABLE t1(a INT, b INT);
36 CREATE USER u1@h;
37 --echo #
38 --echo # Verify that u1 is added into mysql.user.
39 --echo #
40 SELECT user FROM mysql.user where user='u1';
41
42 # Check-1: GRANT
43 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
44 --replace_result $master_uuid MASTER_UUID
45 --error ER_BAD_FIELD_ERROR
46 GRANT SELECT(a), SELECT(c) ON t1 TO u1@h;
47 --echo #
48 --echo # The SELECT privilege on column a is not granted to u1@h,
49 --echo # which means that GRANT can not be failed partially when
50 --echo # granting an available privilege and a non-available
51 --echo # privilege to an existent user.
52 --echo #
53 SELECT user, column_name, column_priv FROM mysql.columns_priv;
54 --echo #
55 --echo # Verify that the failed GRANT statement does not generate
56 --echo # a gtid and save the gtid into @@GLOBAL.GTID_EXECUTED.
57 --echo #
58 --replace_result $master_uuid MASTER_UUID
59 --let $assert_text= Committed gtid MASTER_UUID:3 into @@GLOBAL.GTID_EXECUTED
60 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-3"
61 --source include/assert.inc
62 --echo #
63 --echo # Verify that the failed GRANT statement is not binlogged
64 --echo #
65 --let $binlog_start= $saved_master_pos
66 --source include/show_binlog_events.inc
67
68
69 GRANT SELECT(a) ON t1 TO u1@h;
70 --echo #
71 --echo # Verify that the grant info is added into mysql.columns_priv.
72 --echo #
73 SELECT user, column_name, column_priv FROM mysql.columns_priv;
74
75 # Check-2: REVOKE
76 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
77 --error ER_NONEXISTING_TABLE_GRANT
78 REVOKE SELECT(a), SELECT(b) ON t1 FROM u1@h;
79 --echo #
80 --echo # The SELECT privilege is removed on column a from user u1,
81 --echo # which means that REVOKE statement can be failed partially
82 --echo # when revoking multiple privileges from a user.
83 --echo #
84 SELECT user, column_name, column_priv FROM mysql.columns_priv;
85 --echo #
86 --echo # Verify that the partially failed REVOKE statement does not generate
87 --echo # a gtid master_uuid:5 and save the gtid into @@GLOBAL.GTID_EXECUTED.
88 --echo #
89 --replace_result $master_uuid MASTER_UUID
90 --let $assert_text= Committed gtid MASTER_UUID:4 into @@GLOBAL.GTID_EXECUTED
91 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
92 --source include/assert.inc
93 --echo #
94 --echo # Verify that the partially failed REVOKE statement is not binlogged
95 --echo #
96 --let $binlog_start= $saved_master_pos
97 --source include/show_binlog_events.inc
98
99 # Check-3: DROP USER
100 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
101 --error ER_CANNOT_USER
102 DROP USER u1@h, u2@h;
103 --echo #
104 --echo # u1@h should not have been dropped.
105 --echo #
106 SELECT user FROM mysql.user where user='u1';
107 --echo #
108 --echo # Verify that the failed DROP USER statement does not generate
109 --echo # a gtid and save it into @@GLOBAL.GTID_EXECUTED.
110 --echo #
111 --replace_result $master_uuid MASTER_UUID
112 --let $assert_text= Does not generate MASTER_UUID:5 and commit it into @@GLOBAL.GTID_EXECUTED
113 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
114 --source include/assert.inc
115 --echo #
116 --echo # Verify failed DROP USER statement is not binlogged
117 --echo #
118 --let $binlog_start= $saved_master_pos
119 --source include/show_binlog_events.inc
120
121 # Check-4: RENAME TABLE
122 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
123 --error ER_NO_SUCH_TABLE
124 RENAME TABLE t1 TO t2, t3 TO t4;
125 --echo #
126 --echo # The table t1 was not renamed, which means RENAME TABLE
127 --echo # can not be failed partially.
128 --echo #
129 SHOW CREATE TABLE t1;
130 --echo #
131 --echo # Verify that the failed RENAME TABLE statement does not generate
132 --echo # a new GTID MASTER_UUID:7 and save it into @@GLOBAL.GTID_EXECUTED.
133 --echo #
134 --replace_result $master_uuid MASTER_UUID
135 --let $assert_text= Does not generate MASTER_UUID:6 and commit it into @@GLOBAL.GTID_EXECUTED
136 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
137 --source include/assert.inc
138 --echo #
139 --echo # Verify that the failed RENAME TABLE statement is not binlogged
140 --echo #
141 --let $binlog_start= $saved_master_pos
142 --source include/show_binlog_events.inc
143
144 # Check-5: OPTIMIZE TABLE
145 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
146 --echo #
147 --echo # The OPTIMIZE TABLE statement can be failed partially when optimizing
148 --echo # multiple tables, which contain a non-existent table.
149 --echo #
150 OPTIMIZE TABLE t1, t_non_existent;
151 --echo #
152 --echo # When optimizing a non-existent table, verify that the OPTIMIZE TABLE
153 --echo # statement generates a gtid and save it into @@GLOBAL.GTID_EXECUTED.
154 --echo #
155 --replace_result $master_uuid MASTER_UUID
156 --let $assert_text= Committed gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
157 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-5"
158 --source include/assert.inc
159 --echo #
160 --echo # When optimizing a non-existent table, verify that the OPTIMIZE TABLE
161 --echo # statement is binlogged.
162 --echo #
163 --let $binlog_start= $saved_master_pos
164 --source include/show_binlog_events.inc
165
166 # Check-6: ANALYZE TABLE
167 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
168 --echo #
169 --echo # The ANALYZE TABLE statement can be failed partially when analyzing
170 --echo # multiple tables, which contain a non-existent table.
171 --echo #
172 ANALYZE TABLE t1, t_non_existent;
173 --echo #
174 --echo # When analyzing a non-existent table, verify that the ANALYZE TABLE
175 --echo # statement generates a gtid and save it into @@GLOBAL.GTID_EXECUTED.
176 --echo #
177 --replace_result $master_uuid MASTER_UUID
178 --let $assert_text= Committed gtid MASTER_UUID:8 into @@GLOBAL.GTID_EXECUTED
179 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
180 --source include/assert.inc
181 --echo #
182 --echo # When analyzing a non-existent table, verify that the ANALYZE TABLE
183 --echo # statement is binlogged.
184 --echo #
185 --let $binlog_start= $saved_master_pos
186 --source include/show_binlog_events.inc
187
188 # Check-7: REPARE TABLE
189 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
190 --echo #
191 --echo # The REPAIR TABLE statement can be failed partially when repairing
192 --echo # multiple tables, which contain a non-existent table.
193 --echo #
194 REPAIR TABLE t1, t_non_existent;
195 --echo #
196 --echo # When repairing a non-existent table, verify that the REPAIR TABLE
197 --echo # statement generates a gtid and save it into @@GLOBAL.GTID_EXECUTED.
198 --echo #
199 --replace_result $master_uuid MASTER_UUID
200 --let $assert_text= Committed gtid MASTER_UUID:9 into @@GLOBAL.GTID_EXECUTED
201 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-7"
202 --source include/assert.inc
203 --echo #
204 --echo # When repairing a non-existent table, verify that the REPAIR TABLE
205 --echo # statement is binlogged.
206 --echo #
207 --let $binlog_start= $saved_master_pos
208 --source include/show_binlog_events.inc
209
210 # Check-8: CHECKSUM TABLE
211 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
212 --echo #
213 --echo # The CHECKSUM TABLE statement can be failed partially when checksuming
214 --echo # multiple tables, which contain a non-existent table.
215 --echo #
216 CHECKSUM TABLE t1, t_non_existent;
217 --echo #
218 --echo # When checksuming a non-existent table, verify that the CHECKSUM TABLE
219 --echo # statement generates a gtid and save it into @@GLOBAL.GTID_EXECUTED.
220 --echo #
221 --replace_result $master_uuid MASTER_UUID
222 --let $assert_text= Does not generate MASTER_UUID:10 and commit it into @@GLOBAL.GTID_EXECUTED
223 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-7"
224 --source include/assert.inc
225 --echo #
226 --echo # When checksuming a non-existent table, verify that the CHECKSUM TABLE
227 --echo # statement is not binlogged.
228 --echo #
229 --let $binlog_start= $saved_master_pos
230 --source include/show_binlog_events.inc
231
232 # Clean up
233 DROP TABLE t1;
234 DROP USER u1@h;