MariaDB [test]> set big_tables=0;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [test]> with recursive qn as (select 123 as a union all select 1+a from qn where a<130) select * from qn;
|
+-----+
|
| a |
|
+-----+
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
+-----+
|
8 rows in set (0.00 sec)
|
|
MariaDB [test]> set big_tables=1;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [test]> with recursive qn as (select 123 as a union all select 1+a from qn where a<130) select * from qn;
|
+-----+
|
| a |
|
+-----+
|
| 123 |
|
| 124 |
|
+-----+
|
2 rows in set (0.00 sec)
|
|
- relates to
-
MDEV-15447
Import CTE tests from MySQL 8
-
-
Stalled
{"report":{"fcp":727.4000000953674,"ttfb":209.10000002384186,"pageVisibility":"visible","entityId":66347,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"aaa81571-c4c0-4736-9248-87bf3c9b479a","navigationType":0,"readyForUser":806,"redirectCount":0,"resourceLoadedEnd":833.7000000476837,"resourceLoadedStart":213.90000009536743,"resourceTiming":[{"duration":9.099999904632568,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":213.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":213.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":223,"responseStart":0,"secureConnectionStart":0},{"duration":9.100000023841858,"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":214.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":214.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":223.30000007152557,"responseStart":0,"secureConnectionStart":0},{"duration":68.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":214.30000007152557,"connectEnd":214.30000007152557,"connectStart":214.30000007152557,"domainLookupEnd":214.30000007152557,"domainLookupStart":214.30000007152557,"fetchStart":214.30000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":214.30000007152557,"responseEnd":283.10000002384186,"responseStart":283.10000002384186,"secureConnectionStart":214.30000007152557},{"duration":151.80000007152557,"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":214.60000002384186,"connectEnd":214.60000002384186,"connectStart":214.60000002384186,"domainLookupEnd":214.60000002384186,"domainLookupStart":214.60000002384186,"fetchStart":214.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":214.60000002384186,"responseEnd":366.40000009536743,"responseStart":366.40000009536743,"secureConnectionStart":214.60000002384186},{"duration":155.29999995231628,"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":214.80000007152557,"connectEnd":214.80000007152557,"connectStart":214.80000007152557,"domainLookupEnd":214.80000007152557,"domainLookupStart":214.80000007152557,"fetchStart":214.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":214.80000007152557,"responseEnd":370.10000002384186,"responseStart":370.10000002384186,"secureConnectionStart":214.80000007152557},{"duration":155.59999990463257,"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":214.90000009536743,"connectEnd":214.90000009536743,"connectStart":214.90000009536743,"domainLookupEnd":214.90000009536743,"domainLookupStart":214.90000009536743,"fetchStart":214.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":214.90000009536743,"responseEnd":370.5,"responseStart":370.5,"secureConnectionStart":214.90000009536743},{"duration":155.70000004768372,"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":215.10000002384186,"connectEnd":215.10000002384186,"connectStart":215.10000002384186,"domainLookupEnd":215.10000002384186,"domainLookupStart":215.10000002384186,"fetchStart":215.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":215.10000002384186,"responseEnd":370.8000000715256,"responseStart":370.8000000715256,"secureConnectionStart":215.10000002384186},{"duration":208.20000004768372,"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":215.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":215.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":423.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":208.10000002384186,"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":215.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":215.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":423.60000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":155.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":215.5,"connectEnd":215.5,"connectStart":215.5,"domainLookupEnd":215.5,"domainLookupStart":215.5,"fetchStart":215.5,"redirectEnd":0,"redirectStart":0,"requestStart":215.5,"responseEnd":371.2000000476837,"responseStart":371.2000000476837,"secureConnectionStart":215.5},{"duration":156.10000002384186,"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":215.70000004768372,"connectEnd":215.70000004768372,"connectStart":215.70000004768372,"domainLookupEnd":215.70000004768372,"domainLookupStart":215.70000004768372,"fetchStart":215.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":215.70000004768372,"responseEnd":371.8000000715256,"responseStart":371.8000000715256,"secureConnectionStart":215.70000004768372},{"duration":477.8000000715256,"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":222.10000002384186,"connectEnd":222.10000002384186,"connectStart":222.10000002384186,"domainLookupEnd":222.10000002384186,"domainLookupStart":222.10000002384186,"fetchStart":222.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":222.10000002384186,"responseEnd":699.9000000953674,"responseStart":699.9000000953674,"secureConnectionStart":222.10000002384186},{"duration":532.5,"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":231.60000002384186,"connectEnd":231.60000002384186,"connectStart":231.60000002384186,"domainLookupEnd":231.60000002384186,"domainLookupStart":231.60000002384186,"fetchStart":231.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":231.60000002384186,"responseEnd":764.1000000238419,"responseStart":764.1000000238419,"secureConnectionStart":231.60000002384186},{"duration":265.89999997615814,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":434.40000009536743,"connectEnd":434.40000009536743,"connectStart":434.40000009536743,"domainLookupEnd":434.40000009536743,"domainLookupStart":434.40000009536743,"fetchStart":434.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":434.40000009536743,"responseEnd":700.3000000715256,"responseStart":700.3000000715256,"secureConnectionStart":434.40000009536743},{"duration":167.20000004768372,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":721.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":721.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":888.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":90.29999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":743.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":743.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":833.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":40,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/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":744.4000000953674,"connectEnd":744.4000000953674,"connectStart":744.4000000953674,"domainLookupEnd":744.4000000953674,"domainLookupStart":744.4000000953674,"fetchStart":744.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":744.4000000953674,"responseEnd":784.4000000953674,"responseStart":784.4000000953674,"secureConnectionStart":744.4000000953674},{"duration":46.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":744.9000000953674,"connectEnd":744.9000000953674,"connectStart":744.9000000953674,"domainLookupEnd":744.9000000953674,"domainLookupStart":744.9000000953674,"fetchStart":744.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":744.9000000953674,"responseEnd":791,"responseStart":791,"secureConnectionStart":744.9000000953674}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":41,"responseStart":209,"responseEnd":231,"domLoading":212,"domInteractive":949,"domContentLoadedEventStart":949,"domContentLoadedEventEnd":1009,"domComplete":1057,"loadEventStart":1057,"loadEventEnd":1057,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":899},{"name":"bigPipe.sidebar-id.end","time":900.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":900.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":905.9000000953674},{"name":"activityTabFullyLoaded","time":1026.7000000476837}],"measures":[],"correlationId":"6d21ce393d9802","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":106,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
This bug also can be reproduced with the following test case:
create table folks(id int, name char(32), dob date, father int, mother int);
insert into folks values
(100, 'Me', '2000-01-01', 20, 30),
(20, 'Dad', '1970-02-02', 10, 9),
(30, 'Mom', '1975-03-03', 8, 7),
(10, 'Grandpa Bill', '1940-04-05', null, null),
(9, 'Grandma Ann', '1941-10-15', null, null),
(25, 'Uncle Jim', '1968-11-18', 8, 7),
(98, 'Sister Amy', '2001-06-20', 20, 30),
(7, 'Grandma Sally', '1943-08-23', null, 6),
(8, 'Grandpa Ben', '1940-10-21', null, null),
(6, 'Grandgrandma Martha', '1923-05-17', null, null),
(67, 'Cousin Eddie', '1992-02-28', 25, 27),
(27, 'Auntie Melinda', '1971-03-29', null, null);
set big_tables=0;
with recursive
ancestors
as
(
select *
from folks
where name = 'Me' and dob = '2000-01-01'
union
select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a
where p.id = a.father or p.id = a.mother
)
select * from ancestors;
set big_tables=1;
with recursive
ancestors
as
(
select *
from folks
where name = 'Me' and dob = '2000-01-01'
union
select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a
where p.id = a.father or p.id = a.mother
)
select * from ancestors;
MariaDB [test]> set big_tables=0;
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> with recursive
-> ancestors
-> as
-> (
-> select *
-> from folks
-> where name = 'Me' and dob = '2000-01-01'
-> union
-> select p.id, p.name, p.dob, p.father, p.mother
-> from folks as p, ancestors AS a
-> where p.id = a.father or p.id = a.mother
-> )
-> select * from ancestors;
+------+---------------------+------------+--------+--------+
| id | name | dob | father | mother |
+------+---------------------+------------+--------+--------+
| 100 | Me | 2000-01-01 | 20 | 30 |
| 20 | Dad | 1970-02-02 | 10 | 9 |
| 30 | Mom | 1975-03-03 | 8 | 7 |
| 10 | Grandpa Bill | 1940-04-05 | NULL | NULL |
| 9 | Grandma Ann | 1941-10-15 | NULL | NULL |
| 7 | Grandma Sally | 1943-08-23 | NULL | 6 |
| 8 | Grandpa Ben | 1940-10-21 | NULL | NULL |
| 6 | Grandgrandma Martha | 1923-05-17 | NULL | NULL |
+------+---------------------+------------+--------+--------+
8 rows in set (0.00 sec)
MariaDB [test]> set big_tables=1;
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> with recursive
-> ancestors
-> as
-> (
-> select *
-> from folks
-> where name = 'Me' and dob = '2000-01-01'
-> union
-> select p.id, p.name, p.dob, p.father, p.mother
-> from folks as p, ancestors AS a
-> where p.id = a.father or p.id = a.mother
-> )
-> select * from ancestors;
+------+------+------------+--------+--------+
| id | name | dob | father | mother |
+------+------+------------+--------+--------+
| 100 | Me | 2000-01-01 | 20 | 30 |
| 20 | Dad | 1970-02-02 | 10 | 9 |
| 30 | Mom | 1975-03-03 | 8 | 7 |
+------+------+------------+--------+--------+
3 rows in set (0.00 sec)