| 1 |
--source include/have_ndb.inc |
| 2 |
# |
| 3 |
# Simple test for the partition storage engine |
| 4 |
# Focuses on range partitioning tests |
| 5 |
# |
| 6 |
#-- source include/have_partition.inc |
| 7 |
|
| 8 |
--disable_query_log |
| 9 |
set new=on; |
| 10 |
--enable_query_log |
| 11 |
|
| 12 |
--disable_warnings |
| 13 |
drop table if exists t1; |
| 14 |
--enable_warnings |
| 15 |
|
| 16 |
# |
| 17 |
# Partition by list, basic |
| 18 |
# |
| 19 |
|
| 20 |
CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, |
| 21 |
f_char1 CHAR(10), |
| 22 |
f_char2 CHAR(10), f_charbig VARCHAR(1000), |
| 23 |
PRIMARY KEY (f_int1,f_int2)) |
| 24 |
ENGINE = NDB |
| 25 |
PARTITION BY LIST(MOD(f_int1 + f_int2,4)) |
| 26 |
(PARTITION part_3 VALUES IN (-3), |
| 27 |
PARTITION part_2 VALUES IN (-2), |
| 28 |
PARTITION part_1 VALUES IN (-1), |
| 29 |
PARTITION part0 VALUES IN (0), |
| 30 |
PARTITION part1 VALUES IN (1), |
| 31 |
PARTITION part2 VALUES IN (2), |
| 32 |
PARTITION part3 VALUES IN (3,4,5)); |
| 33 |
|
| 34 |
INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; |
| 35 |
INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 36 |
INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 37 |
INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 38 |
INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 39 |
INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 40 |
INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; |
| 41 |
|
| 42 |
SELECT * FROM t1 ORDER BY f_int1; |
| 43 |
|
| 44 |
DROP TABLE t1; |
| 45 |
|
| 46 |
# Check partition pruning at NdbApi level for list partitioned table |
| 47 |
# |
| 48 |
create table t1 ( a int, b int, c int, primary key (a,b)) engine=ndb |
| 49 |
partition by list (a) |
| 50 |
(partition part0 values in (0,1,2), |
| 51 |
partition part1 values in (3,4,5)); |
| 52 |
|
| 53 |
insert into t1 values (0, 0, 0); |
| 54 |
insert into t1 values (0, 1, 1); |
| 55 |
insert into t1 values (0, 2, 2); |
| 56 |
insert into t1 values (1, 0, 3); |
| 57 |
insert into t1 values (1, 1, 4); |
| 58 |
insert into t1 values (1, 2, 5); |
| 59 |
insert into t1 values (4, 0, 6); |
| 60 |
insert into t1 values (4, 1, 7); |
| 61 |
insert into t1 values (4, 2, 8); |
| 62 |
|
| 63 |
--echo All partitions scan |
| 64 |
--source suite/ndb/include/ndb_init_scan_counts.inc |
| 65 |
select * from t1 order by c; |
| 66 |
--source suite/ndb/include/ndb_scan_counts.inc |
| 67 |
|
| 68 |
--echo Single partition scan |
| 69 |
--source suite/ndb/include/ndb_init_scan_counts.inc |
| 70 |
select * from t1 where a=0 order by c; |
| 71 |
--source suite/ndb/include/ndb_scan_counts.inc |
| 72 |
|
| 73 |
--echo Single partition scan |
| 74 |
--source suite/ndb/include/ndb_init_scan_counts.inc |
| 75 |
select * from t1 where a=4 order by c; |
| 76 |
--source suite/ndb/include/ndb_scan_counts.inc |
| 77 |
|
| 78 |
--echo MRR single partition scan |
| 79 |
--source suite/ndb/include/ndb_init_scan_counts.inc |
| 80 |
select * from t1 where a in (0, 2) order by c; |
| 81 |
--source suite/ndb/include/ndb_scan_counts.inc |
| 82 |
|
| 83 |
drop table t1; |