diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result index d5476aec1c4..e68d5a38283 100644 --- a/mysql-test/r/cte_recursive.result +++ b/mysql-test/r/cte_recursive.result @@ -2343,3 +2343,68 @@ select id + 1, uuid() from data_generator where id < 150000 select * from data_generator ) as a; drop table t1; +# +# MDEV-10773: ANALYZE FORMAT=JSON query_with_CTE crashes +# +analyze format=json +with recursive src(counter) as +(select 1 +union +select counter+1 from src where counter<10 +) select * from src; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 10, + "r_total_time_ms": "REPLACED"e-4, + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "r_loops": 10, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "", + "access_type": "ALL", + "r_loops": 10, + "rows": 2, + "r_rows": 1, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 90, + "attached_condition": "src.counter < 10" + } + } + } + ] + } + } + } + } + } +} diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test index ea0f73be259..bb57a8600b6 100644 --- a/mysql-test/t/cte_recursive.test +++ b/mysql-test/t/cte_recursive.test @@ -1505,3 +1505,15 @@ select id, test_data ) as a; drop table t1; + +--echo # +--echo # MDEV-10773: ANALYZE FORMAT=JSON query_with_CTE crashes +--echo # +--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/ +analyze format=json +with recursive src(counter) as +(select 1 + union + select counter+1 from src where counter<10 +) select * from src; +