~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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