MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_alter_13.inc
1 ################################################################################
2 # inc/partition_alter_13.inc #
3 # #
4 # Purpose: #
5 # Check ALTER partitioned table and the state of the table afterwards #
6 # The partitioning function uses the columns f_int1 and f_int2 #
7 # #
8 # For all partitioning methods #
9 # PARTITION BY HASH/KEY/LIST/RANGE #
10 # PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
11 # do #
12 # 1. Create the partitioned table #
13 # 2. Execute inc/partition_alter_1.inc, which will #
14 # - Insert the first half of the table t0_template into t1 #
15 # - Execute the ALTER TABLE statement #
16 # - Insert the second half of the table t0_template into t1 #
17 # - Execute the usability test include/partition_check.inc #
18 # - Drop the table t1 #
19 # done #
20 # #
21 # The parameters #
22 # $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
23 # CREATE TABLE STATEMENT #
24 # $alter -- ALTER TABLE statement, which has to be executed #
25 # have to be set before sourcing this routine. #
26 # Example: #
27 # let $unique= , UNIQUE INDEX uidx1 (f_int1); #
28 # let $alter= ALTER TABLE t1 DROP UNIQUE INDEX uidx1; #
29 # inc/partition_alter1.inc #
30 # #
31 # Attention: The routine include/partition_alter_11.inc is very similar #
32 # to this one. So if something has to be changed here it #
33 # might be necessary to do it also there #
34 # #
35 #------------------------------------------------------------------------------#
36 # Original Author: mleich #
37 # Original Date: 2006-03-05 #
38 # Change Author: #
39 # Change Date: #
40 # Change: #
41 ################################################################################
42 
43 --disable_warnings
44 DROP TABLE IF EXISTS t1;
45 --enable_warnings
46 
47 let $partitioning= ;
48 #----------- PARTITION BY HASH
49 if ($with_partitioning)
50 {
51 let $partitioning= PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
52 }
53 eval CREATE TABLE t1 (
54 $column_list
55 $unique
56 )
57 $partitioning;
58 --source suite/parts/inc/partition_alter_1.inc
59 
60 #----------- PARTITION BY KEY
61 if ($with_partitioning)
62 {
63 let $partitioning= PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
64 }
65 eval CREATE TABLE t1 (
66 $column_list
67 $unique
68 )
69 $partitioning;
70 --source suite/parts/inc/partition_alter_1.inc
71 
72 #----------- PARTITION BY LIST
73 if ($with_partitioning)
74 {
75 let $partitioning= PARTITION BY LIST(MOD(f_int1 + f_int2,4))
76 (PARTITION part_3 VALUES IN (-3),
77  PARTITION part_2 VALUES IN (-2),
78  PARTITION part_1 VALUES IN (-1),
79  PARTITION part_N VALUES IN (NULL),
80  PARTITION part0 VALUES IN (0),
81  PARTITION part1 VALUES IN (1),
82  PARTITION part2 VALUES IN (2),
83  PARTITION part3 VALUES IN (3));
84 }
85 eval CREATE TABLE t1 (
86 $column_list
87 $unique
88 )
89 $partitioning;
90 --source suite/parts/inc/partition_alter_1.inc
91 
92 #----------- PARTITION BY RANGE
93 if ($with_partitioning)
94 {
95 let $partitioning= PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
96 (PARTITION parta VALUES LESS THAN (0),
97 PARTITION partb VALUES LESS THAN ($max_row_div4),
98 PARTITION partc VALUES LESS THAN ($max_row_div2),
99 PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
100 PARTITION parte VALUES LESS THAN ($max_row),
101 PARTITION partf VALUES LESS THAN $MAX_VALUE);
102 }
103 eval CREATE TABLE t1 (
104 $column_list
105 $unique
106 )
107 $partitioning;
108 --source suite/parts/inc/partition_alter_1.inc
109 
110 #----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
111 if ($with_partitioning)
112 {
113 let $partitioning= PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
114 (PARTITION parta VALUES LESS THAN (0),
115 PARTITION partb VALUES LESS THAN ($max_row_div4),
116 PARTITION partc VALUES LESS THAN ($max_row_div2),
117 PARTITION partd VALUES LESS THAN $MAX_VALUE);
118 }
119 eval CREATE TABLE t1 (
120 $column_list
121 $unique
122 )
123 $partitioning;
124 --source suite/parts/inc/partition_alter_1.inc
125 
126 #----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
127 if ($with_partitioning)
128 {
129 let $partitioning= PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
130 (PARTITION part1 VALUES LESS THAN (0)
131 (SUBPARTITION subpart11, SUBPARTITION subpart12),
132 PARTITION part2 VALUES LESS THAN ($max_row_div4)
133 (SUBPARTITION subpart21, SUBPARTITION subpart22),
134 PARTITION part3 VALUES LESS THAN ($max_row_div2)
135 (SUBPARTITION subpart31, SUBPARTITION subpart32),
136 PARTITION part4 VALUES LESS THAN $MAX_VALUE
137 (SUBPARTITION subpart41, SUBPARTITION subpart42));
138 }
139 eval CREATE TABLE t1 (
140 $column_list
141 $unique
142 )
143 $partitioning;
144 --source suite/parts/inc/partition_alter_1.inc
145 
146 #----------- PARTITION BY LIST -- SUBPARTITION BY HASH
147 if ($with_partitioning)
148 {
149 let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
150 (PARTITION part1 VALUES IN (0)
151  (SUBPARTITION sp11, SUBPARTITION sp12),
152  PARTITION part2 VALUES IN (1)
153  (SUBPARTITION sp21, SUBPARTITION sp22),
154  PARTITION part3 VALUES IN (2)
155  (SUBPARTITION sp31, SUBPARTITION sp32),
156  PARTITION part4 VALUES IN (NULL)
157  (SUBPARTITION sp41, SUBPARTITION sp42));
158 }
159 eval CREATE TABLE t1 (
160 $column_list
161 $unique
162 )
163 $partitioning;
164 --source suite/parts/inc/partition_alter_1.inc
165 
166 #----------- PARTITION BY LIST -- SUBPARTITION BY KEY
167 if ($with_partitioning)
168 {
169 let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,2)))
170 SUBPARTITION BY KEY(f_int2) SUBPARTITIONS $sub_part_no
171 (PARTITION part1 VALUES IN (0),
172  PARTITION part2 VALUES IN (1),
173  PARTITION part3 VALUES IN (NULL));
174 }
175 eval CREATE TABLE t1 (
176 $column_list
177 $unique
178 )
179 $partitioning;
180 --source suite/parts/inc/partition_alter_1.inc