MariaDB [test]> CREATE TABLE `bork` (`a` INT, `b` INT, PRIMARY KEY (`a`), KEY (`b`));
|
Query OK, 0 rows affected (0.112 sec)
|
|
MariaDB [test]> DELETE FROM bork WHERE `a`=1 or `b`=2;
|
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
|
The error message says that a KEY was not used in the delete statement. Both sides of the OR are keys, however the OR apparently is preventing the optimizer from realizing this.
These types of statements are comment when creating a one-to-many or many-to-many linking tables, and attempting to either UPDATE or DELETE these links.
Current work-around is to use an arbitrarily large LIMIT on the query, as this bypasses the WHERE safety check.
It also appears that the optimizer assumes that a LIMIT of 0xFFFFFFFFFFFFFFFF or (2^64)-1 is the same as having no limit at all.
-- 0xFFFFFFFFFFFFFFFE : (2 ^ 64) - 2
|
MariaDB [test]> DELETE FROM bork WHERE `a`=1 or `b`=2 LIMIT 18446744073709551614;
|
Query OK, 0 rows affected (0.000 sec)
|
|
-- 0xFFFFFFFFFFFFFFFF : (2 ^ 64) - 1
|
MariaDB [test]> DELETE FROM bork WHERE `a`=1 or `b`=2 LIMIT 18446744073709551615;
|
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
|
|
-- 0x10000000000000000 : (2 ^ 64)
|
MariaDB [test]> DELETE FROM bork WHERE `a`=1 or `b`=2 LIMIT 18446744073709551616;
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '18446744073709551616' at line 1
|
- relates to
-
MDEV-26745
sql_safe_updates blocks queries that actually do use a key column in WHERE
-
-
Closed
- links to
-
{"report":{"fcp":1434.6000003814697,"ttfb":553.5,"pageVisibility":"visible","entityId":72018,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"ce3b2273-93f1-44ba-8f7c-bcbc3af9c19e","navigationType":0,"readyForUser":1543.6999998092651,"redirectCount":0,"resourceLoadedEnd":1837.5,"resourceLoadedStart":558.1000003814697,"resourceTiming":[{"duration":185.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":558.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":558.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":743.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":187.0999994277954,"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":558.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":558.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":745.5,"responseStart":0,"secureConnectionStart":0},{"duration":268.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":558.6000003814697,"connectEnd":558.6000003814697,"connectStart":558.6000003814697,"domainLookupEnd":558.6000003814697,"domainLookupStart":558.6000003814697,"fetchStart":558.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":558.6000003814697,"responseEnd":827.3000001907349,"responseStart":827.3000001907349,"secureConnectionStart":558.6000003814697},{"duration":389.80000019073486,"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":558.6999998092651,"connectEnd":558.6999998092651,"connectStart":558.6999998092651,"domainLookupEnd":558.6999998092651,"domainLookupStart":558.6999998092651,"fetchStart":558.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":558.6999998092651,"responseEnd":948.5,"responseStart":948.4000005722046,"secureConnectionStart":558.6999998092651},{"duration":397.30000019073486,"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":558.8000001907349,"connectEnd":558.8000001907349,"connectStart":558.8000001907349,"domainLookupEnd":558.8000001907349,"domainLookupStart":558.8000001907349,"fetchStart":558.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":558.8000001907349,"responseEnd":956.1000003814697,"responseStart":956.1000003814697,"secureConnectionStart":558.8000001907349},{"duration":406.9000005722046,"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":559,"connectEnd":559,"connectStart":559,"domainLookupEnd":559,"domainLookupStart":559,"fetchStart":559,"redirectEnd":0,"redirectStart":0,"requestStart":559,"responseEnd":965.9000005722046,"responseStart":965.9000005722046,"secureConnectionStart":559},{"duration":407.1000003814697,"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":559.1999998092651,"connectEnd":559.1999998092651,"connectStart":559.1999998092651,"domainLookupEnd":559.1999998092651,"domainLookupStart":559.1999998092651,"fetchStart":559.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":559.1999998092651,"responseEnd":966.3000001907349,"responseStart":966.3000001907349,"secureConnectionStart":559.1999998092651},{"duration":458.8999996185303,"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":559.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":559.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1018.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":409.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":559.5,"connectEnd":559.5,"connectStart":559.5,"domainLookupEnd":559.5,"domainLookupStart":559.5,"fetchStart":559.5,"redirectEnd":0,"redirectStart":0,"requestStart":559.5,"responseEnd":968.6999998092651,"responseStart":968.6999998092651,"secureConnectionStart":559.5},{"duration":442.5,"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":576.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":576.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1018.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":396,"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":576.5,"connectEnd":576.5,"connectStart":576.5,"domainLookupEnd":576.5,"domainLookupStart":576.5,"fetchStart":576.5,"redirectEnd":0,"redirectStart":0,"requestStart":576.5,"responseEnd":972.5,"responseStart":972.5,"secureConnectionStart":576.5},{"duration":787.0999994277954,"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":577.4000005722046,"connectEnd":577.4000005722046,"connectStart":577.4000005722046,"domainLookupEnd":577.4000005722046,"domainLookupStart":577.4000005722046,"fetchStart":577.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":577.4000005722046,"responseEnd":1364.5,"responseStart":1364.5,"secureConnectionStart":577.4000005722046},{"duration":1233.5999994277954,"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":577.6000003814697,"connectEnd":577.6000003814697,"connectStart":577.6000003814697,"domainLookupEnd":577.6000003814697,"domainLookupStart":577.6000003814697,"fetchStart":577.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":577.6000003814697,"responseEnd":1811.1999998092651,"responseStart":1811.1999998092651,"secureConnectionStart":577.6000003814697},{"duration":327.30000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1038.6000003814697,"connectEnd":1038.6000003814697,"connectStart":1038.6000003814697,"domainLookupEnd":1038.6000003814697,"domainLookupStart":1038.6000003814697,"fetchStart":1038.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1038.6000003814697,"responseEnd":1365.9000005722046,"responseStart":1365.9000005722046,"secureConnectionStart":1038.6000003814697},{"duration":428.3999996185303,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1408.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1408.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1837,"responseStart":0,"secureConnectionStart":0},{"duration":376.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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":1455.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1455.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1832.5,"responseStart":0,"secureConnectionStart":0},{"duration":371.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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":1457.6999998092651,"connectEnd":1457.6999998092651,"connectStart":1457.6999998092651,"domainLookupEnd":1457.6999998092651,"domainLookupStart":1457.6999998092651,"fetchStart":1457.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1457.6999998092651,"responseEnd":1829.6000003814697,"responseStart":1829.6000003814697,"secureConnectionStart":1457.6999998092651},{"duration":378.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/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":1459.1000003814697,"connectEnd":1459.1000003814697,"connectStart":1459.1000003814697,"domainLookupEnd":1459.1000003814697,"domainLookupStart":1459.1000003814697,"fetchStart":1459.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1459.1000003814697,"responseEnd":1837.5,"responseStart":1837.5,"secureConnectionStart":1459.1000003814697}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":395,"responseStart":553,"responseEnd":563,"domLoading":556,"domInteractive":1888,"domContentLoadedEventStart":1888,"domContentLoadedEventEnd":1935,"domComplete":2531,"loadEventStart":2531,"loadEventEnd":2534,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1818.1000003814697},{"name":"bigPipe.sidebar-id.end","time":1818.9000005722046},{"name":"bigPipe.activity-panel-pipe-id.start","time":1819.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1821.9000005722046},{"name":"activityTabFullyLoaded","time":1946.5}],"measures":[],"correlationId":"320f9fa8216625","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}