Execution of the prepared statement for the query
with cte as
|
(select a from t1 where a between 4 and 7 group by a)
|
(select a from cte where exists( select a from t1 where cte.a=t1.a ))
|
union
|
(select a from t1 where a < 2);
|
works fine while the execution this query that is equivalent to the first one
with cte as
|
(select a from t1 where a between 4 and 7 group by a)
|
(select a from t1 where a < 2)
|
union
|
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
|
causes an assertion failure for debug builds and most probably crashes for release builds
MariaDB [test]> create table t1 (a int);
|
MariaDB [test]> insert into t1 values
|
-> (7), (2), (8), (1), (3), (2), (7), (5), (4), (7), (9), (8);
|
MariaDB [test]> prepare stmt from "
|
with cte as
|
(select a from t1 where a between 4 and 7 group by a)
|
(select a from cte where exists( select a from t1 where cte.a=t1.a ))
|
union
|
(select a from t1 where a < 2);
|
";
|
Statement prepared
|
MariaDB [test]> execute stmt;
|
+------+
|
| a |
|
+------+
|
| 7 |
|
| 5 |
|
| 4 |
|
| 1 |
|
+------+
|
MariaDB [test]> execute stmt;
|
+------+
|
| a |
|
+------+
|
| 7 |
|
| 5 |
|
| 4 |
|
| 1 |
|
+------+
|
MariaDB [test]> prepare stmt from "
|
"> with cte as
|
"> (select a from t1 where a between 4 and 7 group by a)
|
"> (select a from t1 where a < 2)
|
"> union
|
"> (select a from cte where exists( select a from t1 where cte.a=t1.a ))
|
"> ";
|
Statement prepared
|
MariaDB [test]> execute stmt;
|
|
mysqld: /home/igor/maria-git/10.2/sql/sql_prepare.cc:2949: void reinit_stmt_before_use(THD*, LEX*): Assertion `sl->join == 0' failed.
|
- relates to
-
MDEV-14777
Crash in MariaDB 10.2.12 on query using VIEW and WITH RECURSIVE
-
-
Closed
{"report":{"fcp":980.8999996185303,"ttfb":229.30000019073486,"pageVisibility":"visible","entityId":64982,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"de0f92e1-ac15-4cbc-9fb4-0324aae0a087","navigationType":0,"readyForUser":1064.1999998092651,"redirectCount":0,"resourceLoadedEnd":1165.3999996185303,"resourceLoadedStart":236.10000038146973,"resourceTiming":[{"duration":257.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":236.10000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":236.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":493.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":257.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":236.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":236.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":494.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":266.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":236.69999980926514,"connectEnd":236.69999980926514,"connectStart":236.69999980926514,"domainLookupEnd":236.69999980926514,"domainLookupStart":236.69999980926514,"fetchStart":236.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":236.69999980926514,"responseEnd":503.6000003814697,"responseStart":503.6000003814697,"secureConnectionStart":236.69999980926514},{"duration":310.20000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":236.89999961853027,"connectEnd":236.89999961853027,"connectStart":236.89999961853027,"domainLookupEnd":236.89999961853027,"domainLookupStart":236.89999961853027,"fetchStart":236.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":236.89999961853027,"responseEnd":547.1000003814697,"responseStart":547.1000003814697,"secureConnectionStart":236.89999961853027},{"duration":314,"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":237.10000038146973,"connectEnd":237.10000038146973,"connectStart":237.10000038146973,"domainLookupEnd":237.10000038146973,"domainLookupStart":237.10000038146973,"fetchStart":237.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":237.10000038146973,"responseEnd":551.1000003814697,"responseStart":551.1000003814697,"secureConnectionStart":237.10000038146973},{"duration":314.69999980926514,"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":237.30000019073486,"connectEnd":237.30000019073486,"connectStart":237.30000019073486,"domainLookupEnd":237.30000019073486,"domainLookupStart":237.30000019073486,"fetchStart":237.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":237.30000019073486,"responseEnd":552,"responseStart":551.8999996185303,"secureConnectionStart":237.30000019073486},{"duration":315.30000019073486,"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":237.5,"connectEnd":237.5,"connectStart":237.5,"domainLookupEnd":237.5,"domainLookupStart":237.5,"fetchStart":237.5,"redirectEnd":0,"redirectStart":0,"requestStart":237.5,"responseEnd":552.8000001907349,"responseStart":552.8000001907349,"secureConnectionStart":237.5},{"duration":413.69999980926514,"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":237.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":237.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":651.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":315.70000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":237.89999961853027,"connectEnd":237.89999961853027,"connectStart":237.89999961853027,"domainLookupEnd":237.89999961853027,"domainLookupStart":237.89999961853027,"fetchStart":237.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":237.89999961853027,"responseEnd":553.6000003814697,"responseStart":553.6000003814697,"secureConnectionStart":237.89999961853027},{"duration":413.5,"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":238,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":238,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":651.5,"responseStart":0,"secureConnectionStart":0},{"duration":316.29999923706055,"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":238.10000038146973,"connectEnd":238.10000038146973,"connectStart":238.10000038146973,"domainLookupEnd":238.10000038146973,"domainLookupStart":238.10000038146973,"fetchStart":238.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":238.10000038146973,"responseEnd":554.3999996185303,"responseStart":554.3999996185303,"secureConnectionStart":238.10000038146973},{"duration":611.7999992370605,"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":239.10000038146973,"connectEnd":239.10000038146973,"connectStart":239.10000038146973,"domainLookupEnd":239.10000038146973,"domainLookupStart":239.10000038146973,"fetchStart":239.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":239.10000038146973,"responseEnd":850.8999996185303,"responseStart":850.8999996185303,"secureConnectionStart":239.10000038146973},{"duration":925.2999992370605,"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":239.10000038146973,"connectEnd":239.10000038146973,"connectStart":239.10000038146973,"domainLookupEnd":239.10000038146973,"domainLookupStart":239.10000038146973,"fetchStart":239.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":239.10000038146973,"responseEnd":1164.3999996185303,"responseStart":1164.3999996185303,"secureConnectionStart":239.10000038146973},{"duration":170.89999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":680.6000003814697,"connectEnd":680.6000003814697,"connectStart":680.6000003814697,"domainLookupEnd":680.6000003814697,"domainLookupStart":680.6000003814697,"fetchStart":680.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":680.6000003814697,"responseEnd":851.5,"responseStart":851.5,"secureConnectionStart":680.6000003814697},{"duration":235.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":930.3000001907349,"connectEnd":930.3000001907349,"connectStart":930.3000001907349,"domainLookupEnd":930.3000001907349,"domainLookupStart":930.3000001907349,"fetchStart":930.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":930.3000001907349,"responseEnd":1165.3999996185303,"responseStart":1165.3999996185303,"secureConnectionStart":930.3000001907349}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":48,"responseStart":229,"responseEnd":233,"domLoading":233,"domInteractive":1187,"domContentLoadedEventStart":1187,"domContentLoadedEventEnd":1235,"domComplete":1566,"loadEventStart":1566,"loadEventEnd":1567,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1166.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1167.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.start","time":1167.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1169.1999998092651},{"name":"activityTabFullyLoaded","time":1255.6000003814697}],"measures":[],"correlationId":"8a03486f65bd21","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":115,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
One can see the same failure after having replace cte for a mergeable one
MariaDB [test]> prepare stmt from "
"> with cte as
"> (select a from t1 where a between 4 and 7)
"> (select a from t1 where a < 2)
"> union
"> (select a from cte where exists( select a from t1 where cte.a=t1.a ));
"> ";
Statement prepared
MariaDB [test]> execute stmt;
mysqld: /home/igor/maria-git/10.2/sql/sql_prepare.cc:2949: void reinit_stmt_before_use(THD*, LEX*): Assertion `sl->join == 0' failed.