Type:
Bug
Priority:
Trivial
Resolution:
Won't Fix
Affects Version/s:
None
Fix Version/s:
None
Component/s:
None
Since mariadb version 5.3.3, I do have regression with sql queries using
sub queries (with order by) and user variables. Theses queries just worked
fine since many months/years, and they now return wrong result. May be
it's just me doing something that's not supposed to work. I include here
detailed explanation. Any hint would be highly appreciated
I wish to parse this stock table in a given order and
display in the same time a column showing the quantity
cumulated. So expected result is (with "ORDER BY uid DESC") :
---- -----------------------
uid
quantity
total_quantity
---- -----------------------
---- -----------------------
DROP TABLE IF EXISTS stock_table;
CREATE TABLE stock_table ( `uid` BIGINT UNSIGNED NOT NULL, `quantity` BIGINT UNSIGNED NOT NULL);
INSERT INTO stock_table values (1, 2), (3, 4);
SET @total_quantity := 0 ;
SELECT
q1.*,
@total_quantity := @total_quantity + q1.quantity as total_quantity
FROM (SELECT stock_table.uid,
stock_table.quantity
FROM
stock_table
ORDER BY
stock_table.uid DESC) as q1;
that was giving the expected result for us since a very long time,
on older version of mariadb and mysql. We were relying on the fact,
in our usage, that mariadb was always parsing the subquery in the specified
order. But theses days (5.5.22-MariaDB-log), it does not work, it give :
---- -----------------------
uid
quantity
total_quantity
---- -----------------------
---- -----------------------
we want uid to be 3 then 1
#
It start failing after we moved from mariadb 5.3.2-beta to 5.3.3-rc
In the changelog http://kb.askmonty.org/en/mariadb-533-changelog
I see that there is optimization on "useless subquery clauses", it
could be related.
Is it expected that the outer query does not read the subquery in
the order specified by the subquery ?
Is there a way to solve this problem with mariadb if this is not considered
as a regression?
{"report":{"fcp":832.3000001907349,"ttfb":172.9000005722046,"pageVisibility":"visible","entityId":21274,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"b6fbb4b2-6521-4c89-8e29-58bdc6c0be72","navigationType":0,"readyForUser":895.6000003814697,"redirectCount":0,"resourceLoadedEnd":892.1000003814697,"resourceLoadedStart":177.9000005722046,"resourceTiming":[{"duration":256.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":177.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":434.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":257,"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":178.20000076293945,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":435.20000076293945,"responseStart":0,"secureConnectionStart":0},{"duration":266,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":178.30000019073486,"connectEnd":178.30000019073486,"connectStart":178.30000019073486,"domainLookupEnd":178.30000019073486,"domainLookupStart":178.30000019073486,"fetchStart":178.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":178.30000019073486,"responseEnd":444.30000019073486,"responseStart":444.30000019073486,"secureConnectionStart":178.30000019073486},{"duration":291.1000003814697,"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":178.5,"connectEnd":178.5,"connectStart":178.5,"domainLookupEnd":178.5,"domainLookupStart":178.5,"fetchStart":178.5,"redirectEnd":0,"redirectStart":0,"requestStart":178.5,"responseEnd":469.6000003814697,"responseStart":469.6000003814697,"secureConnectionStart":178.5},{"duration":294.6000003814697,"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":178.80000019073486,"connectEnd":178.80000019073486,"connectStart":178.80000019073486,"domainLookupEnd":178.80000019073486,"domainLookupStart":178.80000019073486,"fetchStart":178.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":178.80000019073486,"responseEnd":473.4000005722046,"responseStart":473.4000005722046,"secureConnectionStart":178.80000019073486},{"duration":295,"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":178.9000005722046,"connectEnd":178.9000005722046,"connectStart":178.9000005722046,"domainLookupEnd":178.9000005722046,"domainLookupStart":178.9000005722046,"fetchStart":178.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":178.9000005722046,"responseEnd":473.9000005722046,"responseStart":473.9000005722046,"secureConnectionStart":178.9000005722046},{"duration":295.19999980926514,"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":179.10000038146973,"connectEnd":179.10000038146973,"connectStart":179.10000038146973,"domainLookupEnd":179.10000038146973,"domainLookupStart":179.10000038146973,"fetchStart":179.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":179.10000038146973,"responseEnd":474.30000019073486,"responseStart":474.30000019073486,"secureConnectionStart":179.10000038146973},{"duration":296.5,"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":179.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":179.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":475.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":295.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":179.4000005722046,"connectEnd":179.4000005722046,"connectStart":179.4000005722046,"domainLookupEnd":179.4000005722046,"domainLookupStart":179.4000005722046,"fetchStart":179.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":179.4000005722046,"responseEnd":474.80000019073486,"responseStart":474.80000019073486,"secureConnectionStart":179.4000005722046},{"duration":296.19999980926514,"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":179.70000076293945,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":179.70000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":475.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":295.69999980926514,"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":179.80000019073486,"connectEnd":179.80000019073486,"connectStart":179.80000019073486,"domainLookupEnd":179.80000019073486,"domainLookupStart":179.80000019073486,"fetchStart":179.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":179.80000019073486,"responseEnd":475.5,"responseStart":475.5,"secureConnectionStart":179.80000019073486},{"duration":336.6000003814697,"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":180.60000038146973,"connectEnd":180.60000038146973,"connectStart":180.60000038146973,"domainLookupEnd":180.60000038146973,"domainLookupStart":180.60000038146973,"fetchStart":180.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":180.60000038146973,"responseEnd":517.2000007629395,"responseStart":517.2000007629395,"secureConnectionStart":180.60000038146973},{"duration":711.3999996185303,"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":180.70000076293945,"connectEnd":180.70000076293945,"connectStart":180.70000076293945,"domainLookupEnd":180.70000076293945,"domainLookupStart":180.70000076293945,"fetchStart":180.70000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":180.70000076293945,"responseEnd":892.1000003814697,"responseStart":892,"secureConnectionStart":180.70000076293945}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":16,"responseStart":173,"responseEnd":175,"domLoading":176,"domInteractive":971,"domContentLoadedEventStart":971,"domContentLoadedEventEnd":1011,"domComplete":1768,"loadEventStart":1768,"loadEventEnd":1770,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":958.7000007629395},{"name":"bigPipe.sidebar-id.end","time":959.4000005722046},{"name":"bigPipe.activity-panel-pipe-id.start","time":959.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":962.1000003814697},{"name":"activityTabFullyLoaded","time":1019.5}],"measures":[],"correlationId":"fb7e90a4b2046d","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":99,"dbReadsTimeInMs":9,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}