(SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 ISNULL);
DROPTABLE tab1, tab2;
Actual result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
| 1 |
+----+
2 rows in set (0.00 sec)
Expected result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
Elena Stepanova
added a comment - Thank you for the report and test case. Reproducible on 10.0, 10.1, 10.2, with InnoDB and MyISAM.
Exact same case, just put together for copy-paste:
CREATE TABLE `tab1` (
`Id` int (11) NOT NULL ,
PRIMARY KEY (`Id`)
);
INSERT INTO `tab1` (`Id`) VALUES (1);
CREATE TABLE `tab2` (
`tab1_Id` int (11) NOT NULL DEFAULT 0,
`col1` int (11) DEFAULT NULL ,
UNIQUE KEY `col1` (`col1`)
);
INSERT INTO `tab2` (`tab1_Id`, `col1`) VALUES (1, NULL ), (1, NULL );
SELECT Id FROM tab1 WHERE EXISTS
( SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL );
DROP TABLE tab1, tab2;
Actual result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
| 1 |
+----+
2 rows in set (0.00 sec)
Expected result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
Not only Windows, reproduced on Ubuntu 14.04.5 LTS too.
Affects IN statement as well. Probably same processing algorithm?
Martin Štěpař
added a comment - - edited Not only Windows, reproduced on Ubuntu 14.04.5 LTS too.
Affects IN statement as well. Probably same processing algorithm?
actually what server execute is:
select 1 AS `Id` from `test`.`tab2` where ((`test`.`tab2`.`tab1_Id` = 1) and isnull(`test`.`tab2`.`col1`))
probably converted to semijoin than one table elimitnated
Oleksandr Byelkin
added a comment - actually what server execute is:
select 1 AS `Id` from `test`.`tab2` where ((`test`.`tab2`.`tab1_Id` = 1) and isnull(`test`.`tab2`.`col1`))
probably converted to semijoin than one table elimitnated
It is not EXISTS to IN problem because corespondent IN has the same problem:
SELECT Id FROM tab1 WHERE Id in
(SELECT Id FROM tab2 WHERE tab2.col1 IS NULL);
Id
1
1
Oleksandr Byelkin
added a comment - - edited It is not EXISTS to IN problem because corespondent IN has the same problem:
SELECT Id FROM tab1 WHERE Id in
(SELECT Id FROM tab2 WHERE tab2.col1 IS NULL);
Id
1
1
simplify_joins somehow decides that outer join can be converted to inner one. Decision based on fact that condition is null rejecting, I do not see why conversion is legal.
Oleksandr Byelkin
added a comment - simplify_joins somehow decides that outer join can be converted to inner one. Decision based on fact that condition is null rejecting, I do not see why conversion is legal.
Hi guys, any progress here? I understand there is a lot of things to do, but it's over 2 years since issue was reported.
Martin Štěpař
added a comment - Hi guys, any progress here? I understand there is a lot of things to do, but it's over 2 years since issue was reported.
INSERT INTO `tab2` (`tab1_Id`, `col1`) VALUES (1, NULL), (1, NULL);
SELECT Id FROM tab1 WHERE Id in (SELECT tab1_Id FROM tab2 WHERE tab2.col1 IS NULL);
DROP TABLE tab1, tab2;
Oleksandr Byelkin
added a comment - - edited 5.5 test suite
CREATE TABLE `tab1` (
`Id` int(11) NOT NULL,
PRIMARY KEY (`Id`)
);
INSERT INTO `tab1` (`Id`) VALUES (1);
CREATE TABLE `tab2` (
`tab1_Id` int(11) NOT NULL DEFAULT 0,
`col1` int(11) DEFAULT NULL,
UNIQUE KEY `col1` (`col1`)
);
INSERT INTO `tab2` (`tab1_Id`, `col1`) VALUES (1, NULL), (1, NULL);
SELECT Id FROM tab1 WHERE Id in (SELECT tab1_Id FROM tab2 WHERE tab2.col1 IS NULL);
DROP TABLE tab1, tab2;
People
Oleksandr Byelkin
Chris N.
Votes:
1Vote for this issue
Watchers:
6Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":636.8000001907349,"ttfb":162.9000005722046,"pageVisibility":"visible","entityId":61926,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"e1c44f6c-246f-4f2e-8ccd-acec00855bc2","navigationType":0,"readyForUser":713.8000001907349,"redirectCount":0,"resourceLoadedEnd":842.9000005722046,"resourceLoadedStart":168,"resourceTiming":[{"duration":6.300000190734863,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":168,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":168,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":174.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":6.5,"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":168.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":168.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":174.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":64.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":168.4000005722046,"connectEnd":168.4000005722046,"connectStart":168.4000005722046,"domainLookupEnd":168.4000005722046,"domainLookupStart":168.4000005722046,"fetchStart":168.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":168.4000005722046,"responseEnd":232.70000076293945,"responseStart":232.70000076293945,"secureConnectionStart":168.4000005722046},{"duration":149.60000038146973,"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":168.5,"connectEnd":168.5,"connectStart":168.5,"domainLookupEnd":168.5,"domainLookupStart":168.5,"fetchStart":168.5,"redirectEnd":0,"redirectStart":0,"requestStart":168.5,"responseEnd":318.1000003814697,"responseStart":318.1000003814697,"secureConnectionStart":168.5},{"duration":153.60000038146973,"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":168.60000038146973,"connectEnd":168.60000038146973,"connectStart":168.60000038146973,"domainLookupEnd":168.60000038146973,"domainLookupStart":168.60000038146973,"fetchStart":168.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":168.60000038146973,"responseEnd":322.20000076293945,"responseStart":322.20000076293945,"secureConnectionStart":168.60000038146973},{"duration":154.10000038146973,"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":168.60000038146973,"connectEnd":168.60000038146973,"connectStart":168.60000038146973,"domainLookupEnd":168.60000038146973,"domainLookupStart":168.60000038146973,"fetchStart":168.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":168.60000038146973,"responseEnd":322.70000076293945,"responseStart":322.70000076293945,"secureConnectionStart":168.60000038146973},{"duration":154.19999980926514,"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":168.80000019073486,"connectEnd":168.80000019073486,"connectStart":168.80000019073486,"domainLookupEnd":168.80000019073486,"domainLookupStart":168.80000019073486,"fetchStart":168.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":168.80000019073486,"responseEnd":323,"responseStart":323,"secureConnectionStart":168.80000019073486},{"duration":154.5999994277954,"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":168.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":168.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":323.5,"responseStart":0,"secureConnectionStart":0},{"duration":154.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":168.9000005722046,"connectEnd":168.9000005722046,"connectStart":168.9000005722046,"domainLookupEnd":168.9000005722046,"domainLookupStart":168.9000005722046,"fetchStart":168.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":168.9000005722046,"responseEnd":323.4000005722046,"responseStart":323.4000005722046,"secureConnectionStart":168.9000005722046},{"duration":154.69999980926514,"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":169.10000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":169.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":323.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":154.79999923706055,"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":169.20000076293945,"connectEnd":169.20000076293945,"connectStart":169.20000076293945,"domainLookupEnd":169.20000076293945,"domainLookupStart":169.20000076293945,"fetchStart":169.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":169.20000076293945,"responseEnd":324,"responseStart":324,"secureConnectionStart":169.20000076293945},{"duration":629.1000003814697,"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":174.80000019073486,"connectEnd":174.80000019073486,"connectStart":174.80000019073486,"domainLookupEnd":174.80000019073486,"domainLookupStart":174.80000019073486,"fetchStart":174.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":174.80000019073486,"responseEnd":803.9000005722046,"responseStart":803.9000005722046,"secureConnectionStart":174.80000019073486},{"duration":617.4000005722046,"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":187.80000019073486,"connectEnd":187.80000019073486,"connectStart":187.80000019073486,"domainLookupEnd":187.80000019073486,"domainLookupStart":187.80000019073486,"fetchStart":187.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":187.80000019073486,"responseEnd":805.2000007629395,"responseStart":805.2000007629395,"secureConnectionStart":187.80000019073486},{"duration":412.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":391.80000019073486,"connectEnd":391.80000019073486,"connectStart":391.80000019073486,"domainLookupEnd":391.80000019073486,"domainLookupStart":391.80000019073486,"fetchStart":391.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":391.80000019073486,"responseEnd":804.3000001907349,"responseStart":804.3000001907349,"secureConnectionStart":391.80000019073486},{"duration":176,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":629.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":629.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":805.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":16.899999618530273,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/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":809.2000007629395,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":809.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":826.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":18.100000381469727,"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":810.1000003814697,"connectEnd":810.1000003814697,"connectStart":810.1000003814697,"domainLookupEnd":810.1000003814697,"domainLookupStart":810.1000003814697,"fetchStart":810.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":810.1000003814697,"responseEnd":828.2000007629395,"responseStart":828.2000007629395,"secureConnectionStart":810.1000003814697},{"duration":32.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/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":810.6000003814697,"connectEnd":810.6000003814697,"connectStart":810.6000003814697,"domainLookupEnd":810.6000003814697,"domainLookupStart":810.6000003814697,"fetchStart":810.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":810.6000003814697,"responseEnd":842.9000005722046,"responseStart":842.9000005722046,"secureConnectionStart":810.6000003814697}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":26,"responseStart":163,"responseEnd":188,"domLoading":167,"domInteractive":911,"domContentLoadedEventStart":911,"domContentLoadedEventEnd":959,"domComplete":1028,"loadEventStart":1028,"loadEventEnd":1029,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":867.2000007629395},{"name":"bigPipe.sidebar-id.end","time":867.9000005722046},{"name":"bigPipe.activity-panel-pipe-id.start","time":868.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":872.2000007629395},{"name":"activityTabFullyLoaded","time":978.6000003814697}],"measures":[],"correlationId":"be56aec80be270","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":82,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Thank you for the report and test case. Reproducible on 10.0, 10.1, 10.2, with InnoDB and MyISAM.
Exact same case, just put together for copy-paste:
);
);
Actual result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
| 1 |
+----+
2 rows in set (0.00 sec)
Expected result
MariaDB [test]> SELECT Id FROM tab1 WHERE EXISTS
-> (SELECT 1 AS `C1` FROM tab2 WHERE tab1.Id = tab2.tab1_Id AND tab2.col1 IS NULL);
+----+
| Id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)