I got some strange behaviour with subselect and missing rows.
following select produces 2 rows, and is_blacklisted equals 0 in both:
SELECT anon_1.shop_id AS shop_id,
|
anon_1.is_blacklisted AS is_blacklisted
|
FROM
|
(SELECT anon_2.shop_id AS shop_id,
|
CASE
|
WHEN (
|
(
|
(
|
anon_2.shop_white_flag IS NOT NULL
|
AND (anon_2.white_flags IS NULL
|
OR anon_2.white_flags NOT LIKE concat(concat('%|', anon_2.shop_white_flag), '|%')))
|
)
|
) THEN 1
|
ELSE 0
|
END AS is_blacklisted
|
FROM
|
(SELECT
|
customer_data.shop_id AS shop_id,
|
syndication_white_flags_1.code AS shop_white_flag,
|
group_concat(DISTINCT concat('|', syndication_white_flags.code, '|')) AS white_flags
|
FROM customer_data
|
INNER JOIN syndication_partners
|
LEFT OUTER JOIN syndication_partner_white_flags ON syndication_partner_white_flags.partner_id = syndication_partners.id
|
LEFT OUTER JOIN syndication_white_flags ON syndication_white_flags.id = syndication_partner_white_flags.flag_id
|
LEFT OUTER JOIN syndication_shop_white_flags ON syndication_shop_white_flags.customer_data_id = customer_data.id
|
LEFT OUTER JOIN syndication_white_flags AS syndication_white_flags_1 ON syndication_white_flags_1.id = syndication_shop_white_flags.white_flag_id
|
WHERE
|
syndication_partners.id = 427
|
GROUP BY customer_data.shop_id,
|
syndication_white_flags_1.code
|
) AS anon_2
|
) AS anon_1
|
;
|
Now I add a condition on is_blacklisted and I only get 1 row. (I tried several versions, "IS false", "= 0", "IS NOT true", all with the same behaviour)
SELECT anon_1.shop_id AS shop_id,
|
anon_1.is_blacklisted AS is_blacklisted
|
FROM
|
(SELECT anon_2.shop_id AS shop_id,
|
CASE
|
WHEN (
|
(
|
(
|
anon_2.shop_white_flag IS NOT NULL
|
AND (anon_2.white_flags IS NULL
|
OR anon_2.white_flags NOT LIKE concat(concat('%|', anon_2.shop_white_flag), '|%')))
|
)
|
) THEN 1
|
ELSE 0
|
END AS is_blacklisted
|
FROM
|
(SELECT
|
customer_data.shop_id AS shop_id,
|
syndication_white_flags_1.code AS shop_white_flag,
|
group_concat(DISTINCT concat('|', syndication_white_flags.code, '|')) AS white_flags
|
FROM customer_data
|
INNER JOIN syndication_partners
|
LEFT OUTER JOIN syndication_partner_white_flags ON syndication_partner_white_flags.partner_id = syndication_partners.id
|
LEFT OUTER JOIN syndication_white_flags ON syndication_white_flags.id = syndication_partner_white_flags.flag_id
|
LEFT OUTER JOIN syndication_shop_white_flags ON syndication_shop_white_flags.customer_data_id = customer_data.id
|
LEFT OUTER JOIN syndication_white_flags AS syndication_white_flags_1 ON syndication_white_flags_1.id = syndication_shop_white_flags.white_flag_id
|
WHERE
|
syndication_partners.id = 427
|
GROUP BY customer_data.shop_id,
|
syndication_white_flags_1.code
|
) AS anon_2
|
) AS anon_1
|
WHERE anon_1.is_blacklisted IS false
|
;
|
When I select into a temporary table, I get 2 rows again.
CREATE TEMPORARY TABLE foo SELECT anon_1.shop_id AS shop_id,
|
anon_1.is_blacklisted AS is_blacklisted
|
FROM
|
(SELECT anon_2.shop_id AS shop_id,
|
CASE
|
WHEN (
|
(
|
(
|
anon_2.shop_white_flag IS NOT NULL
|
AND (anon_2.white_flags IS NULL
|
OR anon_2.white_flags NOT LIKE concat(concat('%|', anon_2.shop_white_flag), '|%')))
|
)
|
) THEN 1
|
ELSE 0
|
END AS is_blacklisted
|
FROM
|
(SELECT
|
customer_data.shop_id AS shop_id,
|
syndication_white_flags_1.code AS shop_white_flag,
|
group_concat(DISTINCT concat('|', syndication_white_flags.code, '|')) AS white_flags
|
FROM customer_data
|
INNER JOIN syndication_partners
|
LEFT OUTER JOIN syndication_partner_white_flags ON syndication_partner_white_flags.partner_id = syndication_partners.id
|
LEFT OUTER JOIN syndication_white_flags ON syndication_white_flags.id = syndication_partner_white_flags.flag_id
|
LEFT OUTER JOIN syndication_shop_white_flags ON syndication_shop_white_flags.customer_data_id = customer_data.id
|
LEFT OUTER JOIN syndication_white_flags AS syndication_white_flags_1 ON syndication_white_flags_1.id = syndication_shop_white_flags.white_flag_id
|
WHERE
|
syndication_partners.id = 427
|
GROUP BY customer_data.shop_id,
|
syndication_white_flags_1.code
|
) AS anon_2
|
) AS anon_1
|
WHERE anon_1.is_blacklisted IS false
|
;
|
If I remove the syndication_white_flags_1.code in the group_by, it works too.
This bug didn't exist in 10.0.35.
We skipped the versions in between, so I can't say if this bug already existed in 10.1 or 10.2
Possibly related to: https://bugs.mysql.com/bug.php?id=88300
I don't think it's the same bug, but it's the only thing I found related to subqueries and incorrect returnsets
- relates to
-
MDEV-18383
Change of behaviour of OR in IF-conditions 10.2 -> 10.3
-
-
Closed
{"report":{"fcp":1535.6000001430511,"ttfb":463,"pageVisibility":"visible","entityId":68708,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"4a6a769f-6240-488c-af50-51a103c5013d","navigationType":0,"readyForUser":1666,"redirectCount":0,"resourceLoadedEnd":1836.7000000476837,"resourceLoadedStart":468.2000000476837,"resourceTiming":[{"duration":570.7999999523163,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":468.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":468.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1039,"responseStart":0,"secureConnectionStart":0},{"duration":570.9000000953674,"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":468.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":468.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1039.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":580,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":468.7000000476837,"connectEnd":468.7000000476837,"connectStart":468.7000000476837,"domainLookupEnd":468.7000000476837,"domainLookupStart":468.7000000476837,"fetchStart":468.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":468.7000000476837,"responseEnd":1048.7000000476837,"responseStart":1048.7000000476837,"secureConnectionStart":468.7000000476837},{"duration":611.5999999046326,"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":469.90000009536743,"connectEnd":469.90000009536743,"connectStart":469.90000009536743,"domainLookupEnd":469.90000009536743,"domainLookupStart":469.90000009536743,"fetchStart":469.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":469.90000009536743,"responseEnd":1081.5,"responseStart":1081.5,"secureConnectionStart":469.90000009536743},{"duration":615.8999998569489,"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":470.10000014305115,"connectEnd":470.10000014305115,"connectStart":470.10000014305115,"domainLookupEnd":470.10000014305115,"domainLookupStart":470.10000014305115,"fetchStart":470.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":470.10000014305115,"responseEnd":1086,"responseStart":1086,"secureConnectionStart":470.10000014305115},{"duration":616.4000000953674,"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":470.40000009536743,"connectEnd":470.40000009536743,"connectStart":470.40000009536743,"domainLookupEnd":470.40000009536743,"domainLookupStart":470.40000009536743,"fetchStart":470.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":470.40000009536743,"responseEnd":1086.8000001907349,"responseStart":1086.8000001907349,"secureConnectionStart":470.40000009536743},{"duration":616.7000000476837,"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":470.60000014305115,"connectEnd":470.60000014305115,"connectStart":470.60000014305115,"domainLookupEnd":470.60000014305115,"domainLookupStart":470.60000014305115,"fetchStart":470.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":470.60000014305115,"responseEnd":1087.3000001907349,"responseStart":1087.3000001907349,"secureConnectionStart":470.60000014305115},{"duration":735.7000000476837,"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":470.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":470.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1206.6000001430511,"responseStart":0,"secureConnectionStart":0},{"duration":621.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":471,"connectEnd":471,"connectStart":471,"domainLookupEnd":471,"domainLookupStart":471,"fetchStart":471,"redirectEnd":0,"redirectStart":0,"requestStart":471,"responseEnd":1092.9000000953674,"responseStart":1092.9000000953674,"secureConnectionStart":471},{"duration":735.7000000476837,"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":471.10000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":471.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1206.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":622.1999998092651,"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":471.30000019073486,"connectEnd":471.30000019073486,"connectStart":471.30000019073486,"domainLookupEnd":471.30000019073486,"domainLookupStart":471.30000019073486,"fetchStart":471.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":471.30000019073486,"responseEnd":1093.5,"responseStart":1093.5,"secureConnectionStart":471.30000019073486},{"duration":1355,"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":481.40000009536743,"connectEnd":481.40000009536743,"connectStart":481.40000009536743,"domainLookupEnd":481.40000009536743,"domainLookupStart":481.40000009536743,"fetchStart":481.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":481.40000009536743,"responseEnd":1836.4000000953674,"responseStart":1836.4000000953674,"secureConnectionStart":481.40000009536743},{"duration":1355.2000000476837,"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":481.5,"connectEnd":481.5,"connectStart":481.5,"domainLookupEnd":481.5,"domainLookupStart":481.5,"fetchStart":481.5,"redirectEnd":0,"redirectStart":0,"requestStart":481.5,"responseEnd":1836.7000000476837,"responseStart":1836.7000000476837,"secureConnectionStart":481.5},{"duration":299.2000000476837,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1226.6000001430511,"connectEnd":1226.6000001430511,"connectStart":1226.6000001430511,"domainLookupEnd":1226.6000001430511,"domainLookupStart":1226.6000001430511,"fetchStart":1226.6000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1226.6000001430511,"responseEnd":1525.8000001907349,"responseStart":1525.8000001907349,"secureConnectionStart":1226.6000001430511}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":278,"responseStart":463,"responseEnd":480,"domLoading":466,"domInteractive":1860,"domContentLoadedEventStart":1860,"domContentLoadedEventEnd":1915,"domComplete":3341,"loadEventStart":3341,"loadEventEnd":3343,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1843},{"name":"bigPipe.sidebar-id.end","time":1843.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":1843.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1846.5},{"name":"activityTabFullyLoaded","time":1923.9000000953674}],"measures":[],"correlationId":"b998bf79995670","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":105,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}