1
by brian
clean slate |
1 |
################################################################################
|
2 |
# inc/partition_alter1.inc # |
|
3 |
# # |
|
4 |
# Purpose: # |
|
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. # |
|
7 |
# # |
|
8 |
#------------------------------------------------------------------------------# |
|
9 |
# Original Author: mleich # |
|
10 |
# Original Date: 2006-03-05 # |
|
11 |
# Change Author: # |
|
12 |
# Change Date: # |
|
13 |
# Change: # |
|
14 |
################################################################################
|
|
15 |
||
16 |
--echo |
|
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 |
|
30 |
if ($do_pk_tests) |
|
31 |
{
|
|
32 |
# The value of the following test is maybe covered by 1.1.3. |
|
33 |
if ($more_pk_ui_tests) |
|
34 |
{
|
|
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 |
|
38 |
}
|
|
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 |
|
42 |
}
|
|
43 |
# The value of the following test is maybe covered by 1.1.4. |
|
44 |
if ($more_pk_ui_tests) |
|
45 |
{
|
|
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 |
|
49 |
}
|
|
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 |
|
53 |
if ($do_pk_tests) |
|
54 |
{
|
|
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 |
|
60 |
}
|
|
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 |
|
66 |
#
|
|
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 |
|
73 |
if ($do_pk_tests) |
|
74 |
{
|
|
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 |
|
80 |
}
|
|
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 |
|
86 |
if ($do_pk_tests) |
|
87 |
{
|
|
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 |
|
93 |
let $unique= ; |
|
94 |
--source suite/parts/inc/partition_alter_13.inc |
|
95 |
}
|
|
96 |
#
|
|
97 |
#
|
|
98 |
--echo |
|
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) |
|
113 |
{
|
|
114 |
if ($do_pk_tests) |
|
115 |
{
|
|
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 |
|
120 |
}
|
|
121 |
#
|
|
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 |
|
126 |
#
|
|
127 |
if ($do_pk_tests) |
|
128 |
{
|
|
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 |
|
135 |
}
|
|
136 |
#
|
|
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 |
|
143 |
}
|
|
144 |
#
|
|
145 |
if ($do_pk_tests) |
|
146 |
{
|
|
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 |
|
154 |
}
|
|
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 |
|
158 |
#
|
|
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 |
|
164 |
if ($do_pk_tests) |
|
165 |
{
|
|
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 |
|
172 |
}
|
|
173 |
#
|
|
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 |
|
180 |
#
|
|
181 |
if ($do_pk_tests) |
|
182 |
{
|
|
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 |
|
190 |
}
|
|
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 |
|
194 |
||
195 |
if (0) |
|
196 |
{
|
|
197 |
--echo |
|
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 #======================================================================== |
|
206 |
--echo |
|
207 |
}
|