summaryrefslogtreecommitdiff
path: root/mysql-test/t/cte_nonrecursive.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/cte_nonrecursive.test')
-rw-r--r--mysql-test/t/cte_nonrecursive.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test
index 1af91dd38c0..05de03fc7af 100644
--- a/mysql-test/t/cte_nonrecursive.test
+++ b/mysql-test/t/cte_nonrecursive.test
@@ -944,3 +944,23 @@ USE db1;
WITH cte AS (SELECT 1 AS a) SELECT db1.cte.a FROM db1.cte;
DROP DATABASE db1;
+USE test;
+
+--echo #
+--echo # MDEV-15119: CTE c2 specified after CTE c1 and is used in
+--echo # CTE c3 that is embedded into the spec of c1
+--echo #
+
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--error ER_NO_SUCH_TABLE
+WITH c1 AS (WITH c3 AS (SELECT * FROM c2) SELECT * FROM c3),
+ c2 AS (SELECT * FROM t1)
+SELECT * FROM c1;
+
+WITH RECURSIVE c1 AS (WITH c3 AS (SELECT * FROM c2) SELECT * FROM c3),
+ c2 AS (SELECT * FROM t1)
+SELECT * FROM c1;
+
+DROP TABLE t1;