[MDEV-26824] Can't add foreign key with empty referenced columns list Created: 2021-10-14  Updated: 2022-01-12  Resolved: 2022-01-12

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5.0, 10.5, 10.6, 10.7
Fix Version/s: 10.5.14, 10.6.6, 10.7.2, 10.8.1

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: foreign-keys, regression-10.5

Issue Links:
Problem/Incident
is caused by MDEV-20480 Obsolete internal parser for FK in In... Closed
Relates
relates to MDEV-26554 Table-rebuilding DDL on parent table ... Closed

 Description   

Assertion failure i==j on ADD FOREIGN KEY

The following test case triggers a debug assertion failure during ALTER TABLE:

--source include/have_innodb.inc
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2(a INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY(a) REFERENCES t1;
DROP TABLE t2, t1;

10.5 f1acd9f14bd054b8d8d576c6fe567226c097132d

mysqltest: At line 4: query 'ALTER TABLE t2 ADD FOREIGN KEY(a) REFERENCES t1' failed: 2013: Lost connection to MySQL server during query
...
mariadbd: /mariadb/10.5/storage/innobase/handler/ha_innodb.cc:12306: dberr_t create_table_info_t::create_foreign_keys(): Assertion `i == j' failed.

The reason appears to be that an empty column list will be passed for the REFERENCES t1. I would expect that the matching column names be looked up (in this case a) and their data type compatibility be checked before ha_innobase::create() is invoked.



 Comments   
Comment by Aleksey Midenkov [ 2021-12-20 ]

Please review bb-10.5-midenok

Comment by Oleksandr Byelkin [ 2021-12-21 ]

OK to push, but try to make better commit message (describe problem (what was wrong)).

Generated at Thu Feb 08 09:48:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.