1
################################################################################
2
# inc/partition_alter1.inc #
5
# ADD/DROP PRIMARY KEYs and/or UNIQUE INDEXes tests on partitioned tables #
6
# This routine is only useful for the partition_<feature>_<engine> tests. #
8
#------------------------------------------------------------------------------#
9
# Original Author: mleich #
10
# Original Date: 2006-03-05 #
14
################################################################################
17
--echo #========================================================================
18
--echo # 1. ALTER TABLE ADD PRIMARY KEY and/or UNIQUE INDEX
19
--echo #========================================================================
20
# Rule: The table does not have a PRIMARY KEY or UNIQUE INDEX.
21
# ---> $unique must be empty
22
# ---> The PRIMARY KEY or UNIQUE INDEX to be created must contain
23
# the columns used for partitioning.
24
--echo #------------------------------------------------------------------------
25
--echo # 1.1 ADD PRIMARY KEY or UNIQUE INDEX to table with one column (f_int1)
26
--echo # within the partitioning function
27
--echo #------------------------------------------------------------------------
28
# Rule: Only f_int1 is used within the partitioning function
29
# ---> inc/partition_alter_11.inc
32
# The value of the following test is maybe covered by 1.1.3.
33
if ($more_pk_ui_tests)
35
--echo # 1.1.1 PRIMARY KEY consisting of one column
36
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1);
37
--source suite/parts/inc/partition_alter_11.inc
39
# This must fail, because PRIMARY KEY does not contain f_int1
40
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2);
41
--source suite/parts/inc/partition_alter_11.inc
43
# The value of the following test is maybe covered by 1.1.4.
44
if ($more_pk_ui_tests)
46
--echo # 1.1.2 UNIQUE INDEX consisting of one column
47
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1);
48
--source suite/parts/inc/partition_alter_11.inc
50
# This must fail, because UNIQUE INDEX does not contain f_int1
51
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2);
52
--source suite/parts/inc/partition_alter_11.inc
55
--echo # 1.1.3 PRIMARY KEY consisting of two columns
56
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1,f_int2);
57
--source suite/parts/inc/partition_alter_11.inc
58
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2,f_int1);
59
--source suite/parts/inc/partition_alter_11.inc
61
--echo # 1.1.4 UNIQUE INDEX consisting of two columns
62
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2);
63
--source suite/parts/inc/partition_alter_11.inc
64
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1);
65
--source suite/parts/inc/partition_alter_11.inc
67
--echo #------------------------------------------------------------------------
68
--echo # 1.2 ADD PRIMARY KEY or UNIQUE INDEX to table with two columns
69
--echo # (f_int1 and f_int2) within the partitioning function
70
--echo #------------------------------------------------------------------------
71
# Rule: f_int1 and f_int2 is used within the partitioning function
72
# ---> inc/partition_alter_13.inc
75
--echo # 1.2.1 PRIMARY KEY consisting of two columns
76
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1,f_int2);
77
--source suite/parts/inc/partition_alter_13.inc
78
let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2,f_int1);
79
--source suite/parts/inc/partition_alter_13.inc
81
--echo # 1.2.2 UNIQUE INDEX consisting of two columns
82
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2);
83
--source suite/parts/inc/partition_alter_13.inc
84
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1);
85
--source suite/parts/inc/partition_alter_13.inc
88
--echo # 1.2.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns
89
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2), ADD PRIMARY KEY(f_int2,f_int1);
90
--source suite/parts/inc/partition_alter_13.inc
91
let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1), ADD PRIMARY KEY(f_int1,f_int2);
92
--source suite/parts/inc/partition_alter_13.inc
94
--source suite/parts/inc/partition_alter_13.inc
99
--echo #========================================================================
100
--echo # 2 DROP PRIMARY KEY or UNIQUE INDEX
101
--echo #========================================================================
102
# Rule: The table must have a PRIMARY KEY or UNIQUE INDEX.
103
# ---> $unique must not be empty
104
# ---> The PRIMARY KEY or UNIQUE INDEX to be dropped must contain
105
# the columns used for partitioning.
106
--echo #------------------------------------------------------------------------
107
--echo # 2.1 Partitioning function contains one column(f_int1)
108
--echo #------------------------------------------------------------------------
109
# Rule: Only f_int1 is used within the partitioning function
110
# ---> inc/partition_alter_11.inc
111
# The value of the following test is maybe covered by 2.1.5.
112
if ($more_pk_ui_tests)
116
--echo # 2.1.1 DROP PRIMARY KEY consisting of one column
117
let $unique= , PRIMARY KEY(f_int1);
118
let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
119
--source suite/parts/inc/partition_alter_11.inc
122
--echo # 2.1.2 DROP UNIQUE INDEX consisting of one column
123
let $unique= , UNIQUE INDEX uidx1 (f_int1);
124
let $alter= ALTER TABLE t1 DROP INDEX uidx1;
125
--source suite/parts/inc/partition_alter_11.inc
129
--echo # 2.1.3 DROP PRIMARY KEY consisting of two columns
130
let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
131
let $unique= , PRIMARY KEY(f_int1,f_int2);
132
--source suite/parts/inc/partition_alter_11.inc
133
let $unique= , PRIMARY KEY(f_int2,f_int1);
134
--source suite/parts/inc/partition_alter_11.inc
137
--echo # 2.1.4 DROP UNIQUE INDEX consisting of two columns
138
let $alter= ALTER TABLE t1 DROP INDEX uidx1;
139
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
140
--source suite/parts/inc/partition_alter_11.inc
141
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
142
--source suite/parts/inc/partition_alter_11.inc
147
--echo # 2.1.5 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns
148
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
149
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
150
--source suite/parts/inc/partition_alter_11.inc
151
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
152
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
153
--source suite/parts/inc/partition_alter_11.inc
155
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
156
let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2;
157
--source suite/parts/inc/partition_alter_11.inc
159
--echo #------------------------------------------------------------------------
160
--echo # 2.2 Partitioning function contains two columns (f_int1,f_int2)
161
--echo #------------------------------------------------------------------------
162
# Rule: f_int1 and f_int2 is used within the partitioning function
163
# ---> inc/partition_alter_13.inc
166
--echo # 2.2.1 DROP PRIMARY KEY consisting of two columns
167
let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
168
let $unique= , PRIMARY KEY(f_int1,f_int2);
169
--source suite/parts/inc/partition_alter_13.inc
170
let $unique= , PRIMARY KEY(f_int2,f_int1);
171
--source suite/parts/inc/partition_alter_13.inc
174
--echo # 2.2.2 DROP UNIQUE INDEX consisting of two columns
175
let $alter= ALTER TABLE t1 DROP INDEX uidx1;
176
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
177
--source suite/parts/inc/partition_alter_13.inc
178
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
179
--source suite/parts/inc/partition_alter_13.inc
183
--echo # 2.2.3 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns
184
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
185
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
186
--source suite/parts/inc/partition_alter_13.inc
187
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
188
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
189
--source suite/parts/inc/partition_alter_13.inc
191
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
192
let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2;
193
--source suite/parts/inc/partition_alter_13.inc
198
--echo #========================================================================
199
--echo # 3. ALTER TABLE "ALTER" PRIMARY KEY
200
--echo # mleich: I think that an ALTER TABLE statement where a PRIMARY
201
--echo # KEY is dropped and recreated (with different layout) might
202
--echo # be of interest, if the tree containing the table data has
203
--echo # to be reorganized during this operation.
204
--echo # To be implemented
205
--echo #========================================================================