Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.4(EOL) , 10.5 , 10.6 , 10.11 , 11.0(EOL) , 11.1(EOL) , 11.2(EOL) , 11.3(EOL) , 11.4
I only tested this on 10.11. The bug could also be in earlier versions.
Applying this diff:
diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql.test b/storage/spider/mysql-test/spider/bg/t/basic_sql.test
index 9cf4ce99dc3..6a35fe8dd70 100644
--- a/storage/spider/mysql-test/spider/bg/t/basic_sql.test
+++ b/storage/spider/mysql-test/spider/bg/t/basic_sql.test
@@ -156,6 +156,7 @@ if ($USE_CHILD_GROUP2)
}
}
--connection master_1
+set @@optimizer_switch="semijoin=off";
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo
Causes the following result change:
mtr spider/bg.basic_sql
+++ /home/my/maria-10.11/storage/spider/mysql-test/spider/bg/r/basic_sql.reject2023-01-13 20:10:47.205034143 +0200
@@ -49,6 +49,7 @@
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
SELECT a, b, c FROM tb_l
connection master_1;
+set @@optimizer_switch="semijoin=off";
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
@@ -279,11 +280,6 @@
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
-1 f 2008-07-01 10:21:39
-2 g 2000-02-01 00:00:00
-3 j 2007-05-04 20:03:11
-4 i 2003-10-30 05:01:03
-5 h 2001-10-31 23:59:59
select using pushdown
{"report":{"fcp":846.3999999761581,"ttfb":233.69999992847443,"pageVisibility":"visible","entityId":118257,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"e65ef845-fd0f-473a-8142-cf282ebc8dcc","navigationType":0,"readyForUser":924.5,"redirectCount":0,"resourceLoadedEnd":636.5999999046326,"resourceLoadedStart":241.19999992847443,"resourceTiming":[{"duration":5.399999976158142,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":241.19999992847443,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":241.19999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":246.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":5.899999976158142,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":241.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":241.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":247.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":99,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":241.79999995231628,"connectEnd":241.79999995231628,"connectStart":241.79999995231628,"domainLookupEnd":241.79999995231628,"domainLookupStart":241.79999995231628,"fetchStart":241.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":250.59999990463257,"responseEnd":340.7999999523163,"responseStart":291.7999999523163,"secureConnectionStart":241.79999995231628},{"duration":237,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":241.89999997615814,"connectEnd":241.89999997615814,"connectStart":241.89999997615814,"domainLookupEnd":241.89999997615814,"domainLookupStart":241.89999997615814,"fetchStart":241.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":252.19999992847443,"responseEnd":478.89999997615814,"responseStart":334.39999997615814,"secureConnectionStart":241.89999997615814},{"duration":64.80000007152557,"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":242.09999990463257,"connectEnd":242.09999990463257,"connectStart":242.09999990463257,"domainLookupEnd":242.09999990463257,"domainLookupStart":242.09999990463257,"fetchStart":242.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":254.29999995231628,"responseEnd":306.89999997615814,"responseStart":305.7999999523163,"secureConnectionStart":242.09999990463257},{"duration":61.5,"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":242.29999995231628,"connectEnd":242.29999995231628,"connectStart":242.29999995231628,"domainLookupEnd":242.29999995231628,"domainLookupStart":242.29999995231628,"fetchStart":242.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":255,"responseEnd":303.7999999523163,"responseStart":302.7999999523163,"secureConnectionStart":242.29999995231628},{"duration":63.199999928474426,"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":242.5,"connectEnd":242.5,"connectStart":242.5,"domainLookupEnd":242.5,"domainLookupStart":242.5,"fetchStart":242.5,"redirectEnd":0,"redirectStart":0,"requestStart":258.09999990463257,"responseEnd":305.6999999284744,"responseStart":304.1999999284744,"secureConnectionStart":242.5},{"duration":14.300000071525574,"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":242.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":242.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":256.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":77.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":243.29999995231628,"connectEnd":243.29999995231628,"connectStart":243.29999995231628,"domainLookupEnd":243.29999995231628,"domainLookupStart":243.29999995231628,"fetchStart":243.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":260.2999999523163,"responseEnd":320.89999997615814,"responseStart":320.09999990463257,"secureConnectionStart":243.29999995231628},{"duration":15.099999904632568,"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":243.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":243.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":258.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":81.20000004768372,"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":243.69999992847443,"connectEnd":243.69999992847443,"connectStart":243.69999992847443,"domainLookupEnd":243.69999992847443,"domainLookupStart":243.69999992847443,"fetchStart":243.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":263.2999999523163,"responseEnd":324.89999997615814,"responseStart":324.1999999284744,"secureConnectionStart":243.69999992847443},{"duration":35.700000047683716,"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":256.59999990463257,"connectEnd":274.09999990463257,"connectStart":274.09999990463257,"domainLookupEnd":274.09999990463257,"domainLookupStart":274.09999990463257,"fetchStart":256.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":274.5,"responseEnd":292.2999999523163,"responseStart":291.09999990463257,"secureConnectionStart":274.09999990463257},{"duration":376.1999999284744,"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":260.39999997615814,"connectEnd":260.39999997615814,"connectStart":260.39999997615814,"domainLookupEnd":260.39999997615814,"domainLookupStart":260.39999997615814,"fetchStart":260.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":318.6999999284744,"responseEnd":636.5999999046326,"responseStart":633.7999999523163,"secureConnectionStart":260.39999997615814},{"duration":235.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":495.89999997615814,"connectEnd":495.89999997615814,"connectStart":495.89999997615814,"domainLookupEnd":495.89999997615814,"domainLookupStart":495.89999997615814,"fetchStart":495.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":693.6999999284744,"responseEnd":731.5,"responseStart":730.8999999761581,"secureConnectionStart":495.89999997615814},{"duration":107.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":798,"connectEnd":798,"connectStart":798,"domainLookupEnd":798,"domainLookupStart":798,"fetchStart":798,"redirectEnd":0,"redirectStart":0,"requestStart":865.1999999284744,"responseEnd":905.5,"responseStart":905,"secureConnectionStart":798},{"duration":123.09999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":839.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":839.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":962.5999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":59,"responseStart":234,"responseEnd":259,"domLoading":238,"domInteractive":991,"domContentLoadedEventStart":992,"domContentLoadedEventEnd":1048,"domComplete":1208,"loadEventStart":1208,"loadEventEnd":1208,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":967.6999999284744},{"name":"bigPipe.sidebar-id.end","time":968.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":968.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":970.3999999761581},{"name":"activityTabFullyLoaded","time":1062.6999999284744}],"measures":[],"correlationId":"975b9d0ddb8a80","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Somehow with the semijoin=off optimizer switch, it uses the group by
handler (gbh) for the EXISTS subquery. Because such subqueries set
explicit_limit to true (see
Item_exists_subselect::fix_length_and_dec()), the gbh uses the default
limit value 0, which causes the subquery to return empty results.
Either we make gbh use the correct limit 1 in this case, or ban gbh
from being used. The latter requires checking why the optimizer switch
causes gbh to be used for the subquery.