Description:
Originally reported at https://bugs.launchpad.net/percona-server/+bug/1705229
MySQL server reports misleading warning when foreign key creation fails due to incompatible foreign key character set.
How to repeat:
test> create table a(id varchar(1) character set utf8mb4, primary key(id));
test> create table b(id varchar(1) character set utf8, b_id varchar(1) character set utf8, primary key(id), CONSTRAINT a_fkey FOREIGN KEY (b_id) REFERENCES a (id));
ERROR 1215 (HY000): Cannot add foreign key constraint
test> show warnings
```
root@perconatraindb03-sjc1 test> show warnings;
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 150 | Create table 'test/b' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns.
|
| Error | 1215 | Cannot add foreign key constraint |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
```
Suggested fix:
Something more meaningful than column not appearing in index a first column.