Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
10.6.12 , 10.4(EOL) , 10.5 , 10.6 , 10.9(EOL) , 10.10(EOL) , 10.11
First of all - sorry if this should be a comment on the related ticket as opposed to its own ticket; however my report goes further (/has a wider issue than the original report / causes problems with backups); so I believed best to raise as its own ticket.
As per MDEV-30606 , trying to create a table with a FK that has ON UPDATE CASCADE and a CHECK CONSTRAINT returns the (slightly unhelpful) error message: Function or expression %s cannot be used in the CHECK clause of %s . (It would be useful if this error was less generic for the use case, as it is known that the referred column is not a function or expression - but the error makes it seem like you have used the wrong column name).
However running `ALTER TABLE` lets you add the constraint without issue (and then the `CREATE TABLE` statement will fail, breaking restoring backups or copying the table/etc).
Test Script:
# Setup
CREATE OR REPLACE TABLE `x1` (
`a` INT NOT NULL ,
PRIMARY KEY (`a`)
);
# Fails with 'Function or expression ' b ' cannot be used in the CHECK clause of `b-2`'
CREATE OR REPLACE TABLE `x2` (
`b` INT NULL ,
CONSTRAINT FOREIGN KEY (`b`) REFERENCES `x1`(`a`) ON UPDATE CASCADE ,
CONSTRAINT CHECK (`b` > 1)
);
# Succeeds
CREATE OR REPLACE TABLE `x2` (
`b` INT NULL ,
CONSTRAINT FOREIGN KEY (`b`) REFERENCES `x1`(`a`) ON UPDATE CASCADE
);
ALTER TABLE `x2` ADD CONSTRAINT CHECK (`b` > 1);
# Then :
SHOW CREATE TABLE `x2`;
/* Outputs, but running this will error as per the initial create command
CREATE TABLE `x2` (
`b` int(11) DEFAULT NULL,
KEY `b` (`b`),
CONSTRAINT `x2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `x1` (`a`) ON UPDATE CASCADE,
CONSTRAINT `CONSTRAINT_1` CHECK (`b` > 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci
*/
{"report":{"fcp":918.8999999985099,"ttfb":219.79999999701977,"pageVisibility":"visible","entityId":122107,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"1118c3c9-7a98-4f1f-a3d1-09a2db5e6831","navigationType":0,"readyForUser":1002.2999999970198,"redirectCount":0,"resourceLoadedEnd":1193.2999999970198,"resourceLoadedStart":225.69999999552965,"resourceTiming":[{"duration":211.89999999850988,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":225.69999999552965,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":225.69999999552965,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":437.59999999403954,"responseStart":0,"secureConnectionStart":0},{"duration":211.89999999850988,"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":226,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":226,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":437.8999999985099,"responseStart":0,"secureConnectionStart":0},{"duration":226.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":226.09999999403954,"connectEnd":226.09999999403954,"connectStart":226.09999999403954,"domainLookupEnd":226.09999999403954,"domainLookupStart":226.09999999403954,"fetchStart":226.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":226.09999999403954,"responseEnd":452.59999999403954,"responseStart":452.59999999403954,"secureConnectionStart":226.09999999403954},{"duration":318,"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":226.29999999701977,"connectEnd":226.29999999701977,"connectStart":226.29999999701977,"domainLookupEnd":226.29999999701977,"domainLookupStart":226.29999999701977,"fetchStart":226.29999999701977,"redirectEnd":0,"redirectStart":0,"requestStart":226.29999999701977,"responseEnd":544.2999999970198,"responseStart":544.2999999970198,"secureConnectionStart":226.29999999701977},{"duration":321.40000000596046,"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":226.59999999403954,"connectEnd":226.59999999403954,"connectStart":226.59999999403954,"domainLookupEnd":226.59999999403954,"domainLookupStart":226.59999999403954,"fetchStart":226.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":226.59999999403954,"responseEnd":548,"responseStart":548,"secureConnectionStart":226.59999999403954},{"duration":321.80000000447035,"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":226.69999999552965,"connectEnd":226.69999999552965,"connectStart":226.69999999552965,"domainLookupEnd":226.69999999552965,"domainLookupStart":226.69999999552965,"fetchStart":226.69999999552965,"redirectEnd":0,"redirectStart":0,"requestStart":226.69999999552965,"responseEnd":548.5,"responseStart":548.5,"secureConnectionStart":226.69999999552965},{"duration":321.8999999985099,"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":227,"connectEnd":227,"connectStart":227,"domainLookupEnd":227,"domainLookupStart":227,"fetchStart":227,"redirectEnd":0,"redirectStart":0,"requestStart":227,"responseEnd":548.8999999985099,"responseStart":548.8999999985099,"secureConnectionStart":227},{"duration":365.6000000014901,"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":227.09999999403954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":227.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":592.6999999955297,"responseStart":0,"secureConnectionStart":0},{"duration":322.1000000014901,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":227.29999999701977,"connectEnd":227.29999999701977,"connectStart":227.29999999701977,"domainLookupEnd":227.29999999701977,"domainLookupStart":227.29999999701977,"fetchStart":227.29999999701977,"redirectEnd":0,"redirectStart":0,"requestStart":227.29999999701977,"responseEnd":549.3999999985099,"responseStart":549.3999999985099,"secureConnectionStart":227.29999999701977},{"duration":365.3999999985099,"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":227.39999999850988,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":227.39999999850988,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":592.7999999970198,"responseStart":0,"secureConnectionStart":0},{"duration":322.40000000596046,"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":227.59999999403954,"connectEnd":227.59999999403954,"connectStart":227.59999999403954,"domainLookupEnd":227.59999999403954,"domainLookupStart":227.59999999403954,"fetchStart":227.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":227.59999999403954,"responseEnd":550,"responseStart":550,"secureConnectionStart":227.59999999403954},{"duration":433.79999999701977,"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":228.5,"connectEnd":228.5,"connectStart":228.5,"domainLookupEnd":228.5,"domainLookupStart":228.5,"fetchStart":228.5,"redirectEnd":0,"redirectStart":0,"requestStart":228.5,"responseEnd":662.2999999970198,"responseStart":662.2999999970198,"secureConnectionStart":228.5},{"duration":948.8000000044703,"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":232.69999999552965,"connectEnd":232.69999999552965,"connectStart":232.69999999552965,"domainLookupEnd":232.69999999552965,"domainLookupStart":232.69999999552965,"fetchStart":232.69999999552965,"redirectEnd":0,"redirectStart":0,"requestStart":232.69999999552965,"responseEnd":1181.5,"responseStart":1181.5,"secureConnectionStart":232.69999999552965},{"duration":58.600000001490116,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":604.0999999940395,"connectEnd":604.0999999940395,"connectStart":604.0999999940395,"domainLookupEnd":604.0999999940395,"domainLookupStart":604.0999999940395,"fetchStart":604.0999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":604.0999999940395,"responseEnd":662.6999999955297,"responseStart":662.6999999955297,"secureConnectionStart":604.0999999940395},{"duration":316.70000000298023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&slack-enabled=true","startTime":876.5999999940395,"connectEnd":876.5999999940395,"connectStart":876.5999999940395,"domainLookupEnd":876.5999999940395,"domainLookupStart":876.5999999940395,"fetchStart":876.5999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":876.5999999940395,"responseEnd":1193.2999999970198,"responseStart":1193.2999999970198,"secureConnectionStart":876.5999999940395},{"duration":333.1000000014901,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":912.5999999940395,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":912.5999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1245.6999999955297,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":62,"responseStart":220,"responseEnd":225,"domLoading":224,"domInteractive":1203,"domContentLoadedEventStart":1204,"domContentLoadedEventEnd":1246,"domComplete":2864,"loadEventStart":2864,"loadEventEnd":2865,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1183.3999999985099},{"name":"bigPipe.sidebar-id.end","time":1184.2999999970198},{"name":"bigPipe.activity-panel-pipe-id.start","time":1184.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1186.8999999985099},{"name":"activityTabFullyLoaded","time":1249.6999999955297}],"measures":[],"correlationId":"a787e8b8d90876","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":97,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}