pingcap / pingcap/tidb

Support drop and add column with same name in one statement

Open
#38,568 3 comments 0 reactions 0 assignees View on GitHub
type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature request

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE `Test` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`col0` BIGINT NULL,
`col1` BIGINT NULL,
`col2` BIGINT NULL,
`col3` BIGINT NULL,
`col4` BIGINT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE `Test` DROP COLUMN `col0`,
ADD COLUMN `col0` DECIMAL(15, 6) NULL,
DROP COLUMN `col1`,
ADD COLUMN `col1` DATE NULL,
DROP COLUMN `col2`,
ADD COLUMN `col2` DATETIME(0) NULL,
DROP COLUMN `col3`,
ADD COLUMN `col3` JSON NULL,
DROP COLUMN `col4`,
ADD COLUMN `col4` TIMESTAMP(0) NULL;
```

### 2. What did you expect to see? (Required)

Should be work well like MySQL.

### 3. What did you see instead (Required)

```
ERROR 1060 (42S21): Duplicate column name 'col0'
```

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

```
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.3.0
Edition: Community
Git Commit Hash: ecd67531f1721d3e49eb15a202ac7c0ae02291ec
Git Branch: heads/refs/tags/v6.3.0
UTC Build Time: 2022-09-23 14:21:08
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 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.