pingcap / pingcap/tidb

Bad error message for DROP PARTITION of non-existing partition

Open
#42,520 0 comments 0 reactions 1 assignee Claimed by @Defined2014 View on GitHub
component/tablepartition severity/minor 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 t (a int) partition by range (a) (partition p0 values less than (1000000));
alter table t drop partition pNonExisting;
```

The issue is that the number of remaining partitions are checked before the list of partitions is verified.

**Note that we are currently bug compatible with MySQL** :)

### 2. What did you expect to see? (Required)
```
tidb> create table t (a int) partition by range (a) (partition p0 values less than (1000000));
Query OK, 0 rows affected (0.02 sec)

tidb> alter table t drop partition pNonExisting;
ERROR 1507 (HY000): Error in list of partitions to DROP
```

### 3. What did you see instead (Required)
```
tidb> create table t (a int) partition by range (a) (partition p0 values less than (1000000));
Query OK, 0 rows affected (0.02 sec)

tidb> alter table t drop partition pNonExisting;
ERROR 1508 (HY000): Cannot remove all partitions, use DROP TABLE instead
```

### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v7.1.0-alpha-25-gcc02f50146
Edition: Community
Git Commit Hash: cc02f501467181a2b3c62ec7736ebf1fd88c497e
Git Branch: master
UTC Build Time: 2023-03-23 09:33:25
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
```

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.