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
|
#
# Bug#21625393 : Assert condition (e->usage() == 1) failure in
# dd::cache::Shared_multi_map<T>::remove()
#
#
# Create MyISAM table, and drop it, but make drop fail
# before the object is deleted from the dd tables. Now,
# the object exists in the global data dictionary, but
# not in the SE.
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
connect con1, localhost, root;
SET SESSION DEBUG='+d,fail_while_dropping_dd_object';
DROP TABLE t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET SESSION DEBUG='-d,fail_while_dropping_dd_object';
connection default;
# Drop the table for real. Use IF EXISTS clause to ignore
# the fact that table does not exist in SE.
# Without the fix this statement will fail with assert.
DROP TABLE IF EXISTS t1;
Warnings:
Warning 1017 Can't find file: 't1' (errno: 2 - No such file or directory)
connection con1;
disconnect con1;
connection default;
#
# WL#7743 "New data dictionary: changes to DDL-related parts of SE API"
#
# Systematic test coverage for changes in DROP TABLES and DROP DATABASE
# behavior.
#
# 1) Error handling by DROP TABLES.
#
#
# 1.a) DROP TABLES statement which fails due to missing table
# 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;
# Notice that all missing tables are reported.
DROP TABLES t_m, t_i, tt_m, tt_i, t_no_such_table, t_no_such_table_either;
ERROR 42S02: Unknown table 'test.t_no_such_table,test.t_no_such_table_either'
# All tables are still there.
SELECT * FROM t_m, t_i, tt_m, tt_i;
t_m t_i tt_m tt_i
# Notice that all missing tables are reported.
DROP TEMPORARY TABLES tt_m, tt_i, tt_no_such_table, tt_no_such_table_either;
ERROR 42S02: Unknown table 'test.tt_no_such_table,test.tt_no_such_table_either'
# All tables are still there.
SELECT * FROM tt_m, tt_i;
tt_m tt_i
#
# 1.b) DROP TABLES IF EXISTS should ignore missing tables
# as expected and drop existing tables.
#
# 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;
Warnings:
Note 1051 Unknown table 'test.t_no_such_table'
Note 1051 Unknown table 'test.t_no_such_table_either'
# All existing tables are dropped.
SELECT * FROM t_m;
ERROR 42S02: Table 'test.t_m' doesn't exist
SELECT * FROM t_i;
ERROR 42S02: Table 'test.t_i' doesn't exist
CREATE TEMPORARY TABLE tt_m (tt_m INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE tt_i (tt_i INT) ENGINE=InnoDB;
# 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;
Warnings:
Note 1051 Unknown table 'test.tt_no_such_table'
Note 1051 Unknown table 'test.tt_no_such_table_either'
# All existing tables are dropped.
SELECT * FROM tt_m;
ERROR 42S02: Table 'test.tt_m' doesn't exist
SELECT * FROM tt_i;
ERROR 42S02: Table 'test.tt_i' doesn't exist
#
# 1.c) DROP TABLES which fails due to foreign key error does
# 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;
DROP TABLES t_m, t_i_1, t_i_2;
ERROR HY000: Cannot drop table 't_i_2' referenced by a foreign key constraint 't_i_3_ibfk_1' on table 't_i_3'.
# All tables are still there.
SELECT * FROM t_m;
t_m
SELECT * FROM t_i_1;
t_i_1
SELECT * FROM t_i_2;
t_i_2
#
# 1.d) DROP TABLES which fails due to SE error might have side
# effect. Tables in engines which do not support atomic DDL
# which we have managed to drop before error stay dropped.
# Removal of InnoDB tables should be rolled back.
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
DROP TABLES t_m, t_i_1;
ERROR HY000: Unknown error
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
SELECT * FROM t_m;
ERROR 42S02: Table 'test.t_m' doesn't exist
SELECT * FROM t_i_1;
t_i_1
#
# 1.e) DROP TABLES which fails due to SE error and involves only
# tables in engines supporting atomic DDL should not have
# side effects/should be rolled back.
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
DROP TABLES t_i_1, t_i_3;
ERROR HY000: Unknown error
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
SELECT * FROM t_i_1;
t_i_1
SELECT * FROM t_i_3;
t_i_3
# Clean-up.
DROP TABLES t_i_1, t_i_3, t_i_2;
#
# 2) Binary logging and GTID handling for DROP TABLES statements.
#
# 2.a) Binary logging for successfull DROP TABLES statement is
# covered by binlog_stm_mix_innodb_myisam,
# rpl_mixed_drop_create_temp_table and other similar
# tests.
#
# 2.b) Binary logging for failed DROP TABLES statement are
# additionally covered by rpl_binlog_failed_drop_table,
# rpl_gtid/no_gtid_split_statements tests.
#
# 2.c) GTID handling for DROP TABLES statement is covered by
# rpl_gtid_split_statements and
# no_binlog_gtid_next_partially_failed_stmts tests.
#
#
# 3) DROP TABLES IF EXISTS should be able to delete tables with
# entries in the data-dictionary, but absent from SE.
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
# Remove table from SE manually.
FLUSH TABLE t1;
# Plain DROP TABLES reports an error.
DROP TABLE t1;
ERROR HY000: Storage engine can't drop table 'test.t1' because it is missing. Use DROP TABLE IF EXISTS to remove it from data-dictionary.
# DROP TABLES IF EXISTS successfully drops table.
DROP TABLE IF EXISTS t1;
Warnings:
Warning 1017 Can't find file: 't1' (errno: 2 - No such file or directory)
#
# 4) Error handling by DROP DATABASE.
#
#
# 4.a) DROP DATABASE which fails due to foreign key error should
# 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;
DROP DATABASE mysqltest;
ERROR HY000: Cannot drop table 't_i_2' referenced by a foreign key constraint 't1_ibfk_1' on table 't1'.
# Database and all tables are still there.
SELECT * FROM mysqltest.t_m;
t_m
SELECT * FROM mysqltest.t_i_1;
t_i_1
SELECT * FROM mysqltest.t_i_2;
t_i_2
# Stored function f1() is still there too.
SELECT mysqltest.f1();
mysqltest.f1()
0
#
# 4.b) DROP DATABASE which fails due to SE error might have side
# effect. Tables in engines which do not support atomic DDL
# which we have managed to drop before error stay dropped.
# Removal of InnoDB tables should be rolled back.
DROP TABLE t1;
SET SESSION DEBUG='+d,rm_db_fail_after_dropping_tables';
DROP DATABASE mysqltest;
ERROR HY000: Unknown error
SET SESSION DEBUG='-d,rm_db_fail_after_dropping_tables';
SELECT * FROM mysqltest.t_m;
ERROR 42S02: Table 'mysqltest.t_m' doesn't exist
# Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
t_i_1
SELECT * FROM mysqltest.t_i_2;
t_i_2
# Stored function f1() is still there too.
SELECT mysqltest.f1();
mysqltest.f1()
0
#
# 4.c) DROP DATABASE which fails due to SE error and involves only
# tables in engines supporting atomic DDL should not have side
# effects/should be rolled back.
SET SESSION DEBUG='+d,rm_db_fail_after_dropping_tables';
DROP DATABASE mysqltest;
ERROR HY000: Unknown error
SET SESSION DEBUG='-d,rm_db_fail_after_dropping_tables';
# Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
t_i_1
SELECT * FROM mysqltest.t_i_2;
t_i_2
# Stored function f1() is still there too.
SELECT mysqltest.f1();
mysqltest.f1()
0
#
# 4.d) DROP DATABASE which fails due to failure to drop routine
# might have side effect. Tables in engines which do not
# support atomic DDL stay dropped. Removal of InnoDB tables
# should be rolled back.
CREATE TABLE mysqltest.t_m (t_m INT) ENGINE=MyISAM;
SET SESSION DEBUG='+d,fail_drop_db_routines';
DROP DATABASE mysqltest;
ERROR HY000: Failed to DROP ROUTINE
SET SESSION DEBUG='-d,fail_drop_db_routines';
SELECT * FROM mysqltest.t_m;
ERROR 42S02: Table 'mysqltest.t_m' doesn't exist
# Database and tables t_i_1, t_i_2 are still there.
SELECT * FROM mysqltest.t_i_1;
t_i_1
SELECT * FROM mysqltest.t_i_2;
t_i_2
# Stored function f1() is still there too.
SELECT mysqltest.f1();
mysqltest.f1()
0
DROP DATABASE mysqltest;
#
# 5) Binary logging and GTID handling for DROP DATABASE.
#
# GTID handling and Binary logging for successfull and
# failed DROP DATABASE statement are covered by
# rpl_gtid/no_gtid_split_statements_debug tests.
#
#
# Additional coverage for hidden tables handling by DROP DATABASE.
#
CREATE DATABASE mysqltest;
# Create hidden '#sql...' table in mysqltest by starting
# non-atomic ALTER TABLE and crashing the server in the
# middle of it.
CREATE TABLE mysqltest.t1 (i INT) ENGINE=MYISAM;
SET DEBUG='+d,crash_copy_before_commit';
ALTER TABLE mysqltest.t1 ADD COLUMN j INT;
ERROR HY000: Lost connection to MySQL server during query
# restart
# Check that after restart this hidden table is there.
#sqlXXXX.MYD
t1.MYD
# And that DROP DATABASE can remove this table, without problems.
DROP DATABASE mysqltest;
#
# Bug#28923782: DD CRASHES ON ASSERT IF HA_COMMIT_TRANS() RETURNS ERROR
#
# Check result of ha_commit_trans() before committing changes of the DD
# objects.
#
CREATE TABLE t(i INT);
SET debug = '+d,simulate_failure_in_before_commit_hook';
# This test case works only with binlogging, because it depends on the
# 2pc coordinated by the binlog. Hence, to avoid failure when running
# the test with --skip-log-bin, we temporarily suppress the query- and
# result log.
SET debug = '-d,simulate_failure_in_before_commit_hook';
DROP TABLE t;
|