1 ################################################################################
2 # inc/partition_methods2.inc #
5 # Create and check partitioned tables #
6 # The partitioning function uses the columns f_int1 and f_int2 #
7 # For all partitioning methods #
8 # PARTITION BY HASH/KEY/LIST/RANGE #
9 # PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
11 # 1. Create the partitioned table #
12 # 2 Insert the content of the table t0_template into t1 #
13 # 3. Execute inc/partition_check.inc #
14 # 4. Drop the table t1 #
18 # $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
19 # CREATE TABLE STATEMENT #
20 # has to be set before sourcing this routine. #
22 # let $unique= , UNIQUE INDEX uidx1 (f_int1); #
23 # inc/partition_methods2.inc #
25 # Attention: The routine inc/partition_methods1.inc is very similar #
26 # to this one. So if something has to be changed here it #
27 # might be necessary to do it also there #
29 #------------------------------------------------------------------------------#
30 # Original Author: mleich #
31 # Original Date: 2006-03-05 #
35 ################################################################################
38 DROP
TABLE IF EXISTS t1;
42 #----------- PARTITION BY HASH
43 if ($with_partitioning)
45 let $partitioning= PARTITION BY
HASH(f_int1 + f_int2) PARTITIONS 2;
46 if ($with_directories)
49 PARTITION BY
HASH(f_int1 + f_int2) PARTITIONS 2
58 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
59 eval CREATE
TABLE t1 (
65 --source suite/parts/inc/partition_check.inc
68 #----------- PARTITION BY KEY
69 if ($with_partitioning)
71 let $partitioning= PARTITION BY
KEY(f_int1,f_int2) PARTITIONS 5;
72 if ($with_directories)
75 PARTITION BY
KEY(f_int1,f_int2) PARTITIONS 5
93 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
94 eval CREATE
TABLE t1 (
100 --source suite/parts/inc/partition_check.inc
103 #----------- PARTITION BY LIST
104 if ($with_partitioning)
106 let $partitioning= PARTITION BY
LIST(MOD(f_int1 + f_int2,4))
107 (PARTITION part_3 VALUES IN (-3),
108 PARTITION part_2 VALUES IN (-2),
109 PARTITION part_1 VALUES IN (-1),
110 PARTITION part_N VALUES IN (NULL),
111 PARTITION part0 VALUES IN (0),
112 PARTITION part1 VALUES IN (1),
113 PARTITION part2 VALUES IN (2),
114 PARTITION part3 VALUES IN (3));
115 if ($with_directories)
118 PARTITION BY
LIST(MOD(f_int1 + f_int2,4))
119 (PARTITION part_3 VALUES IN (-3)
120 $data_directory $index_directory,
121 PARTITION part_2 VALUES IN (-2)
122 $data_directory $index_directory,
123 PARTITION part_1 VALUES IN (-1)
124 $data_directory $index_directory,
125 PARTITION part_N VALUES IN (NULL)
126 $data_directory $index_directory,
127 PARTITION part0 VALUES IN (0)
128 $data_directory $index_directory,
129 PARTITION part1 VALUES IN (1)
130 $data_directory $index_directory,
131 PARTITION part2 VALUES IN (2)
132 $data_directory $index_directory,
133 PARTITION part3 VALUES IN (3)
134 $data_directory $index_directory);
137 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
138 eval CREATE
TABLE t1 (
144 --source suite/parts/inc/partition_check.inc
147 #----------- PARTITION BY RANGE
148 if ($with_partitioning)
150 let $partitioning= PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
151 (PARTITION parta VALUES LESS THAN (0),
152 PARTITION partb VALUES LESS THAN ($max_row_div4),
153 PARTITION partc VALUES LESS THAN ($max_row_div2),
154 PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
155 PARTITION parte VALUES LESS THAN ($max_row),
156 PARTITION partf VALUES LESS THAN $MAX_VALUE);
157 if ($with_directories)
159 let $partitioning= PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
160 (PARTITION parta VALUES LESS THAN (0)
163 PARTITION partb VALUES LESS THAN ($max_row_div4)
166 PARTITION partc VALUES LESS THAN ($max_row_div2)
169 PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4)
172 PARTITION parte VALUES LESS THAN ($max_row)
175 PARTITION partf VALUES LESS THAN $MAX_VALUE
180 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
181 eval CREATE
TABLE t1 (
187 --source suite/parts/inc/partition_check.inc
190 #----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
191 if ($with_partitioning)
194 PARTITION BY RANGE(f_int1) SUBPARTITION BY
HASH(f_int2) SUBPARTITIONS 2
195 (PARTITION parta VALUES LESS THAN (0),
196 PARTITION partb VALUES LESS THAN ($max_row_div4),
197 PARTITION partc VALUES LESS THAN ($max_row_div2),
198 PARTITION partd VALUES LESS THAN $MAX_VALUE);
199 if ($with_directories)
202 PARTITION BY RANGE(f_int1) SUBPARTITION BY
HASH(f_int2) SUBPARTITIONS 2
203 (PARTITION parta VALUES LESS THAN (0)
206 PARTITION partb VALUES LESS THAN ($max_row_div4)
209 PARTITION partc VALUES LESS THAN ($max_row_div2)
212 PARTITION partd VALUES LESS THAN $MAX_VALUE
217 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
218 eval CREATE
TABLE t1 (
224 --source suite/parts/inc/partition_check.inc
227 #----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
228 if ($with_partitioning)
230 let $partitioning= PARTITION BY RANGE(f_int1) SUBPARTITION BY
KEY(f_int2)
231 (PARTITION part1 VALUES LESS THAN (0)
232 (SUBPARTITION subpart11, SUBPARTITION subpart12),
233 PARTITION part2 VALUES LESS THAN ($max_row_div4)
234 (SUBPARTITION subpart21, SUBPARTITION subpart22),
235 PARTITION part3 VALUES LESS THAN ($max_row_div2)
236 (SUBPARTITION subpart31, SUBPARTITION subpart32),
237 PARTITION part4 VALUES LESS THAN $MAX_VALUE
238 (SUBPARTITION subpart41, SUBPARTITION subpart42));
239 if ($with_directories)
241 let $partitioning= PARTITION BY RANGE(f_int1) SUBPARTITION BY
KEY(f_int2)
242 (PARTITION part1 VALUES LESS THAN (0)
243 (SUBPARTITION subpart11 $data_directory $index_directory,
244 SUBPARTITION subpart12 $data_directory $index_directory),
245 PARTITION part2 VALUES LESS THAN ($max_row_div4)
246 (SUBPARTITION subpart21 $data_directory $index_directory,
247 SUBPARTITION subpart22 $data_directory $index_directory),
248 PARTITION part3 VALUES LESS THAN ($max_row_div2)
249 (SUBPARTITION subpart31 $data_directory $index_directory,
250 SUBPARTITION subpart32 $data_directory $index_directory),
251 PARTITION part4 VALUES LESS THAN $MAX_VALUE
252 (SUBPARTITION subpart41 $data_directory $index_directory,
253 SUBPARTITION subpart42 $data_directory $index_directory));
256 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
257 eval CREATE
TABLE t1 (
263 --source suite/parts/inc/partition_check.inc
266 #----------- PARTITION BY LIST -- SUBPARTITION BY HASH
267 if ($with_partitioning)
269 let $partitioning= PARTITION BY
LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY
HASH(f_int2 + 1)
270 (PARTITION part1 VALUES IN (0)
271 (SUBPARTITION sp11, SUBPARTITION sp12),
272 PARTITION part2 VALUES IN (1)
273 (SUBPARTITION sp21, SUBPARTITION sp22),
274 PARTITION part3 VALUES IN (2)
275 (SUBPARTITION sp31, SUBPARTITION sp32),
276 PARTITION part4 VALUES IN (NULL)
277 (SUBPARTITION sp41, SUBPARTITION sp42));
278 if ($with_directories)
281 PARTITION BY
LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY
HASH(f_int2 + 1)
282 (PARTITION part1 VALUES IN (0)
291 PARTITION part2 VALUES IN (1)
300 PARTITION part3 VALUES IN (2)
305 PARTITION part4 VALUES IN (NULL)
316 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
317 eval CREATE
TABLE t1 (
323 --source suite/parts/inc/partition_check.inc
326 #----------- PARTITION BY LIST -- SUBPARTITION BY KEY
327 if ($with_partitioning)
330 PARTITION BY
LIST(ABS(MOD(f_int1,2)))
331 SUBPARTITION BY
KEY(f_int2) SUBPARTITIONS $sub_part_no
332 (PARTITION part1 VALUES IN (0),
333 PARTITION part2 VALUES IN (1),
334 PARTITION part3 VALUES IN (NULL));
335 if ($with_directories)
338 PARTITION BY
LIST(ABS(MOD(f_int1,2)))
339 SUBPARTITION BY
KEY(f_int2) SUBPARTITIONS $sub_part_no
340 (PARTITION part1 VALUES IN (0)
343 PARTITION part2 VALUES IN (1)
346 PARTITION part3 VALUES IN (NULL)
351 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
352 eval CREATE
TABLE t1 (
358 --source suite/parts/inc/partition_check.inc