~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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
#
 
14
# Test for bug #25044 "ALTER TABLE ... ENABLE KEYS acquires global
 
15
# 'opening tables' lock".
 
16
#
 
17
# ALTER TABLE ... ENABLE KEYS should not acquire LOCK_open mutex for
 
18
# the whole its duration as it prevents other queries from execution.
 
19
--disable_warnings
 
20
drop table if exists t1, t2;
 
21
--enable_warnings
 
22
connect (addconroot, localhost, root,,);
 
23
connection default;
 
24
create table t1 (n1 int, n2 int, n3 int,
 
25
                key (n1, n2, n3),
 
26
                key (n2, n3, n1),
 
27
                key (n3, n1, n2));
 
28
create table t2 (i int);
 
29
 
 
30
# Starting from 5.1 we have runtime settable @@debug variable,
 
31
# which can be used for introducing delays at certain points of
 
32
# statement execution, so we don't need many rows in 't1' to make
 
33
# this test repeatable.
 
34
alter table t1 disable keys;
 
35
insert into t1 values (RAND()*1000, RAND()*1000, RAND()*1000);
 
36
 
 
37
# Later we use binlog to check the order in which statements are
 
38
# executed so let us reset it first.
 
39
reset master;
 
40
set session debug="+d,sleep_alter_enable_indexes";
 
41
--send alter table t1 enable keys;
 
42
connection addconroot;
 
43
--sleep 2
 
44
# This statement should not be blocked by in-flight ALTER and therefore
 
45
# should be executed and written to binlog before ALTER TABLE ... ENABLE KEYS
 
46
# finishes.
 
47
insert into t2 values (1);
 
48
# And this should wait until the end of ALTER TABLE ... ENABLE KEYS.
 
49
insert into t1 values (1, 1, 1);
 
50
connection default;
 
51
--reap
 
52
set session debug="-d,sleep_alter_enable_indexes";
 
53
# Check that statements were executed/binlogged in correct order.
 
54
--replace_column 2 # 5 #
 
55
show binlog events in 'master-bin.000001' from 106;
 
56
 
 
57
# Clean up
 
58
drop tables t1, t2;
 
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
connection addconroot;
 
80
--sleep 2
 
81
insert into t1 values ();
 
82
select * from t1;
 
83
connection default;
 
84
--reap
 
85
--send alter table t1 change c vc varchar(100) default 'Test2';
 
86
connection addconroot;
 
87
--sleep 2
 
88
rename table t1 to t2;
 
89
connection default;
 
90
--reap
 
91
drop table t2;
 
92
# And now tests for ALTER TABLE with RENAME clause. In this
 
93
# case target table name should be properly locked as well.
 
94
create table t1 (i int);
 
95
--send alter table t1 change i c char(10) default 'Test3', rename to t2;
 
96
connection addconroot;
 
97
--sleep 2
 
98
insert into t2 values ();
 
99
select * from t2;
 
100
connection default;
 
101
--reap
 
102
--send alter table t2 change c vc varchar(100) default 'Test2', rename to t1;
 
103
connection addconroot;
 
104
--sleep 2
 
105
rename table t1 to t3;
 
106
connection default;
 
107
--reap
 
108
drop table t3;
 
109
set session debug="-d,sleep_alter_before_main_binlog";
 
110
 
 
111
# Check that all statements were logged in correct order
 
112
--replace_column 2 # 5 #
 
113
show binlog events in 'master-bin.000001' from 106;
 
114
 
 
115
 
 
116
--echo End of 5.1 tests