Bug #96765 Replace dict_foreign_parse_drop_constraints() with SQL-layer check.
Submitted: 5 Sep 2019 8:13 Modified: 8 Oct 2019 17:24
Reporter: Dmitry Lenev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.19-git OS:Any
Assigned to: CPU Architecture:Any

[5 Sep 2019 8:13] Dmitry Lenev
Description:
In MySQL 8.0 all information about foreign keys is available from the
new data-dictionary, corresponding DD API and sometimes from TABLE_SHARE.

So it should be possible to perform most of DDL checks related to foreign
keys on SQL-layer. Specifically, it should be possible to detect and emit
error for cases when one tries to drop non-existing foreign key. However,
this is still handled on SE level.

Specifically, InnoDB does this in dict_foreign_parse_drop_constraints(),
which actually parses SQL statement [sic!] to find out which foreign keys
we are trying to drop. This means that there is quite some code duplication
and results in awkward error messages in some cases. This also will
create problems for upcoming DROP CONSTRAINT support.

This check should be moved to SQL-layer and
dict_foreign_parse_drop_constraints() should be removed.

How to repeat:
Inspect code in storage/innobase/dict/dict0dict.cc.
[8 Oct 2019 17:24] Paul DuBois
Posted by developer:
 
Fixed in 8.0.19.

Foreign key-handling code duplication between the SQL layer and the
data dictionary was eliminated. A side effect is that some error
messages now are more informative and clear.