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
|
--source include/have_debug.inc
--source include/not_valgrind.inc
--source include/not_embedded.inc
#
# Testing of atomic rename with crashes in a lot of different places
#
let $crash_count=4;
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';
# Number of renames in the tested statement
let $renames=5;
let $old_debug=`select @@debug_dbug`;
let $e=0;
--disable_query_log
create table t1 (a int not null);
create table t2 (b int not null);
create table t3 (c int not null);
create table t4 (d int not null);
insert into t1 values(1);
insert into t2 values(2);
insert into t3 values(3);
insert into t4 values(4);
create view v1 as select t1.a from t1;
create view v2 as select t2.b from t2;
create view v3 as select t3.c from t3;
create view v4 as select t4.d from t4;
flush tables;
let $c=0;
while ($c < $crash_count)
{
inc $c;
let $crash=`select ELT($c, $crash_points)`;
let $r=0;
while ($r < $renames)
{
inc $r;
echo "engine: crash point: $crash position: $r";
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--disable_reconnect
--eval set @@debug_dbug="+d,$crash",@debug_crash_counter=$r
let $errno=0;
--error 0,2013
rename table v1 to v5, v2 to v1, v5 to v2, v4 to v5, v3 to v4;
let $error=$errno;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_query_log
--eval set @@debug_dbug="$old_debug"
if ($error == 0)
{
echo "No crash!";
# No crash, rename things back
rename table v4 to v3, v5 to v4, v2 to v5, v1 to v2, v5 to v1;
}
# Ensure that the tables are back to original
let $res=`select v1.a+v2.b+v3.c+v4.d from v1,v2,v3,v4`;
if ($res != 10)
{
die "Got result $res when 10 was expected";
}
}
}
--echo #
--echo # At last check that rename works when there is no crash
--echo #
rename table v1 to v5, v2 to v1, v5 to v2, v4 to v5, v3 to v4;
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)`;
if ($res != 10)
{
die "Got result $res when 10 was expected";
}
drop view v1,v2,v4,v5;
drop table t1,t2,t3,t4;
--enable_query_log
|