diff options
author | Igor Babaev <igor@askmonty.org> | 2017-10-11 08:37:35 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-10-11 10:22:46 -0700 |
commit | 4c9d19ee657b882fcb5a2daea702357a1a73b55f (patch) | |
tree | 5aadbb1ed36644efd04754f62cc738ba17f10ab9 /mysql-test/t/cte_nonrecursive.test | |
parent | dc8ac122bb484b1e88c0aafee3e961208b93bbb5 (diff) | |
download | mariadb-git-4c9d19ee657b882fcb5a2daea702357a1a73b55f.tar.gz |
Fixed the bug mdev-13796.
A reference to a CTE may occur not in the master of the CTE
specification. In this case if the reference to the CTE is
the first one the specification should be detached from its
master and attached to the referencing select.
Also fixed the TYPE column in the lines of the EXPLAIN output
created for CTE tables.
Diffstat (limited to 'mysql-test/t/cte_nonrecursive.test')
-rw-r--r-- | mysql-test/t/cte_nonrecursive.test | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test index 980bff01694..57b7ae1658f 100644 --- a/mysql-test/t/cte_nonrecursive.test +++ b/mysql-test/t/cte_nonrecursive.test @@ -724,3 +724,22 @@ deallocate prepare stmt2; drop view v1,v2; drop table t1,t2; + +--echo # +--echo # MDEV-13796: UNION of two materialized CTEs +--echo # + +CREATE TABLE t1 (id int, k int); +CREATE TABLE t2 (id int); +INSERT INTO t1 VALUES (3,5), (1,7), (4,3); +INSERT INTO t2 VALUES (4), (3), (2); + +let $q= +WITH d1 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id), + d2 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id) +SELECT * FROM d1 UNION SELECT * FROM d2; + +eval $q; +eval explain $q; + +DROP TABLE t1,t2; |