Cannot import mysqldump due to empty named constraint
- 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)
I have a database installed on tidb 5.4.1:
it is working properly. I have backed it up using mysql dump, but cannot import that to same version of tidb. THe issue is a constraint name of ``.
```
show create table wp_tec_occurrences;
wp_tec_occurrences | CREATE TABLE `wp_tec_occurrences` (
`occurrence_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`event_id` bigint(20) unsigned NOT NULL,
`post_id` bigint(20) unsigned NOT NULL,
`start_date` datetime NOT NULL,
`start_date_utc` datetime NOT NULL,
`end_date` datetime NOT NULL,
`end_date_utc` datetime NOT NULL,
`duration` mediumint(30) DEFAULT '7200',
`hash` varchar(40) NOT NULL,
`updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`occurrence_id`) /*T![clustered_index] CLUSTERED */,
UNIQUE KEY `hash` (`hash`),
CONSTRAINT `` FOREIGN KEY (`event_id`) REFERENCES `wp_tec_events` (`event_id`) ON DELETE CASCADE,
CONSTRAINT `ref_event_id` FOREIGN KEY (`event_id`) REFERENCES `wp_tec_events` (`event_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=90001
```
I cannot drop the `` constraint. I created the new named one (ref_event_id), but cannot get rid of the ``.
To be honest I'm not sure how this got created. Its part of wordpress.
### 2. What did you expect to see? (Required)
I expect that a database i dump can be imported as a means of backup/restore or moving between servers.
### 3. What did you see instead (Required)
The restore does not work unless I edit the dump file to name the empty constraint
### 4. What is your TiDB version? (Required)
```
*************************** 1. row ***************************
tidb_version(): Release Version: v5.4.1
Edition: Community
Git Commit Hash: be484475e76b3aaa2cad520111353c3327db35fa
Git Branch: heads/refs/tags/v5.4.1
UTC Build Time: 2022-05-07 04:31:32
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```
So. How can i rename/delete this empty - named constraint?
Contributor guide
Assessment
This issue has not been assessed yet.