summaryrefslogtreecommitdiff
path: root/mysql-test/main/derived_view.test
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-01-29 15:41:05 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2022-01-29 15:41:05 +0100
commit41a163ac5ccf4ac5394edc84e40b3f47acea6b08 (patch)
tree60d5259e290b4a0166d8ef1651975b14b5afe304 /mysql-test/main/derived_view.test
parenta85d942be9008cf19086d8bd330c4be83a18167f (diff)
parente2b50213cf12623da31c8b49be4d40772876223c (diff)
downloadmariadb-git-41a163ac5ccf4ac5394edc84e40b3f47acea6b08.tar.gz
Merge branch '10.2' into 10.3mariadb-10.3.33
Diffstat (limited to 'mysql-test/main/derived_view.test')
-rw-r--r--mysql-test/main/derived_view.test111
1 files changed, 111 insertions, 0 deletions
diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test
index 9ab1ddd3a76..584bde2d75d 100644
--- a/mysql-test/main/derived_view.test
+++ b/mysql-test/main/derived_view.test
@@ -2289,4 +2289,115 @@ select * from ((select a from t1 limit 2) order by a desc) dt;
drop view v1;
drop table t1;
+--echo #
+--echo # MDEV-24454 Second execution of SELECT containing set function
+--echo # MDEV-25086: whose only argument is an outer reference to a column
+--echo # of mergeable view/derived/table/CTE
+--echo #
+
+create table t1 (a int);
+create table t2 (b int);
+insert into t1 values (3), (1), (3);
+insert into t2 values (70), (30), (70);
+create view v1 as select * from t2;
+
+prepare stmt from "
+select (select sum(b) from t1 where a=1) as r from v1;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from "
+select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from "
+with cte as (select * from t2)
+select (select sum(b) from t1 where a=1) as r from cte;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from "
+select (select sum(b) from t1 where a=1) as r
+from (select * from v1 where b > 50) dt;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from "
+select (select sum(b) from t1 where a=1) as r
+from (select * from (select * from t2) dt1 where b > 50) dt;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from "
+with cte as (select * from (select * from t2) dt1 where b > 50)
+select (select sum(b) from t1 where a=1) as r from cte;
+";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+--delimiter |
+create procedure sp1()
+begin
+select (select sum(b) from t1 where a=1) as r from v1;
+end |
+--delimiter ;
+call sp1();
+call sp1();
+drop procedure sp1;
+
+--delimiter |
+create procedure sp1()
+begin
+select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
+end |
+--delimiter ;
+call sp1();
+call sp1();
+drop procedure sp1;
+
+--delimiter |
+create procedure sp1()
+begin
+with cte as (select * from t2)
+select (select sum(b) from t1 where a=1) as r from cte;
+end |
+--delimiter ;
+call sp1();
+call sp1();
+drop procedure sp1;
+
+drop view v1;
+drop table t1,t2;
+
+CREATE TABLE t1(f0 INT);
+INSERT INTO t1 VALUES (3);
+CREATE VIEW v1 AS SELECT f0 AS f1 FROM t1;
+CREATE VIEW v2 AS
+SELECT
+ (SELECT GROUP_CONCAT(v1.f1 SEPARATOR ', ') FROM v1 n) AS f2,
+ GROUP_CONCAT('aa' SEPARATOR ', ') AS f3
+FROM v1;
+CREATE VIEW v3 AS SELECT * FROM v2;
+
+CREATE PROCEDURE p1()
+ SELECT * FROM v3;
+CALL p1();
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP VIEW v1,v2,v3;
+DROP TABLE t1;
+
--echo # End of 10.2 tests