summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect4.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/subselect4.test')
-rw-r--r--mysql-test/t/subselect4.test51
1 files changed, 51 insertions, 0 deletions
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index 4eb9701ee71..253160c46ac 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -1956,5 +1956,56 @@ SELECT x FROM t1 WHERE id > (SELECT MAX(id) - 1000 FROM t1) ORDER BY x LIMIT 1;
drop table t1;
+--echo #
+--echo # MDEV-7691: Assertion `outer_context || !*from_field || *from_field == not_found_field' ...
+--echo #
+set optimizer_switch=default;
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (4),(6);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(8);
+
+PREPARE stmt FROM "
+SELECT * FROM t2
+HAVING 0 IN (
+ SELECT a FROM t1
+ WHERE a IN (
+ SELECT a FROM t1
+ WHERE b = a
+ )
+)
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+--echo # Alternative test case, without HAVING
+CREATE TABLE t3 (i INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (4),(6);
+
+PREPARE stmt FROM "
+SELECT * FROM t3 AS t10
+WHERE EXISTS (
+ SELECT * FROM t3 AS t20 WHERE t10.i IN (
+ SELECT i FROM t3
+ )
+)";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+drop table t1, t2, t3;
+
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;
+
+--echo #
+--echo # MDEV-10232 Scalar result of subquery changes after adding an outer select stmt
+--echo #
+
+create table t1(c1 int, c2 int, primary key(c2));
+insert into t1 values(2,1),(1,2);
+select (select c1 from t1 group by c1,c2 order by c1 limit 1) as x;
+(select c1 from t1 group by c1,c2 order by c1 limit 1);
+drop table t1;