File: drop_debug.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 (309 lines) | stat: -rw-r--r-- 10,681 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# 
# DROP-related tests which execution requires debug server.
#
--source include/have_debug.inc

# Valgrind would complain about memory leaks when we crash on purpose.
--source include/not_valgrind.inc
# Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc

--echo #
--echo # Bug#21625393 : Assert condition (e->usage() == 1) failure in
--echo #                dd::cache::Shared_multi_map<T>::remove()
--echo #

--enable_connect_log

--echo #
--echo # Create MyISAM table, and drop it, but make drop fail
--echo # before the object is deleted from the dd tables. Now,
--echo # the object exists in the global data dictionary, but
--echo # not in the SE.

CREATE TABLE t1 (i INT) ENGINE=MyISAM;

--connect (con1, localhost, root)
SET SESSION DEBUG='+d,fail_while_dropping_dd_object';
--error ER_LOCK_WAIT_TIMEOUT
DROP TABLE t1;
SET SESSION DEBUG='-d,fail_while_dropping_dd_object';

--connection default
--echo # Drop the table for real. Use IF EXISTS clause to ignore
--echo # the fact that table does not exist in SE.
--echo # Without the fix this statement will fail with assert.
DROP TABLE IF EXISTS t1;

--connection con1
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default

--disable_connect_log

--echo #
--echo # WL#7743 "New data dictionary: changes to DDL-related parts of SE API"
--echo #
--echo # Systematic test coverage for changes in DROP TABLES and DROP DATABASE
--echo # behavior.

--echo #
--echo # 1) Error handling by DROP TABLES.
--echo #

