1 drop table if exists t1;
2 create table t1 (a int unsigned)
4 (partition p0 values in (0),
5 partition p1 values in (1),
6 partition pnull values in (null),
7 partition p2 values in (2));
8 insert into t1 values (null),(0),(1),(2);
9 select * from t1 where a < 2;
13 select * from t1 where a <= 0;
16 select * from t1 where a < 1;
19 select * from t1 where a > 0;
23 select * from t1 where a > 1;
26 select * from t1 where a >= 0;
31 select * from t1 where a >= 1;
35 select * from t1 where a is null;
38 select * from t1 where a is not null;
43 select * from t1 where a is null or a > 0;
49 create table t1 (a int unsigned, b int)
51 subpartition by hash (b)
53 (partition p0 values in (0),
54 partition p1 values in (1),
55 partition pnull values in (null, 2),
56 partition p3 values in (3));
57 insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
58 insert into t1 values (2,0),(2,1),(3,0),(3,1);
59 explain partitions select * from t1 where a is null;
60 id select_type table partitions type possible_keys key key_len ref rows Extra
61 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 4 Using where
62 select * from t1 where a is null;
66 explain partitions select * from t1 where a = 2;
67 id select_type table partitions type possible_keys key key_len ref rows Extra
68 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 4 Using where
69 select * from t1 where a = 2;
73 select * from t1 where a <= 0;
77 select * from t1 where a < 3;
85 select * from t1 where a >= 1 or a is null;
102 (partition x123 values in (1,5,6),
103 partition x234 values in (4,7,8));
104 INSERT into t1 VALUES (1,1,1);
105 INSERT into t1 VALUES (2,1,1);
106 ERROR HY000: Table has no partition for value 2
107 INSERT into t1 VALUES (3,1,1);
108 ERROR HY000: Table has no partition for value 3
109 INSERT into t1 VALUES (4,1,1);
110 INSERT into t1 VALUES (5,1,1);
111 INSERT into t1 VALUES (6,1,1);
112 INSERT into t1 VALUES (7,1,1);
113 INSERT into t1 VALUES (8,1,1);
114 INSERT into t1 VALUES (9,1,1);
115 ERROR HY000: Table has no partition for value 9
116 INSERT into t1 VALUES (1,2,1);
117 INSERT into t1 VALUES (1,3,1);
118 INSERT into t1 VALUES (1,4,1);
119 INSERT into t1 VALUES (7,2,1);
120 INSERT into t1 VALUES (7,3,1);
121 INSERT into t1 VALUES (7,4,1);
136 SELECT * from t1 WHERE a=1;
142 SELECT * from t1 WHERE a=7;
148 SELECT * from t1 WHERE b=2;
152 UPDATE t1 SET a=8 WHERE a=7 AND b=3;
167 UPDATE t1 SET a=8 WHERE a=5 AND b=1;
182 DELETE from t1 WHERE a=8;
194 DELETE from t1 WHERE a=2;
206 DELETE from t1 WHERE a=5 OR a=6;
220 (partition x123 values in (1,5,6),
221 partition x234 values in (4,7,8));
232 INSERT into t1 VALUES (6,2,1);
233 INSERT into t1 VALUES (2,2,1);
234 ERROR HY000: Table has no partition for value 2
241 partition by list (a)
242 subpartition by hash (a+b)
243 ( partition x1 values in (1,2,3)
244 ( subpartition x11 nodegroup 0,
245 subpartition x12 nodegroup 1),
246 partition x2 values in (4,5,6)
247 ( subpartition x21 nodegroup 0,
248 subpartition x22 nodegroup 1)
250 INSERT into t1 VALUES (1,1,1);
251 INSERT into t1 VALUES (4,1,1);
252 INSERT into t1 VALUES (7,1,1);
253 ERROR HY000: Table has no partition for value 7
254 UPDATE t1 SET a=5 WHERE a=1;
259 UPDATE t1 SET a=6 WHERE a=4;
264 DELETE from t1 WHERE a=6;
274 partition by list (a)
275 (partition x1 values in (1,2,9,4) tablespace ts1);
277 CREATE TABLE t1 (s1 int) PARTITION BY LIST (s1)
278 (PARTITION p1 VALUES IN (1),
279 PARTITION p2 VALUES IN (2),
280 PARTITION p3 VALUES IN (3),
281 PARTITION p4 VALUES IN (4),
282 PARTITION p5 VALUES IN (5));
283 INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
284 SELECT COUNT(*) FROM t1 WHERE s1 < 3;
288 create table t1 (a int auto_increment primary key)
290 partition by list (a)
291 (partition p0 values in (1, 100));
292 create index inx on t1 (a);
293 insert into t1 values (null);
298 create table t1 (a char(1))
299 partition by list (ascii(ucase(a)))
300 (partition p1 values in (2));
301 ERROR HY000: This partition function is not allowed