Bug #115457 | rename of a column in multi-column foreign key returns ERROR 1146 (42S02) | ||
---|---|---|---|
Submitted: | 28 Jun 14:42 | Modified: | 28 Jun 15:27 |
Reporter: | John Scott | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | foreign key multi-column |
[28 Jun 14:42]
John Scott
[28 Jun 15:07]
John Scott
Forgot to mention: work-around: "set foreign_key_checks=0;"
[28 Jun 15:27]
MySQL Verification Team
HI Mr. Scott, Thank you for your bug report. We repeated your test case: ysql> DROP TABLE IF EXISTS t1, t2; CREATE TABLE `t1` ( `id` bigint NOT NULL AUTO_INCREMENT, `descr` varchar(25) NOT NULL, `js_id` bigint NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY js_id_idx (descr,js_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `t2` ( id bigint not null auto_increment, descr varchar(25) not null, t1_js_id bigint not null, PRIMARY KEY (`id`), UNIQUE KEY fk_t1_js_id_idx (descr,t1_js_id), CONSTRAINT fk_t1_js_id FOREIGN KEY (descr,t1_js_id) references t1 (descr,js_id) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; ALTER TABLE t1 change js_id internal_id bigint not null; show create table t1; show create table t2; DROP TABLE IF EXISTS t1, t2; Query OK, 0 rows affected, 2 warnings (0.06 sec) mysql> mysql> mysql> CREATE TABLE `t1` ( `id` bigint NOT NULL AUTO_INCREMENT, `descr` varchar(25) NOT NULL, `js_id` bigint NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY js_id_idx (descr,js_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; Query OK, 0 rows affected (0.07 sec) mysql> mysql> CREATE TABLE `t2` ( id bigint not null auto_increment, descr varchar(25) not null, t1_js_id bigint not null, PRIMARY KEY (`id`), UNIQUE KEY fk_t1_js_id_idx (descr,t1_js_id), CONSTRAINT fk_t1_js_id FOREIGN KEY (descr,t1_js_id) references t1 (descr,js_id) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; Query OK, 0 rows affected (0.01 sec) mysql> mysql> ALTER TABLE t1 change js_id internal_id bigint not null; ERROR 1146 (42S02): Table 'test.t1' doesn't exist mysql> mysql> show create table t1; +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `id` bigint NOT NULL AUTO_INCREMENT, `descr` varchar(25) NOT NULL, `internal_id` bigint NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `js_id_idx` (`descr`,`internal_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> show create table t2; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t2 | CREATE TABLE `t2` ( `id` bigint NOT NULL AUTO_INCREMENT, `descr` varchar(25) NOT NULL, `t1_js_id` bigint NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `fk_t1_js_id_idx` (`descr`,`t1_js_id`), CONSTRAINT `fk_t1_js_id` FOREIGN KEY (`descr`, `t1_js_id`) REFERENCES `t1` (`descr`, `internal_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> DROP TABLE IF EXISTS t1, t2; Query OK, 0 rows affected (0.01 sec) This is now a verified bug report. Thank you .......
[28 Jun 15:28]
MySQL Verification Team
Changing relevant fields.