| 1 |
--source include/have_debug.inc |
| 2 |
--source include/not_valgrind.inc |
| 3 |
--source include/not_embedded.inc |
| 4 |
|
| 5 |
# |
| 6 |
# Testing of atomic rename with crashes in a lot of different places |
| 7 |
# |
| 8 |
|
| 9 |
let $crash_count=4; |
| 10 |
let $crash_points='ddl_log_rename_before_rename_view','ddl_log_rename_after_rename_view','rename_view_after_rename_schema_file','definition_file_after_create'; |
| 11 |
|
| 12 |
# Number of renames in the tested statement |
| 13 |
let $renames=5; |
| 14 |
|
| 15 |
let $old_debug=`select @@debug_dbug`; |
| 16 |
|
| 17 |
let $e=0; |
| 18 |
|
| 19 |
--disable_query_log |
| 20 |
create table t1 (a int not null); |
| 21 |
create table t2 (b int not null); |
| 22 |
create table t3 (c int not null); |
| 23 |
create table t4 (d int not null); |
| 24 |
insert into t1 values(1); |
| 25 |
insert into t2 values(2); |
| 26 |
insert into t3 values(3); |
| 27 |
insert into t4 values(4); |
| 28 |
create view v1 as select t1.a from t1; |
| 29 |
create view v2 as select t2.b from t2; |
| 30 |
create view v3 as select t3.c from t3; |
| 31 |
create view v4 as select t4.d from t4; |
| 32 |
flush tables; |
| 33 |
|
| 34 |
let $c=0; |
| 35 |
while ($c < $crash_count) |
| 36 |
{ |
| 37 |
inc $c; |
| 38 |
let $crash=`select ELT($c, $crash_points)`; |
| 39 |
let $r=0; |
| 40 |
while ($r < $renames) |
| 41 |
{ |
| 42 |
inc $r; |
| 43 |
echo "engine: crash point: $crash position: $r"; |
| 44 |
|
| 45 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 46 |
--disable_reconnect |
| 47 |
--eval set @@debug_dbug="+d,$crash",@debug_crash_counter=$r |
| 48 |
let $errno=0; |
| 49 |
--error 0,2013 |
| 50 |
rename table v1 to v5, v2 to v1, v5 to v2, v4 to v5, v3 to v4; |
| 51 |
let $error=$errno; |
| 52 |
--enable_reconnect |
| 53 |
--source include/wait_until_connected_again.inc |
| 54 |
--disable_query_log |
| 55 |
--eval set @@debug_dbug="$old_debug" |
| 56 |
|
| 57 |
if ($error == 0) |
| 58 |
{ |
| 59 |
echo "No crash!"; |
| 60 |
# No crash, rename things back |
| 61 |
rename table v4 to v3, v5 to v4, v2 to v5, v1 to v2, v5 to v1; |
| 62 |
} |
| 63 |
|
| 64 |
# Ensure that the tables are back to original |
| 65 |
let $res=`select v1.a+v2.b+v3.c+v4.d from v1,v2,v3,v4`; |
| 66 |
if ($res != 10) |
| 67 |
{ |
| 68 |
die "Got result $res when 10 was expected"; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
--echo # |
| 74 |
--echo # At last check that rename works when there is no crash |
| 75 |
--echo # |
| 76 |
|
| 77 |
rename table v1 to v5, v2 to v1, v5 to v2, v4 to v5, v3 to v4; |
| 78 |
let $res=`select (select sum(v1.b) from v1)+ (select sum(v2.a) from v2) + (select sum(v4.c) from v4)+ (select sum(v5.d) from v5)`; |
| 79 |
if ($res != 10) |
| 80 |
{ |
| 81 |
die "Got result $res when 10 was expected"; |
| 82 |
} |
| 83 |
drop view v1,v2,v4,v5; |
| 84 |
drop table t1,t2,t3,t4; |
| 85 |
--enable_query_log |