Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
10.2(EOL) , 10.3(EOL) , 10.4(EOL) , 10.5 , 10.6
InnoDB fails to rename the foreign key constraint during rename table alter using
copy algorithm.
The following test case repeats the scenario:
--source include/have_innodb.inc
create table t1(f1 int not null, index(f1))engine=innodb;
create table t2(f1 int not null,
foreign key(f1) references t1(f1))engine=innodb;
alter table t1 rename to tm1, algorithm=copy;
show create table tm1;
Table Create Table
tm1 CREATE TABLE `tm1` (
`f1` int(11) NOT NULL,
KEY `f1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) NOT NULL,
KEY `f1` (`f1`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
test/t2_ibfk_1 test/t2 test/t1 1 0
create table t1(f1 int not null)engine=innodb;
Error failed: 1215: Cannot add foreign key constraint
Analysis:
=========
Copy alter algorithm does the following steps:
1) Create a new table (#sql) and copies the row from old table
Doesn't add anything in SYS_FOREIGN
2) Rename t1 to #sql2
Rename the table name in InnoDB dictionary
Rename the file name too
Doesn't rename the constraint in SYS_FOREIGN tables
3) RENAME #sql to tm1
Rename the table name in InnoDB dictionary
Loads the foreign & referenced index from SYS_FOREIGN
using the table name(tm1). But InnoDB doesn't have any FK constraint
with the name (tm1)
4) DROP #sql2
Does check whether the SYS_FOREIGN has the foreign key constraint using the table name.
{"report":{"fcp":4141.599999904633,"ttfb":1592.3999996185303,"pageVisibility":"visible","entityId":100358,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0,"journeyId":"7c2c6be0-6de5-4467-9911-49e0beb1a98d","navigationType":0,"readyForUser":4217.599999904633,"redirectCount":0,"resourceLoadedEnd":4740.39999961853,"resourceLoadedStart":1721.2999997138977,"resourceTiming":[{"duration":1571.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":1721.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1721.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3292.7999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":1571.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":1721.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1721.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3293.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":1573.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":1721.8999996185303,"connectEnd":1721.8999996185303,"connectStart":1721.8999996185303,"domainLookupEnd":1721.8999996185303,"domainLookupStart":1721.8999996185303,"fetchStart":1721.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":1721.8999996185303,"responseEnd":3295.7999997138977,"responseStart":3295.7999997138977,"secureConnectionStart":1721.8999996185303},{"duration":1686.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":1722.0999999046326,"connectEnd":1722.0999999046326,"connectStart":1722.0999999046326,"domainLookupEnd":1722.0999999046326,"domainLookupStart":1722.0999999046326,"fetchStart":1722.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1722.0999999046326,"responseEnd":3408.7999997138977,"responseStart":3408.7999997138977,"secureConnectionStart":1722.0999999046326},{"duration":1752.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":1722.2999997138977,"connectEnd":1722.2999997138977,"connectStart":1722.2999997138977,"domainLookupEnd":1722.2999997138977,"domainLookupStart":1722.2999997138977,"fetchStart":1722.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":1722.2999997138977,"responseEnd":3475.0999999046326,"responseStart":3475.0999999046326,"secureConnectionStart":1722.2999997138977},{"duration":1799.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":1722.5,"connectEnd":1722.5,"connectStart":1722.5,"domainLookupEnd":1722.5,"domainLookupStart":1722.5,"fetchStart":1722.5,"redirectEnd":0,"redirectStart":0,"requestStart":1722.5,"responseEnd":3522,"responseStart":3522,"secureConnectionStart":1722.5},{"duration":1816.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":1723,"connectEnd":1723,"connectStart":1723,"domainLookupEnd":1723,"domainLookupStart":1723,"fetchStart":1723,"redirectEnd":0,"redirectStart":0,"requestStart":1723,"responseEnd":3539.0999999046326,"responseStart":3539.0999999046326,"secureConnectionStart":1723},{"duration":1852,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":1723.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1723.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3575.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":1818.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":1723.5,"connectEnd":1723.5,"connectStart":1723.5,"domainLookupEnd":1723.5,"domainLookupStart":1723.5,"fetchStart":1723.5,"redirectEnd":0,"redirectStart":0,"requestStart":1723.5,"responseEnd":3541.5999999046326,"responseStart":3541.5999999046326,"secureConnectionStart":1723.5},{"duration":1906.6999998092651,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":1723.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1723.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3630.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":1906.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":1723.8999996185303,"connectEnd":1723.8999996185303,"connectStart":1723.8999996185303,"domainLookupEnd":1723.8999996185303,"domainLookupStart":1723.8999996185303,"fetchStart":1723.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":1723.8999996185303,"responseEnd":3630.2999997138977,"responseStart":3630.2999997138977,"secureConnectionStart":1723.8999996185303},{"duration":2914.300000190735,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":1724.8999996185303,"connectEnd":1724.8999996185303,"connectStart":1724.8999996185303,"domainLookupEnd":1724.8999996185303,"domainLookupStart":1724.8999996185303,"fetchStart":1724.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":1724.8999996185303,"responseEnd":4639.199999809265,"responseStart":4639.199999809265,"secureConnectionStart":1724.8999996185303},{"duration":3015.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":1725,"connectEnd":1725,"connectStart":1725,"domainLookupEnd":1725,"domainLookupStart":1725,"fetchStart":1725,"redirectEnd":0,"redirectStart":0,"requestStart":1725,"responseEnd":4740.39999961853,"responseStart":4740.39999961853,"secureConnectionStart":1725},{"duration":856.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":3619.2999997138977,"connectEnd":3619.2999997138977,"connectStart":3619.2999997138977,"domainLookupEnd":3619.2999997138977,"domainLookupStart":3619.2999997138977,"fetchStart":3619.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":3619.2999997138977,"responseEnd":4475.799999713898,"responseStart":4475.799999713898,"secureConnectionStart":3619.2999997138977},{"duration":854.5999999046326,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":4081.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":4081.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":4936.099999904633,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":1400,"responseStart":1592,"responseEnd":1601,"domLoading":1685,"domInteractive":4861,"domContentLoadedEventStart":4861,"domContentLoadedEventEnd":4935,"domComplete":7151,"loadEventStart":7151,"loadEventEnd":7153,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":4835.799999713898},{"name":"bigPipe.sidebar-id.end","time":4836.699999809265},{"name":"bigPipe.activity-panel-pipe-id.start","time":4836.799999713898},{"name":"bigPipe.activity-panel-pipe-id.end","time":4840.199999809265},{"name":"activityTabFullyLoaded","time":5110.799999713898}],"measures":[],"correlationId":"83c27c6a00fac2","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":93,"dbReadsTimeInMs":11,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}