[MDEV-19453] FK errors are hidden behind an obscure command Created: 2019-05-13  Updated: 2020-08-08

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Sergei Golubchik Assignee: Marko Mäkelä
Resolution: Unresolved Votes: 1
Labels: None

Issue Links:
Relates
relates to MDEV-16356 Allow ALGORITHM=NOCOPY for ADD CONSTR... Open
relates to MDEV-16417 Store Foreign Key metadata outside of... In Review

 Description   

Whenever creating a foreign key fails, the server reports something like

1005: Can't create table test.t3 (errno: 150 "Foreign key constraint is incorrectly formed")

which is not very informative. One can get a much better understanding of an error by issuing SHOW ENGINE INNODB STATUS, if one knows to do it.

But one shouldn't be required to. The error information should be returned when an error happens. For example, InnoDB could return a warning with, say, "There is no index in the referenced table where the referenced columns appear as the first columns" (may be slightly paraphrased, as appropriate for a warning message).

It could still do its SHOW ENGINE INNODB STATUS, but returning a warning goes a long way towards helping users to understand the problem



 Comments   
Comment by Marko Mäkelä [ 2020-08-08 ]

I think that this should be addressed as part of MDEV-16417.

If ALTER TABLE is using the native algorithm (not ALGORITHM=COPY), then better messages could already be reported. But, until MDEV-16356 is fixed, ADD FOREIGN KEY will require ALGORITHM=COPY unless SET foreign_key_checks=0 is in effect.

Generated at Thu Feb 08 08:51:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.