[MDEV-31212] Range partition: allow ADD PARTITION into the middle of ranges list Created: 2023-05-08  Updated: 2023-05-08

Status: Open
Project: MariaDB Server
Component/s: Partitioning
Fix Version/s: None

Type: Task Priority: Major
Reporter: Aleksey Midenkov Assignee: Aleksey Midenkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-27180 Fully atomic partitioning DDL operations Stalled
Relates
relates to MDEV-25495 Auto-drop old history partition for s... In Review
relates to MDEV-31213 CONVERT TABLE TO PARTITION: allow cop... Open

 Description   

1. Fast ADD case: existing rows do not match new partition range

Reproduce

create or replace table t1 (x int)
partition by range columns (x) (
  partition p0 values less than (10),
  partition p1 values less than (20),
  partition pn values less than maxvalue);
 
insert into t1 values (1);
insert into t1 values (11);
insert into t1 values (31);
 
alter table t1 add partition (partition p2 values less than (30));

Result

alter table t1 add partition (partition p2 values less than (30));
ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition

Expected

Partition p2 added between p1 and pn.

Workaround via CONVERT PARTITION

create or replace table t1 (x int)
partition by range columns (x) (
  partition p0 values less than (10),
  partition p1 values less than (20),
  partition pn values less than maxvalue);
 
insert into t1 values (1);
insert into t1 values (11);
insert into t1 values (31);
 
alter table t1 convert partition pn to table pn;
alter table t1 add partition (partition p2 values less than (30));
alter table t1 convert table pn to partition pn values less than maxvalue;

Workaround result

CREATE TABLE `t1` (
  `x` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
 PARTITION BY RANGE  COLUMNS(`x`)
(PARTITION `p0` VALUES LESS THAN (10) ENGINE = InnoDB,
 PARTITION `p1` VALUES LESS THAN (20) ENGINE = InnoDB,
 PARTITION `p2` VALUES LESS THAN (30) ENGINE = InnoDB,
 PARTITION `pn` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB)

2. Copy case: existing rows match new partition range

Reproduce

create or replace table t1 (x int)
partition by range columns (x) (
  partition p0 values less than (10),
  partition p1 values less than (20),
  partition pn values less than maxvalue);
 
insert into t1 values (21);
 
alter table t1 add partition (partition p2 values less than (30));

Expected

Partition p2 is added between p1 and pn; row 21 is moved to partition p2.

Workaround via CONVERT PARTITION does not work (MDEV-31213)

create or replace table t1 (x int)
partition by range columns (x) (
  partition p0 values less than (10),
  partition p1 values less than (20),
  partition pn values less than maxvalue);
 
insert into t1 values (21);
 
alter table t1 convert partition pn to table pn;
alter table t1 add partition (partition p2 values less than (30));
alter table t1 convert table pn to partition pn values less than maxvalue;

Result

alter table t1 convert table pn to partition pn values less than maxvalue;
ERROR 1737 (HY000): Found a row that does not match the partition


Generated at Thu Feb 08 10:22:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.