~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_alter_table_online2.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#############################################################
 
2
# Author: Tomas
 
3
# Date: 2007-09
 
4
# Purpose: online alter under load test
 
5
##############################################################
 
6
# Change Author: Jonathan
 
7
# Date 2007-10
 
8
# Purpose: Add testing for online alter w/partitions
 
9
#          and some original test cleanup and additions
 
10
##############################################################
 
11
--source include/ndb_have_online_alter.inc
 
12
-- source include/have_multi_ndb.inc
 
13
# test uses mysqlslap, hence not in embedded
 
14
-- source include/not_embedded.inc
 
15
# mysqlslap seems to be not_windows. remove this when removed from mysqlslap.test
 
16
-- source include/not_windows.inc
 
17
# -- source include/have_log_bin.inc
 
18
 
 
19
--disable_warnings
 
20
DROP TABLE IF EXISTS t1;
 
21
CREATE DATABASE IF NOT EXISTS mysqlslap;
 
22
--enable_warnings
 
23
 
 
24
# Create utiltity table used to hold the output from ndb_show_table
 
25
CREATE TEMPORARY TABLE IF NOT EXISTS ndb_show_tables_results (
 
26
  id INT,
 
27
  type VARCHAR(20),
 
28
  state VARCHAR(20),
 
29
  logging VARCHAR(20),
 
30
  _database VARCHAR(255),
 
31
  _schema VARCHAR(20),
 
32
  name VARCHAR(255)
 
33
);
 
34
 
 
35
 
 
36
--echo
 
37
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
38
--echo ~ basic online alter test during load
 
39
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
40
--echo
 
41
 
 
42
create table t1 (pk int key, a int) engine ndb;
 
43
insert into t1 values (1,0);
 
44
 
 
45
--source ndb_show_tables_result.inc
 
46
set @t1_id = (select id from ndb_show_tables_results where name like '%t1%' and type like '%UserTable%');
 
47
 
 
48
--echo
 
49
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
50
--echo ~ Starting mysqlslap
 
51
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
52
--echo
 
53
 
 
54
let $end_mysqlslap= 5000;
 
55
--exec $MYSQL_SLAP --query="update test.t1 set a=a+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
56
 
 
57
# wait for 100 updates
 
58
--disable_result_log
 
59
--disable_query_log
 
60
select @end:=100;
 
61
let $val= 1;
 
62
while ($val)
 
63
{
 
64
  --sleep 0.1
 
65
  select @val:=a from t1 where pk=1;
 
66
  let $val= `select @end > @val `;
 
67
}
 
68
--enable_result_log
 
69
--enable_query_log
 
70
 
 
71
--echo
 
72
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
73
--echo ~ Alter table t1 add column b
 
74
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 
75
--echo
 
76
 
 
77
# add a column online
 
78
ALTER ONLINE TABLE t1 ADD b INT;
 
79
 
 
80
--echo
 
81
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
82
--echo ~ Check table t1 ID has not changed
 
83
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
84
--echo
 
85
 
 
86
--source ndb_show_tables_result.inc
 
87
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
 
88
 
 
89
--echo
 
90
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
91
--echo ~ Starting mysqlslap using column b
 
92
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 
93
--echo
 
94
 
 
95
update t1 set b= 0;
 
96
--exec $MYSQL_SLAP --query="update test.t1 set b=b+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
97
 
 
98
# wait for 100 updates
 
99
--disable_result_log
 
100
--disable_query_log
 
101
select @end:=100;
 
102
let $val= 1;
 
103
while ($val)
 
104
{
 
105
  --sleep 0.1
 
106
  select @val:=b from t1 where pk=1;
 
107
  let $val= `select @end > @val`;
 
108
}
 
109
--enable_result_log
 
110
--enable_query_log
 
111
 
 
112
--echo
 
113
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
114
--echo ~ Alter table t1 add column c
 
115
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
116
--echo
 
117
 
 
118
# add a column online
 
119
ALTER ONLINE TABLE t1 ADD c INT;
 
120
 
 
121
--echo
 
122
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
123
--echo ~ Check table t1 ID has not changed
 
124
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
125
--echo
 
126
 
 
127
--source ndb_show_tables_result.inc
 
128
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
 
129
 
 
130
--echo
 
131
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
132
--echo ~ Starting mysqlslap using column c
 
133
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
134
--echo
 
135
 
 
136
update t1 set c= 0;
 
137
--exec $MYSQL_SLAP --query="update test.t1 set c=c+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
138
 
 
139
# wait for mysqlslap to end
 
140
--disable_result_log
 
141
--disable_query_log
 
142
--eval select @end:=$end_mysqlslap
 
143
let $val= 1;
 
144
# 10 minutes = 600s sleep 0.1 => 6000
 
145
let $maxwait = 6000;
 
146
while ($val)
 
147
{
 
148
  --sleep 0.1
 
149
  select @val1:=a,@val2:=b,@val3:=c from t1 where pk=1;
 
150
  let $val= `select @end > @val1 || @end > @val2 || @end > @val3`;
 
151
  dec $maxwait;
 
152
 
 
153
  if (!$maxwait)
 
154
  {
 
155
    let $val = 0;
 
156
  }
 
157
}
 
158
--enable_result_log
 
159
--enable_query_log
 
160
 
 
161
select * from t1;
 
162
 
 
163
--echo
 
164
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
165
--echo ~ Alter table t1 and try to add partitions
 
166
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
167
--echo
 
168
 
 
169
--error ER_NOT_SUPPORTED_YET
 
170
ALTER ONLINE TABLE t1 PARTITION BY HASH(pk);
 
171
 
 
172
--echo
 
173
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
174
--echo ~ Check table t1 ID has not changed
 
175
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
176
--echo
 
177
 
 
178
--source ndb_show_tables_result.inc
 
179
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
 
180
 
 
181
--echo
 
182
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
183
--echo ~ cleanup section
 
184
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
185
--echo
 
186
 
 
187
# drop the table
 
188
drop table t1, ndb_show_tables_results;
 
189
drop database mysqlslap;