Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.5, 10.6, 10.11, 11.4, 11.7(EOL)
-
None
Description
--source include/have_innodb.inc
|
|
set foreign_key_checks=0; |
create or replace table t2 (b int, foreign key (b) references t1(a)) engine=InnoDB; |
create or replace table t1 (pk int primary key, a int) engine=InnoDB; |
set foreign_key_checks=1; |
check table t2 extended; |
alter table t1 add key(a); |
check table t2 extended; |
|
create or replace table t2 (b int, foreign key (b) references t1(a)) engine=InnoDB; |
check table t2 extended; |
|
drop table t2, t1; |
bb-11.8-check-table ceb64ee4d1d5af7ab608bbfd35de88510cce82ea |
check table t2 extended; |
Table Op Msg_type Msg_text |
test.t2 check Warning No suitable key found for foreign key t2_ibfk_1 in table test.t1 |
test.t2 check error Corrupt |
alter table t1 add key(a); |
check table t2 extended; |
Table Op Msg_type Msg_text |
test.t2 check Warning No suitable key found for foreign key t2_ibfk_1 in table test.t1 |
test.t2 check error Corrupt |
create or replace table t2 (b int, foreign key (b) references t1(a)) engine=InnoDB; |
check table t2 extended; |
Table Op Msg_type Msg_text |
test.t2 check status OK |
The first CHECK correctly returns the error: no suitable key, indeed.
Then the error is corrected, the key is added.
But the second CHECK still returns the error, although there is no real problem anymore, which is confirmed by re-creating the referencing table with the same definition as before.
FLUSH TABLES before the 2nd CHECK does not help, either.
Attachments
Issue Links
- relates to
-
MDEV-34309 CHECK TABLE should check that foreign key relations are correct
-
- In Testing
-
In fact, it is not a problem of the CHECK, the FK itself does not work properly in this case. So, the CHECK correctly shows a problem, it's just that we shouldn't have a problem here.
main 4c956fa15be059e35f8ed0de85dc72d5827cee4d
The above is true for 10.6+.
10.5 is worse, it doesn't even allow to re-create the referencing table. But there is no way such a thing would be fixed in 10.5 now, so it doesn't matter.