summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect_sj.test
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-02-23 21:35:05 +0100
committerSergei Golubchik <serg@mariadb.org>2016-02-23 21:35:05 +0100
commita5679af1b13bb0c7c4eaa75f27551072dc18fb7d (patch)
tree7d039fb5e83c331daa75f9b9b67625b0469f6a9b /mysql-test/t/subselect_sj.test
parent20c4dfd4a9e7c5f2f570488a7ead0b7c74e61817 (diff)
parent5f2f3c4fa81851b45dcee33601f14e05f6407333 (diff)
downloadmariadb-git-a5679af1b13bb0c7c4eaa75f27551072dc18fb7d.tar.gz
Merge branch '10.0' into 10.1
Diffstat (limited to 'mysql-test/t/subselect_sj.test')
-rw-r--r--mysql-test/t/subselect_sj.test69
1 files changed, 69 insertions, 0 deletions
diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test
index c2b93c919dd..b6d6e0a5172 100644
--- a/mysql-test/t/subselect_sj.test
+++ b/mysql-test/t/subselect_sj.test
@@ -2704,5 +2704,74 @@ explain
select 1 from t1 where _cp932 "1" in (select '1' from t1);
drop table t1;
+--echo #
+--echo # MDEV-7823: Server crashes in next_depth_first_tab on nested IN clauses with SQ inside
+--echo #
+set @tmp_mdev7823=@@optimizer_switch;
+set optimizer_switch=default;
+CREATE TABLE t1 (f1 INT);
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (f2 INT, KEY(f2));
+INSERT INTO t2 VALUES (8),(0);
+
+CREATE TABLE t3 (f3 INT);
+INSERT INTO t3 VALUES (1),(2);
+
+CREATE TABLE t4 (f4 INT);
+INSERT INTO t4 VALUES (0),(5);
+
+explain
+SELECT * FROM t1, t2, t3 WHERE f2 IN ( f1 IN ( SELECT f4 FROM t4 ) );
+SELECT * FROM t1, t2, t3 WHERE f2 IN ( f1 IN ( SELECT f4 FROM t4 ) );
+
+drop table t1,t2,t3,t4;
+set optimizer_switch= @tmp_mdev7823;
+
+--echo #
+--echo # MDEV-6859: scalar subqueries in a comparison produced unexpected result
+--echo #
+set @tmp_mdev6859=@@optimizer_switch;
+set optimizer_switch=default;
+CREATE TABLE t1 (
+ project_number varchar(50) NOT NULL,
+ PRIMARY KEY (project_number)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 (project_number) VALUES ('aaa'),('bbb');
+
+CREATE TABLE t2 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ project_number varchar(50) NOT NULL,
+ history_date date NOT NULL,
+ country varchar(50) NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=MyISAM;
+
+INSERT INTO t2 (id, project_number, history_date, country) VALUES
+(1, 'aaa', '2014-08-09', 'france'),(2, 'aaa', '2014-09-09', 'singapore');
+
+CREATE TABLE t3 (
+ region varchar(50) NOT NULL,
+ country varchar(50) NOT NULL
+) ENGINE=MyISAM;
+
+INSERT INTO t3 (region, country) VALUES ('apac', 'singapore'),('eame', 'france');
+
+SELECT SQL_NO_CACHE a.project_number
+FROM t1 a
+WHERE ( SELECT z.country
+ FROM t2 z
+ WHERE z.project_number = a.project_number AND z.history_date <= '2014-09-01'
+ ORDER BY z.id DESC LIMIT 1
+ ) IN (
+ SELECT r.country
+ FROM t3 r
+ WHERE r.region = 'eame'
+ );
+
+drop table t1, t2, t3;
+set optimizer_switch= @tmp_mdev6859;
+
# The following command must be the last one the file
set optimizer_switch=@subselect_sj_tmp;