1
-- source include/have_ndb.inc
2
#--disable_abort_on_error
4
# Simple test for the partition storage engine
5
# Focuses on range partitioning tests
7
#-- source include/have_partition.inc
10
drop table if exists t1;
14
# Partition by range, basic
23
partition by range (a)
25
(partition x1 values less than (5),
26
partition x2 values less than (10),
27
partition x3 values less than (20));
29
# Simple insert and verify test
30
INSERT into t1 values (1, 1, 1);
31
INSERT into t1 values (6, 1, 1);
32
INSERT into t1 values (10, 1, 1);
33
INSERT into t1 values (15, 1, 1);
35
--replace_column 16 # 19 # 20 #
36
select * from information_schema.partitions where table_name= 't1';
38
select * from t1 order by a;
40
select * from t1 where a=1 order by a;
41
select * from t1 where a=15 and b=1 order by a;
42
select * from t1 where a=21 and b=1 order by a;
43
select * from t1 where a=21 order by a;
44
select * from t1 where a in (1,6,10,21) order by a;
45
select * from t1 where b=1 and a in (1,6,10,21) order by a;
50
# Partition by range, basic
59
partition by range (b)
61
(partition x1 values less than (5),
62
partition x2 values less than (10),
63
partition x3 values less than (20));
65
# Simple insert and verify test
66
INSERT into t1 values (1, 1, 1);
67
INSERT into t1 values (2, 6, 1);
68
INSERT into t1 values (3, 10, 1);
69
INSERT into t1 values (4, 15, 1);
71
select * from t1 order by a;
72
UPDATE t1 set a = 5 WHERE b = 15;
73
select * from t1 order by a;
74
UPDATE t1 set a = 6 WHERE a = 5;
75
select * from t1 order by a;
77
select * from t1 where b=1 order by b;
78
select * from t1 where b=15 and a=1 order by b;
79
select * from t1 where b=21 and a=1 order by b;
80
select * from t1 where b=21 order by b;
81
select * from t1 where b in (1,6,10,21) order by b;
82
select * from t1 where a in (1,2,5,6) order by b;
83
select * from t1 where a=1 and b in (1,6,10,21) order by b;
85
DELETE from t1 WHERE b = 6;
86
DELETE from t1 WHERE a = 6;
89
# Test that explicit partition info _is_ shown in show create table
90
# result _should_ contain (PARTITION x1 ... etc)
98
# Alter partitioned NDB table causes mysqld to core
102
(id MEDIUMINT NOT NULL,
106
d DECIMAL(10,4) DEFAULT 0,
108
total BIGINT UNSIGNED,
111
PARTITION BY RANGE (YEAR(t))
112
(PARTITION p0 VALUES LESS THAN (1901),
113
PARTITION p1 VALUES LESS THAN (1946),
114
PARTITION p2 VALUES LESS THAN (1966),
115
PARTITION p3 VALUES LESS THAN (1986),
116
PARTITION p4 VALUES LESS THAN (2005),
117
PARTITION p5 VALUES LESS THAN MAXVALUE);
119
INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
121
ALTER TABLE t1 ENGINE=MYISAM;
125
CREATE LOGFILE GROUP lg1
126
ADD UNDOFILE 'undofile.dat'
131
CREATE TABLESPACE ts1
132
ADD DATAFILE 'datafile.dat'
133
USE LOGFILE GROUP lg1
137
CREATE TABLE test.t1 (
145
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
146
PARTITION BY LIST (a1)
147
(PARTITION p0 VALUES IN (1,2,3,4,5),
148
PARTITION p1 VALUES IN (6,7,8,9, 10),
149
PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
151
# Alter table directly without any statements inbetween
152
ALTER TABLE test.t1 DROP COLUMN a6;
153
ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255);
159
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
160
b'1',$j.00,$j+1,"By NIK $j");
164
SELECT COUNT(*) FROM test.t1;
166
ALTER TABLE test.t1 DROP COLUMN a4;
167
SELECT COUNT(*) FROM test.t1;
171
CREATE TABLE test.t1 (
179
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
180
PARTITION BY HASH(a1)
187
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
188
b'1',$j.00,$j+1,"By NIK $j");
192
SELECT COUNT(*) FROM test.t1;
194
ALTER TABLE test.t1 DROP COLUMN a4;
195
SELECT COUNT(*) FROM test.t1;
200
DROP DATAFILE 'datafile.dat'
202
DROP TABLESPACE ts1 ENGINE=NDB;
203
DROP LOGFILE GROUP lg1 ENGINE=NDB;
207
# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test
211
(id MEDIUMINT NOT NULL,
215
d DECIMAL(10,4) DEFAULT 0,
217
total BIGINT UNSIGNED,
220
PARTITION BY LIST(id)
221
(PARTITION p0 VALUES IN (2, 4),
222
PARTITION p1 VALUES IN (42, 142));
224
INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
226
ALTER TABLE t1 ADD PARTITION
227
(PARTITION p2 VALUES IN (412));
232
# Bug #17806 Update on NDB table with list partition causes mysqld to core
233
# Bug #16385 Partitions: crash when updating a range partitioned NDB table
241
(partition x123 values in (1,5,6),
242
partition x234 values in (4,7,8));
243
INSERT into t1 VALUES (5,1,1);
245
UPDATE t1 SET a=8 WHERE a=5 AND b=1;
249
CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb
250
PARTITION BY RANGE(f1)
251
( PARTITION part1 VALUES LESS THAN (2),
252
PARTITION part2 VALUES LESS THAN (1000));
253
INSERT INTO t1 VALUES(1, '---1---');
254
INSERT INTO t1 VALUES(2, '---2---');
255
select * from t1 order by f1;
256
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2;
257
select * from t1 order by f1;
258
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1;
259
select * from t1 order by f1;