Description:
If the FOREIGN KEY of the child table which is the prefix of parent table's PK/UK should not have the same name as the parent table's PK/UK.
This is confusing.
In class Table_share_foreign_key_info, unique_constraint_name is the name of unique key matching FK in parent table, "" if there is no unique key.
```
typedef struct Table_share_foreign_key_info {
LEX_CSTRING referenced_table_db;
LEX_CSTRING referenced_table_name;
/**
Name of unique key matching FK in parent table, "" if there is no
unique key.
*/
LEX_CSTRING unique_constraint_name;
dd::Foreign_key::enum_rule update_rule, delete_rule;
uint columns;
/**
Arrays with names of referencing columns of the FK.
*/
LEX_CSTRING *column_name;
/*
Check whether foreign key of Child table have the same columns with parent
table.
*/
bool is_full_referenced;
} TABLE_SHARE_FOREIGN_KEY_INFO;
```
How to repeat:
CREATE TABLE parent (
id INT NOT NULL,
did INT,
PRIMARY KEY (id, did)
) ENGINE=INNODB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
INDEX par_ind (parent_id),
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=INNODB;
The unique_constraint_name of child table's FOREIGN KEY in table_share is 'PRIMARY' which has only one column 'parent_id'.
However, the PRIMARY KEY of parent table has two columns which are id and did.
Suggested fix:
There are two possible ways to fix it.
1. Add an attribute to the TABLE_SHARE_FOREIGN_KEY_INFO class, which is used to indicate whether all the columns of the unique key of the parent table are all referenced.
2. When not all unique key columns are referenced, set unique_constraint_name to "".