| 1 |
--source include/have_debug.inc |
| 2 |
--source include/have_innodb.inc |
| 3 |
--source include/have_csv.inc |
| 4 |
--source include/have_log_bin.inc |
| 5 |
--source include/not_valgrind.inc |
| 6 |
|
| 7 |
# Speed up wait_until_connected_again.inc |
| 8 |
let NO_WSREP=1; |
| 9 |
RESET MASTER; |
| 10 |
|
| 11 |
# |
| 12 |
# Testing of atomic rename with binlogging |
| 13 |
# - First crash is before binlog is written, in which case the rename should |
| 14 |
# be reverted |
| 15 |
# - Second crash is after binlog is written, in which case the rename should hold |
| 16 |
# |
| 17 |
|
| 18 |
let $engine_count=2; |
| 19 |
let $engines='myisam', 'aria'; |
| 20 |
|
| 21 |
let $crash_count=2; |
| 22 |
let $crash_points='ddl_log_rename_before_binlog','ddl_log_rename_after_binlog'; |
| 23 |
let $crash_positions= 1; |
| 24 |
|
| 25 |
let $old_debug=`select @@debug_dbug`; |
| 26 |
|
| 27 |
let $e=0; |
| 28 |
--disable_query_log |
| 29 |
while ($e < $engine_count) |
| 30 |
{ |
| 31 |
inc $e; |
| 32 |
let $engine=`select ELT($e, $engines)`; |
| 33 |
let $default_engine=$engine; |
| 34 |
let $extra_option=; |
| 35 |
|
| 36 |
if ($engine == "aria") |
| 37 |
{ |
| 38 |
let $extra_option=transactional=1; |
| 39 |
} |
| 40 |
if ($engine == "aria_notrans") |
| 41 |
{ |
| 42 |
let $default_engine="aria"; |
| 43 |
let $extra_option=transactional=0; |
| 44 |
} |
| 45 |
|
| 46 |
--eval set @@default_storage_engine=$default_engine |
| 47 |
--eval create table t1 (a int not null) $extra_option; |
| 48 |
--eval create table t2 (b int not null) $extra_option; |
| 49 |
--eval create table t3 (c int not null) $extra_option; |
| 50 |
--eval create table t4 (d int not null) $extra_option; |
| 51 |
insert into t1 values(1); |
| 52 |
insert into t2 values(2); |
| 53 |
insert into t3 values(3); |
| 54 |
insert into t4 values(4); |
| 55 |
|
| 56 |
delimiter |; |
| 57 |
create trigger t1_trg before insert on t1 for each row |
| 58 |
begin |
| 59 |
if isnull(new.a) then |
| 60 |
set new.a:= 1000; |
| 61 |
end if; |
| 62 |
end| |
| 63 |
create trigger t2_trg before insert on t2 for each row |
| 64 |
begin |
| 65 |
if isnull(new.b) then |
| 66 |
set new.b:= 2000; |
| 67 |
end if; |
| 68 |
end| |
| 69 |
create trigger t3_trg before insert on t3 for each row |
| 70 |
begin |
| 71 |
if isnull(new.c) then |
| 72 |
set new.c:= 4000; |
| 73 |
end if; |
| 74 |
end| |
| 75 |
create trigger t4_trg before insert on t4 for each row |
| 76 |
begin |
| 77 |
if isnull(new.d) then |
| 78 |
set new.d:= 8000; |
| 79 |
end if; |
| 80 |
end| |
| 81 |
delimiter ;| |
| 82 |
|
| 83 |
let $c=0; |
| 84 |
while ($c < $crash_count) |
| 85 |
{ |
| 86 |
inc $c; |
| 87 |
let $crash=`select ELT($c, $crash_points)`; |
| 88 |
let $r=0; |
| 89 |
while ($r < $crash_positions) |
| 90 |
{ |
| 91 |
inc $r; |
| 92 |
echo "engine: $engine crash point: $crash position: $r"; |
| 93 |
flush tables; |
| 94 |
|
| 95 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 96 |
--disable_reconnect |
| 97 |
--eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 |
| 98 |
let $errno=0; |
| 99 |
--error 0,2013 |
| 100 |
rename table t1 to t5, t2 to t1, t5 to t2, t4 to t5, t3 to t4; |
| 101 |
let $error=$errno; |
| 102 |
--enable_reconnect |
| 103 |
--source include/wait_until_connected_again.inc |
| 104 |
--disable_query_log |
| 105 |
--eval set @@debug_dbug="$old_debug" |
| 106 |
|
| 107 |
if ($error == 0) |
| 108 |
{ |
| 109 |
echo "No crash!"; |
| 110 |
# No crash, rename things back |
| 111 |
rename table t4 to t3, t5 to t4, t2 to t5, t1 to t2, t5 to t1; |
| 112 |
} |
| 113 |
if ($c == 1) |
| 114 |
{ |
| 115 |
# Check that the tables are back to original |
| 116 |
let $res=`select t1.a+t2.b+t3.c+t4.d from t1,t2,t3,t4`; |
| 117 |
if ($res != 10) |
| 118 |
{ |
| 119 |
die "Got result $res when 10 was expected"; |
| 120 |
} |
| 121 |
|
| 122 |
# Ensure that triggers work |
| 123 |
insert into t1 values(null); |
| 124 |
insert into t2 values(null); |
| 125 |
insert into t3 values(null); |
| 126 |
insert into t4 values(null); |
| 127 |
let $res=`select (select sum(t1.a) from t1)+ (select sum(t2.b) from t2) + (select sum(t3.c) from t3)+ (select sum(t4.d) from t4)`; |
| 128 |
if ($res != 15010) |
| 129 |
{ |
| 130 |
die "Got result $res when 15010 was expected"; |
| 131 |
} |
| 132 |
# Restore tables |
| 133 |
delete from t1 where a > 100; |
| 134 |
delete from t2 where b > 100; |
| 135 |
delete from t3 where c > 100; |
| 136 |
delete from t4 where d > 100; |
| 137 |
} |
| 138 |
if ($c == 2) |
| 139 |
{ |
| 140 |
# Check that rename succeded |
| 141 |
insert into t1 values(null); |
| 142 |
insert into t2 values(null); |
| 143 |
insert into t5 values(null); |
| 144 |
insert into t4 values(null); |
| 145 |
let $res=`select (select sum(t1.b) from t1)+ (select sum(t2.a) from t2) + (select sum(t4.c) from t4)+ (select sum(t5.d) from t5)`; |
| 146 |
if ($res != 15010) |
| 147 |
{ |
| 148 |
die "Got result $res when 15010 was expected"; |
| 149 |
} |
| 150 |
let $res=`select (select count(*)=2 from t1) + (select count(*)=2 from t2) + (select count(*)=2 from t4)+ (select count(*)=2 from t5)`; |
| 151 |
if ($res != 4) |
| 152 |
{ |
| 153 |
die "Got result $res when 4 was expected"; |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
drop table t1,t2,t4,t5; |
| 159 |
} |
| 160 |
--enable_query_log |
| 161 |
|
| 162 |
# Show the binlogs that holds the renames |
| 163 |
--let $binlog_file=master-bin.000002 |
| 164 |
--source include/show_binlog_events.inc |
| 165 |
--let $binlog_file=master-bin.000003 |
| 166 |
--source include/show_binlog_events.inc |
| 167 |
--let $binlog_file=master-bin.000004 |
| 168 |
--source include/show_binlog_events.inc |
| 169 |
--let $binlog_file=master-bin.000005 |
| 170 |
--source include/show_binlog_events.inc |