Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
11.6.2, 11.7.1
-
None
-
openSUSE Tumbleweed
Description
> create table ss (id integer primary key, struct TEXT);
|
> create table mm (id integer primary key, sss integer NOT null references ss(id), name TEXT, UNIQUE(sss, name));
|
ERROR 1005 (HY000): Can't create table `clang_struct`.`mm` (errno: 150 "Foreign key constraint is incorrectly formed")
|
> SHOW ENGINE INNODB STATUS;
|
...
|
LATEST FOREIGN KEY ERROR
|
------------------------
|
2025-02-14 09:29:24 0x7f3ab01ff6c0 Error in foreign key constraint of table `clang_struct`.`mm`:
|
Create table `clang_struct`.`mm` with foreign key (sss) constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns.------------
|
> show index from ss;
|
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
|
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
| ss | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | NO |
|
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
------------------------
|
This looks like a bug. If I remove UNIQUE(), it works.
Attachments
Issue Links
- duplicates
-
MDEV-33658 Cannot add a foreign key on a table with a long UNIQUE multi-column index, that contains a foreign key as a prefix.
-
- Closed
-
mariadb:11.7-rc from docker (e544e5936f26) behaves the same.