mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
dea5746de2
for ALTER_PARTITION_ADMIN (CHECK/REPAIR/LOAD INDEX/CACHE INDEX/etc) partitioning marks affected partitions with PART_ADMIN state. The assumption is that the server will call a corresponding method of ha_partition which will reset the state back to PART_NORMAL. This assumption is invalid, the server is not required to do so, indeed, in CHECK ... FOR UPGRADE the server might decide early that the table is fine and won't call ha_partition::check(), leaving partitions in the wrong state. It will thus leak into the next statement confusing the engine about what it is doing (see ha_partition::create_handler_file()), causing a crash later. Let's force all partitions into PART_NORMAL state after the admin operation succeeded, in case it did so without consulting the engine.
234 lines
6.1 KiB
Text
234 lines
6.1 KiB
Text
#
|
|
# Simple test for the erroneos create statements using the
|
|
# partition storage engine
|
|
#
|
|
-- source include/have_partition.inc
|
|
|
|
#
|
|
# Try faulty DROP PARTITION and COALESCE PARTITION
|
|
#
|
|
CREATE TABLE t1 (a int, b int)
|
|
PARTITION BY RANGE (a)
|
|
(PARTITION x0 VALUES LESS THAN (2),
|
|
PARTITION x1 VALUES LESS THAN (4),
|
|
PARTITION x2 VALUES LESS THAN (6),
|
|
PARTITION x3 VALUES LESS THAN (8),
|
|
PARTITION x4 VALUES LESS THAN (10),
|
|
PARTITION x5 VALUES LESS THAN (12),
|
|
PARTITION x6 VALUES LESS THAN (14),
|
|
PARTITION x7 VALUES LESS THAN (16),
|
|
PARTITION x8 VALUES LESS THAN (18),
|
|
PARTITION x9 VALUES LESS THAN (20));
|
|
|
|
--error ER_REORG_OUTSIDE_RANGE
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
|
|
(PARTITION x01 VALUES LESS THAN (2),
|
|
PARTITION x11 VALUES LESS THAN (5));
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 DROP PARTITION x0, x1, x2, x3, x3;
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 DROP PARTITION x0, x1, x2, x10;
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 DROP PARTITION x10, x1, x2, x1;
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 DROP PARTITION x10, x1, x2, x3;
|
|
|
|
--error ER_REORG_PARTITION_NOT_EXIST
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 INTO
|
|
(PARTITION x11 VALUES LESS THAN (22));
|
|
|
|
--error ER_SAME_NAME_PARTITION
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO
|
|
(PARTITION x3 VALUES LESS THAN (6));
|
|
|
|
--error ER_CONSECUTIVE_REORG_PARTITIONS
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0, x2 INTO
|
|
(PARTITION x11 VALUES LESS THAN (2));
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO
|
|
(PARTITION x11 VALUES LESS THAN (4));
|
|
|
|
--error ER_REORG_OUTSIDE_RANGE
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
|
|
(PARTITION x01 VALUES LESS THAN (5));
|
|
|
|
--error ER_RANGE_NOT_INCREASING_ERROR
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
|
|
(PARTITION x01 VALUES LESS THAN (4),
|
|
PARTITION x11 VALUES LESS THAN (2));
|
|
|
|
--error ER_RANGE_NOT_INCREASING_ERROR
|
|
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
|
|
(PARTITION x01 VALUES LESS THAN (6),
|
|
PARTITION x11 VALUES LESS THAN (4));
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY KEY (a)
|
|
PARTITIONS 2;
|
|
|
|
--error ER_SAME_NAME_PARTITION
|
|
ALTER TABLE t1 ADD PARTITION (PARTITION p1);
|
|
|
|
DROP TABLE t1;
|
|
|
|
--error ER_SAME_NAME_PARTITION
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY KEY (a)
|
|
(PARTITION x0, PARTITION x1, PARTITION x2, PARTITION x3, PARTITION x3);
|
|
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY RANGE (a)
|
|
SUBPARTITION BY KEY (a)
|
|
SUBPARTITIONS 2
|
|
(PARTITION x0 VALUES LESS THAN (4),
|
|
PARTITION x1 VALUES LESS THAN (8));
|
|
|
|
--error ER_RANGE_NOT_INCREASING_ERROR
|
|
ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (5)
|
|
(SUBPARTITION sp0, SUBPARTITION sp1));
|
|
|
|
--error ER_ADD_PARTITION_SUBPART_ERROR
|
|
ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (12)
|
|
(SUBPARTITION sp0, SUBPARTITION sp1, SUBPARTITION sp2));
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY LIST (a)
|
|
(PARTITION x0 VALUES IN (1,2,3),
|
|
PARTITION x1 VALUES IN (4,5,6));
|
|
|
|
--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
|
|
ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES IN (3,4));
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a int);
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 DROP PARTITION x1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 COALESCE PARTITION 1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 ANALYZE PARTITION p1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 CHECK PARTITION p1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 OPTIMIZE PARTITION p1;
|
|
|
|
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
|
|
ALTER TABLE t1 REPAIR PARTITION p1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY KEY (a)
|
|
(PARTITION x0, PARTITION x1);
|
|
|
|
--error ER_ADD_PARTITION_NO_NEW_PARTITION
|
|
ALTER TABLE t1 ADD PARTITION PARTITIONS 0;
|
|
|
|
--error ER_TOO_MANY_PARTITIONS_ERROR
|
|
ALTER TABLE t1 ADD PARTITION PARTITIONS 8192;
|
|
|
|
--error ER_ONLY_ON_RANGE_LIST_PARTITION
|
|
ALTER TABLE t1 DROP PARTITION x0;
|
|
|
|
ALTER TABLE t1 COALESCE PARTITION 1;
|
|
|
|
--error ER_DROP_LAST_PARTITION
|
|
ALTER TABLE t1 COALESCE PARTITION 1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (a int)
|
|
PARTITION BY RANGE (a)
|
|
(PARTITION x0 VALUES LESS THAN (4),
|
|
PARTITION x1 VALUES LESS THAN (8));
|
|
|
|
--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
|
|
ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
|
|
|
|
--error ER_DROP_PARTITION_NON_EXISTENT
|
|
ALTER TABLE t1 DROP PARTITION x2;
|
|
|
|
--error ER_COALESCE_ONLY_ON_HASH_PARTITION
|
|
ALTER TABLE t1 COALESCE PARTITION 1;
|
|
|
|
ALTER TABLE t1 DROP PARTITION x1;
|
|
|
|
--error ER_DROP_LAST_PARTITION
|
|
ALTER TABLE t1 DROP PARTITION x0;
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Bug# 16534 - Trying to add multiple partitions crashes server
|
|
#
|
|
CREATE TABLE t1 ( id INT NOT NULL,
|
|
fname VARCHAR(50) NOT NULL,
|
|
lname VARCHAR(50) NOT NULL,
|
|
hired DATE NOT NULL )
|
|
PARTITION BY RANGE(YEAR(hired)) (
|
|
PARTITION p1 VALUES LESS THAN (1991),
|
|
PARTITION p2 VALUES LESS THAN (1996),
|
|
PARTITION p3 VALUES LESS THAN (2001),
|
|
PARTITION p4 VALUES LESS THAN (2005));
|
|
ALTER TABLE t1 ADD PARTITION (
|
|
PARTITION p5 VALUES LESS THAN (2010),
|
|
PARTITION p6 VALUES LESS THAN MAXVALUE);
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
#BUG 15523 ALTER TABLE ... PARTITION BY does not work
|
|
#
|
|
CREATE TABLE t1 (a INT);
|
|
SHOW CREATE TABLE t1;
|
|
ALTER TABLE t1 PARTITION BY KEY(a) PARTITIONS 2;
|
|
SHOW CREATE TABLE t1;
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
#BUG 15820 create table with 1 partition, doing ALTER TABLE ADD PARTITION fails
|
|
#
|
|
CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
|
|
ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
#BUG 15408: Partitions: subpartition names are not unique
|
|
#
|
|
--error ER_SAME_NAME_PARTITION
|
|
CREATE TABLE t1 (s1 int, s2 int)
|
|
PARTITION BY LIST (s1)
|
|
SUBPARTITION BY KEY (s2) (
|
|
PARTITION p1 VALUES IN (0) (SUBPARTITION p1b),
|
|
PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
|
|
);
|
|
|
|
--echo # End of 5.5 tests
|
|
|
|
--echo #
|
|
--echo # MDEV-32155 MariaDB Server crashes with ill-formed partitions
|
|
--echo #
|
|
create table t1 (c1 set ( 'abc' ) binary unicode) partition by linear hash (c1 mod c1) partitions 10;
|
|
alter table t1 check partition all for upgrade;
|
|
--error ER_BAD_FIELD_ERROR
|
|
alter table t1 order by nonexistent;
|
|
drop table t1;
|
|
|
|
--echo # End of 10.5 tests
|