Even after fix for MDEV-5112 (and MySQL Bug#69581), a query that runs index_merge intersection (union is probably affected too) over partitioned table, may return wrong query result.
Testcase:
create table t11 (
|
a int not null,
|
b int not null,
|
pk int not null,
|
primary key (pk),
|
key(a),
|
key(b)
|
) partition by hash(pk) partitions 10;
|
|
insert into t11 values (1,2,4); -- both
|
insert into t11 values (1,0,17); -- left
|
insert into t11 values (1,2,25); -- both
|
|
insert into t11 values (10,20,122);
|
insert into t11 values (10,20,123);
|
|
-- Now, fill in some data so that the optimizer choses index_merge
|
create table t12 (a int);
|
insert into t12 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
insert into t11 select 1,2, 200 + A.a + 10*B.a + 100*C.a from t12 A, t12 B, t12 C;
|
|
insert into t11 select 10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
2000 + A.a + 10*B.a + 100*C.a + 1000*D.a
|
from t12 A, t12 B, t12 C ,t12 D;
|
|
-- This should show index_merge, using intersect
|
explain select * from t11 where a=1 and b=2 and pk between 1 and 999999 ;
|
-- 794 rows in output
|
select * from t11 where a=1 and b=2 and pk between 1 and 999 ;
|
-- 802 rows in output
|
select * from t11 ignore index(a,b) where a=1 and b=2 and pk between 1 and 999 ;
|
- relates to
-
MDEV-5821
Wrong result of SELECT query while two indexed colums are in WHERE section
-
-
Closed
{"report":{"fcp":974.7999999523163,"ttfb":244,"pageVisibility":"visible","entityId":26113,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"2ef13695-d65c-4e22-abcd-62df80673f7f","navigationType":0,"readyForUser":1058.3999999761581,"redirectCount":0,"resourceLoadedEnd":1295.7000000476837,"resourceLoadedStart":249.10000002384186,"resourceTiming":[{"duration":259.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":249.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":249.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":509,"responseStart":0,"secureConnectionStart":0},{"duration":259.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":249.39999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":249.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":509.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":268.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":249.60000002384186,"connectEnd":249.60000002384186,"connectStart":249.60000002384186,"domainLookupEnd":249.60000002384186,"domainLookupStart":249.60000002384186,"fetchStart":249.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":249.60000002384186,"responseEnd":518.1000000238419,"responseStart":518.1000000238419,"secureConnectionStart":249.60000002384186},{"duration":320.3000000715256,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":249.79999995231628,"connectEnd":249.79999995231628,"connectStart":249.79999995231628,"domainLookupEnd":249.79999995231628,"domainLookupStart":249.79999995231628,"fetchStart":249.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":249.79999995231628,"responseEnd":570.1000000238419,"responseStart":570.1000000238419,"secureConnectionStart":249.79999995231628},{"duration":323.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":250,"connectEnd":250,"connectStart":250,"domainLookupEnd":250,"domainLookupStart":250,"fetchStart":250,"redirectEnd":0,"redirectStart":0,"requestStart":250,"responseEnd":573.7000000476837,"responseStart":573.7000000476837,"secureConnectionStart":250},{"duration":324,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":250.20000004768372,"connectEnd":250.20000004768372,"connectStart":250.20000004768372,"domainLookupEnd":250.20000004768372,"domainLookupStart":250.20000004768372,"fetchStart":250.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":250.20000004768372,"responseEnd":574.2000000476837,"responseStart":574.2000000476837,"secureConnectionStart":250.20000004768372},{"duration":324.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":250.39999997615814,"connectEnd":250.39999997615814,"connectStart":250.39999997615814,"domainLookupEnd":250.39999997615814,"domainLookupStart":250.39999997615814,"fetchStart":250.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":250.39999997615814,"responseEnd":574.6000000238419,"responseStart":574.6000000238419,"secureConnectionStart":250.39999997615814},{"duration":410.2000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":250.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":250.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":660.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":324.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":250.70000004768372,"connectEnd":250.70000004768372,"connectStart":250.70000004768372,"domainLookupEnd":250.70000004768372,"domainLookupStart":250.70000004768372,"fetchStart":250.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":250.70000004768372,"responseEnd":575.1000000238419,"responseStart":575.1000000238419,"secureConnectionStart":250.70000004768372},{"duration":409.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":250.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":250.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":660.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":324.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":251,"connectEnd":251,"connectStart":251,"domainLookupEnd":251,"domainLookupStart":251,"fetchStart":251,"redirectEnd":0,"redirectStart":0,"requestStart":251,"responseEnd":575.7000000476837,"responseStart":575.7000000476837,"secureConnectionStart":251},{"duration":508.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":257.10000002384186,"connectEnd":257.10000002384186,"connectStart":257.10000002384186,"domainLookupEnd":257.10000002384186,"domainLookupStart":257.10000002384186,"fetchStart":257.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":257.10000002384186,"responseEnd":765.7000000476837,"responseStart":765.7000000476837,"secureConnectionStart":257.10000002384186},{"duration":1022.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":263.10000002384186,"connectEnd":263.10000002384186,"connectStart":263.10000002384186,"domainLookupEnd":263.10000002384186,"domainLookupStart":263.10000002384186,"fetchStart":263.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":263.10000002384186,"responseEnd":1285.6000000238419,"responseStart":1285.6000000238419,"secureConnectionStart":263.10000002384186},{"duration":95.29999995231628,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":671.6000000238419,"connectEnd":671.6000000238419,"connectStart":671.6000000238419,"domainLookupEnd":671.6000000238419,"domainLookupStart":671.6000000238419,"fetchStart":671.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":671.6000000238419,"responseEnd":766.8999999761581,"responseStart":766.7999999523163,"secureConnectionStart":671.6000000238419},{"duration":365.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/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":930.5,"connectEnd":930.5,"connectStart":930.5,"domainLookupEnd":930.5,"domainLookupStart":930.5,"fetchStart":930.5,"redirectEnd":0,"redirectStart":0,"requestStart":930.5,"responseEnd":1295.7000000476837,"responseStart":1295.7000000476837,"secureConnectionStart":930.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":26,"responseStart":244,"responseEnd":263,"domLoading":247,"domInteractive":1329,"domContentLoadedEventStart":1329,"domContentLoadedEventEnd":1384,"domComplete":1578,"loadEventStart":1578,"loadEventEnd":1578,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1287.3999999761581},{"name":"bigPipe.sidebar-id.end","time":1288.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":1288.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1293.7999999523163},{"name":"activityTabFullyLoaded","time":1406.7000000476837}],"measures":[],"correlationId":"7dba5e4bd43bb8","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":136,"dbReadsTimeInMs":18,"dbConnsTimeInMs":27,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
It seems it's ok with MySQL 5.6.16, I obtain 802 rows in either cases.
MariaDB 5.5.35 still returns 794 and 802.