MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_engine.inc
1 ################################################################################
2 # inc/partition_engine.inc #
3 # #
4 # Purpose: #
5 # Tests around Create/Alter partitioned tables and storage engine settings #
6 # at different places within the statement. #
7 # This routine is only useful for the partition_<feature>_<engine> tests. #
8 # #
9 # Note: There were some problems in history. #
10 # It looks like a table holds informations about the storage engine #
11 # for #
12 # "the whole table" -> in statement after column list before partitioning #
13 # a partition -> in statement after definition of partition #
14 # a subpartition -> in statement after definition of subpartition #
15 # If there is a CREATE TABLE statement where not at all of these place #
16 # a storage engine is assigned, the server must decide by itself whic #
17 # storage engine to use. #
18 # #
19 #------------------------------------------------------------------------------#
20 # Original Author: mleich #
21 # Original Date: 2006-03-05 #
22 # Change Author: #
23 # Change Date: #
24 # Change: #
25 ################################################################################
26 
27 --echo
28 --echo #========================================================================
29 --echo # Checks where the engine is assigned on all supported (CREATE TABLE
30 --echo # statement) positions + basic operations on the tables
31 --echo # Storage engine mixups are currently (2005-12-23) not supported
32 --echo #========================================================================
33 --disable_warnings
34 DROP TABLE IF EXISTS t1;
35 --enable_warnings
36 
37 #
38 --echo #------------------------------------------------------------------------
39 --echo # 1 Assignment of storage engine just after column list only
40 --echo #------------------------------------------------------------------------
41 eval CREATE TABLE t1 (
42 $column_list
43 ) ENGINE = $engine
44  PARTITION BY HASH(f_int1) PARTITIONS 2;
45 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
46 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
47 --source suite/parts/inc/partition_check.inc
48 DROP TABLE t1;
49 #
50 --echo #------------------------------------------------------------------------
51 --echo # 2 Assignment of storage engine just after partition or subpartition
52 --echo # name only
53 --echo #------------------------------------------------------------------------
54 eval CREATE TABLE t1 (
55 $column_list
56 )
57 PARTITION BY HASH(f_int1)
58 ( PARTITION part1 STORAGE ENGINE = $engine,
59  PARTITION part2 STORAGE ENGINE = $engine
60 );
61 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
62 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
63 --source suite/parts/inc/partition_check.inc
64 DROP TABLE t1;
65 eval CREATE TABLE t1 (
66 $column_list
67 )
68 PARTITION BY RANGE(f_int1)
69 SUBPARTITION BY HASH(f_int1)
70 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
71  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
72  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
73  PARTITION part2 VALUES LESS THAN $MAX_VALUE
74  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
75  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
76 );
77 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
78 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
79 --source suite/parts/inc/partition_check.inc
80 DROP TABLE t1;
81 #
82 --echo #------------------------------------------------------------------------
83 --echo # 3 Some but not all named partitions or subpartitions get a storage
84 --echo # engine assigned
85 --echo #------------------------------------------------------------------------
86 --error ER_MIX_HANDLER_ERROR
87 eval CREATE TABLE t1 (
88 $column_list
89 )
90 PARTITION BY HASH(f_int1)
91 ( PARTITION part1 STORAGE ENGINE = $engine,
92  PARTITION part2
93 );
94 --error ER_MIX_HANDLER_ERROR
95 eval CREATE TABLE t1 (
96 $column_list
97 )
98 PARTITION BY HASH(f_int1)
99 ( PARTITION part1 ,
100  PARTITION part2 STORAGE ENGINE = $engine
101 );
102 --error ER_MIX_HANDLER_ERROR
103 eval CREATE TABLE t1 (
104 $column_list
105 )
106 PARTITION BY RANGE(f_int1)
107 SUBPARTITION BY HASH(f_int1)
108 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
109  (SUBPARTITION subpart11,
110  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
111  PARTITION part2 VALUES LESS THAN $MAX_VALUE
112  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
113  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
114 );
115 --error ER_MIX_HANDLER_ERROR
116 eval CREATE TABLE t1 (
117 $column_list
118 )
119 PARTITION BY RANGE(f_int1)
120 SUBPARTITION BY HASH(f_int1)
121 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
122  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
123  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
124  PARTITION part2 VALUES LESS THAN $MAX_VALUE
125  (SUBPARTITION subpart21,
126  SUBPARTITION subpart22 )
127 );
128 eval CREATE TABLE t1 (
129 $column_list
130 )
131 ENGINE = $engine
132 PARTITION BY RANGE(f_int1)
133 SUBPARTITION BY HASH(f_int1)
134 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
135  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
136  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
137  PARTITION part2 VALUES LESS THAN $MAX_VALUE
138  (SUBPARTITION subpart21,
139  SUBPARTITION subpart22 )
140 );
141 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
142 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
143 --source suite/parts/inc/partition_check.inc
144 DROP TABLE t1;
145 #
146 --echo #------------------------------------------------------------------------
147 --echo # 4 Storage engine assignment after partition name + after name of
148 --echo # subpartitions belonging to another partition
149 --echo #------------------------------------------------------------------------
150 --error ER_MIX_HANDLER_ERROR
151 eval CREATE TABLE t1 (
152 $column_list
153 )
154 PARTITION BY RANGE(f_int1)
155 SUBPARTITION BY HASH(f_int1)
156 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
157  (SUBPARTITION subpart11,
158  SUBPARTITION subpart12),
159  PARTITION part2 VALUES LESS THAN $MAX_VALUE
160  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
161  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
162 );
163 eval CREATE TABLE t1 (
164 $column_list
165 )
166 ENGINE = $engine
167 PARTITION BY RANGE(f_int1)
168 SUBPARTITION BY HASH(f_int1)
169 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
170  (SUBPARTITION subpart11,
171  SUBPARTITION subpart12),
172  PARTITION part2 VALUES LESS THAN $MAX_VALUE
173  (SUBPARTITION subpart21,
174  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
175 );
176 DROP TABLE t1;
177 eval CREATE TABLE t1 (
178 $column_list
179 )
180 PARTITION BY RANGE(f_int1)
181 SUBPARTITION BY HASH(f_int1)
182 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
183  (SUBPARTITION subpart11,
184  SUBPARTITION subpart12),
185  PARTITION part2 VALUES LESS THAN $MAX_VALUE
186  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
187  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
188 );
189 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
190 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
191 --source suite/parts/inc/partition_check.inc
192 DROP TABLE t1;
193 eval CREATE TABLE t1 (
194 $column_list
195 )
196 PARTITION BY RANGE(f_int1)
197 SUBPARTITION BY HASH(f_int1)
198 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
199  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
200  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
201  PARTITION part2 VALUES LESS THAN $MAX_VALUE ENGINE = $engine
202  (SUBPARTITION subpart21 ENGINE = $engine,
203  SUBPARTITION subpart22)
204 );
205 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
206 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
207 --source suite/parts/inc/partition_check.inc
208 DROP TABLE t1;
209 #
210 --echo #------------------------------------------------------------------------
211 --echo # 5 Precedence of storage engine assignments (if there is any)
212 --echo #------------------------------------------------------------------------
213 --echo # 5.1 Storage engine assignment after column list + after partition
214 --echo # or subpartition name
215 eval CREATE TABLE t1 (
216 $column_list
217 ) ENGINE = $engine
218 PARTITION BY HASH(f_int1)
219 ( PARTITION part1 STORAGE ENGINE = $engine,
220  PARTITION part2 STORAGE ENGINE = $engine
221 );
222 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
223 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
224 --source suite/parts/inc/partition_check.inc
225 DROP TABLE t1;
226 eval CREATE TABLE t1 (
227 $column_list
228 )
229 PARTITION BY RANGE(f_int1)
230 SUBPARTITION BY HASH(f_int1)
231 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
232  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
233  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
234  PARTITION part2 VALUES LESS THAN $MAX_VALUE
235  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
236  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
237 );
238 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
239 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
240 --source suite/parts/inc/partition_check.inc
241 DROP TABLE t1;
242 --echo # 6.2 Storage engine assignment after partition name + after
243 --echo # subpartition name
244 --echo # in partition part + in sub partition part
245 eval CREATE TABLE t1 (
246 $column_list
247 )
248 PARTITION BY RANGE(f_int1)
249 SUBPARTITION BY HASH(f_int1)
250 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) STORAGE ENGINE = $engine
251  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
252  SUBPARTITION subpart12 STORAGE ENGINE = $engine),
253  PARTITION part2 VALUES LESS THAN $MAX_VALUE
254  (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
255  SUBPARTITION subpart22 STORAGE ENGINE = $engine)
256 );
257 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
258 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
259 --source suite/parts/inc/partition_check.inc
260 DROP TABLE t1;
261 
262 --echo #------------------------------------------------------------------------
263 --echo # 6 Session default engine differs from engine used within create table
264 --echo #------------------------------------------------------------------------
265 eval SET SESSION default_storage_engine=$engine_other;
266 # Bug#16775 Partitions: strange effects on subpartitioned tables, mixed storage engines
267 # Bug#15966 Partitions: crash if session default engine <> engine used in create table
268 eval CREATE TABLE t1 (
269 $column_list
270 )
271 PARTITION BY HASH(f_int1) ( PARTITION part1 ENGINE = $engine);
272 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
273 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
274 --source suite/parts/inc/partition_check.inc
275 DROP TABLE t1;
276 # Bug#15966 Partitions: crash if session default engine <> engine used in create table
277 eval CREATE TABLE t1 (
278 $column_list
279 )
280 PARTITION BY RANGE(f_int1)
281 SUBPARTITION BY HASH(f_int1)
282 ( PARTITION part1 VALUES LESS THAN (1000)
283  (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
284  SUBPARTITION subpart12 STORAGE ENGINE = $engine));
285 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
286 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
287 --source suite/parts/inc/partition_check.inc
288 DROP TABLE t1;
289 eval SET SESSION default_storage_engine=$engine;