Skip to content

Commit 8128ae4

Browse files
committed
Test case for mdev-13753 CTE is not visible during view creation
The bug was fixed by the patch for the bug mdev-13780.
1 parent 343bcb1 commit 8128ae4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

mysql-test/r/cte_nonrecursive.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,3 +1128,22 @@ NULL UNION RESULT <union1,6> ALL NULL NULL NULL NULL NULL NULL
11281128
Warnings:
11291129
Note 1003 with cte_e as (with cte_o as (with cte_i as (select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 7)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 1)select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 3 and `test`.`t1`.`a` > 1 and `test`.`t1`.`a` < 7 and `test`.`t1`.`a` > 1 union select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4 and `test`.`t1`.`a` > 1 and `test`.`t1`.`a` < 7 and `test`.`t1`.`a` > 1)select `cte_e1`.`a` AS `a` from `cte_e` `cte_e1` where `cte_e1`.`a` > 1 union select `cte_e2`.`a` AS `a` from `cte_e` `cte_e2`
11301130
drop table t1;
1131+
#
1132+
# MDEV-13753: embedded CTE in a VIEW created in prepared statement
1133+
#
1134+
SET @sql_query = "
1135+
CREATE OR REPLACE VIEW cte_test AS
1136+
WITH cte1 AS ( SELECT 1 as a from dual )
1137+
, cte2 AS ( SELECT * FROM cte1 )
1138+
SELECT * FROM cte2;
1139+
";
1140+
PREPARE stmt FROM @sql_query;
1141+
EXECUTE stmt;
1142+
DEALLOCATE PREPARE stmt;
1143+
SHOW CREATE VIEW cte_test;
1144+
View Create View character_set_client collation_connection
1145+
cte_test CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `cte_test` AS with cte1 as (select 1 AS `a`), cte2 as (select `cte1`.`a` AS `a` from `cte1`)select `cte2`.`a` AS `a` from `cte2` latin1 latin1_swedish_ci
1146+
SELECT * FROM cte_test;
1147+
a
1148+
1
1149+
DROP VIEW cte_test;

mysql-test/t/cte_nonrecursive.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,22 @@ eval $q;
771771
eval explain extended $q;
772772

773773
drop table t1;
774+
775+
--echo #
776+
--echo # MDEV-13753: embedded CTE in a VIEW created in prepared statement
777+
--echo #
778+
779+
SET @sql_query = "
780+
CREATE OR REPLACE VIEW cte_test AS
781+
WITH cte1 AS ( SELECT 1 as a from dual )
782+
, cte2 AS ( SELECT * FROM cte1 )
783+
SELECT * FROM cte2;
784+
";
785+
PREPARE stmt FROM @sql_query;
786+
EXECUTE stmt;
787+
DEALLOCATE PREPARE stmt;
788+
789+
SHOW CREATE VIEW cte_test;
790+
SELECT * FROM cte_test;
791+
792+
DROP VIEW cte_test;

0 commit comments

Comments
 (0)