Note that this is not limited to Item_copy or Item_sum_field-derived items.
Slightly modified Alice's testcase:
CREATETABLE t1 ( id varchar(10));
INSERTINTO t1 values (1),(2),(3);
SELECT
dense_rank() over (ORDERBYavg(1)+3),
rank() over (ORDERBYavg(1))
FROM t4
GROUPBY
nullif(id, 15532);
This crashes compare_order_elements, too, and we have:
(gdb) p item1
$8 = (Item_func_plus *) 0x7fff74013ad8
(gdb) p item2
$9 = (Item_avg_field_decimal *) 0x7fff740178d0
... so the ORDER BY list can have an arbitrary item.
I don't see this causing any problems in window function computation code btw. Only compare_order_elements has an issue.
Sergei Petrunia
added a comment - - edited Note that this is not limited to Item_copy or Item_sum_field-derived items.
Slightly modified Alice's testcase:
CREATE TABLE t1 ( id varchar (10));
INSERT INTO t1 values (1),(2),(3);
SELECT
dense_rank() over ( ORDER BY avg (1)+3),
rank() over ( ORDER BY avg (1))
FROM t4
GROUP BY
nullif (id, 15532);
This crashes compare_order_elements, too, and we have:
(gdb) p item1
$8 = (Item_func_plus *) 0x7fff74013ad8
(gdb) p item2
$9 = (Item_avg_field_decimal *) 0x7fff740178d0
... so the ORDER BY list can have an arbitrary item.
I don't see this causing any problems in window function computation code btw. Only compare_order_elements has an issue.
Suggestion: can we get rid of the crash by adjusting the comparison function to
compare Item_field objects like it does now
any item that's not an Item_field is greater than any Item_field
two non-Item-field items are compared as their pointers.
This is "compatible" with the current ordering for Item_field objects.
It may miss some optimization opportunities when multiple window functions use the same PARTITION/ORDER BY expressions.
Comparing Item* pointers means the ordering will vary across executions. (What is the effect of this? Window Function step will run sorts in different order?)
Sergei Petrunia
added a comment - Suggestion: can we get rid of the crash by adjusting the comparison function to
compare Item_field objects like it does now
any item that's not an Item_field is greater than any Item_field
two non-Item-field items are compared as their pointers.
This is "compatible" with the current ordering for Item_field objects.
It may miss some optimization opportunities when multiple window functions use the same PARTITION/ORDER BY expressions.
Comparing Item* pointers means the ordering will vary across executions. (What is the effect of this? Window Function step will run sorts in different order?)
Sergei Petrunia
added a comment - Ok, the new fix is here https://github.com/MariaDB/server/commit/85cc56875e9ddb7f5f56013bac22e36805288c16
and it fixes MDEV-26614 , too.
People
Sergei Petrunia
Alice Sherepa
Votes:
0Vote for this issue
Watchers:
4Start 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":1195.7000002861023,"ttfb":458.6000003814697,"pageVisibility":"visible","entityId":75864,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"36b86c09-b02a-4c13-9003-4503a65d01f2","navigationType":0,"readyForUser":1307.8000001907349,"redirectCount":0,"resourceLoadedEnd":1445.7000002861023,"resourceLoadedStart":464.30000019073486,"resourceTiming":[{"duration":77.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":464.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":464.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":542.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":77.7999997138977,"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":464.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":464.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":542.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":143.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":464.80000019073486,"connectEnd":464.80000019073486,"connectStart":464.80000019073486,"domainLookupEnd":464.80000019073486,"domainLookupStart":464.80000019073486,"fetchStart":464.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":464.80000019073486,"responseEnd":608,"responseStart":608,"secureConnectionStart":464.80000019073486},{"duration":270.6000003814697,"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":465,"connectEnd":465,"connectStart":465,"domainLookupEnd":465,"domainLookupStart":465,"fetchStart":465,"redirectEnd":0,"redirectStart":0,"requestStart":465,"responseEnd":735.6000003814697,"responseStart":735.6000003814697,"secureConnectionStart":465},{"duration":273.69999980926514,"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":465.2000002861023,"connectEnd":465.2000002861023,"connectStart":465.2000002861023,"domainLookupEnd":465.2000002861023,"domainLookupStart":465.2000002861023,"fetchStart":465.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":465.2000002861023,"responseEnd":738.9000000953674,"responseStart":738.9000000953674,"secureConnectionStart":465.2000002861023},{"duration":274.30000019073486,"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":465.40000009536743,"connectEnd":465.40000009536743,"connectStart":465.40000009536743,"domainLookupEnd":465.40000009536743,"domainLookupStart":465.40000009536743,"fetchStart":465.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":465.40000009536743,"responseEnd":739.7000002861023,"responseStart":739.6000003814697,"secureConnectionStart":465.40000009536743},{"duration":274.59999990463257,"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":465.7000002861023,"connectEnd":465.7000002861023,"connectStart":465.7000002861023,"domainLookupEnd":465.7000002861023,"domainLookupStart":465.7000002861023,"fetchStart":465.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":465.7000002861023,"responseEnd":740.3000001907349,"responseStart":740.3000001907349,"secureConnectionStart":465.7000002861023},{"duration":313.40000009536743,"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":465.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":465.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":779.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":276.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":466,"connectEnd":466,"connectStart":466,"domainLookupEnd":466,"domainLookupStart":466,"fetchStart":466,"redirectEnd":0,"redirectStart":0,"requestStart":466,"responseEnd":742.8000001907349,"responseStart":742.8000001907349,"secureConnectionStart":466},{"duration":313.2999997138977,"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":466.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":466.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":779.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":278,"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":466.30000019073486,"connectEnd":466.30000019073486,"connectStart":466.30000019073486,"domainLookupEnd":466.30000019073486,"domainLookupStart":466.30000019073486,"fetchStart":466.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":466.30000019073486,"responseEnd":744.3000001907349,"responseStart":744.3000001907349,"secureConnectionStart":466.30000019073486},{"duration":970,"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":473.5,"connectEnd":473.5,"connectStart":473.5,"domainLookupEnd":473.5,"domainLookupStart":473.5,"fetchStart":473.5,"redirectEnd":0,"redirectStart":0,"requestStart":473.5,"responseEnd":1443.5,"responseStart":1443.5,"secureConnectionStart":473.5},{"duration":971.4000000953674,"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":474.30000019073486,"connectEnd":474.30000019073486,"connectStart":474.30000019073486,"domainLookupEnd":474.30000019073486,"domainLookupStart":474.30000019073486,"fetchStart":474.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":474.30000019073486,"responseEnd":1445.7000002861023,"responseStart":1445.7000002861023,"secureConnectionStart":474.30000019073486},{"duration":648.7999997138977,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":795.1000003814697,"connectEnd":795.1000003814697,"connectStart":795.1000003814697,"domainLookupEnd":795.1000003814697,"domainLookupStart":795.1000003814697,"fetchStart":795.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":795.1000003814697,"responseEnd":1443.9000000953674,"responseStart":1443.9000000953674,"secureConnectionStart":795.1000003814697},{"duration":263.40000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1188.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1188.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1451.8000001907349,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":251,"responseStart":459,"responseEnd":472,"domLoading":462,"domInteractive":1552,"domContentLoadedEventStart":1552,"domContentLoadedEventEnd":1613,"domComplete":2265,"loadEventStart":2265,"loadEventEnd":2266,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1512.9000000953674},{"name":"bigPipe.sidebar-id.end","time":1513.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1514},{"name":"bigPipe.activity-panel-pipe-id.end","time":1517.1000003814697},{"name":"activityTabFullyLoaded","time":1632.2000002861023}],"measures":[],"correlationId":"252af14398b0a3","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":141,"dbReadsTimeInMs":18,"dbConnsTimeInMs":33,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Note that this is not limited to Item_copy or Item_sum_field-derived items.
Slightly modified Alice's testcase:
This crashes compare_order_elements, too, and we have:
(gdb) p item1
$8 = (Item_func_plus *) 0x7fff74013ad8
(gdb) p item2
$9 = (Item_avg_field_decimal *) 0x7fff740178d0
... so the ORDER BY list can have an arbitrary item.
I don't see this causing any problems in window function computation code btw. Only compare_order_elements has an issue.