~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_range.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
#--disable_abort_on_error
 
3
#
 
4
# Simple test for the partition storage engine
 
5
# Focuses on range partitioning tests
 
6
 
7
#-- source include/have_partition.inc
 
8
 
 
9
--disable_query_log
 
10
set new=on;
 
11
--enable_query_log
 
12
 
 
13
--disable_warnings
 
14
drop table if exists t1;
 
15
--enable_warnings
 
16
 
 
17
#
 
18
# Partition by range, basic
 
19
#
 
20
CREATE TABLE t1 (
 
21
a int not null,
 
22
b int not null,
 
23
c int not null,
 
24
primary key(a,b),
 
25
index (a))
 
26
engine = ndb
 
27
partition by range (a)
 
28
partitions 3
 
29
(partition x1 values less than (5),
 
30
 partition x2 values less than (10),
 
31
 partition x3 values less than (20));
 
32
 
 
33
# Simple insert and verify test
 
34
INSERT into t1 values (1, 1, 1);
 
35
INSERT into t1 values (6, 1, 1);
 
36
INSERT into t1 values (10, 1, 1);
 
37
INSERT into t1 values (15, 1, 1);
 
38
 
 
39
--replace_column 16 # 19 # 20 #
 
40
select * from information_schema.partitions where table_name= 't1';
 
41
 
 
42
select * from t1 order by a;
 
43
 
 
44
select * from t1 where a=1 order by a;
 
45
select * from t1 where a=15 and b=1 order by a;
 
46
select * from t1 where a=21 and b=1 order by a;
 
47
select * from t1 where a=21 order by a;
 
48
select * from t1 where a in (1,6,10,21) order by a;
 
49
select * from t1 where b=1 and a in (1,6,10,21) order by a;
 
50
 
 
51
# BUG#33061: ORDER BY DESC becomes ASC in NDB partition pruning to one partition
 
52
INSERT into t1 values (1, 2, 2);
 
53
select max(b) from t1 where a = 1;
 
54
select b from t1 where a = 1 order by b desc;
 
55
 
 
56
drop table t1;
 
57
 
 
58
#
 
59
# Partition by range, basic
 
60
#
 
61
CREATE TABLE t1 (
 
62
a int not null,
 
63
b int not null,
 
64
c int not null,
 
65
primary key(b),
 
66
unique (a))
 
67
engine = ndb
 
68
partition by range (b)
 
69
partitions 3
 
70
(partition x1 values less than (5),
 
71
 partition x2 values less than (10),
 
72
 partition x3 values less than (20));
 
73
 
 
74
# Simple insert and verify test
 
75
INSERT into t1 values (1, 1, 1);
 
76
INSERT into t1 values (2, 6, 1);
 
77
INSERT into t1 values (3, 10, 1);
 
78
INSERT into t1 values (4, 15, 1);
 
79
 
 
80
select * from t1 order by a;
 
81
UPDATE t1 set a = 5 WHERE b = 15;
 
82
select * from t1 order by a;
 
83
UPDATE t1 set a = 6 WHERE a = 5;
 
84
select * from t1 order by a;
 
85
 
 
86
select * from t1 where b=1 order by b;
 
87
select * from t1 where b=15 and a=1 order by b;
 
88
select * from t1 where b=21 and a=1 order by b;
 
89
select * from t1 where b=21 order by b;
 
90
select * from t1 where b in (1,6,10,21) order by b;
 
91
select * from t1 where a in (1,2,5,6) order by b;
 
92
select * from t1 where a=1 and b in (1,6,10,21) order by b;
 
93
 
 
94
DELETE from t1 WHERE b = 6;
 
95
DELETE from t1 WHERE a = 6;
 
96
 
 
97
#
 
98
# Test that explicit partition info _is_ shown in show create table
 
99
# result _should_ contain (PARTITION x1 ... etc)
 
100
#
 
101
show create table t1;
 
102
 
 
103
drop table t1;
 
104
 
 
105
#
 
106
# Bug #17499, #17687
 
107
#  Alter partitioned NDB table causes mysqld to core
 
108
#
 
109
 
 
110
CREATE TABLE t1
 
111
       (id MEDIUMINT NOT NULL,
 
112
        b1 BIT(8),
 
113
        vc VARCHAR(255),
 
114
        bc CHAR(255),
 
115
        d DECIMAL(10,4) DEFAULT 0,
 
116
        f FLOAT DEFAULT 0,
 
117
        total BIGINT UNSIGNED,
 
118
        y YEAR,
 
119
        t DATE) ENGINE=NDB
 
120
   PARTITION BY RANGE (YEAR(t))
 
121
       (PARTITION p0 VALUES LESS THAN (1901),
 
122
        PARTITION p1 VALUES LESS THAN (1946),
 
123
        PARTITION p2 VALUES LESS THAN (1966),
 
124
        PARTITION p3 VALUES LESS THAN (1986),
 
125
        PARTITION p4 VALUES LESS THAN (2005),
 
126
        PARTITION p5 VALUES LESS THAN MAXVALUE);
 
127
 
 
128
INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 
129
SELECT * FROM t1;
 
130
ALTER TABLE t1 ENGINE=MYISAM;
 
131
SELECT * FROM t1;
 
132
DROP TABLE t1;
 
133
 
 
134
CREATE LOGFILE GROUP lg1
 
135
  ADD UNDOFILE 'undofile.dat'
 
