diff options
author | Igor Babaev <igor@askmonty.org> | 2016-08-05 14:12:01 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-08-05 14:12:01 -0700 |
commit | e1c92a6ca9130ae07c9fa596c969a4b4f3a95ee3 (patch) | |
tree | ee3583e19d090c302132315561208507cd1206c6 /mysql-test/t/cte_nonrecursive.test | |
parent | 247632e67ea49227978cfc50f4df6274ccda4a33 (diff) | |
download | mariadb-git-e1c92a6ca9130ae07c9fa596c969a4b4f3a95ee3.tar.gz |
Fixed a problem with unreferenced CTE:
explain for the query containing WITH clause
with an unreferenced CTE caused a crash.
Added a test covered this case.
Also added a test for usage CTE in different parts of union.
Diffstat (limited to 'mysql-test/t/cte_nonrecursive.test')
-rw-r--r-- | mysql-test/t/cte_nonrecursive.test | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test index 8caf0832df4..eb6677e7f75 100644 --- a/mysql-test/t/cte_nonrecursive.test +++ b/mysql-test/t/cte_nonrecursive.test @@ -152,6 +152,28 @@ select * from (select * from t1 where b >= 'c') as r1, with t(c) as (select a from t1 where b >= 'c') select * from t r1, t r2 where r1.c=r2.c; +--echo # t two references of t used in different parts of a union +with t as (select a from t1 where b >= 'c') + select * from t where a < 2 + union + select * from t where a >= 4; +select * from (select a from t1 where b >= 'c') as t + where t.a < 2 +union +select * from (select a from t1 where b >= 'c') as t + where t.a >= 4; +explain +with t as (select a from t1 where b >= 'c') + select * from t where a < 2 + union + select * from t where a >= 4; +explain +select * from (select a from t1 where b >= 'c') as t + where t.a < 2 +union +select * from (select a from t1 where b >= 'c') as t + where t.a >= 4; + --echo # specification of t contains union with t as (select a from t1 where b >= 'f' union @@ -437,6 +459,16 @@ with t(f) as (select * from t1 where b >= 'c') with t(f1,f1) as (select * from t1 where b >= 'c') select t1.b from t2,t1 where t1.a = t2.c; +--echo # explain for query with unreferenced with table + +explain +with t as (select a from t1 where b >= 'c') + select t1.b from t2,t1 where t1.a = t2.c; + +explain +with t as (select a, count(*) from t1 where b >= 'c' group by a) + select t1.b from t2,t1 where t1.a = t2.c; + drop table t1,t2; --echo # |