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

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_partition_key.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
-- source include/have_ndb.inc
 
2
 
 
3
--disable_warnings
 
4
DROP TABLE IF EXISTS t1;
 
5
--enable_warnings
 
6
 
 
7
#
 
8
# Basic syntax test
 
9
#
 
10
 
 
11
# Support for partition key verified
 
12
CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c))
 
13
  ENGINE = NDB
 
14
  PARTITION BY KEY (a,b);
 
15
 
 
16
insert into t1 values (1,1,1,1);
 
17
select * from t1;
 
18
update t1 set d = 2 where a = 1 and b = 1 and c = 1;
 
19
select * from t1;
 
20
delete from t1;
 
21
select * from t1;
 
22
 
 
23
drop table t1;
 
24
 
 
25
# only support for partition key on primary key
 
26
--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
 
27
CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b))
 
28
  ENGINE = NDB
 
29
  PARTITION BY KEY (c);
 
30
 
 
31
CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b))
 
32
  ENGINE = NDB
 
33
  PARTITION BY KEY (a);
 
34
 
 
35
insert into t1 values 
 
36
       (1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3),
 
37
       (1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3);
 
38
 
 
39
select * from t1 order by b;
 
40
 
 
41
# BUG#33061: ORDER BY DESC becomes ASC in NDB partition pruning to one partition
 
42
select max(b) from t1 where a = 1;
 
43
select b from t1 where a = 1 order by b desc;
 
44
 
 
45
DROP TABLE t1;
 
46
 
 
47
#
 
48
# Test partition and char support
 
49
#
 
50
 
 
51
CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT,
 
52
                 PRIMARY KEY (a,b,c) USING HASH)
 
53
                 ENGINE=NDB
 
54
                 DEFAULT CHARSET=latin1
 
55
                 PARTITION BY KEY (b);
 
56
 
 
57
insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1);
 
58
 
 
59
# should show only one attribute with DISTRIBUTION KEY
 
60
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | sed 's/Version: [0-9]*//' | sed 's/\(Length of frm data: \)[0-9]*/\1#/'
 
61
 
 
62
#
 
63
# Test that explicit partition info is not shown in show create table
 
64
# result should not contain (PARTITION P0 ... etc) since this is what shows up in
 
65
# mysqldump, and we don't want that info there
 
66
#
 
67
show create table t1;
 
68
 
 
69
DROP TABLE t1;
 
70
 
 
71
#
 
72
# Bug #13155: Problem in Create Table using SHOW CREATE TABLE syntax
 
73
#
 
74
CREATE TABLE t1 (a int not null primary key)
 
75
PARTITION BY KEY(a)
 