136
  INITIAL_SIZE 16M
 
137
  UNDO_BUFFER_SIZE=1M
 
138
  ENGINE=NDB;
 
139
 
 
140
CREATE TABLESPACE ts1
 
141
  ADD DATAFILE 'datafile.dat'
 
142
  USE LOGFILE GROUP lg1
 
143
  INITIAL_SIZE 12M
 
144
  ENGINE NDB;
 
145
 
 
146
CREATE TABLE test.t1 (
 
147
  a1 INT,
 
148
  a2 TEXT NOT NULL,
 
149
  a3 BIT NOT NULL,
 
150
  a4 DECIMAL(8,3),
 
151
  a5 INT NOT NULL,
 
152
  a6 INT,
 
153
  PRIMARY KEY(a1))
 
154
  TABLESPACE ts1 STORAGE DISK ENGINE=NDB
 
155
  PARTITION BY LIST (a1)
 
156
 (PARTITION p0 VALUES IN (1,2,3,4,5),
 
157
  PARTITION p1 VALUES IN (6,7,8,9, 10),
 
158
  PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
 
159
 
 
160
# Alter table directly without any statements inbetween
 
161
ALTER TABLE test.t1 DROP COLUMN a6;
 
162
ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255);
 
163
 
 
164
let $j= 15;
 
165
--disable_query_log
 
166
while ($j)
 
167
{
 
168
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
 
169
b'1',$j.00,$j+1,"By NIK $j");
 
170
dec $j;
 
171
}
 
172
--enable_query_log
 
173
SELECT COUNT(*) FROM test.t1;
 
174
 
 
175
ALTER TABLE test.t1 DROP COLUMN a4;
 
176
SELECT COUNT(*) FROM test.t1;
 
177
 
 
178
DROP TABLE t1;
 
179
 
 
180
CREATE TABLE test.t1 (
 
181
  a1 INT,
 
182
  a2 TEXT NOT NULL,
 
183
  a3 BIT NOT NULL,
 
184
  a4 DECIMAL(8,3),
 
185
  a5 INT NOT NULL,
 
186
  a6 VARCHAR(255),
 
187
  PRIMARY KEY(a1))
 
188
  TABLESPACE ts1 STORAGE DISK ENGINE=NDB
 
189
  PARTITION BY HASH(a1)
 
190
  PARTITIONS 4;
 
191
 
 
192
let $j= 15;
 
193
--disable_query_log
 
194
while ($j)
 
195
{
 
196
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
 
197
b'1',$j.00,$j+1,"By NIK $j");
 
198
dec $j;
 
199
}
 
200
--enable_query_log
 
201
SELECT COUNT(*) FROM test.t1;
 
202
 
 
203
ALTER TABLE test.t1 DROP COLUMN a4;
 
204
SELECT COUNT(*) FROM test.t1;
 
205
 
 
206
DROP TABLE t1;
 
207
 
 
208
ALTER TABLESPACE ts1 
 
209
  DROP DATAFILE 'datafile.dat' 
 
210
  ENGINE=NDB;
 
211
DROP TABLESPACE ts1 ENGINE=NDB;
 
212
DROP LOGFILE GROUP lg1 ENGINE=NDB;
 
213
 
 
214
 
 
215
#
 
216
# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test
 
217
#
 
218
 
 
219
CREATE TABLE t1
 
220
    (id MEDIUMINT NOT NULL,
 
221
     b1 BIT(8),
 
222
     vc VARCHAR(255),
 
223
     bc CHAR(255),
 
224
     d DECIMAL(10,4) DEFAULT 0,
 
225
     f FLOAT DEFAULT 0,
 
226
     total BIGINT UNSIGNED,
 
227
     y YEAR,
 
228
     t DATE) ENGINE=NDB
 
229
  PARTITION BY LIST(id)
 
230
    (PARTITION p0 VALUES IN (2, 4),
 
231
     PARTITION p1 VALUES IN (42, 142));
 
232
 
 
233
INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 
234
SELECT * FROM t1;
 
235
ALTER TABLE t1 ADD PARTITION
 
236
    (PARTITION p2 VALUES IN (412));
 
237
SELECT * FROM t1;
 
238
DROP TABLE t1;
 
239
 
 
240
#
 
241
# Bug #17806 Update on NDB table with list partition causes mysqld to core
 
242
# Bug #16385 Partitions: crash when updating a range partitioned NDB table
 
243
#
 
244
CREATE TABLE t1 (
 
245
a int not null,
 
246
b int not null,
 
247
c int not null)
 
248
partition by list(a)
 
249
partitions 2
 
250
(partition x123 values in (1,5,6),
 
251
 partition x234 values in (4,7,8));
 
252
INSERT into t1 VALUES (5,1,1);
 
253
select * from t1;
 
254
UPDATE t1 SET a=8 WHERE a=5 AND b=1;
 
255
select * from t1;
 
256
drop table t1;
 
257
 
 
258
CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb
 
259
PARTITION BY RANGE(f1)
 
260
( PARTITION part1 VALUES LESS THAN (2),
 
261
PARTITION part2 VALUES LESS THAN (1000));
 
262
INSERT INTO t1 VALUES(1, '---1---');
 
263
INSERT INTO t1 VALUES(2, '---2---');
 
264
select * from t1 order by f1;
 
265
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2;
 
266
select * from t1 order by f1;
 
267
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1;
 
268
select * from t1 order by f1;
 
269
drop table t1;