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.
Aleksey Midenkov
made changes -
2021-10-18 22:32
Labels
regression-10.5
foreign-keys regression-10.5
Sergei Golubchik
made changes -
2021-12-06 21:35
Workflow
MariaDB v3
[ 126218
]
MariaDB v4
[ 143252
]
Aleksey Midenkov
made changes -
2021-12-18 19:22
Description
The following test case triggers a debug assertion failure during {{ALTER TABLE}}:
{code:sql}
--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;
{code}
{noformat:title=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.
{noformat}
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.
Assertion failure i==j on ADD FOREIGN KEY
The following test case triggers a debug assertion failure during {{ALTER TABLE}}:
{code:sql}
--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;
{code}
{noformat:title=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.
{noformat}
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.
Aleksey Midenkov
made changes -
2021-12-18 19:22
Summary
Assertion failure i==j on ADD FOREIGN KEY
Can't add foreign key with empty referenced columns list
Aleksey Midenkov
made changes -
2021-12-18 19:35
Status
Open
[ 1
]
In Progress
[ 3
]
Aleksey Midenkov
made changes -
2021-12-20 11:52
Status
In Progress
[ 3
]
In Review
[ 10002
]
Aleksey Midenkov
made changes -
2021-12-20 11:52
Assignee
Aleksey Midenkov
[ midenok
]
Oleksandr Byelkin
[ sanja
]
Oleksandr Byelkin
made changes -
2021-12-21 07:53
Assignee
Oleksandr Byelkin
[ sanja
]
Aleksey Midenkov
[ midenok
]
Status
In Review
[ 10002
]
Stalled
[ 10000
]
Aleksey Midenkov
made changes -
2021-12-21 22:54
Status
Stalled
[ 10000
]
In Progress
[ 3
]
Aleksey Midenkov
made changes -
2022-01-12 18:27
Fix Version/s
10.5.14
[ 26809
]
Fix Version/s
10.6.6
[ 26811
]
Fix Version/s
10.7.2
[ 26813
]
Fix Version/s
10.8.1
[ 26815
]
Fix Version/s
10.5
[ 23123
]
Fix Version/s
10.6
[ 24028
]
Fix Version/s
10.7
[ 24805
]
Resolution
Fixed
[ 1
]
Status
In Progress
[ 3
]
Closed
[ 6
]
{"report":{"fcp":1989.1999998092651,"ttfb":301.9000005722046,"pageVisibility":"visible","entityId":103917,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"d6f20ad6-69ca-4729-80b3-1bb02f4c0bb2","navigationType":0,"readyForUser":2117.300000190735,"redirectCount":0,"resourceLoadedEnd":2428.6000003814697,"resourceLoadedStart":316.5,"resourceTiming":[{"duration":712.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":316.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":316.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1029,"responseStart":0,"secureConnectionStart":0},{"duration":712.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":316.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":316.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1029.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":720.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":317,"connectEnd":317,"connectStart":317,"domainLookupEnd":317,"domainLookupStart":317,"fetchStart":317,"redirectEnd":0,"redirectStart":0,"requestStart":317,"responseEnd":1037.1999998092651,"responseStart":1037.1999998092651,"secureConnectionStart":317},{"duration":1202.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":317.1000003814697,"connectEnd":317.1000003814697,"connectStart":317.1000003814697,"domainLookupEnd":317.1000003814697,"domainLookupStart":317.1000003814697,"fetchStart":317.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":317.1000003814697,"responseEnd":1519.9000005722046,"responseStart":1519.9000005722046,"secureConnectionStart":317.1000003814697},{"duration":1207,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":317.30000019073486,"connectEnd":317.30000019073486,"connectStart":317.30000019073486,"domainLookupEnd":317.30000019073486,"domainLookupStart":317.30000019073486,"fetchStart":317.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":317.30000019073486,"responseEnd":1524.3000001907349,"responseStart":1524.3000001907349,"secureConnectionStart":317.30000019073486},{"duration":1207.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":317.5,"connectEnd":317.5,"connectStart":317.5,"domainLookupEnd":317.5,"domainLookupStart":317.5,"fetchStart":317.5,"redirectEnd":0,"redirectStart":0,"requestStart":317.5,"responseEnd":1524.8000001907349,"responseStart":1524.8000001907349,"secureConnectionStart":317.5},{"duration":1207.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":317.6000003814697,"connectEnd":317.6000003814697,"connectStart":317.6000003814697,"domainLookupEnd":317.6000003814697,"domainLookupStart":317.6000003814697,"fetchStart":317.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":317.6000003814697,"responseEnd":1525.1000003814697,"responseStart":1525.1000003814697,"secureConnectionStart":317.6000003814697},{"duration":1208.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":317.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":317.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1526.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":1207.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":318,"connectEnd":318,"connectStart":318,"domainLookupEnd":318,"domainLookupStart":318,"fetchStart":318,"redirectEnd":0,"redirectStart":0,"requestStart":318,"responseEnd":1525.6000003814697,"responseStart":1525.6000003814697,"secureConnectionStart":318},{"duration":1221.2000007629395,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":318.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":318.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1539.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":1208.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":318.4000005722046,"connectEnd":318.4000005722046,"connectStart":318.4000005722046,"domainLookupEnd":318.4000005722046,"domainLookupStart":318.4000005722046,"fetchStart":318.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":318.4000005722046,"responseEnd":1526.5,"responseStart":1526.5,"secureConnectionStart":318.4000005722046},{"duration":1568.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":323,"connectEnd":323,"connectStart":323,"domainLookupEnd":323,"domainLookupStart":323,"fetchStart":323,"redirectEnd":0,"redirectStart":0,"requestStart":323,"responseEnd":1891.1999998092651,"responseStart":1891.1999998092651,"secureConnectionStart":323},{"duration":2085.800000190735,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":323.1000003814697,"connectEnd":323.1000003814697,"connectStart":323.1000003814697,"domainLookupEnd":323.1000003814697,"domainLookupStart":323.1000003814697,"fetchStart":323.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":323.1000003814697,"responseEnd":2408.9000005722046,"responseStart":2408.9000005722046,"secureConnectionStart":323.1000003814697},{"duration":344.8999996185303,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1196.8000001907349,"connectEnd":1196.8000001907349,"connectStart":1196.8000001907349,"domainLookupEnd":1196.8000001907349,"domainLookupStart":1196.8000001907349,"fetchStart":1196.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1196.8000001907349,"responseEnd":1541.6999998092651,"responseStart":1541.6999998092651,"secureConnectionStart":1196.8000001907349},{"duration":422.29999923706055,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1551.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1551.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1974.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":864,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1552.8000001907349,"connectEnd":1552.8000001907349,"connectStart":1552.8000001907349,"domainLookupEnd":1552.8000001907349,"domainLookupStart":1552.8000001907349,"fetchStart":1552.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1552.8000001907349,"responseEnd":2416.800000190735,"responseStart":2416.800000190735,"secureConnectionStart":1552.8000001907349},{"duration":875.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/53a43b6764f587426c7bb9a150184c00-CDN/lu2bv2/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":1553.1999998092651,"connectEnd":1553.1999998092651,"connectStart":1553.1999998092651,"domainLookupEnd":1553.1999998092651,"domainLookupStart":1553.1999998092651,"fetchStart":1553.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1553.1999998092651,"responseEnd":2428.6000003814697,"responseStart":2428.6000003814697,"secureConnectionStart":1553.1999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":98,"responseStart":302,"responseEnd":311,"domLoading":314,"domInteractive":2464,"domContentLoadedEventStart":2464,"domContentLoadedEventEnd":2520,"domComplete":3517,"loadEventStart":3517,"loadEventEnd":3518,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2413.699999809265},{"name":"bigPipe.sidebar-id.end","time":2414.699999809265},{"name":"bigPipe.activity-panel-pipe-id.start","time":2414.9000005722046},{"name":"bigPipe.activity-panel-pipe-id.end","time":2418.300000190735},{"name":"activityTabFullyLoaded","time":2546.9000005722046}],"measures":[],"correlationId":"bbfd19f20041a3","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":132,"dbReadsTimeInMs":22,"dbConnsTimeInMs":30,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}