The following test case
SET optimizer_switch = 'derived_merge=on';
|
|
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
|
INSERT INTO t1 VALUES (1),(2);
|
|
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
|
INSERT INTO t2 VALUES (3),(4);
|
|
CREATE TABLE t3 (c INT) ENGINE=MyISAM;
|
INSERT INTO t3 VALUES (5),(6);
|
|
SELECT * FROM ( SELECT c FROM ( t1 INNER JOIN t2 ) RIGHT JOIN t3 ON a = c ) AS alias;
|
returns NULLs:
If the subquery is executed separately, it returns not null values, which is the correct result:
The problem was either introduced or made visible with the revision http://bazaar.launchpad.net/~maria-captains/maria/5.3/revision/3574:
revno: 3574
|
committer: sanja@montyprogram.com
|
branch nick: work-maria-5.3-MDEV-486
|
timestamp: Wed 2012-09-05 23:23:58 +0300
|
message:
|
MDEV-486 LP BUG#1010116 fix.
|
|
Link view/derived table fields to a real table to check turning the table record to null row.
|
|
Item_direct_view_ref wrapper now checks if table is turned to null row.
|
Reproducible on current maria/5.3, maria/5.5, maria/10.0.
MySQL 5.6 and MariaDB 5.2 return the correct result.
Minimal optimizer_switch: derived_merge=on.
Also reproducible with the default optimizer_switch:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on
|
EXPLAIN with the default optimizer_switch (also wrong result):
id select_type table type possible_keys key key_len ref rows filtered Extra
|
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (incremental, BNL join)
|
Warnings:
|
Note 1003 select `test`.`t3`.`c` AS `c` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((`test`.`t1`.`a` = `test`.`t3`.`c`)) where 1
|
EXPLAIN with the minimal optimizer_switch (also wrong result):
id select_type table type possible_keys key key_len ref rows filtered Extra
|
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
|
Warnings:
|
Note 1003 select `test`.`t3`.`c` AS `c` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((`test`.`t1`.`a` = `test`.`t3`.`c`)) where 1
|
- relates to
-
MDEV-486
LP:1010116 - Incorrect query results in subqueries
-
-
Closed
{"report":{"fcp":934.1000001430511,"ttfb":197.90000009536743,"pageVisibility":"visible","entityId":22203,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"8bb99412-6d11-41f8-be01-017cf06c670a","navigationType":0,"readyForUser":1040.1000001430511,"redirectCount":0,"resourceLoadedEnd":596.2999999523163,"resourceLoadedStart":208.20000004768372,"resourceTiming":[{"duration":34,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":208.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":208.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":242.20000004768372,"responseStart":0,"secureConnectionStart":0},{"duration":34,"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":208.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":208.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":242.5,"responseStart":0,"secureConnectionStart":0},{"duration":236.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":208.70000004768372,"connectEnd":208.70000004768372,"connectStart":208.70000004768372,"domainLookupEnd":208.70000004768372,"domainLookupStart":208.70000004768372,"fetchStart":208.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":246.40000009536743,"responseEnd":444.7999999523163,"responseStart":277.90000009536743,"secureConnectionStart":208.70000004768372},{"duration":387.09999990463257,"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":209.20000004768372,"connectEnd":209.20000004768372,"connectStart":209.20000004768372,"domainLookupEnd":209.20000004768372,"domainLookupStart":209.20000004768372,"fetchStart":209.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":247.79999995231628,"responseEnd":596.2999999523163,"responseStart":291.2000000476837,"secureConnectionStart":209.20000004768372},{"duration":73.30000019073486,"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":209.29999995231628,"connectEnd":209.29999995231628,"connectStart":209.29999995231628,"domainLookupEnd":209.29999995231628,"domainLookupStart":209.29999995231628,"fetchStart":209.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":248.10000014305115,"responseEnd":282.60000014305115,"responseStart":280.7999999523163,"secureConnectionStart":209.29999995231628},{"duration":74.29999995231628,"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":211.40000009536743,"connectEnd":211.40000009536743,"connectStart":211.40000009536743,"domainLookupEnd":211.40000009536743,"domainLookupStart":211.40000009536743,"fetchStart":211.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":253.10000014305115,"responseEnd":285.7000000476837,"responseStart":283.2999999523163,"secureConnectionStart":211.40000009536743},{"duration":74.5,"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":211.5,"connectEnd":211.5,"connectStart":211.5,"domainLookupEnd":211.5,"domainLookupStart":211.5,"fetchStart":211.5,"redirectEnd":0,"redirectStart":0,"requestStart":253.20000004768372,"responseEnd":286,"responseStart":283.90000009536743,"secureConnectionStart":211.5},{"duration":37.39999985694885,"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":211.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":211.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":249,"responseStart":0,"secureConnectionStart":0},{"duration":74.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":211.70000004768372,"connectEnd":211.70000004768372,"connectStart":211.70000004768372,"domainLookupEnd":211.70000004768372,"domainLookupStart":211.70000004768372,"fetchStart":211.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":254.10000014305115,"responseEnd":286.2000000476837,"responseStart":284.5,"secureConnectionStart":211.70000004768372},{"duration":40.90000009536743,"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":211.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":211.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":252.70000004768372,"responseStart":0,"secureConnectionStart":0},{"duration":77.10000014305115,"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":212,"connectEnd":212,"connectStart":212,"domainLookupEnd":212,"domainLookupStart":212,"fetchStart":212,"redirectEnd":0,"redirectStart":0,"requestStart":257,"responseEnd":289.10000014305115,"responseStart":287,"secureConnectionStart":212},{"duration":300.40000009536743,"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":224.5,"connectEnd":224.5,"connectStart":224.5,"domainLookupEnd":224.5,"domainLookupStart":224.5,"fetchStart":224.5,"redirectEnd":0,"redirectStart":0,"requestStart":273.7000000476837,"responseEnd":524.9000000953674,"responseStart":519.1000001430511,"secureConnectionStart":224.5},{"duration":297.59999990463257,"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":229.60000014305115,"connectEnd":229.60000014305115,"connectStart":229.60000014305115,"domainLookupEnd":229.60000014305115,"domainLookupStart":229.60000014305115,"fetchStart":229.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":282.7999999523163,"responseEnd":527.2000000476837,"responseStart":522.2999999523163,"secureConnectionStart":229.60000014305115},{"duration":163.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":589.7000000476837,"connectEnd":589.7000000476837,"connectStart":589.7000000476837,"domainLookupEnd":589.7000000476837,"domainLookupStart":589.7000000476837,"fetchStart":589.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":723.2000000476837,"responseEnd":753.6000001430511,"responseStart":753,"secureConnectionStart":589.7000000476837},{"duration":214.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":829.6000001430511,"connectEnd":829.6000001430511,"connectStart":829.6000001430511,"domainLookupEnd":829.6000001430511,"domainLookupStart":829.6000001430511,"fetchStart":829.6000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1012.5,"responseEnd":1044.1000001430511,"responseStart":1043.4000000953674,"secureConnectionStart":829.6000001430511}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":19,"responseStart":198,"responseEnd":229,"domLoading":202,"domInteractive":1142,"domContentLoadedEventStart":1142,"domContentLoadedEventEnd":1201,"domComplete":1501,"loadEventStart":1501,"loadEventEnd":1502,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1120.2999999523163},{"name":"bigPipe.sidebar-id.end","time":1121.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":1121.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1122.6000001430511},{"name":"activityTabFullyLoaded","time":1215.6000001430511}],"measures":[],"correlationId":"eedae603c019d2","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":98,"dbReadsTimeInMs":22,"dbConnsTimeInMs":31,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}