Does not support add column and make it a foreign key in single statement
- 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)
```
mysql> CREATE TABLE `schema_authorwithevenlongername` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(255) NOT NULL, `height` integer UNSIGNED NULL CHECK (`height` >= 0));
Query OK, 0 rows affected, 1 warning (0.08 sec)
mysql> CREATE TABLE `schema_bookwithlongname` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `author_foreign_key_with_really_long_field_name_id` integer NOT NULL);
Query OK, 0 rows affected (0.09 sec)
mysql> ALTER TABLE `schema_bookwithlongname` ADD COLUMN `author_other_really_long_named_i_mean_so_long_fk_id` integer NOT NULL , ADD CONSTRAINT `schema_bookwithlongn_author_other_really__6c36f4d2_fk_schema_au` FOREIGN KEY (`author_other_really_long_named_i_mean_so_long_fk_id`) REFERENCES `schema_authorwithevenlongername`(`id`);
```
### 2. What did you expect to see? (Required)
Add column successfully.
### 3. What did you see instead (Required)
```
ERROR 1072 (42000): Key column 'author_other_really_long_named_i_mean_so_long_fk_id' doesn't exist in table
```
### 4. What is your TiDB version? (Required)
Release Version: v7.2.0
Edition: Community
Git Commit Hash: 9fd5f4a8e4f273a60fbe7d3848f85a1be8f0600b
Git Branch: heads/refs/tags/v7.2.0
UTC Build Time: 2023-06-27 14:56:57
GoVersion: go1.20.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Contributor guide
Assessment
This issue has not been assessed yet.