46
46
insert into t2i select * from t2;
47
47
insert into t3i select * from t3;
49
--echo /********************************************************************
50
--echo * Simple tests.
51
--echo ********************************************************************/
52
--echo # non-indexed nullable fields
55
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
56
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
60
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
61
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
65
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
66
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
49
# force the use of materialization
50
set @@optimizer_switch=no_semijoin;
52
/******************************************************************************
54
******************************************************************************/
55
# non-indexed nullable fields
57
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
58
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
61
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
62
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
65
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
66
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
70
69
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
71
70
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
76
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
77
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
81
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
82
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
86
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
87
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
91
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
92
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
74
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
75
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
78
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
79
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
82
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
83
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
86
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
87
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
96
90
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
97
91
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
99
93
# materialize the result of ORDER BY
100
94
# non-indexed fields
103
96
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
104
97
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
108
100
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
109
101
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
111
103
# nested subqueries, views
115
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
116
(a1, a2) in (select c1, c2 from t3
117
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
119
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
120
(a1, a2) in (select c1, c2 from t3
121
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
126
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
127
(a1, a2) in (select c1, c2 from t3i
128
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
130
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
131
(a1, a2) in (select c1, c2 from t3i
132
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
106
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
107
(a1, a2) in (select c1, c2 from t3
108
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
110
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
111
(a1, a2) in (select c1, c2 from t3
112
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
116
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
117
(a1, a2) in (select c1, c2 from t3i
118
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
120
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
121
(a1, a2) in (select c1, c2 from t3i
122
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
137
126
where (a1, a2) in (select b1, b2 from t2
630
606
/******************************************************************************
631
607
* Test the cache of the left operand of IN.
632
608
******************************************************************************/
609
set @@optimizer_switch=no_semijoin;
633
611
# Test that default values of Cached_item are not used for comparison
634
create temporary table t1 (s1 int) ENGINE=MyISAM;
635
create temporary table t2 (s2 int) ENGINE=MyISAM;
612
create table t1 (s1 int) ENGINE=MyISAM;
613
create table t2 (s2 int) ENGINE=MyISAM;
636
614
insert into t1 values (5),(1),(0);
637
615
insert into t2 values (0), (1);
638
616
select s2 from t2 where s2 in (select s1 from t1);
639
617
drop table t1, t2;
641
create temporary table t1 (a int not null, b int not null) ENGINE=MyISAM;
642
create temporary table t2 (c int not null, d int not null) ENGINE=MyISAM;
643
create temporary table t3 (e int not null) ENGINE=MyISAM;
619
create table t1 (a int not null, b int not null) ENGINE=MyISAM;
620
create table t2 (c int not null, d int not null) ENGINE=MyISAM;
621
create table t3 (e int not null) ENGINE=MyISAM;
645
623
# the first outer row has no matching inner row
646
624
insert into t1 values (1,10);