~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
--disable_warnings
19
19
drop table if exists t1, t2;
20
20
--enable_warnings
 
21
set debug_sync='RESET';
 
22
 
21
23
connect (addconroot, localhost, root,,);
 
24
connect (addconroot2, localhost, root,,);
22
25
connection default;
23
26
create table t1 (n1 int, n2 int, n3 int,
24
27
                key (n1, n2, n3),
26
29
                key (n3, n1, n2));
27
30
create table t2 (i int);
28
31
 
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
32
alter table t1 disable keys;
34
 
--disable_warnings
35
 
insert into t1 values (RAND()*1000, RAND()*1000, RAND()*1000);
36
 
--enable_warnings
 
33
insert into t1 values (1, 2, 3);
37
34
 
38
35
# Later we use binlog to check the order in which statements are
39
36
# executed so let us reset it first.
40
37
reset master;
41
 
set session debug="+d,sleep_alter_enable_indexes";
 
38
set debug_sync='alter_table_enable_indexes SIGNAL parked WAIT_FOR go';
42
39
--send alter table t1 enable keys;
43
40
connection addconroot;
44
 
--sleep 2
 
41
# Wait until ALTER TABLE acquires metadata lock.
 
42
set debug_sync='now WAIT_FOR parked';
45
43
# This statement should not be blocked by in-flight ALTER and therefore
46
44
# should be executed and written to binlog before ALTER TABLE ... ENABLE KEYS
47
45
# finishes.
48
46
insert into t2 values (1);
49
47
# And this should wait until the end of ALTER TABLE ... ENABLE KEYS.
50
 
insert into t1 values (1, 1, 1);
51
 
connection default;
52
 
--reap
53
 
set session debug="-d,sleep_alter_enable_indexes";
 
48
--send insert into t1 values (1, 1, 1);
 
49
connection addconroot2;
 
50
# Wait until the above INSERT INTO t1 is blocked due to ALTER
 
51
let $wait_condition=
 
52
    select count(*) = 1 from information_schema.processlist
 
53
    where state = "Waiting for table metadata lock" and
 
54
          info = "insert into t1 values (1, 1, 1)";
 
55
--source include/wait_condition.inc
 
56
# Resume ALTER execution.
 
57
set debug_sync='now SIGNAL go';
 
58
connection default;
 
59
--reap
 
60
connection addconroot;
 
61
--reap
 
62
connection default;
54
63
# Check that statements were executed/binlogged in correct order.
55
64
source include/show_binlog_events.inc;
56
65
 
57
66
# Clean up
58
67
drop tables t1, t2;
59
68
disconnect addconroot;
60
 
 
 
69
disconnect addconroot2;
 
70
set debug_sync='RESET';
61
71
 
62
72
--echo End of 5.0 tests
63
73
 
72
82
--disable_warnings
73
83
drop table if exists t1, t2, t3;
74
84
--enable_warnings
 
85
connect (addconroot, localhost, root,,);
 
86
connect (addconroot2, localhost, root,,);
 
87
connection default;
75
88
create table t1 (i int);
76
89
# We are going to check that statements are logged in correct order
77
90
reset master;
78
 
set session debug="+d,sleep_alter_before_main_binlog";
 
91
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
79
92
--send alter table t1 change i c char(10) default 'Test1';
80
 
connect (addconroot, localhost, root,,);
81
 
connection addconroot;
82
 
--sleep 2
83
 
insert into t1 values ();
 
93
connection addconroot;
 
94
# Wait until ALTER TABLE acquires metadata lock.
 
95
set debug_sync='now WAIT_FOR parked'; 
 
96
--send insert into t1 values ();
 
97
connection addconroot2;
 
98
# Wait until the above INSERT INTO t1 is blocked due to ALTER
 
99
let $wait_condition=
 
100
    select count(*) = 1 from information_schema.processlist
 
101
    where state = "Waiting for table metadata lock" and
 
102
          info = "insert into t1 values ()";
 
103
--source include/wait_condition.inc
 
104
# Resume ALTER execution.
 
105
set debug_sync='now SIGNAL go';
 
106
connection default;
 
107
--reap
 
108
connection addconroot;
 
109
--reap
 
110
connection default;
84
111
select * from t1;
85
 
connection default;
86
 
--reap
 
112
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
87
113
--send alter table t1 change c vc varchar(100) default 'Test2';
88
114
connection addconroot;
89
 
--sleep 2
90
 
rename table t1 to t2;
91
 
connection default;
92
 
--reap
 
115
# Wait until ALTER TABLE acquires metadata lock.
 
116
set debug_sync='now WAIT_FOR parked';
 
117
--send rename table t1 to t2;
 
118
connection addconroot2;
 
119
# Wait until the above RENAME TABLE is blocked due to ALTER
 
120
let $wait_condition=
 
121
    select count(*) = 1 from information_schema.processlist
 
122
    where state = "Waiting for table metadata lock" and
 
123
          info = "rename table t1 to t2";
 
124
--source include/wait_condition.inc
 
125
# Resume ALTER execution.
 
126
set debug_sync='now SIGNAL go';
 
127
connection default;
 
128
--reap
 
129
connection addconroot;
 
130
--reap
 
131
connection default;
93
132
drop table t2;
94
133
# And now tests for ALTER TABLE with RENAME clause. In this
95
134
# case target table name should be properly locked as well.
96
135
create table t1 (i int);
 
136
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
97
137
--send alter table t1 change i c char(10) default 'Test3', rename to t2;
98
138
connection addconroot;
99
 
--sleep 2
100
 
insert into t2 values ();
 
139
# Wait until ALTER TABLE acquires metadata lock.
 
140
set debug_sync='now WAIT_FOR parked';
 
141
--send insert into t2 values();
 
142
connection addconroot2;
 
143
# Wait until the above INSERT INTO t2 is blocked due to ALTER
 
144
let $wait_condition=
 
145
    select count(*) = 1 from information_schema.processlist
 
146
    where state = "Waiting for table metadata lock" and
 
147
           info = "insert into t2 values()";
 
148
--source include/wait_condition.inc
 
149
# Resume ALTER execution.
 
150
set debug_sync='now SIGNAL go';
 
151
connection default;
 
152
--reap
 
153
connection addconroot;
 
154
--reap
 
155
connection default;
101
156
select * from t2;
102
 
connection default;
103
 
--reap
104
157
--send alter table t2 change c vc varchar(100) default 'Test2', rename to t1;
105
158
connection addconroot;
106
 
--sleep 2
 
159
connection default;
 
160
--reap
107
161
rename table t1 to t3;
108
 
connection default;
109
 
--reap
 
162
 
110
163
disconnect addconroot;
 
164
disconnect addconroot2;
111
165
drop table t3;
112
 
set session debug="-d,sleep_alter_before_main_binlog";
 
166
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
 
167
set debug_sync='RESET';
113
168
 
114
169
# Check that all statements were logged in correct order
115
170
source include/show_binlog_events.inc;
116
171
 
117
172
 
118
173
--echo End of 5.1 tests
119