76
(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
 
77
 
 
78
drop table t1;
 
79
 
 
80
CREATE TABLE t1 (a int not null primary key);
 
81
ALTER TABLE t1
 
82
ENGINE = NDB
 
83
PARTITION BY KEY(a)
 
84
(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
 
85
 
 
86
drop table t1;
 
87
 
 
88
CREATE TABLE t1 (a int not null primary key) ENGINE = NDB;
 
89
ALTER TABLE t1
 
90
PARTITION BY KEY(a)
 
91
(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
 
92
 
 
93
drop table t1;
 
94
 
 
95
#
 
96
# Bug #17754 Improper handling of removal of partitioning in ALTER TABLE
 
97
# Also added a number of general test cases in the same area
 
98
#
 
99
create table t1 (a int)
 
100
engine=ndb
 
101
partition by key(a)
 
102
(partition p0, partition p1);
 
103
show create table t1;
 
104
 
 
105
alter table t1 engine=heap;
 
106
show create table t1;
 
107
 
 
108
alter table t1 engine=ndb;
 
109
show create table t1;
 
110
 
 
111
alter table t1 engine=heap remove partitioning;
 
112
show create table t1;
 
113
 
 
114
alter table t1 engine=ndb
 
115
partition by key(a)
 
116
(partition p0, partition p1 engine = ndb);
 
117
show create table t1;
 
118
 
 
119
alter table t1
 
120
partition by key (a)
 
121
(partition p0 engine=ndb, partition p1 engine=ndb);
 
122
show create table t1;
 
123
 
 
124
alter table t1 remove partitioning;
 
125
show create table t1;
 
126
 
 
127
# after bug#31931 was fixed
 
128
# this is OK, since the storage engine is specified
 
129
# on table level before.
 
130
#--error ER_MIX_HANDLER_ERROR
 
131
alter table t1
 
132
partition by key(a)
 
133
(partition p0 engine=ndb, partition p1);
 
134
 
 
135
alter table t1
 
136
engine=ndb
 
137
partition by key(a)
 
138
(partition p0 engine=ndb, partition p1 engine = ndb);
 
139
show create table t1;
 
140
 
 
141
drop table t1;
 
142
 
 
143
#
 
144
# BUG 16810 Out of memory when coalesce partition
 
145
#
 
146
CREATE TABLE t1 (
 
147
  c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
 
148
  c2 TEXT NOT NULL,
 
149
  c3 INT NOT NULL,
 
150
  c4 BIT NOT NULL,
 
151
  c5 FLOAT,
 
152
  c6 VARCHAR(255),
 
153
  c7 TIMESTAMP,
 
154
  PRIMARY KEY(c1,c3))
 
155
  ENGINE=NDB
 
156
  PARTITION BY KEY(c3) PARTITIONS 5;
 
157
 
 
158
let $j= 11;
 
159
--disable_query_log
 
160
while ($j)
 
161
{
 
162
  eval INSERT INTO t1 VALUES (NULL, "Tested Remotely from Texas, USA", $j,
 
163
b'0',
 
164
                                   $j.00,"By JBM $j","2006-01-26");
 
165
  dec $j;
 
166
}
 
167
--enable_query_log
 
168
ALTER TABLE t1 COALESCE PARTITION 4;
 
169
 
 
170
DROP TABLE t1;
 
171
 
 
172
#
 
173
# Bug 16822: OPTIMIZE TABLE hangs test
 
174
#
 
175
CREATE TABLE t1 (a int primary key)
 
176
ENGINE=NDB
 
177
PARTITION BY KEY(a);
 
178
ANALYZE TABLE t1;
 
179
CHECK TABLE t1;
 
180
OPTIMIZE TABLE t1;
 
181
REPAIR TABLE t1;
 
182
ALTER TABLE t1 OPTIMIZE PARTITION p0;
 
183
ALTER TABLE t1 CHECK PARTITION p0;
 
184
ALTER TABLE t1 REPAIR PARTITION p0;
 
185
ALTER TABLE t1 ANALYZE PARTITION p0;
 
186
--error ER_ILLEGAL_HA
 
187
ALTER TABLE t1 REBUILD PARTITION p0;
 
188
DROP TABLE t1;
 
189
 
 
190
#
 
191
# BUG 16806: ALTER TABLE fails
 
192
#
 
193
CREATE TABLE t1 (
 
194
  c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
 
195
  c2 TEXT NOT NULL,
 
196
  c3 INT NOT NULL,
 
197
  PRIMARY KEY(c1,c3))
 
198
  ENGINE=NDB
 
199
  PARTITION BY KEY(c3) PARTITIONS 5;
 
200
 
 
201
ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
 
202
DROP TABLE t1;
 
203
 
 
204
CREATE TABLE t1 (
 
205
  c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
 
206
  c2 TEXT NOT NULL,
 
207
  c3 INT NOT NULL,
 
208
  PRIMARY KEY(c1,c3))
 
209
  ENGINE=NDB
 
210
  PARTITION BY KEY(c3)
 
211
  (PARTITION p0 NODEGROUP 0, PARTITION p1 NODEGROUP 0);
 
212
 
 
213
ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
 
214
SELECT NODEGROUP,PARTITION_NAME FROM information_schema.partitions WHERE
 
215
table_name = "t1";
 
216
DROP TABLE t1;
 
217
 
 
218
# bug#25587
 
219
 
 
220
CREATE TABLE t1 (
 
221
a tinyint unsigned NOT NULL,
 
222
b bigint(20) unsigned NOT NULL,
 
223
c char(12),
 
224
PRIMARY KEY (a,b)
 
225
) ENGINE ndb DEFAULT CHARSET=latin1 PARTITION BY KEY (a);
 
226
 
 
227
insert into t1 values(1,1,'1'), (2,2,'2'), (3,3,'3'), (4,4,'4'), (5,5,'5');
 
228
select * from t1 where a = 1;
 
229
select * from t1 where a = 2;
 
230
select * from t1 where a = 3;
 
231
select * from t1 where a = 4;
 
232
select * from t1 where a = 5;
 
233
delete from t1 where a = 1;
 
234
select * from t1 order by 1;
 
235
delete from t1 where a = 2;
 
236
select * from t1 order by 1;
 
237
delete from t1 where a = 3;
 
238
select * from t1 order by 1;
 
239
delete from t1 where a = 4;
 
240
select * from t1 order by 1;
 
241
delete from t1 where a = 5;
 
242
select * from t1 order by 1;
 
243
 
 
244
drop table t1;