summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2017-01-18 00:56:24 +0300
committerSergei Petrunia <psergey@askmonty.org>2017-01-18 00:56:24 +0300
commit45f11a729c9ccacd57a82a3b523ba73e4113311b (patch)
treebe311bc6a7b958c4f1c62310be807b819bee93c7
parent6a65de6cda17cc955d73b992f91acb76e8ef7512 (diff)
downloadmariadb-git-45f11a729c9ccacd57a82a3b523ba73e4113311b.tar.gz
MDEV-10773: ANALYZE FORMAT=JSON query_with_CTE crashes
Added testcase
-rw-r--r--mysql-test/r/cte_recursive.result65
-rw-r--r--mysql-test/t/cte_recursive.test12
2 files changed, 77 insertions, 0 deletions
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": "<derived2>",
+ "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": "<union2,3>",
+ "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": "<derived2>",
+ "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;
+