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

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_dd_alter.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
# Author: JBM
 
3
# Date: 2006-01-12
 
4
# Purpose: To test using ndb memory and disk tables together.
 
5
##############################################################
 
6
 
 
7
##############################################################
 
8
# Author: Nikolay
 
9
# Date: 2006-05-12
 
10
# Purpose: To test using ndb memory and disk tables together.
 
11
#
 
12
# Select from disk into memory table
 
13
# Select from disk into memory table
 
14
# Create test that loads data, use mysql dump to dump data, drop table,
 
15
# create table and load from mysql dump.
 
16
# Use group by asc and dec; Use having; Use order by
 
17
# ALTER Tests (Meta data testing):
 
18
#  ALTER from InnoDB to Cluster Disk Data
 
19
#  ALTER from MyISAM to Cluster Disk Data
 
20
#  ALTER from Cluster Disk Data to InnoDB
 
21
#  ALTER from Cluster Disk Data to MyISAM
 
22
#  ALTER DD Tables and add columns
 
23
#  ALTER DD Tables and add Indexes
 
24
#  ALTER DD Tables and drop columns
 
25
#
 
26
##############################################################
 
27
# Author: Jonathan
 
28
# Date 2006-08-28
 
29
# Purpose: To take out some of the test that are already
 
30
#          Covered by other tests. Per Jonas
 
31
#          The new purpose of this test is testing "Alter"
 
32
#          Statements. Therefore the name is changed to
 
33
#          ndb_dd_alter.test
 
34
# Removed tests include:
 
35
# Select from disk into memory table
 
36
# Select from disk into memory table
 
37
# Create test that loads data, use mysql dump to dump data, drop table,
 
38
# create table and load from mysql dump.
 
39
# Use group by asc and dec; Use having; Use order by
 
40
##############################################################
 
41
 
 
42
-- source include/have_ndb.inc
 
43
-- source include/have_innodb.inc
 
44
-- source include/not_embedded.inc
 
45
 
 
46
--disable_warnings
 
47
DROP TABLE IF EXISTS test.t1;
 
48
DROP TABLE IF EXISTS test.t2;
 
49
--enable_warnings
 
50
 
 
51
############ Test Setup Section #############
 
52
-- echo **** Test Setup Section ****
 
53
################## ALTER Tests (Meta data testing) ####################
 
54
 
 
55
 CREATE LOGFILE GROUP lg
 
56
 ADD UNDOFILE './lg_group/undofile.dat'
 
57
 INITIAL_SIZE 16M
 
58
 UNDO_BUFFER_SIZE = 1M
 
59
 ENGINE=NDB;
 
60
 
 
61
 CREATE TABLESPACE ts
 
62
 ADD DATAFILE './table_space/datafile.dat'
 
63
 USE LOGFILE GROUP lg
 
64
 INITIAL_SIZE 12M
 
65
 ENGINE NDB;
 
66
 
 
67
#### Try to ALTER from InnoDB to Cluster Disk Data
 
68
 
 
69
CREATE TABLE test.t1 (
 
70
  a1 smallint NOT NULL,
 
71
  a2 int NOT NULL,
 
72
  a3 bigint NOT NULL,
 
73
  a4 char(10),
 
74
  a5 decimal(5,1),
 
75
  a6 time,
 
76
  a7 date,
 
77
  a8 datetime,
 
78
  a9 VARCHAR(255),
 
79
  a10 blob,
 
80
  PRIMARY KEY(a1)
 
81
) ENGINE=InnoDB;
 
82
 
 
83
let $1=20;
 
84
disable_query_log;
 
85
while ($1)
 
