49
49
# force the use of materialization
50
50
set @@optimizer_switch=no_semijoin;
52
--echo /********************************************************************
53
--echo * Simple tests.
54
--echo ********************************************************************/
55
--echo # non-indexed nullable fields
58
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
59
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
63
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
64
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
68
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
69
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
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);
73
69
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
74
70
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
79
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
80
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
84
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
85
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
89
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
90
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
94
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
95
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);
99
90
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
100
91
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
102
93
# materialize the result of ORDER BY
103
94
# non-indexed fields
106
96
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
107
97
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
111
100
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
112
101
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
114
103
# nested subqueries, views
118
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
119
(a1, a2) in (select c1, c2 from t3
120
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
122
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
123
(a1, a2) in (select c1, c2 from t3
124
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
129
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
130
(a1, a2) in (select c1, c2 from t3i
131
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
133
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
134
(a1, a2) in (select c1, c2 from t3i
135
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'));
140
126
where (a1, a2) in (select b1, b2 from t2
260
240
select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
262
242
/* GROUP BY clause */
263
create temporary table columns (col int key) ENGINE=MyISAM;
243
create table columns (col int key);
264
244
insert into columns values (1), (2);
268
select * from t1 group by (select col from columns limit 1);
269
select * from t1 group by (select col from columns limit 1);
273
select * from t1 group by (a1 in (select col from columns));
274
select * from t1 group by (a1 in (select col from columns));
276
--echo /* ORDER BY clause */
279
select * from t1 order by (select col from columns limit 1);
280
select * from t1 order by (select col from columns limit 1);
247
select * from t1 group by (select col from columns limit 1);
248
select * from t1 group by (select col from columns limit 1);
251
select * from t1 group by (a1 in (select col from columns));
252
select * from t1 group by (a1 in (select col from columns));
254
/* ORDER BY clause */
256
select * from t1 order by (select col from columns limit 1);
257
select * from t1 order by (select col from columns limit 1);
284
259
/******************************************************************************
285
260
* Column types/sizes that affect materialization.
629
604
where a1 in (select group_concat(b1) from t2_1025 group by b2);
631
606
drop table t1_1025, t2_1025, t3_1025;
632
drop table t1, t2, t3;
608
# test for BIT fields
609
create table t1bit (a1 bit(3), a2 bit(3));
610
create table t2bit (b1 bit(3), b2 bit(3));
612
insert into t1bit values (b'000', b'100');
613
insert into t1bit values (b'001', b'101');
614
insert into t1bit values (b'010', b'110');
616
insert into t2bit values (b'001', b'101');
617
insert into t2bit values (b'010', b'110');
618
insert into t2bit values (b'110', b'111');
620
set @@optimizer_switch=no_semijoin;
622
explain extended select bin(a1), bin(a2)
624
where (a1, a2) in (select b1, b2 from t2bit);
626
select bin(a1), bin(a2)
628
where (a1, a2) in (select b1, b2 from t2bit);
630
drop table t1bit, t2bit;
632
# test mixture of BIT and BLOB
633
create table t1bb (a1 bit(3), a2 blob(3));
634
create table t2bb (b1 bit(3), b2 blob(3));
636
insert into t1bb values (b'000', '100');
637
insert into t1bb values (b'001', '101');
638
insert into t1bb values (b'010', '110');
640
insert into t2bb values (b'001', '101');
641
insert into t2bb values (b'010', '110');
642
insert into t2bb values (b'110', '111');
644
explain extended select bin(a1), a2
646
where (a1, a2) in (select b1, b2 from t2bb);
650
where (a1, a2) in (select b1, b2 from t2bb);
652
drop table t1bb, t2bb;
653
drop table t1, t2, t3, t1i, t2i, t3i, columns;
634
655
/******************************************************************************
635
656
* Test the cache of the left operand of IN.