1
################################################################################
2
# inc/partition_methods1.inc #
5
# Create and check partitioned tables #
6
# The partitioning function use the column f_int1 #
8
# For all partitioning methods #
9
# PARTITION BY HASH/KEY/LIST/RANGE #
10
# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
12
# 1. Create the partitioned table #
13
# 2 Insert the content of the table t0_template into t1 #
14
# 3. Execute inc/partition_check.inc #
15
# 4. Drop the table t1 #
19
# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
20
# CREATE TABLE STATEMENT #
21
# has to be set before sourcing this routine. #
23
# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
24
# inc/partition_method1s.inc #
26
# Attention: The routine inc/partition_methods2.inc is very similar #
27
# to this one. So if something has to be changed here it #
28
# might be necessary to do it also there #
30
#------------------------------------------------------------------------------#
31
# Original Author: mleich #
32
# Original Date: 2006-03-05 #
36
################################################################################
39
DROP TABLE IF EXISTS t1;
43
#----------- PARTITION BY HASH
44
if ($with_partitioning)
46
let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
48
eval CREATE TABLE t1 (
54
--source suite/parts/inc/partition_check.inc
57
#----------- PARTITION BY KEY
58
if ($with_partitioning)
60
let $partitioning= PARTITION BY KEY(f_int1) PARTITIONS 5;
62
eval CREATE TABLE t1 (
68
--source suite/parts/inc/partition_check.inc
71
#----------- PARTITION BY LIST
72
if ($with_partitioning)
74
let $partitioning= PARTITION BY LIST(MOD(f_int1,4))
75
(PARTITION part_3 VALUES IN (-3),
76
PARTITION part_2 VALUES IN (-2),
77
PARTITION part_1 VALUES IN (-1),
78
PARTITION part_N VALUES IN (NULL),
79
PARTITION part0 VALUES IN (0),
80
PARTITION part1 VALUES IN (1),
81
PARTITION part2 VALUES IN (2),
82
PARTITION part3 VALUES IN (3));
84
eval CREATE TABLE t1 (
90
--source suite/parts/inc/partition_check.inc
93
#----------- PARTITION BY RANGE
94
if ($with_partitioning)
97
eval SET @aux = 'PARTITION BY RANGE(f_int1)
98
(PARTITION parta VALUES LESS THAN (0),
99
PARTITION partb VALUES LESS THAN ($max_row_div4),
100
PARTITION partc VALUES LESS THAN ($max_row_div2),
101
PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
102
PARTITION parte VALUES LESS THAN ($max_row),
103
PARTITION partf VALUES LESS THAN $MAX_VALUE)';
104
let $partitioning= `SELECT @aux`;
107
eval CREATE TABLE t1 (
113
--source suite/parts/inc/partition_check.inc
116
#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
117
if ($with_partitioning)
121
'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
122
(PARTITION parta VALUES LESS THAN (0),
123
PARTITION partb VALUES LESS THAN ($max_row_div4),
124
PARTITION partc VALUES LESS THAN ($max_row_div2),
125
PARTITION partd VALUES LESS THAN $MAX_VALUE)';
126
let $partitioning= `SELECT @aux`;
129
eval CREATE TABLE t1 (
135
--source suite/parts/inc/partition_check.inc
138
#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
139
if ($with_partitioning)
142
eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
143
(PARTITION part1 VALUES LESS THAN (0)
144
(SUBPARTITION subpart11, SUBPARTITION subpart12),
145
PARTITION part2 VALUES LESS THAN ($max_row_div4)
146
(SUBPARTITION subpart21, SUBPARTITION subpart22),
147
PARTITION part3 VALUES LESS THAN ($max_row_div2)
148
(SUBPARTITION subpart31, SUBPARTITION subpart32),
149
PARTITION part4 VALUES LESS THAN $MAX_VALUE
150
(SUBPARTITION subpart41, SUBPARTITION subpart42))';
151
let $partitioning= `SELECT @aux`;
154
eval CREATE TABLE t1 (
160
--source suite/parts/inc/partition_check.inc
163
#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
164
if ($with_partitioning)
166
let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
167
(PARTITION part1 VALUES IN (0)
168
(SUBPARTITION sp11, SUBPARTITION sp12),
169
PARTITION part2 VALUES IN (1)
170
(SUBPARTITION sp21, SUBPARTITION sp22),
171
PARTITION part3 VALUES IN (2)
172
(SUBPARTITION sp31, SUBPARTITION sp32),
173
PARTITION part4 VALUES IN (NULL)
174
(SUBPARTITION sp41, SUBPARTITION sp42));
176
eval CREATE TABLE t1 (
182
--source suite/parts/inc/partition_check.inc
185
#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
186
if ($with_partitioning)
190
'PARTITION BY LIST(ABS(MOD(f_int1,2)))
191
SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
192
(PARTITION part1 VALUES IN (0),
193
PARTITION part2 VALUES IN (1),
194
PARTITION part3 VALUES IN (NULL))';
195
let $partitioning= `SELECT @aux`;
198
eval CREATE TABLE t1 (
204
--source suite/parts/inc/partition_check.inc