[MDEV-29717] Foreign key constraint is incorrectly formed Created: 2022-10-05 Updated: 2022-10-08 Resolved: 2022-10-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.9.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Farid | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 x64 |
||
| Description |
|
Can not create the FK between these two tables.
|
| Comments |
| Comment by Sergei Golubchik [ 2022-10-07 ] |
|
The documentation says
Your IX1IN_SYNC_OBJECT is likely a HASH index, use SHOW INDEX to double-check. MySQL also has 3072 limitation, but doesn't support arbitrary long UNIQUE constraints, so your example above fails in MySQL with "Error ER_TOO_LONG_KEY: Specified key was too long; max key length is 3072 bytes" — https://www.db-fiddle.com/f/pwEBEe3SW3YK8fYfxTSZ6z/0 |
| Comment by Farid [ 2022-10-08 ] |
|
The foreign key definition is valid, so the error message can be clearer and say something like: This is an implementation issue with MariaDB and MySQL auto-indexing foreign keys. On other DBMSs this is not an issue and both the unique index and the foreign keys are successfully created. Db2 -> works So, at a minimum, the error message can be more informative on why the foreign key can not be created. |