1################################################################################
2# inc/partition_alter_11.inc                                                   #
3#                                                                              #
4# Purpose:                                                                     #
5#   Check ALTER partitioned table and the state of the table afterwards        #
6#   The partitioning function use the column f_int1                            #
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_13.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
44DROP TABLE IF EXISTS t1;
45--enable_warnings
46
47let $partitioning= ;
48#----------- PARTITION BY HASH
49if ($with_partitioning)
50{
51let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
52}
53eval 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
61if ($with_partitioning)
62{
63let $partitioning= PARTITION BY KEY(f_int1) PARTITIONS 5;
64}
65eval 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
73if ($with_partitioning)
74{
75let $partitioning= PARTITION BY LIST(MOD(f_int1,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}
85eval 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
93if ($with_partitioning)
94{
95let $partitioning= PARTITION BY RANGE(f_int1)
96(PARTITION parta VALUES LESS THAN (0),
97PARTITION partb VALUES LESS THAN ($max_row_div4),
98PARTITION partc VALUES LESS THAN ($max_row_div2),
99PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
100PARTITION parte VALUES LESS THAN ($max_row),
101PARTITION partf VALUES LESS THAN $MAX_VALUE);
102}
103eval 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
111if ($with_partitioning)
112{
113let $partitioning= PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
114(PARTITION parta VALUES LESS THAN (0),
115PARTITION partb VALUES LESS THAN ($max_row_div4),
116PARTITION partc VALUES LESS THAN ($max_row_div2),
117PARTITION partd VALUES LESS THAN $MAX_VALUE);
118}
119eval 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
127if ($with_partitioning)
128{
129let $partitioning= PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
130(PARTITION part1 VALUES LESS THAN (0)
131(SUBPARTITION subpart11, SUBPARTITION subpart12),
132PARTITION part2 VALUES LESS THAN ($max_row_div4)
133(SUBPARTITION subpart21, SUBPARTITION subpart22),
134PARTITION part3 VALUES LESS THAN ($max_row_div2)
135(SUBPARTITION subpart31, SUBPARTITION subpart32),
136PARTITION part4 VALUES LESS THAN $MAX_VALUE
137(SUBPARTITION subpart41, SUBPARTITION subpart42));
138}
139eval 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
147if ($with_partitioning)
148{
149let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 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}
159eval 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
167if ($with_partitioning)
168{
169let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,2)))
170SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
171(PARTITION part1 VALUES IN (0),
172 PARTITION part2 VALUES IN (1),
173 PARTITION part3 VALUES IN (NULL));
174}
175eval CREATE TABLE t1 (
176$column_list
177$unique
178)
179$partitioning;
180--source suite/parts/inc/partition_alter_1.inc
181