Non matching attribute when executing exchange partition
- 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)
```sql
DROP TABLE p0;
DROP TABLE t0;
CREATE TABLE `p0` (
`id` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`code` varchar(64) NOT NULL DEFAULT '',
`third_user_name` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`,`code`) /*T![clustered_index] CLUSTERED */,
KEY `idx_third_user_name` (`third_user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY LIST COLUMNS(`code`)
(PARTITION `code_261` VALUES IN ('261'),
PARTITION `code_518` VALUES IN ('518'));
CREATE TABLE `t0` (
`id` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`code` varchar(64) NOT NULL DEFAULT '',
`third_user_name` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`,`code`) /*T![clustered_index] CLUSTERED */,
KEY `idx_third_user_name` (`third_user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
ALTER TABLE `t0` DROP INDEX `idx_third_user_name`;
ALTER TABLE `t0` ADD INDEX `idx_third_user_name` (`third_user_name`);
ALTER TABLE p0 EXCHANGE PARTITION code_518 WITH TABLE t0;
```
### 2. What did you expect to see? (Required)
exchange ddl is successfully executed
### 3. What did you see instead (Required)
```sql
ERROR 1731 (HY000): Non matching attribute 'index: idx_third_user_name' between partition and table
```
Based on the error message, we checked the information about index in the table structure and found that the definition was exactly the same, so we could not determine the reason for the execution failure.
The behaviour can be confusing for users. Maybe, it is better to optimize the error information to explicitly state the cause of the error to avoid confusion.
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.