The following query returns different result between MYSQL and MARIADB (5.5.28):
CREATE TABLE t(a int,b int,c int, amount1 int, amount2 int);
|
INSERT INTO t (a, b, c, amount1, amount2) values (1,1,1,1,1);
|
INSERT INTO t (a, b, c, amount1, amount2) values (2,2,2,2,1);
|
INSERT INTO t (a, b, c, amount1, amount2) values (2,3,3,3,1);
|
|
SELECT *,
|
IF(`t_reorder`.`b` IS NULL, @ccount1:=amount1, @ccount1) AS `a_amount1`,
|
IF(`t_reorder`.`b` IS NULL, @dcount1:=amount2, @dcount1) AS `a_amount2`
|
FROM (
|
SELECT *
|
FROM (
|
SELECT `a`, `b`,`c`,
|
SUM(`amount1`) AS `amount1`, SUM(`amount2`) AS `amount2`
|
FROM `t`
|
WHERE (c IN (1,2,3)) AND ((`a` IS NOT NULL) AND (`b` IS NOT NULL))
|
GROUP BY `a`, `b` WITH ROLLUP) `t_rollup`
|
ORDER BY `a`, `b`
|
)`t_reorder`;
|
|
mysql.exe Ver 14.14 Distrib 5.5.28, for Win32 (x86)
|
(Correct)
|
+------+------+------+---------+---------+-----------+-----------+
|
| a | b | c | amount1 | amount2 | a_amount1 | a_amount2 |
|
+------+------+------+---------+---------+-----------+-----------+
|
| NULL | NULL | 3 | 6 | 3 | 6 | 3 |
|
| 1 | NULL | 1 | 1 | 1 | 1 | 1 |
|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
|
| 2 | NULL | 3 | 5 | 2 | 5 | 2 |
|
| 2 | 2 | 2 | 2 | 1 | 5 | 2 |
|
| 2 | 3 | 3 | 3 | 1 | 5 | 2 |
|
+------+------+------+---------+---------+-----------+-----------+
|
|
mysql.exe Ver 15.1 Distrib 5.5.28-MariaDB, for Win32 (x86)
|
(Wrong values on a_amount1 and a_amount2)
|
ORDER BY `a`, `b` does not have any effect to this qyery
|
+------+------+------+---------+---------+-----------+-----------+
|
| a | b | c | amount1 | amount2 | a_amount1 | a_amount2 |
|
+------+------+------+---------+---------+-----------+-----------+
|
| 1 | 1 | 1 | 1 | 1 | 6 | 3 |
|
| 1 | NULL | 1 | 1 | 1 | 1 | 1 |
|
| 2 | 2 | 2 | 2 | 1 | 1 | 1 |
|
| 2 | 3 | 3 | 3 | 1 | 1 | 1 |
|
| 2 | NULL | 3 | 5 | 2 | 5 | 2 |
|
| NULL | NULL | 3 | 6 | 3 | 6 | 3 |
|
+------+------+------+---------+---------+-----------+-----------+
|
MariaDB seems to ignore ORDER BY statement after subquery having GROUP BY ... WITH ROLLUP.
Optimizer_switch settings as per default.
{"report":{"fcp":685.6000001430511,"ttfb":149.30000019073486,"pageVisibility":"visible","entityId":22300,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"cf669150-569b-490c-bf49-54b96807cc59","navigationType":0,"readyForUser":748.5,"redirectCount":0,"resourceLoadedEnd":683.3000001907349,"resourceLoadedStart":155.80000019073486,"resourceTiming":[{"duration":9.599999904632568,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":155.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":155.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":165.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":9.700000047683716,"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":156.10000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":156.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":165.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":64.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":156.20000004768372,"connectEnd":156.20000004768372,"connectStart":156.20000004768372,"domainLookupEnd":156.20000004768372,"domainLookupStart":156.20000004768372,"fetchStart":156.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":156.20000004768372,"responseEnd":220.60000014305115,"responseStart":220.60000014305115,"secureConnectionStart":156.20000004768372},{"duration":113.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":156.30000019073486,"connectEnd":156.30000019073486,"connectStart":156.30000019073486,"domainLookupEnd":156.30000019073486,"domainLookupStart":156.30000019073486,"fetchStart":156.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":156.30000019073486,"responseEnd":269.40000009536743,"responseStart":269.40000009536743,"secureConnectionStart":156.30000019073486},{"duration":116.90000009536743,"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":156.40000009536743,"connectEnd":156.40000009536743,"connectStart":156.40000009536743,"domainLookupEnd":156.40000009536743,"domainLookupStart":156.40000009536743,"fetchStart":156.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":156.40000009536743,"responseEnd":273.30000019073486,"responseStart":273.30000019073486,"secureConnectionStart":156.40000009536743},{"duration":117.39999985694885,"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":156.60000014305115,"connectEnd":156.60000014305115,"connectStart":156.60000014305115,"domainLookupEnd":156.60000014305115,"domainLookupStart":156.60000014305115,"fetchStart":156.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":156.60000014305115,"responseEnd":274,"responseStart":274,"secureConnectionStart":156.60000014305115},{"duration":118.29999995231628,"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":156.60000014305115,"connectEnd":156.60000014305115,"connectStart":156.60000014305115,"domainLookupEnd":156.60000014305115,"domainLookupStart":156.60000014305115,"fetchStart":156.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":156.60000014305115,"responseEnd":274.90000009536743,"responseStart":274.90000009536743,"secureConnectionStart":156.60000014305115},{"duration":119,"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":156.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":156.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":275.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":119.5,"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":156.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":156.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":276.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":118.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":156.90000009536743,"connectEnd":156.90000009536743,"connectStart":156.90000009536743,"domainLookupEnd":156.90000009536743,"domainLookupStart":156.90000009536743,"fetchStart":156.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":156.90000009536743,"responseEnd":275.80000019073486,"responseStart":275.7000000476837,"secureConnectionStart":156.90000009536743},{"duration":119.5,"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":157.10000014305115,"connectEnd":157.10000014305115,"connectStart":157.10000014305115,"domainLookupEnd":157.10000014305115,"domainLookupStart":157.10000014305115,"fetchStart":157.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":157.10000014305115,"responseEnd":276.60000014305115,"responseStart":276.60000014305115,"secureConnectionStart":157.10000014305115},{"duration":525,"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":157.90000009536743,"connectEnd":157.90000009536743,"connectStart":157.90000009536743,"domainLookupEnd":157.90000009536743,"domainLookupStart":157.90000009536743,"fetchStart":157.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":157.90000009536743,"responseEnd":682.9000000953674,"responseStart":682.9000000953674,"secureConnectionStart":157.90000009536743},{"duration":525.3000001907349,"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":158,"connectEnd":158,"connectStart":158,"domainLookupEnd":158,"domainLookupStart":158,"fetchStart":158,"redirectEnd":0,"redirectStart":0,"requestStart":158,"responseEnd":683.3000001907349,"responseStart":683.3000001907349,"secureConnectionStart":158},{"duration":231,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":450.5,"connectEnd":450.5,"connectStart":450.5,"domainLookupEnd":450.5,"domainLookupStart":450.5,"fetchStart":450.5,"redirectEnd":0,"redirectStart":0,"requestStart":450.5,"responseEnd":681.5,"responseStart":681.5,"secureConnectionStart":450.5},{"duration":56.89999985694885,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":663.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":663.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":720.7000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":25,"responseStart":149,"responseEnd":151,"domLoading":153,"domInteractive":813,"domContentLoadedEventStart":813,"domContentLoadedEventEnd":855,"domComplete":1517,"loadEventStart":1517,"loadEventEnd":1519,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":793.7000000476837},{"name":"bigPipe.sidebar-id.end","time":794.6000001430511},{"name":"bigPipe.activity-panel-pipe-id.start","time":794.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":797},{"name":"activityTabFullyLoaded","time":861.3000001907349}],"measures":[],"correlationId":"6f1eca742a2e48","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":67,"dbReadsTimeInMs":11,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}