|
| 1 | +# |
| 2 | +# Tests for the new column list partitioning introduced in second |
| 3 | +# version for partitioning. |
| 4 | +# |
| 5 | +--source include/have_partition.inc |
| 6 | + |
| 7 | +--disable_warnings |
| 8 | +drop table if exists t1; |
| 9 | +--enable_warnings |
| 10 | + |
| 11 | +create table t1 (a int, b char(10), c varchar(25), d datetime) |
| 12 | +partition by range column_list(a,b,c,d) |
| 13 | +subpartition by hash (to_seconds(d)) |
| 14 | +subpartitions 4 |
| 15 | +( partition p0 values less than (column_list(1, NULL, MAXVALUE, NULL)), |
| 16 | + partition p1 values less than (column_list(1, 'a', MAXVALUE, TO_DAYS('1999-01-01'))), |
| 17 | + partition p2 values less than (column_list(1, 'a', MAXVALUE, MAXVALUE)), |
| 18 | + partition p3 values less than (column_list(1, MAXVALUE, MAXVALUE, MAXVALUE))); |
| 19 | +drop table t1; |
| 20 | + |
| 21 | +create table t1 (a int, b char(10), c varchar(5), d int) |
| 22 | +partition by range column_list(a,b,c) |
| 23 | +subpartition by key (c,d) |
| 24 | +subpartitions 3 |
| 25 | +( partition p0 values less than (column_list(1,'abc','abc')), |
| 26 | + partition p1 values less than (column_list(2,'abc','abc')), |
| 27 | + partition p2 values less than (column_list(3,'abc','abc')), |
| 28 | + partition p3 values less than (column_list(4,'abc','abc'))); |
| 29 | + |
| 30 | +insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3); |
| 31 | +insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3); |
| 32 | +insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3); |
| 33 | +insert into t1 values (1,'d','e',1),(2,'d','e',2),(3,'d','e',3); |
| 34 | +select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) OR |
| 35 | + (a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2)))); |
| 36 | +drop table t1; |
| 37 | + |
| 38 | +create table t1 (a int, b varchar(2), c int) |
| 39 | +partition by range column_list (a, b, c) |
| 40 | +(partition p0 values less than (column_list(1, 'A', 1)), |
| 41 | + partition p1 values less than (column_list(1, 'B', 1))); |
| 42 | +insert into t1 values (1, 'A', 1); |
| 43 | +explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1; |
| 44 | +select * from t1 where a = 1 AND b <= 'A' and c = 1; |
| 45 | +drop table t1; |
| 46 | + |
| 47 | +create table t1 (a char, b char, c char) |
| 48 | +partition by list column_list(a) |
| 49 | +( partition p0 values in (column_list('a'))); |
| 50 | +insert into t1 (a) values ('a'); |
| 51 | +select * from t1 where a = 'a'; |
| 52 | +drop table t1; |
| 53 | + |
| 54 | +--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR |
| 55 | +create table t1 (d timestamp) |
| 56 | +partition by range column_list(d) |
| 57 | +( partition p0 values less than (column_list('2000-01-01')), |
| 58 | + partition p1 values less than (column_list('2040-01-01'))); |
| 59 | + |
| 60 | +create table t1 (a int, b int) |
| 61 | +partition by range column_list(a,b) |
| 62 | +(partition p0 values less than (column_list(null, 10))); |
| 63 | +drop table t1; |
| 64 | + |
| 65 | +create table t1 (d date) |
| 66 | +partition by range column_list(d) |
| 67 | +( partition p0 values less than (column_list('2000-01-01')), |
| 68 | + partition p1 values less than (column_list('2009-01-01'))); |
| 69 | +drop table t1; |
| 70 | + |
| 71 | +create table t1 (d date) |
| 72 | +partition by range column_list(d) |
| 73 | +( partition p0 values less than (column_list('1999-01-01')), |
| 74 | + partition p1 values less than (column_list('2000-01-01'))); |
| 75 | +drop table t1; |
| 76 | + |
| 77 | +create table t1 (d date) |
| 78 | +partition by range column_list(d) |
| 79 | +( partition p0 values less than (column_list('2000-01-01')), |
| 80 | + partition p1 values less than (column_list('3000-01-01'))); |
| 81 | +drop table t1; |
| 82 | + |
| 83 | +create table t1 (a int, b int) |
| 84 | +partition by range column_list(a,b) |
| 85 | +(partition p2 values less than (column_list(99,99)), |
| 86 | + partition p1 values less than (column_list(99,999))); |
| 87 | + |
| 88 | +insert into t1 values (99,998); |
| 89 | +select * from t1 where b = 998; |
| 90 | +drop table t1; |
| 91 | + |
| 92 | +create table t1 as select to_seconds(null) as to_seconds; |
| 93 | +select data_type from information_schema.columns |
| 94 | +where column_name='to_seconds'; |
| 95 | +drop table t1; |
| 96 | + |
| 97 | +--error ER_PARSE_ERROR |
| 98 | +create table t1 (a int, b int) |
| 99 | +partition by list column_list(a,b) |
| 100 | +(partition p0 values in (column_list(maxvalue,maxvalue))); |
| 101 | +create table t1 (a int, b int) |
| 102 | +partition by range column_list(a,b) |
| 103 | +(partition p0 values less than (column_list(maxvalue,maxvalue))); |
| 104 | +drop table t1; |
| 105 | + |
| 106 | +create table t1 (a int) |
| 107 | +partition by list column_list(a) |
| 108 | +(partition p0 values in (column_list(0))); |
| 109 | +select partition_method from information_schema.partitions where table_name='t1'; |
| 110 | +drop table t1; |
| 111 | + |
| 112 | +create table t1 (a char(6)) |
| 113 | +partition by range column_list(a) |
| 114 | +(partition p0 values less than (column_list('H23456')), |
| 115 | + partition p1 values less than (column_list('M23456'))); |
| 116 | +insert into t1 values ('F23456'); |
| 117 | +select * from t1; |
| 118 | +drop table t1; |
| 119 | + |
| 120 | +-- error 1054 |
| 121 | +create table t1 (a char(6)) |
| 122 | +partition by range column_list(a) |
| 123 | +(partition p0 values less than (column_list(H23456)), |
| 124 | + partition p1 values less than (column_list(M23456))); |
| 125 | + |
| 126 | +-- error ER_RANGE_NOT_INCREASING_ERROR |
| 127 | +create table t1 (a char(6)) |
| 128 | +partition by range column_list(a) |
| 129 | +(partition p0 values less than (column_list(23456)), |
| 130 | + partition p1 values less than (column_list(23456))); |
| 131 | + |
| 132 | +-- error 1064 |
| 133 | +create table t1 (a int, b int) |
| 134 | +partition by range column_list(a,b) |
| 135 | +(partition p0 values less than (10)); |
| 136 | + |
| 137 | +-- error ER_PARTITION_COLUMN_LIST_ERROR |
| 138 | +create table t1 (a int, b int) |
| 139 | +partition by range column_list(a,b) |
| 140 | +(partition p0 values less than (column_list(1,1,1)); |
| 141 | + |
| 142 | +create table t1 (a int, b int) |
| 143 | +partition by range column_list(a,b) |
| 144 | +(partition p0 values less than (column_list(1, NULL)), |
| 145 | + partition p1 values less than (column_list(2, maxvalue)), |
| 146 | + partition p2 values less than (column_list(3, 3)), |
| 147 | + partition p3 values less than (column_list(10, NULL))); |
| 148 | + |
| 149 | +-- error ER_NO_PARTITION_FOR_GIVEN_VALUE |
| 150 | +insert into t1 values (10,0); |
| 151 | +insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1); |
| 152 | +select * from t1; |
| 153 | + |
| 154 | +alter table t1 |
| 155 | +partition by range column_list(b,a) |
| 156 | +(partition p0 values less than (column_list(1,2)), |
| 157 | + partition p1 values less than (column_list(3,3)), |
| 158 | + partition p2 values less than (column_list(9,5))); |
| 159 | +explain partitions select * from t1 where b < 2; |
| 160 | +select * from t1 where b < 2; |
| 161 | +explain partitions select * from t1 where b < 4; |
| 162 | +select * from t1 where b < 4; |
| 163 | + |
| 164 | +alter table t1 reorganize partition p1 into |
| 165 | +(partition p11 values less than (column_list(2,2)), |
| 166 | + partition p12 values less than (column_list(3,3))); |
| 167 | + |
| 168 | +-- error ER_REORG_OUTSIDE_RANGE |
| 169 | +alter table t1 reorganize partition p0 into |
| 170 | +(partition p01 values less than (column_list(0,3)), |
| 171 | + partition p02 values less than (column_list(1,1))); |
| 172 | + |
| 173 | +-- error ER_PARTITION_COLUMN_LIST_ERROR |
| 174 | +alter table t1 reorganize partition p2 into |
| 175 | +(partition p2 values less than(column_list(9,6,1))); |
| 176 | + |
| 177 | +-- error ER_PARTITION_COLUMN_LIST_ERROR |
| 178 | +alter table t1 reorganize partition p2 into |
| 179 | +(partition p2 values less than (10)); |
| 180 | + |
| 181 | +alter table t1 reorganize partition p2 into |
| 182 | +(partition p21 values less than (column_list(4,7)), |
| 183 | + partition p22 values less than (column_list(9,5))); |
| 184 | +explain partitions select * from t1 where b < 4; |
| 185 | +select * from t1 where b < 4; |
| 186 | +drop table t1; |
| 187 | + |
| 188 | +#create table t1 (a int, b int) |
| 189 | +#partition by range column_list(a,b) |
| 190 | +#(partition p0 values less than (column_list(99,99)), |
| 191 | +# partition p1 values less than (column_list(99,maxvalue))); |
| 192 | +#drop table t1; |
| 193 | + |
| 194 | +create table t1 (a int, b int) |
| 195 | +partition by list column_list(a,b) |
| 196 | +subpartition by hash (b) |
| 197 | +subpartitions 2 |
| 198 | +(partition p0 values in (column_list(0,0), column_list(1,1)), |
| 199 | + partition p1 values in (column_list(1000,1000))); |
| 200 | +insert into t1 values (1000,1000); |
| 201 | +#select * from t1 where a = 0 and b = 0; |
| 202 | +drop table t1; |
| 203 | + |
| 204 | +create table t1 (a char, b char, c char) |
| 205 | +partition by range column_list(a,b,c) |
| 206 | +( partition p0 values less than (column_list('a','b','c'))); |
| 207 | +alter table t1 add partition |
| 208 | +(partition p1 values less than (column_list('b','c','d'))); |
| 209 | +drop table t1; |
0 commit comments