| 1 |
################################################################################ |
| 2 |
# inc/partition_alter1_2.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: debanerj # |
| 12 |
# Change Date: 2015-02-18 # |
| 13 |
# Change: Added tests for alter table drop + add primary/unique key # |
| 14 |
################################################################################ |
| 15 |
# |
| 16 |
--echo |
| 17 |
--echo #======================================================================== |
| 18 |
--echo # 2 DROP PRIMARY KEY or UNIQUE INDEX |
| 19 |
--echo #======================================================================== |
| 20 |
# Rule: The table must have a PRIMARY KEY or UNIQUE INDEX. |
| 21 |
# ---> $unique must not be empty |
| 22 |
# ---> The PRIMARY KEY or UNIQUE INDEX to be dropped must contain |
| 23 |
# the columns used for partitioning. |
| 24 |
--echo #------------------------------------------------------------------------ |
| 25 |
--echo # 2.1 Partitioning function contains one column(f_int1) |
| 26 |
--echo #------------------------------------------------------------------------ |
| 27 |
# Rule: Only f_int1 is used within the partitioning function |
| 28 |
# ---> inc/partition_alter_11.inc |
| 29 |
# The value of the following test is maybe covered by 2.1.5. |
| 30 |
if ($more_pk_ui_tests) |
| 31 |
{ |
| 32 |
if ($do_pk_tests) |
| 33 |
{ |
| 34 |
--echo # 2.1.1 DROP PRIMARY KEY consisting of one column |
| 35 |
let $unique= , PRIMARY KEY(f_int1); |
| 36 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY; |
| 37 |
--source suite/parts/inc/partition_alter_11.inc |
| 38 |
} |
| 39 |
# |
| 40 |
--echo # 2.1.2 DROP UNIQUE INDEX consisting of one column |
| 41 |
let $unique= , UNIQUE INDEX uidx1 (f_int1); |
| 42 |
let $alter= ALTER TABLE t1 DROP INDEX uidx1; |
| 43 |
--source suite/parts/inc/partition_alter_11.inc |
| 44 |
# |
| 45 |
if ($do_pk_tests) |
| 46 |
{ |
| 47 |
--echo # 2.1.3 DROP PRIMARY KEY consisting of two columns |
| 48 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY; |
| 49 |
let $unique= , PRIMARY KEY(f_int1,f_int2); |
| 50 |
--source suite/parts/inc/partition_alter_11.inc |
| 51 |
let $unique= , PRIMARY KEY(f_int2,f_int1); |
| 52 |
--source suite/parts/inc/partition_alter_11.inc |
| 53 |
} |
| 54 |
# |
| 55 |
--echo # 2.1.4 DROP UNIQUE INDEX consisting of two columns |
| 56 |
let $alter= ALTER TABLE t1 DROP INDEX uidx1; |
| 57 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2); |
| 58 |
--source suite/parts/inc/partition_alter_11.inc |
| 59 |
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1); |
| 60 |
--source suite/parts/inc/partition_alter_11.inc |
| 61 |
} |
| 62 |
# |
| 63 |
if ($do_pk_tests) |
| 64 |
{ |
| 65 |
--echo # 2.1.5 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns |
| 66 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1); |
| 67 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1; |
| 68 |
--source suite/parts/inc/partition_alter_11.inc |
| 69 |
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2); |
| 70 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1; |
| 71 |
--source suite/parts/inc/partition_alter_11.inc |
| 72 |
} |
| 73 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1); |
| 74 |
let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2; |
| 75 |
--source suite/parts/inc/partition_alter_11.inc |
| 76 |
# |
| 77 |
--echo #------------------------------------------------------------------------ |
| 78 |
--echo # 2.2 Partitioning function contains two columns (f_int1,f_int2) |
| 79 |
--echo #------------------------------------------------------------------------ |
| 80 |
# Rule: f_int1 and f_int2 is used within the partitioning function |
| 81 |
# ---> inc/partition_alter_13.inc |
| 82 |
if ($do_pk_tests) |
| 83 |
{ |
| 84 |
--echo # 2.2.1 DROP PRIMARY KEY consisting of two columns |
| 85 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY; |
| 86 |
let $unique= , PRIMARY KEY(f_int1,f_int2); |
| 87 |
--source suite/parts/inc/partition_alter_13.inc |
| 88 |
let $unique= , PRIMARY KEY(f_int2,f_int1); |
| 89 |
--source suite/parts/inc/partition_alter_13.inc |
| 90 |
} |
| 91 |
# |
| 92 |
--echo # 2.2.2 DROP UNIQUE INDEX consisting of two columns |
| 93 |
let $alter= ALTER TABLE t1 DROP INDEX uidx1; |
| 94 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2); |
| 95 |
--source suite/parts/inc/partition_alter_13.inc |
| 96 |
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1); |
| 97 |
--source suite/parts/inc/partition_alter_13.inc |
| 98 |
# |
| 99 |
if ($do_pk_tests) |
| 100 |
{ |
| 101 |
--echo # 2.2.3 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns |
| 102 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1); |
| 103 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1; |
| 104 |
--source suite/parts/inc/partition_alter_13.inc |
| 105 |
let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2); |
| 106 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1; |
| 107 |
--source suite/parts/inc/partition_alter_13.inc |
| 108 |
} |
| 109 |
let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1); |
| 110 |
let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2; |
| 111 |
--source suite/parts/inc/partition_alter_13.inc |
| 112 |
|
| 113 |
if ($do_pk_tests) |
| 114 |
{ |
| 115 |
--echo |
| 116 |
--echo #======================================================================== |
| 117 |
--echo # 3. ALTER TABLE "ALTER"(DROP + ADD) PRIMARY KEY |
| 118 |
--echo # mleich: I think that an ALTER TABLE statement where a PRIMARY |
| 119 |
--echo # KEY is dropped and recreated (with different layout) might |
| 120 |
--echo # be of interest, if the tree containing the table data has |
| 121 |
--echo # to be reorganized during this operation. |
| 122 |
--echo #======================================================================== |
| 123 |
# Rule: The table must have a PRIMARY KEY or UNIQUE KEY |
| 124 |
# ---> $unique must not be empty |
| 125 |
# ---> The KEY to be dropped must contain the columns |
| 126 |
# used for partitioning. |
| 127 |
|
| 128 |
# Override column list to add NOT NULL constraint for partition by key() |
| 129 |
# tests. May be it is better to add more columns in partition.pre but would |
| 130 |
# impact a lot more tests. |
| 131 |
|
| 132 |
let $column_list= f_int1 INTEGER NOT NULL, |
| 133 |
f_int2 INTEGER NOT NULL, |
| 134 |
f_char1 CHAR(20), |
| 135 |
f_char2 CHAR(20), |
| 136 |
f_charbig VARCHAR(1000); |
| 137 |
|
| 138 |
let $expect_inplace_error= 0; |
| 139 |
|
| 140 |
--echo #------------------------------------------------------------------------ |
| 141 |
--echo # 3.1 Partitioning function uses the PRIMARY/UNIQUE KEY |
| 142 |
--echo #------------------------------------------------------------------------ |
| 143 |
# Rule: PRIMARY/UNIQUE KEY is used in partitioning function |
| 144 |
# ---> inc/partition_alter_12.inc |
| 145 |
|
| 146 |
--echo # 3.1.1 DROP and CREATE PRIMARY KEY on different column |
| 147 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(f_int2, f_int1); |
| 148 |
let $unique= , PRIMARY KEY(f_int1); |
| 149 |
--source suite/parts/inc/partition_alter_12.inc |
| 150 |
|
| 151 |
--echo # 3.1.2 Negative test: Try DROP and CREATE PRIMARY KEY INPLACE |
| 152 |
--echo # Expect error for INPLACE ALTER |
| 153 |
let $expect_inplace_error= 1; |
| 154 |
let $alter= ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(f_int2, f_int1), |
| 155 |
ALGORITHM = INPLACE; |
| 156 |
let $unique= , PRIMARY KEY(f_int1); |
| 157 |
--source suite/parts/inc/partition_alter_12.inc |
| 158 |
let $expect_inplace_error= 0; |
| 159 |
|
| 160 |
--echo # 3.1.3 DROP and CREATE UNIQUE KEY on different column |
| 161 |
let $alter= ALTER TABLE t1 DROP KEY ukey1, ADD UNIQUE KEY |
| 162 |
ukey2(f_int2, f_int1); |
| 163 |
let $unique= , UNIQUE KEY ukey1(f_int1); |
| 164 |
--source suite/parts/inc/partition_alter_12.inc |
| 165 |
|
| 166 |
--echo # 3.1.4 Negative test: Try DROP and CREATE UNIQUE KEY INPLACE |
| 167 |
--echo # Expect error for INPLACE ALTER |
| 168 |
let $expect_inplace_error= 1; |
| 169 |
let $alter= ALTER TABLE t1 DROP KEY ukey1, ADD UNIQUE KEY |
| 170 |
ukey2(f_int2, f_int1), ALGORITHM = INPLACE; |
| 171 |
let $unique= , UNIQUE KEY ukey1(f_int1); |
| 172 |
--source suite/parts/inc/partition_alter_12.inc |
| 173 |
let $expect_inplace_error= 0; |
| 174 |
} |
| 175 |
|