Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
5.5(EOL) , 10.0(EOL) , 10.1(EOL) , 10.2(EOL) , 10.3(EOL) , 10.4(EOL)
CREATE OR REPLACE TABLE t1 (id SERIAL, a DECIMAL (10,2) NOT NULL , KEY (a)) ENGINE=MyISAM;
INSERT INTO t1 (a) VALUES (11),(11),(11),(11),(11),(11);
explain SELECT * FROM t1 WHERE a<10.999; -- this rounds to 11.00
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | t1 | ALL | a | NULL | NULL | NULL | 6 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
Notice, it uses full table scan. Looks wrong. The expected behavior would be to use range search and exclude all values of 11 . The constant 10.999 rounds to 11.00 in case of DECIMAL(10,2) . So in the above condition, 10.999 and 11 should be equal.
Note, if I now change the constant from 10.999 to 11 :
CREATE OR REPLACE TABLE t1 (id SERIAL, a DECIMAL (10,2) NOT NULL , KEY (a)) ENGINE=MyISAM;
INSERT INTO t1 (a) VALUES (11),(11),(11),(11),(11),(11);
explain SELECT * FROM t1 WHERE a<11;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| 1 | SIMPLE | t1 | range | a | a | 5 | NULL | 1 | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
it correctly starts to use range search.
Note, the reverse operation (greater-than) works fine. These two scripts:
CREATE OR REPLACE TABLE t1 (id SERIAL, a DECIMAL (10,2) NOT NULL , KEY (a)) ENGINE=MyISAM;
INSERT INTO t1 (a) VALUES (11),(11),(11),(11),(11),(11);
explain SELECT * FROM t1 WHERE a>11.001; -- this rounds to 11.00
CREATE OR REPLACE TABLE t1 (id SERIAL, a DECIMAL (10,2) NOT NULL , KEY (a)) ENGINE=MyISAM;
INSERT INTO t1 (a) VALUES (11),(11),(11),(11),(11),(11);
explain SELECT * FROM t1 WHERE a>11;
both use range search as expected:
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| 1 | SIMPLE | t1 | range | a | a | 5 | NULL | 1 | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
The problem possibly happens because the code in opt_range.cc in case of the less-than operation does not call stored_field_cmp_to_item() and therefore does not notice when the constant rounds to a greater value.
On the contrary, for all other operations (less-or-equal , greater-than , greater-or-equal ) the function stored_field_cmp_to_item() is called, so truncation/rounding are taken into account.
There are no comments yet on this issue.
{"report":{"fcp":963.6999999880791,"ttfb":296.5999999642372,"pageVisibility":"visible","entityId":68771,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a011dfee-e8d9-4adb-b511-50089fd5fc07","navigationType":0,"readyForUser":1083.5999999642372,"redirectCount":0,"resourceLoadedEnd":1138.0999999642372,"resourceLoadedStart":301.5999999642372,"resourceTiming":[{"duration":208.9000000357628,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":301.5999999642372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":301.5999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":510.5,"responseStart":0,"secureConnectionStart":0},{"duration":208.80000001192093,"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":301.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":301.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":510.69999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":217.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":302.0999999642372,"connectEnd":302.0999999642372,"connectStart":302.0999999642372,"domainLookupEnd":302.0999999642372,"domainLookupStart":302.0999999642372,"fetchStart":302.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":302.0999999642372,"responseEnd":519.3999999761581,"responseStart":519.3999999761581,"secureConnectionStart":302.0999999642372},{"duration":294.2999999523163,"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":302.30000001192093,"connectEnd":302.30000001192093,"connectStart":302.30000001192093,"domainLookupEnd":302.30000001192093,"domainLookupStart":302.30000001192093,"fetchStart":302.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":302.30000001192093,"responseEnd":596.5999999642372,"responseStart":596.5999999642372,"secureConnectionStart":302.30000001192093},{"duration":298.0999999642372,"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":302.5,"connectEnd":302.5,"connectStart":302.5,"domainLookupEnd":302.5,"domainLookupStart":302.5,"fetchStart":302.5,"redirectEnd":0,"redirectStart":0,"requestStart":302.5,"responseEnd":600.5999999642372,"responseStart":600.5999999642372,"secureConnectionStart":302.5},{"duration":298.2999999523163,"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":302.80000001192093,"connectEnd":302.80000001192093,"connectStart":302.80000001192093,"domainLookupEnd":302.80000001192093,"domainLookupStart":302.80000001192093,"fetchStart":302.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":302.80000001192093,"responseEnd":601.0999999642372,"responseStart":601.0999999642372,"secureConnectionStart":302.80000001192093},{"duration":298.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":302.89999997615814,"connectEnd":302.89999997615814,"connectStart":302.89999997615814,"domainLookupEnd":302.89999997615814,"domainLookupStart":302.89999997615814,"fetchStart":302.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":302.89999997615814,"responseEnd":601.3999999761581,"responseStart":601.3999999761581,"secureConnectionStart":302.89999997615814},{"duration":353.80000001192093,"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":303.0999999642372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":303.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":656.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":298.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":303.19999998807907,"connectEnd":303.19999998807907,"connectStart":303.19999998807907,"domainLookupEnd":303.19999998807907,"domainLookupStart":303.19999998807907,"fetchStart":303.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":303.19999998807907,"responseEnd":601.8000000119209,"responseStart":601.8000000119209,"secureConnectionStart":303.19999998807907},{"duration":353.60000002384186,"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":303.39999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":303.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":657,"responseStart":0,"secureConnectionStart":0},{"duration":298.80000001192093,"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":303.5,"connectEnd":303.5,"connectStart":303.5,"domainLookupEnd":303.5,"domainLookupStart":303.5,"fetchStart":303.5,"redirectEnd":0,"redirectStart":0,"requestStart":303.5,"responseEnd":602.3000000119209,"responseStart":602.3000000119209,"secureConnectionStart":303.5},{"duration":532.8999999761581,"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":308.80000001192093,"connectEnd":308.80000001192093,"connectStart":308.80000001192093,"domainLookupEnd":308.80000001192093,"domainLookupStart":308.80000001192093,"fetchStart":308.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":308.80000001192093,"responseEnd":841.6999999880791,"responseStart":841.6999999880791,"secureConnectionStart":308.80000001192093},{"duration":812.6000000238419,"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":308.89999997615814,"connectEnd":308.89999997615814,"connectStart":308.89999997615814,"domainLookupEnd":308.89999997615814,"domainLookupStart":308.89999997615814,"fetchStart":308.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":308.89999997615814,"responseEnd":1121.5,"responseStart":1121.5,"secureConnectionStart":308.89999997615814},{"duration":159.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":682.5999999642372,"connectEnd":682.5999999642372,"connectStart":682.5999999642372,"domainLookupEnd":682.5999999642372,"domainLookupStart":682.5999999642372,"fetchStart":682.5999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":682.5999999642372,"responseEnd":842.1999999880791,"responseStart":842.1999999880791,"secureConnectionStart":682.5999999642372},{"duration":204.5,"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":920.8999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":920.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1125.3999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":206.39999997615814,"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":921.6999999880791,"connectEnd":921.6999999880791,"connectStart":921.6999999880791,"domainLookupEnd":921.6999999880791,"domainLookupStart":921.6999999880791,"fetchStart":921.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":921.6999999880791,"responseEnd":1128.0999999642372,"responseStart":1128.0999999642372,"secureConnectionStart":921.6999999880791},{"duration":216,"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":922.0999999642372,"connectEnd":922.0999999642372,"connectStart":922.0999999642372,"domainLookupEnd":922.0999999642372,"domainLookupStart":922.0999999642372,"fetchStart":922.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":922.0999999642372,"responseEnd":1138.0999999642372,"responseStart":1138.0999999642372,"secureConnectionStart":922.0999999642372},{"duration":248.30000001192093,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":957.8999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":957.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1206.199999988079,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":119,"responseStart":297,"responseEnd":301,"domLoading":300,"domInteractive":1151,"domContentLoadedEventStart":1151,"domContentLoadedEventEnd":1196,"domComplete":1378,"loadEventStart":1378,"loadEventEnd":1378,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1133.5999999642372},{"name":"bigPipe.sidebar-id.end","time":1134.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1134.699999988079},{"name":"bigPipe.activity-panel-pipe-id.end","time":1135.0999999642372},{"name":"activityTabFullyLoaded","time":1209.699999988079}],"measures":[],"correlationId":"aa0c7ee28f6d2","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":103,"dbReadsTimeInMs":14,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}