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