I was having issues where a certain query would not return the expected results. So I dug and found this: https://bugs.mysql.com/bug.php?id=68897
I can replicate the issue on MariaDB 10.0.14. Copy-pasta of a test case:
CREATE TABLE `features_test` (
|
`param` int(11) NOT NULL,
|
`idx` int(11) NOT NULL,
|
`text` varchar(255) default NULL,
|
PRIMARY KEY (`param`,`idx`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
INSERT INTO `features_test` (`param`, `idx`, `text`) VALUES
|
(1, 0, 'select'),
|
(1, 1, 'Kabel mit Stecker 5-polig'),
|
(1, 2, 'Kabel ohne Stecker'),
|
(2, 0, 'number'),
|
(2, 1, '22'),
|
(2, 2, '25');
|
CREATE TABLE `idList` (
|
`id` int PRIMARY KEY
|
);
|
|
INSERT INTO idList VALUES (1),(2),(3),(4);
|
SELECT idList.id AS id, T.text AS xtext,GROUP_CONCAT(T3.text) AS optionen
|
FROM idList
|
LEFT JOIN features_test AS T ON(T.param=idList.id AND T.idx=0 )
|
LEFT JOIN features_test AS T3 ON(T3.param=idList.id AND T3.idx>0 )
|
GROUP BY idList.id
|
ORDER BY id ASC;
|
|
SELECT idList.id AS id, T.text AS xtext,GROUP_CONCAT(T3.text) AS optionen
|
FROM idList
|
LEFT JOIN features_test AS T ON(T.param=idList.id AND T.idx=0 )
|
LEFT JOIN features_test AS T3 ON(T3.param=idList.id AND T3.idx>0 )
|
GROUP BY idList.id
|
ORDER BY id DESC;
|
I would expect the DESC and ASC to return similar results, instead one returns a NULL value.
- duplicates
-
MDEV-5719
Wrong result with GROUP BY and LEFT OUTER JOIN
-
-
Closed
- links to
-
Transition |
Time In Source Status |
Execution Times |
Open |
|
Closed |
|
84d 20h 57m
|
1
|
{"report":{"fcp":971.4000005722046,"ttfb":291.69999980926514,"pageVisibility":"visible","entityId":49111,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"3d661445-2f58-4454-9b43-e2b8fd93c315","navigationType":0,"readyForUser":1054.1999998092651,"redirectCount":0,"resourceLoadedEnd":661.6000003814697,"resourceLoadedStart":296.69999980926514,"resourceTiming":[{"duration":50.90000057220459,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":296.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":296.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":347.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":51,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":296.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":296.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":347.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":254,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":297.1000003814697,"connectEnd":297.1000003814697,"connectStart":297.1000003814697,"domainLookupEnd":297.1000003814697,"domainLookupStart":297.1000003814697,"fetchStart":297.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":355.69999980926514,"responseEnd":551.1000003814697,"responseStart":390.6000003814697,"secureConnectionStart":297.1000003814697},{"duration":364.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":297.30000019073486,"connectEnd":297.30000019073486,"connectStart":297.30000019073486,"domainLookupEnd":297.30000019073486,"domainLookupStart":297.30000019073486,"fetchStart":297.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":355.5,"responseEnd":661.6000003814697,"responseStart":391.30000019073486,"secureConnectionStart":297.30000019073486},{"duration":86.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":297.5,"connectEnd":297.5,"connectStart":297.5,"domainLookupEnd":297.5,"domainLookupStart":297.5,"fetchStart":297.5,"redirectEnd":0,"redirectStart":0,"requestStart":355.9000005722046,"responseEnd":384.30000019073486,"responseStart":381.19999980926514,"secureConnectionStart":297.5},{"duration":87.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":297.6000003814697,"connectEnd":297.6000003814697,"connectStart":297.6000003814697,"domainLookupEnd":297.6000003814697,"domainLookupStart":297.6000003814697,"fetchStart":297.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":355.9000005722046,"responseEnd":385.1000003814697,"responseStart":382,"secureConnectionStart":297.6000003814697},{"duration":90,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":297.80000019073486,"connectEnd":297.80000019073486,"connectStart":297.80000019073486,"domainLookupEnd":297.80000019073486,"domainLookupStart":297.80000019073486,"fetchStart":297.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":356.1000003814697,"responseEnd":387.80000019073486,"responseStart":385.4000005722046,"secureConnectionStart":297.80000019073486},{"duration":52.59999942779541,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":297.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":350.5,"responseStart":0,"secureConnectionStart":0},{"duration":89,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":298.1000003814697,"connectEnd":298.1000003814697,"connectStart":298.1000003814697,"domainLookupEnd":298.1000003814697,"domainLookupStart":298.1000003814697,"fetchStart":298.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":356.19999980926514,"responseEnd":387.1000003814697,"responseStart":384.4000005722046,"secureConnectionStart":298.1000003814697},{"duration":52.39999961853027,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":298.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":350.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":89.79999923706055,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":298.4000005722046,"connectEnd":298.4000005722046,"connectStart":298.4000005722046,"domainLookupEnd":298.4000005722046,"domainLookupStart":298.4000005722046,"fetchStart":298.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":356.30000019073486,"responseEnd":388.19999980926514,"responseStart":385.80000019073486,"secureConnectionStart":298.4000005722046},{"duration":341.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":303.80000019073486,"connectEnd":303.80000019073486,"connectStart":303.80000019073486,"domainLookupEnd":303.80000019073486,"domainLookupStart":303.80000019073486,"fetchStart":303.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":401.5,"responseEnd":645.5,"responseStart":637.6999998092651,"secureConnectionStart":303.80000019073486},{"duration":343,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":303.80000019073486,"connectEnd":303.80000019073486,"connectStart":303.80000019073486,"domainLookupEnd":303.80000019073486,"domainLookupStart":303.80000019073486,"fetchStart":303.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":464.80000019073486,"responseEnd":646.8000001907349,"responseStart":640.8000001907349,"secureConnectionStart":303.80000019073486},{"duration":137.4000005722046,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":677.5,"connectEnd":677.5,"connectStart":677.5,"domainLookupEnd":677.5,"domainLookupStart":677.5,"fetchStart":677.5,"redirectEnd":0,"redirectStart":0,"requestStart":765.3000001907349,"responseEnd":814.9000005722046,"responseStart":814,"secureConnectionStart":677.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":37,"responseStart":292,"responseEnd":300,"domLoading":295,"domInteractive":1112,"domContentLoadedEventStart":1112,"domContentLoadedEventEnd":1157,"domComplete":1616,"loadEventStart":1616,"loadEventEnd":1617,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1093.3000001907349},{"name":"bigPipe.sidebar-id.end","time":1094.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.start","time":1094.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1095},{"name":"activityTabFullyLoaded","time":1174.3000001907349}],"measures":[],"correlationId":"42aedb17082a8b","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}