| 1 |
--source include/have_debug.inc |
| 2 |
--source include/have_sequence.inc |
| 3 |
--source include/have_innodb.inc |
| 4 |
--source include/have_log_bin.inc |
| 5 |
--source include/not_valgrind.inc |
| 6 |
|
| 7 |
# |
| 8 |
# Testing of atomic create table with crashes in a lot of different places |
| 9 |
# |
| 10 |
# This is very similar to the alter_table.inc, but includes testing of |
| 11 |
# triggers in with ALTER TABLE .. RENAME. |
| 12 |
# |
| 13 |
|
| 14 |
--disable_query_log |
| 15 |
call mtr.add_suppression("InnoDB: .* does not exist in the InnoDB internal"); |
| 16 |
# Speed up wait_until_connected_again.inc |
| 17 |
let NO_WSREP=1; |
| 18 |
RESET MASTER; |
| 19 |
--enable_query_log |
| 20 |
let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 21 |
|
| 22 |
let $engine_count=1; |
| 23 |
let $engines='myisam','innodb'; |
| 24 |
|
| 25 |
let $crash_count=3; |
| 26 |
let $crash_points='ddl_log_alter_before_rename_triggers', 'ddl_log_alter_after_rename_triggers', 'ddl_log_alter_after_drop_original_table'; |
| 27 |
|
| 28 |
let $statement_count=3; |
| 29 |
let $statements='ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2', |
| 30 |
'ALTER TABLE t1 COMMENT "new", rename t2', |
| 31 |
'ALTER TABLE t1 change column b c int, COMMENT "new", rename t2'; |
| 32 |
|
| 33 |
# If there is a need of testing one specific state (crash point and query), |
| 34 |
# one can remove the comments below and modify them. |
| 35 |
#let $crash_count=1; |
| 36 |
#let $crash_points='ddl_log_alter_before_rename_triggers'; |
| 37 |
#let $statement_count= 1; |
| 38 |
#let $statements='ALTER TABLE t1 change column b c int, COMMENT "new", rename t2'; |
| 39 |
|
| 40 |
let $old_debug=`select @@debug_dbug`; |
| 41 |
|
| 42 |
let $e=0; |
| 43 |
let $keep_include_silent=1; |
| 44 |
let $grep_script=ALTER; |
| 45 |
--disable_query_log |
| 46 |
|
| 47 |
while ($e < $engine_count) |
| 48 |
{ |
| 49 |
inc $e; |
| 50 |
let $engine=`select ELT($e, $engines)`; |
| 51 |
let $default_engine=$engine; |
| 52 |
|
| 53 |
--echo |
| 54 |
--echo engine: $engine |
| 55 |
--echo |
| 56 |
|
| 57 |
let $r=0; |
| 58 |
while ($r < $statement_count) |
| 59 |
{ |
| 60 |
inc $r; |
| 61 |
let $statement=`select ELT($r, $statements)`; |
| 62 |
--echo |
| 63 |
--echo query: $statement |
| 64 |
--echo |
| 65 |
let $c=0; |
| 66 |
while ($c < $crash_count) |
| 67 |
{ |
| 68 |
inc $c; |
| 69 |
let $crash=`select ELT($c, $crash_points)`; |
| 70 |
|
| 71 |
--eval create table t1 (a int, b int) engine=$engine |
| 72 |
insert into t1 (a) values (1),(2); |
| 73 |
flush tables; |
| 74 |
delimiter |; |
| 75 |
create trigger t1_trg before insert on t1 for each row |
| 76 |
begin |
| 77 |
if isnull(new.a) then |
| 78 |
set new.a:= 1000; |
| 79 |
end if; |
| 80 |
end| |
| 81 |
delimiter ;| |
| 82 |
|
| 83 |
FLUSH BINARY LOGS; |
| 84 |
--let $start_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 85 |
|
| 86 |
--echo crash point: $crash |
| 87 |
if ($crash_count != 1) |
| 88 |
{ |
| 89 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 90 |
} |
| 91 |
--disable_reconnect |
| 92 |
--eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 |
| 93 |
let $errno=0; |
| 94 |
--error 0,2013 |
| 95 |
--eval $statement; |
| 96 |
let $error=$errno; |
| 97 |
--enable_reconnect |
| 98 |
--source include/wait_until_connected_again.inc |
| 99 |
--disable_query_log |
| 100 |
--eval set @@debug_dbug="$old_debug" |
| 101 |
|
| 102 |
if ($error == 0) |
| 103 |
{ |
| 104 |
echo "No crash!"; |
| 105 |
} |
| 106 |
if ($error != 0) |
| 107 |
{ |
| 108 |
--list_files $MYSQLD_DATADIR/test t* |
| 109 |
--list_files $MYSQLD_DATADIR/test *sql* |
| 110 |
# Check which tables still exists |
| 111 |
--error 0,1 |
| 112 |
--file_exists $MYSQLD_DATADIR/test/t1.frm |
| 113 |
let $error2=$errno; |
| 114 |
if ($error2 == 0) |
| 115 |
{ |
| 116 |
show create table t1; |
| 117 |
# Ensure that triggers work |
| 118 |
insert into t1 (a) values(null); |
| 119 |
select sum(a) from t1; |
| 120 |
} |
| 121 |
if ($error2 == 1) |
| 122 |
{ |
| 123 |
show create table t2; |
| 124 |
select count(*) from t2; |
| 125 |
# Ensure that triggers work |
| 126 |
insert into t2 (a) values(null); |
| 127 |
select sum(a) from t2; |
| 128 |
} |
| 129 |
|
| 130 |
--let $binlog_file=$start_binlog_file |
| 131 |
--let $binlog_output_name=master-bin.000001 |
| 132 |
if ($error) |
| 133 |
{ |
| 134 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 135 |
--let $binlog_output_name=master-bin.000002 |
| 136 |
if ($binlog_file != $start_binlog_file) |
| 137 |
{ |
| 138 |
--source include/show_binlog_events.inc |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
--disable_warnings |
| 143 |
drop table if exists t1,t2; |
| 144 |
--enable_warnings |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
--enable_query_log |