86
{
 
87
 eval insert into test.t1 values($1, $1+1, $1+2000000000, "aaa$1", 34.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data");
 
88
 dec $1;
 
89
}
 
90
enable_query_log;
 
91
 
 
92
SHOW CREATE TABLE test.t1;
 
93
SELECT * FROM test.t1 ORDER BY a1;
 
94
ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB;
 
95
SHOW CREATE TABLE test.t1;
 
96
# Check column storage
 
97
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
98
SELECT * FROM test.t1 ORDER BY a1;
 
99
DROP TABLE test.t1;
 
100
 
 
101
#### Try to ALTER from MyISAM to Cluster Disk Data
 
102
 
 
103
CREATE TABLE test.t1 (
 
104
  a1 smallint NOT NULL,
 
105
  a2 int NOT NULL,
 
106
  a3 bigint NOT NULL,
 
107
  a4 char(10),
 
108
  a5 decimal(5,1),
 
109
  a6 time,
 
110
  a7 date,
 
111
  a8 datetime,
 
112
  a9 VARCHAR(255),
 
113
  a10 blob,
 
114
  PRIMARY KEY(a1)
 
115
) ENGINE=MyISAM;
 
116
 
 
117
let $1=20;
 
118
disable_query_log;
 
119
while ($1)
 
120
{
 
121
 eval insert into test.t1 values($1, $1+1, $1+2000000000, "aaa$1", 34.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data");
 
122
 dec $1;
 
123
}
 
124
enable_query_log;
 
125
 
 
126
SHOW CREATE TABLE test.t1;
 
127
SELECT * FROM test.t1 ORDER BY a1;
 
128
ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB;
 
129
SHOW CREATE TABLE test.t1;
 
130
# Check column storage
 
131
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
132
SELECT * FROM test.t1 ORDER BY a1;
 
133
 
 
134
#### Try to ALTER from Cluster Disk Data to InnoDB
 
135
 
 
136
ALTER TABLE test.t1 ENGINE=InnoDB;
 
137
SHOW CREATE TABLE test.t1;
 
138
SELECT * FROM test.t1 ORDER BY a1;
 
139
ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB;
 
140
SHOW CREATE TABLE test.t1;
 
141
# Check column storage
 
142
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
143
 
 
144
#### Try to ALTER from Cluster Disk Data to MyISAM
 
145
 
 
146
ALTER TABLE test.t1 ENGINE=MyISAM;
 
147
SHOW CREATE TABLE test.t1;
 
148
DROP TABLE test.t1;
 
149
 
 
150
#### Try to ALTER DD Tables and add columns
 
151
 
 
152
CREATE TABLE test.t1 (a1 INT PRIMARY KEY) TABLESPACE ts STORAGE DISK ENGINE=NDB;
 
153
 
 
154
let $1=20;
 
155
disable_query_log;
 
156
while ($1)
 
157
{
 
158
 eval insert into test.t1 values($1);
 
159
 dec $1;
 
160
}
 
161
enable_query_log;
 
162
 
 
163
SELECT * FROM test.t1 ORDER BY a1;
 
164
 
 
165
SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 
166
 
 
167
ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
 
168
 
 
169
SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 
170
 
 
171
let $1=20;
 
172
disable_query_log;
 
173
while ($1)
 
174
{
 
175
 eval update test.t1 set a2 =  $1+1.2345, a3 = $1+20000000.00 where a1 = $1;
 
176
 dec $1;
 
177
}
 
178
enable_query_log;
 
179
 
 
180
SELECT * FROM test.t1 ORDER BY a1;
 
181
 
 
182
ALTER TABLE test.t1  ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME;
 
183
 
 
184
let $1=20;
 
185
disable_query_log;
 
186
while ($1)
 
187
{
 
188
 eval update test.t1 set a4 =  0, a5 = 1, a6 = $1+23456, a7 = '2006-1-1', 
 
189
      a8 = '07:04:00' where a1 = $1;
 
190
 dec $1;
 
191
}
 
192
enable_query_log;
 
193
 
 
194
SELECT a1,a2,a3,hex(a4), a5,a6,a7,a8 FROM test.t1 ORDER BY a1;
 
195
 
 
196
ALTER TABLE test.t1 ADD a9 DATETIME, ADD a10 TINYTEXT, ADD a11 MEDIUMTEXT, ADD a12 LONGTEXT, ADD a13 TEXT, ADD a14 BLOB;
 
197
SHOW CREATE TABLE test.t1;
 
198
# Check column storage
 
199
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
200
 
 
201
disable_query_log;
 
202
set @d2 = 'dd2';
 
203
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
204
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
205
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
206
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
207
enable_query_log;
 
208
 
 
209
let $1=20;
 
210
disable_query_log;
 
211
while ($1)
 
212
{
 
213
 eval update test.t1 set a9 =  '1971-5-28 16:55:03', a10 = 'abc', a11 = 'abcdefg', 
 
214
      a12 = 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL', a13 = 'Text Field', 
 
215
      a14 = @d2 where a1 = $1;
 
216
 dec $1;
 
217
}
 
218
enable_query_log;
 
219
 
 
220
SELECT a1, a2,a3,hex(a4),a5,a6,a7,a8,a9,a10,a11,a12,a13 FROM test.t1 ORDER BY a1;
 
221
 
 
222
#### Try to ALTER DD Tables and add Indexes
 
223
 
 
224
ALTER TABLE test.t1 ADD INDEX a2_i (a2), ADD INDEX a3_i (a3);
 
225
 
 
226
SHOW CREATE TABLE test.t1;
 
227
 
 
228
# Check column storage
 
229
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
230
 
 
231
ALTER TABLE test.t1 DROP INDEX a2_i;
 
232
 
 
233
SHOW CREATE TABLE test.t1;
 
234
 
 
235
# Check column storage
 
236
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
237
 
 
238
TRUNCATE TABLE test.t1;
 
239
 
 
240
SHOW CREATE TABLE test.t1;
 
241
 
 
242
# Check column storage
 
243
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
244
 
 
245
#### Try to ALTER DD Tables and drop columns
 
246
 
 
247
 
 
248
ALTER TABLE test.t1 DROP a14;
 
249
ALTER TABLE test.t1 DROP a13;
 
250
ALTER TABLE test.t1 DROP a12;
 
251
ALTER TABLE test.t1 DROP a11;
 
252
ALTER TABLE test.t1 DROP a10;
 
253
ALTER TABLE test.t1 DROP a9;
 
254
ALTER TABLE test.t1 DROP a8;
 
255
ALTER TABLE test.t1 DROP a7;
 
256
ALTER TABLE test.t1 DROP a6;
 
257
ALTER TABLE test.t1 DROP PRIMARY KEY;
 
258
 
 
259
SHOW CREATE TABLE test.t1;
 
260
 
 
261
# Check column storage
 
262
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
 
263
 
 
264
DROP TABLE test.t1;
 
265
 
 
266
 ALTER TABLESPACE ts
 
267
 DROP DATAFILE './table_space/datafile.dat'
 
268
 ENGINE NDB;
 
269
 DROP TABLESPACE ts ENGINE NDB;
 
270
 DROP LOGFILE GROUP lg ENGINE=NDB;
 
271
 
 
272
####################### End section 4 #########################
 
273
#End 5.1 test case
 
274