~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/suite/parts/t/ndb_partition_range.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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_warnings
 
10
drop table if exists t1;
 
11
--enable_warnings
 
12
 
 
13
#
 
14
# Partition by range, basic
 
15
#
 
16
CREATE TABLE t1 (
 
17
a int not null,
 
18
b int not null,
 
19
c int not null,
 
20
primary key(a,b),
 
21
index (a))
 
22
engine = ndb
 
23
partition by range (a)
 
24
partitions 3
 
25
(partition x1 values less than (5),
 
26
 partition x2 values less than (10),
 
27
 partition x3 values less than (20));
 
28
 
 
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);
 
34
 
 
35
--replace_column 16 # 19 # 20 #
 
36
select * from information_schema.partitions where table_name= 't1';
 
37
 
 
38
select * from t1 order by a;
 
39
 
 
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;
 
46
 
 
47
drop table t1;
 
48
 
 
49
#
 
50
# Partition by range, basic
 
51
#
 
52
CREATE TABLE t1 (
 
53
a int not null,
 
54
b int not null,
 
55
c int not null,
 
56
primary key(b),
 
57
unique (a))
 
58
engine = ndb
 
59
partition by range (b)
 
60
partitions 3
 
61
(partition x1 values less than (5),
 
62
 partition x2 values less than (10),
 
63
 partition x3 values less than (20));
 
64
 
 
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);
 
70
 
 
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;
 
76
 
 
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;
 
84
 
 
85
DELETE from t1 WHERE b = 6;
 
86
DELETE from t1 WHERE a = 6;
 
87
 
 
88
#
 
89
# Test that explicit partition info _is_ shown in show create table
 
90
# result _should_ contain (PARTITION x1 ... etc)
 
91
#
 
92
show create table t1;
 
93
 
 
94
drop table t1;
 
95
 
 
96
#
 
97
# Bug #17499, #17687
 
98
#  Alter partitioned NDB table causes mysqld to core
 
99
#
 
100
 
 
101
CREATE TABLE t1
 
102
       (id MEDIUMINT NOT NULL,
 
103
        b1 BIT(8),
 
104
        vc VARCHAR(255),
 
105
        bc CHAR(255),
 
106
        d DECIMAL(10,4) DEFAULT 0,
 
107
        f FLOAT DEFAULT 0,
 
108
        total BIGINT UNSIGNED,
 
109
        y YEAR,
 
110
        t DATE) ENGINE=NDB
 
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);
 
118
 
 
119
INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 
120
SELECT * FROM t1;
 
121
ALTER TABLE t1 ENGINE=MYISAM;
 
122
SELECT * FROM t1;
 
123
DROP TABLE t1;
 
124
 
 
125
CREATE LOGFILE GROUP lg1
 
126
  ADD UNDOFILE 'undofile.dat'
 
127
  INITIAL_SIZE 16M
 
128
  UNDO_BUFFER_SIZE=1M
 
129
  ENGINE=NDB;
 
130
 
 
131
CREATE TABLESPACE ts1
 
132
  ADD DATAFILE 'datafile.dat'
 
133
  USE LOGFILE GROUP lg1
 
134
  INITIAL_SIZE 12M
 
135
  ENGINE NDB;
 
136
 
 
137
CREATE TABLE test.t1 (
 
138
  a1 INT,
 
139
  a2 TEXT NOT NULL,
 
140
  a3 BIT NOT NULL,
 
141
  a4 DECIMAL(8,3),
 
142
  a5 INT NOT NULL,
 
143
  a6 INT,
 
144
  PRIMARY KEY(a1))
 
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));
 
150
 
 
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);
 
154
 
 
155
let $j= 15;
 
156
--disable_query_log
 
157
while ($j)
 
158
{
 
159
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
 
160
b'1',$j.00,$j+1,"By NIK $j");
 
161
dec $j;
 
162
}
 
163
--enable_query_log
 
164
SELECT COUNT(*) FROM test.t1;
 
165
 
 
166
ALTER TABLE test.t1 DROP COLUMN a4;
 
167
SELECT COUNT(*) FROM test.t1;
 
168
 
 
169
DROP TABLE t1;
 
170
 
 
171
CREATE TABLE test.t1 (
 
172
  a1 INT,
 
173
  a2 TEXT NOT NULL,
 
174
  a3 BIT NOT NULL,
 
175
  a4 DECIMAL(8,3),
 
176
  a5 INT NOT NULL,
 
177
  a6 VARCHAR(255),
 
178
  PRIMARY KEY(a1))
 
179
  TABLESPACE ts1 STORAGE DISK ENGINE=NDB
 
180
  PARTITION BY HASH(a1)
 
181
  PARTITIONS 4;
 
182
 
 
183
let $j= 15;
 
184
--disable_query_log
 
185
while ($j)
 
186
{
 
187
eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
 
188
b'1',$j.00,$j+1,"By NIK $j");
 
189
dec $j;
 
190
}
 
191
--enable_query_log
 
192
SELECT COUNT(*) FROM test.t1;
 
193
 
 
194
ALTER TABLE test.t1 DROP COLUMN a4;
 
195
SELECT COUNT(*) FROM test.t1;
 
196
 
 
197
DROP TABLE t1;
 
198
 
 
199
ALTER TABLESPACE ts1 
 
200
  DROP DATAFILE 'datafile.dat' 
 
201
  ENGINE=NDB;
 
202
DROP TABLESPACE ts1 ENGINE=NDB;
 
203
DROP LOGFILE GROUP lg1 ENGINE=NDB;
 
204
 
 
205
 
 
206
#
 
207
# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test
 
208
#
 
209
 
 
210
CREATE TABLE t1
 
211
    (id MEDIUMINT NOT NULL,
 
212
     b1 BIT(8),
 
213
     vc VARCHAR(255),
 
214
     bc CHAR(255),
 
215
     d DECIMAL(10,4) DEFAULT 0,
 
216
     f FLOAT DEFAULT 0,
 
217
     total BIGINT UNSIGNED,
 
218
     y YEAR,
 
219
     t DATE) ENGINE=NDB
 
220
  PARTITION BY LIST(id)
 
221
    (PARTITION p0 VALUES IN (2, 4),
 
222
     PARTITION p1 VALUES IN (42, 142));
 
223
 
 
224
INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 
225
SELECT * FROM t1;
 
226
ALTER TABLE t1 ADD PARTITION
 
227
    (PARTITION p2 VALUES IN (412));
 
228
SELECT * FROM t1;
 
229
DROP TABLE t1;
 
230
 
 
231
#
 
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
 
234
#
 
235
CREATE TABLE t1 (
 
236
a int not null,
 
237
b int not null,
 
238
c int not null)
 
239
partition by list(a)
 
240
partitions 2
 
241
(partition x123 values in (1,5,6),
 
242
 partition x234 values in (4,7,8));
 
243
INSERT into t1 VALUES (5,1,1);
 
244
select * from t1;
 
245
UPDATE t1 SET a=8 WHERE a=5 AND b=1;
 
246
select * from t1;
 
247
drop table t1;
 
248
 
 
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;
 
260
drop table t1;