7
7
drop table if exists t1, t2, t3, t1i, t2i, t3i;
10
create table t1 (a1 char(8), a2 char(8));
11
create table t2 (b1 char(8), b2 char(8));
12
create table t3 (c1 char(8), c2 char(8));
10
create table t1 (a1 char(8), a2 char(8)) ENGINE=MyISAM;
11
create table t2 (b1 char(8), b2 char(8)) ENGINE=MyISAM;
12
create table t3 (c1 char(8), c2 char(8)) ENGINE=MyISAM;
14
14
insert into t1 values ('1 - 00', '2 - 00');
15
15
insert into t1 values ('1 - 01', '2 - 01');
27
27
insert into t3 values ('1 - 04', '2 - 04');
30
create table t1i (a1 char(8), a2 char(8));
31
create table t2i (b1 char(8), b2 char(8));
32
create table t3i (c1 char(8), c2 char(8));
30
create table t1i (a1 char(8), a2 char(8)) ENGINE=MyISAM;
31
create table t2i (b1 char(8), b2 char(8)) ENGINE=MyISAM;
32
create table t3i (c1 char(8), c2 char(8)) ENGINE=MyISAM;
33
33
create index it1i1 on t1i (a1);
34
34
create index it1i2 on t1i (a2);
35
35
create index it1i3 on t1i (a1, a2);
228
228
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
229
229
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
231
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
232
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
235
232
/******************************************************************************
271
268
set @blob_len = 16;
272
269
set @suffix_len = @blob_len - @prefix_len;
274
create table t1_16 (a1 blob(16), a2 blob(16));
275
create table t2_16 (b1 blob(16), b2 blob(16));
276
create table t3_16 (c1 blob(16), c2 blob(16));
271
create table t1_16 (a1 blob, a2 blob) ENGINE=MyISAM;
272
create table t2_16 (b1 blob, b2 blob) ENGINE=MyISAM;
273
create table t3_16 (c1 blob, c2 blob) ENGINE=MyISAM;
278
275
insert into t1_16 values
279
276
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
364
361
set @blob_len = 512;
365
362
set @suffix_len = @blob_len - @prefix_len;
367
create table t1_512 (a1 blob(512), a2 blob(512));
368
create table t2_512 (b1 blob(512), b2 blob(512));
369
create table t3_512 (c1 blob(512), c2 blob(512));
364
create table t1_512 (a1 blob, a2 blob) ENGINE=MyISAM;
365
create table t2_512 (b1 blob, b2 blob) ENGINE=MyISAM;
366
create table t3_512 (c1 blob, c2 blob) ENGINE=MyISAM;
371
368
insert into t1_512 values
372
369
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
446
443
set @blob_len = 1024;
447
444
set @suffix_len = @blob_len - @prefix_len;
449
create table t1_1024 (a1 blob(1024), a2 blob(1024));
450
create table t2_1024 (b1 blob(1024), b2 blob(1024));
451
create table t3_1024 (c1 blob(1024), c2 blob(1024));
446
create table t1_1024 (a1 blob, a2 blob) ENGINE=MyISAM;
447
create table t2_1024 (b1 blob, b2 blob) ENGINE=MyISAM;
448
create table t3_1024 (c1 blob, c2 blob) ENGINE=MyISAM;
453
450
insert into t1_1024 values
454
451
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
528
525
set @blob_len = 1025;
529
526
set @suffix_len = @blob_len - @prefix_len;
531
create table t1_1025 (a1 blob(1025), a2 blob(1025));
532
create table t2_1025 (b1 blob(1025), b2 blob(1025));
533
create table t3_1025 (c1 blob(1025), c2 blob(1025));
528
create table t1_1025 (a1 blob, a2 blob) ENGINE=MyISAM;
529
create table t2_1025 (b1 blob, b2 blob) ENGINE=MyISAM;
530
create table t3_1025 (c1 blob, c2 blob) ENGINE=MyISAM;
535
532
insert into t1_1025 values
536
533
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
604
601
where a1 in (select group_concat(b1) from t2_1025 group by b2);
606
603
drop table t1_1025, t2_1025, t3_1025;
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;
604
drop table t1, t2, t3;
655
606
/******************************************************************************
656
607
* Test the cache of the left operand of IN.
658
609
set @@optimizer_switch=no_semijoin;
660
611
# Test that default values of Cached_item are not used for comparison
661
create table t1 (s1 int);
662
create table t2 (s2 int);
612
create table t1 (s1 int) ENGINE=MyISAM;
613
create table t2 (s2 int) ENGINE=MyISAM;
663
614
insert into t1 values (5),(1),(0);
664
615
insert into t2 values (0), (1);
665
616
select s2 from t2 where s2 in (select s1 from t1);
666
617
drop table t1, t2;
668
create table t1 (a int not null, b int not null);
669
create table t2 (c int not null, d int not null);
670
create table t3 (e int not null);
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;
672
623
# the first outer row has no matching inner row
673
624
insert into t1 values (1,10);