| 1 |
# |
| 2 |
# MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER |
| 3 |
# |
| 4 |
CREATE TABLE t1(a INT) engine=myisam PARTITION BY RANGE(a) SUBPARTITION BY KEY(a) (PARTITION p0 VALUES LESS THAN (10) (SUBPARTITION s0,SUBPARTITION s1), PARTITION p1 VALUES LESS THAN (20) (SUBPARTITION s2,SUBPARTITION s3)); |
| 5 |
show create table t1; |
| 6 |
Table Create Table |
| 7 |
t1 CREATE TABLE `t1` ( |
| 8 |
`a` int(11) DEFAULT NULL |
| 9 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 10 |
PARTITION BY RANGE (`a`) |
| 11 |
SUBPARTITION BY KEY (`a`) |
| 12 |
(PARTITION `p0` VALUES LESS THAN (10) |
| 13 |
(SUBPARTITION `s0` ENGINE = MyISAM, |
| 14 |
SUBPARTITION `s1` ENGINE = MyISAM), |
| 15 |
PARTITION `p1` VALUES LESS THAN (20) |
| 16 |
(SUBPARTITION `s2` ENGINE = MyISAM, |
| 17 |
SUBPARTITION `s3` ENGINE = MyISAM)) |
| 18 |
ALTER TABLE t1 ADD COLUMN c INT,ALGORITHM=INSTANT; |
| 19 |
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY |
| 20 |
DROP table if exists t1; |
| 21 |
# |
| 22 |
# MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata | |
| 23 |
# ERROR 1507 (HY000): Error in list of partitions to DROP |
| 24 |
# |
| 25 |
CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3)); |
| 26 |
ALTER TABLE t1 DROP PARTITION p; |
| 27 |
DROP TABLE if exists t1; |
| 28 |
# |
| 29 |
# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition |
| 30 |
# |
| 31 |
CREATE TABLE t1 (i INT); |
| 32 |
CREATE VIEW v1 as SELECT * FROM t1; |
| 33 |
CREATE TABLE t2 (i INT); |
| 34 |
ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ; |
| 35 |
ERROR 42000: Can't open table |
| 36 |
DROP VIEW v1; |
| 37 |
DROP TABLE t1, t2; |
| 38 |
# |
| 39 |
# MDEV-34813 ALGORITHM=INSTANT does not work for partitioned tables on indexed column |
| 40 |
# |
| 41 |
CREATE TABLE `t1` ( |
| 42 |
`f1` datetime , |
| 43 |
`f2` VARCHAR(2) , |
| 44 |
`f3` VARCHAR(200) , |
| 45 |
`f4` VARCHAR(100) , |
| 46 |
INDEX `i3` (`f4`) ) |
| 47 |
PARTITION BY RANGE COLUMNS(`f2`) |
| 48 |
(PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB, |
| 49 |
PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB); |
| 50 |
ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE; |
| 51 |
drop table t1; |
| 52 |
# End of 10.5 tests |
| 53 |
# |
| 54 |
# MDEV-34951: InnoDB index corruption when renaming key name with same letter to upper case. |
| 55 |
# |
| 56 |
# Tests on partitioned tables |
| 57 |
# partitioned table with index 'idx' (lowercase) |
| 58 |
CREATE TABLE t_part (a INT, KEY idx(a)) ENGINE=InnoDB |
| 59 |
PARTITION BY HASH(a) PARTITIONS 1; |
| 60 |
# non-partitioned table with index 'IDX' (uppercase) |
| 61 |
CREATE TABLE t_nonpart (a INT, KEY IDX(a)) ENGINE=InnoDB; |
| 62 |
INSERT INTO t_part VALUES (1); |
| 63 |
# Exchange partition |
| 64 |
# ALTER TABLE should fail. Without fix, ALTER TABLE succeeds, SELECT fails. |
| 65 |
ALTER TABLE t_part EXCHANGE PARTITION p0 WITH TABLE t_nonpart; |
| 66 |
ERROR HY000: Tables have different definitions |
| 67 |
SELECT * FROM t_nonpart; |
| 68 |
a |
| 69 |
DROP TABLE t_part, t_nonpart; |
| 70 |
# End of 10.6 tests |
| 71 |
# |
| 72 |
# MDEV-22165 CONVERT PARTITION: move in partition from existing table |
| 73 |
# |
| 74 |
create or replace table tp1 (a int); |
| 75 |
create or replace table t1 (a int) |
| 76 |
partition by hash (a) partitions 2; |
| 77 |
alter table t1 convert table tp1 to partition p2; |
| 78 |
ERROR HY000: CONVERT TABLE TO PARTITION can only be used on RANGE/LIST partitions |
| 79 |
create or replace table t1 (a int) |
| 80 |
partition by range (a) |
| 81 |
(partition p0 values less than (0)); |
| 82 |
alter table t1 convert table non_existent to partition p1 values less than (10); |
| 83 |
ERROR 42S02: Table 'test.non_existent' doesn't exist |
| 84 |
alter table t1 convert table tp1 to partition p1 values less than (10); |
| 85 |
show create table tp1; |
| 86 |
ERROR 42S02: Table 'test.tp1' doesn't exist |
| 87 |
show create table t1; |
| 88 |
Table Create Table |
| 89 |
t1 CREATE TABLE `t1` ( |
| 90 |
`a` int(11) DEFAULT NULL |
| 91 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 92 |
PARTITION BY RANGE (`a`) |
| 93 |
(PARTITION `p0` VALUES LESS THAN (0) ENGINE = X, |
| 94 |
PARTITION `p1` VALUES LESS THAN (10) ENGINE = X) |
| 95 |
create table tp2 (x int); |
| 96 |
alter table t1 convert table tp2 to partition p2 values less than (20); |
| 97 |
ERROR HY000: Tables have different definitions |
| 98 |
show create table tp2; |
| 99 |
Table Create Table |
| 100 |
tp2 CREATE TABLE `tp2` ( |
| 101 |
`x` int(11) DEFAULT NULL |
| 102 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 103 |
show create table t1; |
| 104 |
Table Create Table |
| 105 |
t1 CREATE TABLE `t1` ( |
| 106 |
`a` int(11) DEFAULT NULL |
| 107 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 108 |
PARTITION BY RANGE (`a`) |
| 109 |
(PARTITION `p0` VALUES LESS THAN (0) ENGINE = X, |
| 110 |
PARTITION `p1` VALUES LESS THAN (10) ENGINE = X) |
| 111 |
create or replace table tp2 (a int); |
| 112 |
insert tp2 values (1), (15), (17); |
| 113 |
alter table t1 convert table tp2 to partition p2 values less than (20); |
| 114 |
ERROR HY000: Found a row that does not match the partition |
| 115 |
delete from tp2; |
| 116 |
insert tp2 values (15), (1), (17); |
| 117 |
alter table t1 convert table tp2 to partition p2 values less than (20); |
| 118 |
ERROR HY000: Found a row that does not match the partition |
| 119 |
delete from tp2; |
| 120 |
insert tp2 values (15), (17), (1); |
| 121 |
alter table t1 convert table tp2 to partition p2 values less than (20); |
| 122 |
ERROR HY000: Found a row that does not match the partition |
| 123 |
delete from tp2; |
| 124 |
insert tp2 values (15), (17); |
| 125 |
alter table t1 convert table tp2 to partition p2 values less than (20); |
| 126 |
show create table tp2; |
| 127 |
ERROR 42S02: Table 'test.tp2' doesn't exist |
| 128 |
show create table t1; |
| 129 |
Table Create Table |
| 130 |
t1 CREATE TABLE `t1` ( |
| 131 |
`a` int(11) DEFAULT NULL |
| 132 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 133 |
PARTITION BY RANGE (`a`) |
| 134 |
(PARTITION `p0` VALUES LESS THAN (0) ENGINE = X, |
| 135 |
PARTITION `p1` VALUES LESS THAN (10) ENGINE = X, |
| 136 |
PARTITION `p2` VALUES LESS THAN (20) ENGINE = X) |
| 137 |
select * from t1 partition (p2); |
| 138 |
a |
| 139 |
15 |
| 140 |
17 |
| 141 |
create or replace table t1 (a int) |
| 142 |
partition by range (a) ( |
| 143 |
p0 values less than (0), |
| 144 |
pn values less than (30)); |
| 145 |
insert into t1 values (1); |
| 146 |
create or replace table tp1 (a int); |
| 147 |
insert into tp1 values (2); |
| 148 |
alter table t1 convert table tp1 to partition p1 values less than (10); |
| 149 |
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition |
| 150 |
drop tables t1, tp1; |
| 151 |
# |
| 152 |
# MDEV-22166 CONVERT PARTITION: move out partition into a table |
| 153 |
# |
| 154 |
create or replace table t1 (x int); |
| 155 |
alter table t1 convert partition p1 to table tp1; |
| 156 |
ERROR HY000: Partition management on a not partitioned table is not possible |
| 157 |
create or replace table t1 (x int) |
| 158 |
partition by hash(x) partitions 2; |
| 159 |
alter table t1 convert partition p1 to table tp1; |
| 160 |
ERROR HY000: CONVERT PARTITION can only be used on RANGE/LIST partitions |
| 161 |
create or replace table t1 (x int) |
| 162 |
partition by key(x) partitions 2; |
| 163 |
alter table t1 convert partition p1 to table tp1; |
| 164 |
ERROR HY000: CONVERT PARTITION can only be used on RANGE/LIST partitions |
| 165 |
create or replace table t1 (x int) |
| 166 |
partition by range(x) |
| 167 |
subpartition by hash(x) subpartitions 3 ( |
| 168 |
partition p1 values less than (10), |
| 169 |
partition pn values less than maxvalue); |
| 170 |
alter table t1 convert partition p1 to table p1; |
| 171 |
ERROR HY000: Convert partition is not supported for subpartitioned table. |
| 172 |
alter table t1 convert partition p1sp0 to table p1; |
| 173 |
ERROR HY000: Wrong partition name or partition list |
| 174 |
create or replace table t1 (x int) |
| 175 |
partition by range(x) ( |
| 176 |
partition p1 values less than (10)); |
| 177 |
alter table t1 convert partition p1 to table tp1; |
| 178 |
ERROR HY000: Cannot remove all partitions, use DROP TABLE instead |
| 179 |
create or replace temporary table t1 (x int) |
| 180 |
partition by range(x) ( |
| 181 |
partition p0 values less than (10), |
| 182 |
partition pn values less than maxvalue); |
| 183 |
ERROR HY000: Partitioned tables do not support CREATE TEMPORARY TABLE |
| 184 |
create or replace table t1 (x int) |
| 185 |
partition by range(x) ( |
| 186 |
partition p1 values less than (10), |
| 187 |
partition p2 values less than (20), |
| 188 |
partition p3 values less than (30), |
| 189 |
partition p4 values less than (40), |
| 190 |
partition p5 values less than (50), |
| 191 |
partition pn values less than maxvalue); |
| 192 |
insert into t1 values (2), (12), (22), (32), (42), (52); |
| 193 |
create or replace table tp2 (y int); |
| 194 |
insert tp2 values (88); |
| 195 |
alter table t1 convert partition p2 to table tp2, drop partition p3; |
| 196 |
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' drop partition p3' at line 1 |
| 197 |
alter table t1 convert partition p00 to table tp00; |
| 198 |
ERROR HY000: Wrong partition name or partition list |
| 199 |
alter table t1 convert partition p00 to table tp2; |
| 200 |
ERROR 42S01: Table 'tp2' already exists |
| 201 |
alter table t1 convert partition p2 to table tp2; |
| 202 |
ERROR 42S01: Table 'tp2' already exists |
| 203 |
create trigger tr1 before update on t1 for each row |
| 204 |
begin |
| 205 |
alter table t1 convert partition p2 to table tp2; |
| 206 |
end$ |
| 207 |
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger |
| 208 |
create function f1() returns int |
| 209 |
begin |
| 210 |
alter table t1 convert partition p2 to table tp2; |
| 211 |
end$ |
| 212 |
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger |
| 213 |
select * from tp2; |
| 214 |
y |
| 215 |
88 |
| 216 |
drop table tp2; |
| 217 |
alter table t1 convert partition p2 to table tp2; |
| 218 |
show create table tp2; |
| 219 |
Table Create Table |
| 220 |
tp2 CREATE TABLE `tp2` ( |
| 221 |
`x` int(11) DEFAULT NULL |
| 222 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 223 |
select * from tp2; |
| 224 |
x |
| 225 |
12 |
| 226 |
show create table t1; |
| 227 |
Table Create Table |
| 228 |
t1 CREATE TABLE `t1` ( |
| 229 |
`x` int(11) DEFAULT NULL |
| 230 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 231 |
PARTITION BY RANGE (`x`) |
| 232 |
(PARTITION `p1` VALUES LESS THAN (10) ENGINE = X, |
| 233 |
PARTITION `p3` VALUES LESS THAN (30) ENGINE = X, |
| 234 |
PARTITION `p4` VALUES LESS THAN (40) ENGINE = X, |
| 235 |
PARTITION `p5` VALUES LESS THAN (50) ENGINE = X, |
| 236 |
PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) |
| 237 |
select * from t1 order by x; |
| 238 |
x |
| 239 |
2 |
| 240 |
22 |
| 241 |
32 |
| 242 |
42 |
| 243 |
52 |
| 244 |
alter table t1 convert partition p3 to table inexistent.tp3; |
| 245 |
ERROR 42000: Unknown database 'inexistent' |
| 246 |
create database EXISTENT; |
| 247 |
alter table t1 convert partition p3 to table EXISTENT.TP3; |
| 248 |
show create table EXISTENT.TP3; |
| 249 |
Table Create Table |
| 250 |
TP3 CREATE TABLE `TP3`-ok ( |
| 251 |
`x` int(11) DEFAULT NULL |
| 252 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 253 |
select * from EXISTENT.TP3 order by x; |
| 254 |
x |
| 255 |
22 |
| 256 |
show create table t1; |
| 257 |
Table Create Table |
| 258 |
t1 CREATE TABLE `t1` ( |
| 259 |
`x` int(11) DEFAULT NULL |
| 260 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 261 |
PARTITION BY RANGE (`x`) |
| 262 |
(PARTITION `p1` VALUES LESS THAN (10) ENGINE = X, |
| 263 |
PARTITION `p4` VALUES LESS THAN (40) ENGINE = X, |
| 264 |
PARTITION `p5` VALUES LESS THAN (50) ENGINE = X, |
| 265 |
PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) |
| 266 |
select * from t1 order by x; |
| 267 |
x |
| 268 |
2 |
| 269 |
32 |
| 270 |
42 |
| 271 |
52 |
| 272 |
# LOCK TABLES |
| 273 |
lock tables t1 write; |
| 274 |
alter table t1 convert partition p4 to table tp4; |
| 275 |
show create table tp4; |
| 276 |
ERROR HY000: Table 'tp4' was not locked with LOCK TABLES |
| 277 |
unlock tables; |
| 278 |
show create table tp4; |
| 279 |
Table Create Table |
| 280 |
tp4 CREATE TABLE `tp4` ( |
| 281 |
`x` int(11) DEFAULT NULL |
| 282 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 283 |
select * from tp4; |
| 284 |
x |
| 285 |
32 |
| 286 |
show create table t1; |
| 287 |
Table Create Table |
| 288 |
t1 CREATE TABLE `t1` ( |
| 289 |
`x` int(11) DEFAULT NULL |
| 290 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 291 |
PARTITION BY RANGE (`x`) |
| 292 |
(PARTITION `p1` VALUES LESS THAN (10) ENGINE = X, |
| 293 |
PARTITION `p5` VALUES LESS THAN (50) ENGINE = X, |
| 294 |
PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) |
| 295 |
select * from t1 order by x; |
| 296 |
x |
| 297 |
2 |
| 298 |
42 |
| 299 |
52 |
| 300 |
# PS |
| 301 |
prepare stmt from 'alter table t1 convert partition p5 to table tp5'; |
| 302 |
execute stmt; |
| 303 |
show create table tp5; |
| 304 |
Table Create Table |
| 305 |
tp5 CREATE TABLE `tp5` ( |
| 306 |
`x` int(11) DEFAULT NULL |
| 307 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 308 |
select * from tp5; |
| 309 |
x |
| 310 |
42 |
| 311 |
show create table t1; |
| 312 |
Table Create Table |
| 313 |
t1 CREATE TABLE `t1` ( |
| 314 |
`x` int(11) DEFAULT NULL |
| 315 |
) ENGINE=X DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 316 |
PARTITION BY RANGE (`x`) |
| 317 |
(PARTITION `p1` VALUES LESS THAN (10) ENGINE = X, |
| 318 |
PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) |
| 319 |
select * from t1 order by x; |
| 320 |
x |
| 321 |
2 |
| 322 |
52 |
| 323 |
drop table tp5; |
| 324 |
execute stmt; |
| 325 |
ERROR HY000: Wrong partition name or partition list |
| 326 |
execute stmt; |
| 327 |
ERROR HY000: Wrong partition name or partition list |
| 328 |
drop prepare stmt; |
| 329 |
# Privileges |
| 330 |
create user alan; |
| 331 |
grant usage on *.* to alan; |
| 332 |
grant create, insert on test.* to alan; |
| 333 |
connect alan,localhost,alan,,test; |
| 334 |
show grants for current_user; |
| 335 |
Grants for alan@% |
| 336 |
GRANT USAGE ON *.* TO `alan`@`%` |
| 337 |
GRANT INSERT, CREATE ON `test`.* TO `alan`@`%` |
| 338 |
alter table t1 convert partition p1 to table tp1; |
| 339 |
ERROR 42000: DROP command denied to user 'alan'@'localhost' for table `test`.`t1` |
| 340 |
connection default; |
| 341 |
revoke all on test.* from alan; |
| 342 |
grant create, insert, alter on test.* to alan; |
| 343 |
connection alan; |
| 344 |
use test; |
| 345 |
show grants for current_user; |
| 346 |
Grants for alan@% |
| 347 |
GRANT USAGE ON *.* TO `alan`@`%` |
| 348 |
GRANT INSERT, CREATE, ALTER ON `test`.* TO `alan`@`%` |
| 349 |
alter table t1 convert partition p1 to table tp1; |
| 350 |
ERROR 42000: DROP command denied to user 'alan'@'localhost' for table `test`.`t1` |
| 351 |
connection default; |
| 352 |
revoke all on test.* from alan; |
| 353 |
grant create, drop, alter on test.* to alan; |
| 354 |
connection alan; |
| 355 |
use test; |
| 356 |
show grants for current_user; |
| 357 |
Grants for alan@% |
| 358 |
GRANT USAGE ON *.* TO `alan`@`%` |
| 359 |
GRANT CREATE, DROP, ALTER ON `test`.* TO `alan`@`%` |
| 360 |
alter table t1 convert partition p1 to table tp1; |
| 361 |
ERROR 42000: INSERT command denied to user 'alan'@'localhost' for table `test`.`tp1` |
| 362 |
connection default; |
| 363 |
revoke all on test.* from alan; |
| 364 |
grant insert, drop, alter on test.* to alan; |
| 365 |
connection alan; |
| 366 |
use test; |
| 367 |
show grants for current_user; |
| 368 |
Grants for alan@% |
| 369 |
GRANT USAGE ON *.* TO `alan`@`%` |
| 370 |
GRANT INSERT, DROP, ALTER ON `test`.* TO `alan`@`%` |
| 371 |
alter table t1 convert partition p1 to table tp1; |
| 372 |
ERROR 42000: CREATE command denied to user 'alan'@'localhost' for table `test`.`tp1` |
| 373 |
connection default; |
| 374 |
grant create, insert, drop, alter on test.* to alan; |
| 375 |
connection alan; |
| 376 |
use test; |
| 377 |
show grants for current_user; |
| 378 |
Grants for alan@% |
| 379 |
GRANT USAGE ON *.* TO `alan`@`%` |
| 380 |
GRANT INSERT, CREATE, DROP, ALTER ON `test`.* TO `alan`@`%` |
| 381 |
alter table t1 convert partition p1 to table tp1; |
| 382 |
disconnect alan; |
| 383 |
connection default; |
| 384 |
drop database EXISTENT; |
| 385 |
drop user alan; |
| 386 |
drop tables t1, tp1, tp2, tp4; |
| 387 |
# |
| 388 |
# MDEV-31014 Database privileges are insufficient for CONVERT TABLE TO PARTITION |
| 389 |
# |
| 390 |
create database db; |
| 391 |
create user u@localhost; |
| 392 |
grant all on db.* to u@localhost; |
| 393 |
connect con1,localhost,u,,db; |
| 394 |
create table t1 (a int) partition by range(a) (p1 values less than (100), p2 values less than (1000)); |
| 395 |
alter table t1 convert partition p2 to table tp; |
| 396 |
alter table t1 convert table tp to partition p2 values less than (1000); |
| 397 |
disconnect con1; |
| 398 |
connection default; |
| 399 |
drop user u@localhost; |
| 400 |
drop database db; |
| 401 |
# |
| 402 |
# MDEV-37328 Assertion failure in make_empty_rec upon CONVERT PARTITION |
| 403 |
# |
| 404 |
create table t (f1 int, f2 int, f3 int, f4 int, f5 int, f6 int, f7 int) engine=myisam |
| 405 |
partition by list (f3) ( |
| 406 |
partition p0 values in (null,0), |
| 407 |
partition p1 values in (1,2,3), |
| 408 |
partition p2 default |
| 409 |
); |
| 410 |
alter table t convert partition p0 to table tp; |
| 411 |
drop table if exists tp, t; |
| 412 |
# End of 10.11 tests |
| 413 |
# |
| 414 |
# MDEV-22164 without validation for exchange partition/convert in |
| 415 |
# |
| 416 |
call mtr.add_suppression('was altered WITHOUT'); |
| 417 |
create table validation(x int); |
| 418 |
drop table validation; |
| 419 |
create table t (a int primary key); |
| 420 |
create table tp (a int primary key) partition by range (a) ( |
| 421 |
partition p0 values less than (100), |
| 422 |
p1 values less than (300)); |
| 423 |
insert into t values (1), (99); |
| 424 |
insert into tp values (2), (200); |
| 425 |
select * from t order by a; |
| 426 |
a |
| 427 |
1 |
| 428 |
99 |
| 429 |
select * from tp partition (p0) order by a; |
| 430 |
a |
| 431 |
2 |
| 432 |
select * from tp partition (p1) order by a; |
| 433 |
a |
| 434 |
200 |
| 435 |
alter table tp exchange partition p0 with table t; |
| 436 |
select * from t order by a; |
| 437 |
a |
| 438 |
2 |
| 439 |
select * from tp partition (p0) order by a; |
| 440 |
a |
| 441 |
1 |
| 442 |
99 |
| 443 |
select * from tp partition (p1) order by a; |
| 444 |
a |
| 445 |
200 |
| 446 |
alter table tp exchange partition p0 with table t; |
| 447 |
select * from t order by a; |
| 448 |
a |
| 449 |
1 |
| 450 |
99 |
| 451 |
select * from tp partition (p0) order by a; |
| 452 |
a |
| 453 |
2 |
| 454 |
select * from tp partition (p1) order by a; |
| 455 |
a |
| 456 |
200 |
| 457 |
alter table tp exchange partition p1 with table t; |
| 458 |
ERROR HY000: Found a row that does not match the partition |
| 459 |
alter table tp exchange partition p1 with table t with validation; |
| 460 |
ERROR HY000: Found a row that does not match the partition |
| 461 |
alter table tp exchange partition p1 with table t without validation; |
| 462 |
FOUND 1 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 463 |
select * from t order by a; |
| 464 |
a |
| 465 |
200 |
| 466 |
select * from tp partition (p1) order by a; |
| 467 |
a |
| 468 |
1 |
| 469 |
99 |
| 470 |
alter table tp check partition p0; |
| 471 |
Table Op Msg_type Msg_text |
| 472 |
test.tp check status OK |
| 473 |
alter table tp check partition p1; |
| 474 |
Table Op Msg_type Msg_text |
| 475 |
test.tp check error Found a misplaced row |
| 476 |
test.tp check error Partition p1 returned error |
| 477 |
test.tp check error Upgrade required. Please do "REPAIR TABLE `tp`" or dump/reload to fix it! |
| 478 |
alter table tp exchange partition p1 with table t with validation; |
| 479 |
alter table tp exchange partition p1 with table t with validation; |
| 480 |
ERROR HY000: Found a row that does not match the partition |
| 481 |
select * from t order by a; |
| 482 |
a |
| 483 |
1 |
| 484 |
99 |
| 485 |
select * from tp partition (p1) order by a; |
| 486 |
a |
| 487 |
200 |
| 488 |
create or replace procedure validation() |
| 489 |
alter table tp exchange partition p1 with table t with validation; |
| 490 |
create or replace procedure without_validation() |
| 491 |
alter table tp exchange partition p1 with table t without validation; |
| 492 |
call validation; |
| 493 |
ERROR HY000: Found a row that does not match the partition |
| 494 |
call without_validation; |
| 495 |
FOUND 2 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 496 |
call validation; |
| 497 |
call validation; |
| 498 |
ERROR HY000: Found a row that does not match the partition |
| 499 |
call without_validation; |
| 500 |
FOUND 3 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 501 |
select * from t order by a; |
| 502 |
a |
| 503 |
200 |
| 504 |
select * from tp partition (p1) order by a; |
| 505 |
a |
| 506 |
1 |
| 507 |
99 |
| 508 |
call validation; |
| 509 |
select * from t order by a; |
| 510 |
a |
| 511 |
1 |
| 512 |
99 |
| 513 |
select * from tp partition (p1) order by a; |
| 514 |
a |
| 515 |
200 |
| 516 |
drop procedure validation; |
| 517 |
drop procedure without_validation; |
| 518 |
prepare validation from "alter table tp exchange partition p1 with table t with validation"; |
| 519 |
prepare without_validation from "alter table tp exchange partition p1 with table t without validation"; |
| 520 |
execute validation; |
| 521 |
ERROR HY000: Found a row that does not match the partition |
| 522 |
execute without_validation; |
| 523 |
FOUND 4 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 524 |
execute validation; |
| 525 |
execute validation; |
| 526 |
ERROR HY000: Found a row that does not match the partition |
| 527 |
execute without_validation; |
| 528 |
FOUND 5 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 529 |
select * from t order by a; |
| 530 |
a |
| 531 |
200 |
| 532 |
select * from tp partition (p1) order by a; |
| 533 |
a |
| 534 |
1 |
| 535 |
99 |
| 536 |
execute validation; |
| 537 |
select * from t order by a; |
| 538 |
a |
| 539 |
1 |
| 540 |
99 |
| 541 |
select * from tp partition (p1) order by a; |
| 542 |
a |
| 543 |
200 |
| 544 |
drop prepare validation; |
| 545 |
drop prepare without_validation; |
| 546 |
alter table tp convert table t to partition p2 values less than (maxvalue); |
| 547 |
ERROR HY000: Found a row that does not match the partition |
| 548 |
alter table tp convert table t to partition p2 values less than (maxvalue) with validation; |
| 549 |
ERROR HY000: Found a row that does not match the partition |
| 550 |
alter table tp convert table t to partition p2 values less than (maxvalue) without validation; |
| 551 |
FOUND 6 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 552 |
select * from tp partition (p0) order by a; |
| 553 |
a |
| 554 |
2 |
| 555 |
select * from tp partition (p1) order by a; |
| 556 |
a |
| 557 |
200 |
| 558 |
select * from tp partition (p2) order by a; |
| 559 |
a |
| 560 |
1 |
| 561 |
99 |
| 562 |
create table t (a int primary key); |
| 563 |
insert t values (1), (2); |
| 564 |
create or replace table tp (a int primary key) |
| 565 |
partition by hash(a) partitions 2; |
| 566 |
insert tp values (1), (2), (3), (4); |
| 567 |
alter table tp exchange partition p0 with table t; |
| 568 |
ERROR HY000: Found a row that does not match the partition |
| 569 |
alter table tp exchange partition p0 with table t without validation; |
| 570 |
FOUND 7 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 571 |
select * from t; |
| 572 |
a |
| 573 |
2 |
| 574 |
4 |
| 575 |
alter table tp exchange partition p0 with table t; |
| 576 |
drop table tp; |
| 577 |
create or replace table tp (a int primary key) |
| 578 |
partition by list(a) ( |
| 579 |
partition p0 values in (2, 3, 4), |
| 580 |
partition p1 values in (12, 13, 14), |
| 581 |
partition p2 values in (52, 53, 54)); |
| 582 |
insert tp values (12), (2), (3), (4); |
| 583 |
alter table tp exchange partition p0 with table t; |
| 584 |
ERROR HY000: Table has no partition for value 0 |
| 585 |
alter table tp exchange partition p0 with table t without validation; |
| 586 |
FOUND 8 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err |
| 587 |
select * from t; |
| 588 |
a |
| 589 |
2 |
| 590 |
3 |
| 591 |
4 |
| 592 |
alter table tp exchange partition p0 with table t; |
| 593 |
drop tables tp, t; |
| 594 |
# End of 11.4 tests |