--echo #
--echo # 1.a) DROP TABLES statement which fails due to missing table
--echo #      should not have any side-effects.
CREATE TABLE t_m (t_m INT) ENGINE=MyISAM;
CREATE TABLE t_i (t_i INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE tt_m (tt_m INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE tt_i (tt_i INT) ENGINE=InnoDB;
--echo # Notice that all missing tables are reported.
--error ER_BAD_TABLE_ERROR
DROP TABLES t_m, t_i, tt_m, tt_i, t_no_such_table, t_no_such_table_either;
--echo # All tables are still there.
SELECT * FROM t_m, t_i, tt_m, tt_i;
--echo # Notice that all missing tables are reported.
--error ER_BAD_TABLE_ERROR
DROP TEMPORARY TABLES tt_m, tt_i, tt_no_such_table, tt_no_such_table_either;
--echo # All tables are still there.
SELECT * FROM tt_m, tt_i;

--echo #
--echo # 1.b) DROP TABLES IF EXISTS should ignore missing tables
--echo #      as expected and drop existing tables.
--echo #
--echo # Notice that all missing tables are reported in warning.
DROP TABLES IF EXISTS t_m, t_i, tt_m, tt_i, t_no_such_table, t_no_such_table_either;
--echo # All existing tables are dropped.
--error ER_NO_SUCH_TABLE
SELECT * FROM t_m;
--error ER_NO_SUCH_TABLE
SELECT * FROM t_i;
CREATE TEMPORARY TABLE tt_m (tt_m INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE tt_i (tt_i INT) ENGINE=InnoDB;
--echo # Notice that all missing tables are reported in warning.
DROP TEMPORARY TABLES IF EXISTS tt_m, tt_i, tt_no_such_table, tt_no_such_table_either;
--echo # All existing tables are dropped.
--error ER_NO_SUCH_TABLE
SELECT * FROM tt_m;
--error ER_NO_SUCH_TABLE
SELECT * FROM tt_i;

--echo #
--echo # 1.c) DROP TABLES which fails due to foreign key error does
--echo #      not have side effect.
CREATE TABLE t_m (t_m INT) ENGINE=MyISAM;
CREATE TABLE t_i_1 (t_i_1 INT) ENGINE=InnoDB;
CREATE TABLE t_i_2 (t_i_2 INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t_i_3 (t_i_3 INT, FOREIGN KEY(t_i_3) REFERENCES t_i_2(t_i_2)) ENGINE=InnoDB;
--error ER_FK_CANNOT_DROP_PARENT
DROP TABLES t_m, t_i_1, t_i_2;
--echo # All tables are still there.
SELECT * FROM t_m;
SELECT * FROM t_i_1;
SELECT * FROM t_i_2;

--echo #
--echo # 1.d) DROP TABLES which fails due to SE error might have side
--echo #      effect. Tables in engines which do not support atomic DDL
--echo #      which we have managed to drop before error stay dropped.
--echo #      Removal of InnoDB tables should be rolled back.
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
--error ER_UNKNOWN_ERROR
DROP TABLES t_m, t_i_1;
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
--error ER_NO_SUCH_TABLE
SELECT * FROM t_m;
SELECT * FROM t_i_1;

--echo #
--echo # 1.e) DROP TABLES which fails due to SE error and involves only
--echo #      tables in engines supporting atomic DDL should not have
--echo #      side effects/should be rolled back.
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
--error ER_UNKNOWN_ERROR
DROP TABLES t_i_1, t_i_3;
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
SELECT * FROM t_i_1;
SELECT * FROM t_i_3;

--echo # Clean-up.
DROP TABLES t_i_1, t_i_3, t_i_2;

--echo #
--echo # 2) Binary logging and GTID handling for DROP TABLES statements.
--echo #

--echo # 2.a) Binary logging for successfull DROP TABLES statement is
--echo #      covered by binlog_stm_mix_innodb_myisam,
--echo #      rpl_mixed_drop_create_temp_table and other similar
--echo #      tests.
--echo #

--echo # 2.b) Binary logging for failed DROP TABLES statement are
--echo #      additionally covered by rpl_binlog_failed_drop_table,
--echo #      rpl_gtid/no_gtid_split_statements tests.
--echo #

--echo # 2.c) GTID handling for DROP TABLES statement is covered by
--echo #      rpl_gtid_split_statements and 
--echo #      no_binlog_gtid_next_partially_failed_stmts tests.
--echo #

--echo #
--echo # 3) DROP TABLES IF EXISTS should be able to delete tables with
--echo #    entries in the data-dictionary, but absent from SE.
--echo #
LET $MYSQLD_DATADIR = `SELECT @@datadir`;
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
--echo # Remove table from SE manually.
FLUSH TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.MYI
--remove_file $MYSQLD_DATADIR/test/t1.MYD
--echo # Plain DROP TABLES reports an error.
--error ER_ENGINE_CANT_DROP_MISSING_TABLE
DROP TABLE t1;
--echo # DROP TABLES IF EXISTS successfully drops table.
DROP TABLE IF EXISTS t1;

--echo #
--echo # 4) Error handling by DROP DATABASE.
--echo #

--echo #
--echo # 4.a) DROP DATABASE which fails due to foreign key error should
--echo #      not have side effect.
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t_m (t_m INT) ENGINE=MyISAM;
CREATE TABLE mysqltest.t_i_1 (t_i_1 INT) ENGINE= InnoDB;
CREATE TABLE mysqltest.t_i_2 (t_i_2 INT PRIMARY KEY) ENGINE= InnoDB;
CREATE FUNCTION mysqltest.f1() RETURNS INT RETURN 0;
CREATE TABLE t1 (fk INT,
                 FOREIGN KEY (fk) REFERENCES mysqltest.t_i_2(t_i_2))
                 ENGINE=InnoDB;
--error ER_FK_CANNOT_DROP_PARENT
DROP DATABASE mysqltest;
--echo # Database and all tables are still there.
SELECT * FROM mysqltest.t_m;
SELECT * FROM mysqltest.t_i_1;
SELECT * FROM mysqltest.t_i_2;
--echo # Stored function f1() is still there too.
SELECT mysqltest.f1();

--echo #
--echo # 4.b) DROP DATABASE which fails due to SE error might have side
--echo #      effect. Tables in engines which do not support atomic DDL
--echo #      which we have managed to drop before error stay dropped.
--echo #      Removal of InnoDB tables should be rolled back.
DROP TABLE t1;
SET SESSION DEBUG='+d,rm_db_fail_after_dropping_tables';
--error ER_UNKNOWN_ERROR
DROP DATABASE mysqltest;
SET SESSION DEBUG='-d,rm_db_fail_after_dropping_tables';
--error ER_NO_SUCH_TABLE
SELECT * FROM mysqltest.t_m;
--echo # Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
SELECT * FROM mysqltest.t_i_2;
--echo # Stored function f1() is still there too.
SELECT mysqltest.f1();

--echo #
--echo # 4.c) DROP DATABASE which fails due to SE error and involves only
--echo #      tables in engines supporting atomic DDL should not have side
--echo #      effects/should be rolled back.
SET SESSION DEBUG='+d,rm_db_fail_after_dropping_tables';
--error ER_UNKNOWN_ERROR
DROP DATABASE mysqltest;
SET SESSION DEBUG='-d,rm_db_fail_after_dropping_tables';
--echo # Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
SELECT * FROM mysqltest.t_i_2;
--echo # Stored function f1() is still there too.
SELECT mysqltest.f1();

--echo #
--echo # 4.d) DROP DATABASE which fails due to failure to drop routine
--echo #      might have side effect. Tables in engines which do not
--echo #      support atomic DDL stay dropped. Removal of InnoDB tables
--echo #      should be rolled back.
CREATE TABLE mysqltest.t_m (t_m INT) ENGINE=MyISAM;
SET SESSION DEBUG='+d,fail_drop_db_routines';
--error ER_SP_DROP_FAILED
DROP DATABASE mysqltest;
SET SESSION DEBUG='-d,fail_drop_db_routines';
--error ER_NO_SUCH_TABLE
SELECT * FROM mysqltest.t_m;
--echo # Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
SELECT * FROM mysqltest.t_i_2;
--echo # Stored function f1() is still there too.
SELECT mysqltest.f1();

DROP DATABASE mysqltest;

--echo #
--echo # 5) Binary logging and GTID handling for DROP DATABASE.
--echo #
--echo # GTID handling and Binary logging for successfull and
--echo # failed DROP DATABASE statement are covered by
--echo # rpl_gtid/no_gtid_split_statements_debug tests.
--echo #


--echo #
--echo # Additional coverage for hidden tables handling by DROP DATABASE.
--echo #

CREATE DATABASE mysqltest;

--echo # Create hidden '#sql...' table in mysqltest by starting
--echo # non-atomic ALTER TABLE and crashing the server in the
--echo # middle of it.
CREATE TABLE mysqltest.t1 (i INT) ENGINE=MYISAM;
--source include/expect_crash.inc
SET DEBUG='+d,crash_copy_before_commit';
--error 2013
ALTER TABLE mysqltest.t1 ADD COLUMN j INT;

--source include/start_mysqld.inc

--echo # Check that after restart this hidden table is there.
let $MYSQLD_DATADIR= `SELECT @@global.datadir`;
--replace_regex /#sql.*\./#sqlXXXX./
--list_files $MYSQLD_DATADIR/mysqltest *.MYD
--echo # And that DROP DATABASE can remove this table, without problems.
DROP DATABASE mysqltest;


--echo #
--echo # Bug#28923782: DD CRASHES ON ASSERT IF HA_COMMIT_TRANS() RETURNS ERROR
--echo #
--echo # Check result of ha_commit_trans() before committing changes of the DD
--echo # objects.
--echo #

CREATE TABLE t(i INT);
SET debug = '+d,simulate_failure_in_before_commit_hook';

--echo # This test case works only with binlogging, because it depends on the
--echo # 2pc coordinated by the binlog. Hence, to avoid failure when running
--echo # the test with --skip-log-bin, we temporarily suppress the query- and
--echo # result log.

--disable_query_log
--disable_result_log
if (`SELECT @@global.log_bin`)
{
  # Before the patch, this would fail with an assert due to an inconsistency
  # between the state of the DD cache and the contents of the DD tables.
  --error ER_RUN_HOOK_ERROR
  DROP TABLE t;
}
--enable_result_log
--enable_query_log

SET debug = '-d,simulate_failure_in_before_commit_hook';
DROP TABLE t;