pingcap / pingcap/tidb

REORGANIZE behavior is not consistent with mysql

Open
#60,760 2 comments 0 reactions 0 assignees View on GitHub
component/ddl sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
```
CREATE TABLE sales_partitioned (
sale_id INT AUTO_INCREMENT,
region VARCHAR(50),
amount DECIMAL(10,2),
sale_date DATE DEFAULT '2023-01-01',
PRIMARY KEY (sale_id, sale_date)
) PARTITION BY RANGE COLUMNS(sale_date) (
PARTITION p2022 VALUES LESS THAN ('2023-01-01'),
PARTITION p2023 VALUES LESS THAN ('2024-01-01')
);

ALTER TABLE sales_partitioned REORGANIZE PARTITION p2023 INTO (
PARTITION p2023q1 VALUES LESS THAN ('2023-04-01'),
PARTITION p2023q2 VALUES LESS THAN ('2023-07-01')
);
```
### 2. What did you expect to see? (Required)

Results from mysql:
```
MySQL [test2]> ALTER TABLE sales_partitioned REORGANIZE PARTITION p2023 INTO (
-> PARTITION p2023q1 VALUES LESS THAN ('2023-04-01'),
-> PARTITION p2023q2 VALUES LESS THAN ('2023-07-01')
-> );
ERROR 1520 (HY000): Reorganize of range partitions cannot change total ranges except for last partition where it can extend the range
```

### 3. What did you see instead (Required)
results from tidb:
```
MySQL [test1]> ALTER TABLE sales_partitioned REORGANIZE PARTITION p2023 INTO (
-> PARTITION p2023q1 VALUES LESS THAN ('2023-04-01'),
-> PARTITION p2023q2 VALUES LESS THAN ('2023-07-01')
-> );
Query OK, 0 rows affected, 1 warning (1.67 sec)
```

### 4. What is your TiDB version? (Required)
```
MySQL [test1]> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.5.6
Edition: Community
Git Commit Hash: 1ad553d6de2cb0c9b2f3cfdb760aaae109b2c466
Git Branch: HEAD
UTC Build Time: 2025-03-12 10:49:51
GoVersion: go1.21.13
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.