summaryrefslogtreecommitdiff
path: root/mysql-test/r/cte_nonrecursive.result
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-11-20 21:35:54 -0800
committerIgor Babaev <igor@askmonty.org>2021-11-20 21:35:54 -0800
commit114e18b8b68a00b3829ac231cc8f84187f529287 (patch)
tree6b0ef69ef2907eec8d30f3fa2c5581bee7f14593 /mysql-test/r/cte_nonrecursive.result
parent0dae41637abd24c8f08e925ef00490e949ce581d (diff)
downloadmariadb-git-114e18b8b68a00b3829ac231cc8f84187f529287.tar.gz
MDEV-26470 "No database" selected when using CTE in a subquery of DELETE statement
This bug led to reporting bogus messages "No database selected" for DELETE statements if they used subqueries in their WHERE conditions and these subqueries contained references to CTEs. The bug happened because the grammar rule for DELETE statement did not call the function LEX::check_cte_dependencies_and_resolve_references() and as a result of it references to CTEs were not identified as such. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'mysql-test/r/cte_nonrecursive.result')
-rw-r--r--mysql-test/r/cte_nonrecursive.result22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result
index d9b7f054271..b2fee0d3c6f 100644
--- a/mysql-test/r/cte_nonrecursive.result
+++ b/mysql-test/r/cte_nonrecursive.result
@@ -2162,4 +2162,26 @@ a
1
3
drop table t1,t2;
+#
+# MDEV-26470: CTE in WITH clause of subquery used in DELETE
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (5);
+create table t2 (b int);
+insert into t2 values (4), (1), (3), (2);
+delete from t1
+where a in (with cte(a) as (select * from t2 where b <=2) select a from cte);
+select * from t1;
+a
+3
+7
+5
+insert into t1 values (1), (3);
+delete t1 from t1, t2
+where t1.a=t2.b or
+t1.a in (with cte(a) as (select b+1 from t2) select * from cte);
+select * from t1;
+a
+7
+drop table t1,t2;
# End of 10.2 tests