query 'ALTER TABLE t1 DROP FOREIGN KEY x, ALGORITHM=COPY' failed with wrong errno 1025: 'Error on rename of './test/t1' to './test/#sql2-10fa-4' (errno: 152 "Cannot delete a parent row")', instead of 1091...
Without ALGORITHM=COPY it fails with ER_CANT_DROP_FIELD_OR_KEY as expected.
Jan Lindström (Inactive)
added a comment -
http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-10.4-MDEV-22230
https://github.com/MariaDB/server/commit/ba80fb383c7172eaa77375d2945fad77829df9c6
ALTERTABLE t1 MODIFYCOLUMN a VARCHAR(2), DROPFOREIGNKEYIF EXISTS x;
# Cleanup
DROPTABLE t1;
as it doesn't tamper explicitly with the algorithm and it has "IF EXISTS" for the foreign key drop, so it's a perfectly normal valid ALTER which shouldn't fail. But it does
11.1 3883eb63
mysqltest: At line 4: query 'ALTER TABLE t1 MODIFY COLUMN a VARCHAR(2), DROP FOREIGN KEY IF EXISTS x' failed: ER_ERROR_ON_RENAME (1025): Error on rename of'./test/t1'to'./test/#sql-backup-246583-4' (errno: 152 "Cannot delete a parent row")
Elena Stepanova
added a comment - Maybe a more convincing test case would be
--source include/have_innodb.inc
CREATE TABLE t1 (a INT ) ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN a VARCHAR (2), DROP FOREIGN KEY IF EXISTS x;
# Cleanup
DROP TABLE t1;
as it doesn't tamper explicitly with the algorithm and it has "IF EXISTS" for the foreign key drop, so it's a perfectly normal valid ALTER which shouldn't fail. But it does
11.1 3883eb63
mysqltest: At line 4: query 'ALTER TABLE t1 MODIFY COLUMN a VARCHAR(2), DROP FOREIGN KEY IF EXISTS x' failed: ER_ERROR_ON_RENAME (1025): Error on rename of './test/t1' to './test/#sql-backup-246583-4' (errno: 152 "Cannot delete a parent row" )
The FOREIGN KEY handling was refactored in 10.5.0 by MDEV-20480. I think that it would make sense to fix this only in 10.5 and later major releases, because 10.4 will reach end of life soon.
Marko Mäkelä
added a comment - The FOREIGN KEY handling was refactored in 10.5.0 by MDEV-20480 . I think that it would make sense to fix this only in 10.5 and later major releases, because 10.4 will reach end of life soon.
This needs some more work, including test coverage to ensure that ALTER TABLE some_table DROP FOREIGN KEY IF EXISTS fk_in_another_table will not drop a constraint by that name from another table.
Marko Mäkelä
added a comment - This needs some more work, including test coverage to ensure that ALTER TABLE some_table DROP FOREIGN KEY IF EXISTS fk_in_another_table will not drop a constraint by that name from another table.
People
Thirunarayanan Balathandayuthapani
Elena Stepanova
Votes:
0Vote for this issue
Watchers:
5Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1125.6999998092651,"ttfb":245.90000009536743,"pageVisibility":"visible","entityId":85406,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"3c941d1c-3372-411c-9a48-8eeca414f638","navigationType":0,"readyForUser":1210.1999998092651,"redirectCount":0,"resourceLoadedEnd":1722.5999999046326,"resourceLoadedStart":251.69999980926514,"resourceTiming":[{"duration":392.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":251.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":251.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":644.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":392.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":252,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":252,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":644.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":401.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":252.09999990463257,"connectEnd":252.09999990463257,"connectStart":252.09999990463257,"domainLookupEnd":252.09999990463257,"domainLookupStart":252.09999990463257,"fetchStart":252.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":252.09999990463257,"responseEnd":653.6999998092651,"responseStart":653.6999998092651,"secureConnectionStart":252.09999990463257},{"duration":449.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":252.40000009536743,"connectEnd":252.40000009536743,"connectStart":252.40000009536743,"domainLookupEnd":252.40000009536743,"domainLookupStart":252.40000009536743,"fetchStart":252.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":252.40000009536743,"responseEnd":702.2999997138977,"responseStart":702.2999997138977,"secureConnectionStart":252.40000009536743},{"duration":453.90000009536743,"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":252.59999990463257,"connectEnd":252.59999990463257,"connectStart":252.59999990463257,"domainLookupEnd":252.59999990463257,"domainLookupStart":252.59999990463257,"fetchStart":252.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":252.59999990463257,"responseEnd":706.5,"responseStart":706.5,"secureConnectionStart":252.59999990463257},{"duration":454.90000009536743,"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":252.69999980926514,"connectEnd":252.69999980926514,"connectStart":252.69999980926514,"domainLookupEnd":252.69999980926514,"domainLookupStart":252.69999980926514,"fetchStart":252.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":252.69999980926514,"responseEnd":707.5999999046326,"responseStart":707.5999999046326,"secureConnectionStart":252.69999980926514},{"duration":455.59999990463257,"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":253,"connectEnd":253,"connectStart":253,"domainLookupEnd":253,"domainLookupStart":253,"fetchStart":253,"redirectEnd":0,"redirectStart":0,"requestStart":253,"responseEnd":708.5999999046326,"responseStart":708.5999999046326,"secureConnectionStart":253},{"duration":551.4000000953674,"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":253.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":253.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":804.5,"responseStart":0,"secureConnectionStart":0},{"duration":456.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":253.2999997138977,"connectEnd":253.2999997138977,"connectStart":253.2999997138977,"domainLookupEnd":253.2999997138977,"domainLookupStart":253.2999997138977,"fetchStart":253.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":253.2999997138977,"responseEnd":709.9000000953674,"responseStart":709.9000000953674,"secureConnectionStart":253.2999997138977},{"duration":551.1999998092651,"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":253.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":253.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":804.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":457.59999990463257,"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":253.59999990463257,"connectEnd":253.59999990463257,"connectStart":253.59999990463257,"domainLookupEnd":253.59999990463257,"domainLookupStart":253.59999990463257,"fetchStart":253.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":253.59999990463257,"responseEnd":711.1999998092651,"responseStart":711.1999998092651,"secureConnectionStart":253.59999990463257},{"duration":1467.5,"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":254.7999997138977,"connectEnd":254.7999997138977,"connectStart":254.7999997138977,"domainLookupEnd":254.7999997138977,"domainLookupStart":254.7999997138977,"fetchStart":254.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":254.7999997138977,"responseEnd":1722.2999997138977,"responseStart":1722.2999997138977,"secureConnectionStart":254.7999997138977},{"duration":1463.3000001907349,"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":259.2999997138977,"connectEnd":259.2999997138977,"connectStart":259.2999997138977,"domainLookupEnd":259.2999997138977,"domainLookupStart":259.2999997138977,"fetchStart":259.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":259.2999997138977,"responseEnd":1722.5999999046326,"responseStart":1722.5999999046326,"secureConnectionStart":259.2999997138977},{"duration":751.0999999046326,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":818.0999999046326,"connectEnd":818.0999999046326,"connectStart":818.0999999046326,"domainLookupEnd":818.0999999046326,"domainLookupStart":818.0999999046326,"fetchStart":818.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":818.0999999046326,"responseEnd":1569.1999998092651,"responseStart":1569.1999998092651,"secureConnectionStart":818.0999999046326},{"duration":631.5999999046326,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1119.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1119.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1750.7999997138977,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":51,"responseStart":246,"responseEnd":251,"domLoading":249,"domInteractive":1757,"domContentLoadedEventStart":1757,"domContentLoadedEventEnd":1809,"domComplete":2173,"loadEventStart":2173,"loadEventEnd":2174,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1730},{"name":"bigPipe.sidebar-id.end","time":1730.7999997138977},{"name":"bigPipe.activity-panel-pipe-id.start","time":1730.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1733.7999997138977},{"name":"activityTabFullyLoaded","time":1827.9000000953674}],"measures":[],"correlationId":"d85e9e4b1fddbe","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":130,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
While testing my fix I noticed that DROP CONSTRAINT ..., ALGORITHM=COPY has no effect. If you remove ALGORITHM it works as expected.
CREATE TABLE t1 (a INT primary key, b int) ENGINE=InnoDB;
CREATE TABLE t2 (a int primary key, b int, constraint b foreign key (b) references t1(a)) engine=innodb;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`),
CONSTRAINT `b` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t2 DROP CONSTRAINT b, ALGORITHM=COPY;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`),
CONSTRAINT `b` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1