~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/alter_table-big.test

Cleanup around SAFEMALLOC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Tests for various concurrency-related aspects of ALTER TABLE implemetation
 
3
#
 
4
# This test takes rather long time so let us run it only in --big-test mode
 
5
--source include/big_test.inc
 
6
# Also we are using SBR to check that statements are executed
 
7
# in proper order.
 
8
--source include/have_binlog_format_mixed_or_statement.inc
 
9
 
 
10
 
 
11
#
 
12
# Test for bug #25044 "ALTER TABLE ... ENABLE KEYS acquires global
 
13
# 'opening tables' lock".
 
14
#
 
15
# ALTER TABLE ... ENABLE KEYS should not acquire LOCK_open mutex for
 
16
# the whole its duration as it prevents other queries from execution.
 
17
--disable_warnings
 
18
drop table if exists t1, t2;
 
19
--enable_warnings
 
20
connect (addconroot, localhost, root,,);
 
21
connection default;
 
22
create table t1 (n1 int, n2 int, n3 int,
 
23
                key (n1, n2, n3),
 
24
                key (n2, n3, n1),
 
25
                key (n3, n1, n2));
 
26
create table t2 (i int);
 
27
 
 
28
# Starting from 5.1 we have runtime settable @@debug variable,
 
29
# which can be used for introducing delays at certain points of
 
30
# statement execution, so we don't need many rows in 't1' to make
 
31
# this test repeatable.
 
32
alter table t1 disable keys;
 
33
insert into t1 values (RAND()*1000, RAND()*1000, RAND()*1000);
 
34
 
 
35
# Later we use binlog to check the order in which statements are
 
36
# executed so let us reset it first.
 
37
reset master;
 
38
--send alter table t1 enable keys;
 
39
connection addconroot;
 
40
--sleep 2
 
41
# This statement should not be blocked by in-flight ALTER and therefore
 
42
# should be executed and written to binlog before ALTER TABLE ... ENABLE KEYS
 
43
# finishes.
 
44
insert into t2 values (1);
 
45
# And this should wait until the end of ALTER TABLE ... ENABLE KEYS.
 
46
insert into t1 values (1, 1, 1);
 
47
connection default;
 
48
--reap
 
49
# Check that statements were executed/binlogged in correct order.
 
50
--replace_column 2 # 5 #
 
51
show binlog events in 'master-bin.000001' from 106;
 
52
 
 
53
# Clean up
 
54
drop tables t1, t2;
 
55
 
 
56
 
 
57
--echo End of 5.0 tests
 
58
 
 
59
#
 
60
# Additional coverage for the main ALTER TABLE case
 
61
#
 
62
# We should be sure that table being altered is properly
 
63
# locked during statement execution and in particular that
 
64
# no DDL or DML statement can sneak in and get access to
 
65
# the table when real operation has already taken place
 
66
# but this fact has not been noted in binary log yet.
 
67
--disable_warnings
 
68
drop table if exists t1, t2, t3;
 
69
--enable_warnings
 
70
create table t1 (i int);
 
71
# We are going to check that statements are logged in correct order
 
72
reset master;
 
73
--send alter table t1 change i c char(10) default 'Test1';
 
74
connection addconroot;
 
75
--sleep 2
 
76
insert into t1 values ();
 
77
select * from t1;
 
78
connection default;
 
79
--reap
 
80
--send alter table t1 change c vc varchar(100) default 'Test2';
 
81
connection addconroot;
 
82
--sleep 2
 
83
rename table t1 to t2;
 
84
connection default;
 
85
--reap
 
86
drop table t2;
 
87
# And now tests for ALTER TABLE with RENAME clause. In this
 
88
# case target table name should be properly locked as well.
 
89
create table t1 (i int);
 
90
--send alter table t1 change i c char(10) default 'Test3', rename to t2;
 
91
connection addconroot;
 
92
--sleep 2
 
93
insert into t2 values ();
 
94
select * from t2;
 
95
connection default;
 
96
--reap
 
97
--send alter table t2 change c vc varchar(100) default 'Test2', rename to t1;
 
98
connection addconroot;
 
99
--sleep 2
 
100
rename table t1 to t3;
 
101
connection default;
 
102
--reap
 
103
drop table t3;
 
104
 
 
105
# Check that all statements were logged in correct order
 
106
--replace_column 2 # 5 #
 
107
show binlog events in 'master-bin.000001' from 106;
 
108
 
 
109
 
 
110
--echo End of 5.1 tests