summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-05-17 22:56:27 -0700
committerIgor Babaev <igor@askmonty.org>2018-05-17 22:58:21 -0700
commitde86997160ea5e02e7fc6eb877d5823e96b64523 (patch)
treed841fc4cad41d13437fbce025151b5b68cdeccd3 /mysql-test/t
parent52c98bf830cc14948f6a950961c77d64d20677a6 (diff)
downloadmariadb-git-de86997160ea5e02e7fc6eb877d5823e96b64523.tar.gz
MDEV-15581 Incorrect result (missing row) with UNION DISTINCT in anchor parts
The current code does not support recursive CTEs whose specifications contain a mix of ALL UNION and DISTINCT UNION operations. This patch catches such specifications and reports errors for them.
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/cte_recursive.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test
index b3276475fa4..32a82c494e0 100644
--- a/mysql-test/t/cte_recursive.test
+++ b/mysql-test/t/cte_recursive.test
@@ -2258,3 +2258,27 @@ SELECT 1 FROM dual UNION ALL
SELECT 1 FROM qn
ORDER BY (SELECT * FROM qn))
SELECT count(*) FROM qn;
+
+--echo #
+--echo # MDEV-15581: mix of ALL and DISTINCT UNION in recursive CTE
+--echo #
+
+create table t1(a int);
+insert into t1 values(1),(2);
+insert into t1 values(1),(2);
+
+set @c=0, @d=0;
+--error ER_NOT_SUPPORTED_YET
+WITH RECURSIVE qn AS
+(
+select 1,0 as col from t1
+union distinct
+select 1,0 from t1
+union all
+select 3, 0*(@c:=@c+1) from qn where @c<1
+union all
+select 3, 0*(@d:=@d+1) from qn where @d<1
+)
+select * from qn;
+
+drop table t1;