~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/subselect_mat.test

  • Committer: Brian Aker
  • Date: 2009-07-11 19:23:04 UTC
  • mfrom: (1089.1.14 merge)
  • Revision ID: brian@gaz-20090711192304-ootijyl5yf9jq9kd
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
drop table if exists t1, t2, t3, t1i, t2i, t3i;
8
8
--enable_warnings
9
9
 
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;
13
13
 
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');
28
28
 
29
29
# Indexed columns
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);
227
227
explain extended
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');
230
 
explain extended
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);
233
230
 
234
231
 
235
232
/******************************************************************************
240
237
select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
241
238
 
242
239
/* GROUP BY clause */
243
 
create table columns (col int key);
 
240
create table columns (col int key) ENGINE=MyISAM;
244
241
insert into columns values (1), (2);
245
242
 
246
243
explain extended
271
268
set @blob_len = 16;
272
269
set @suffix_len = @blob_len - @prefix_len;
273
270
 
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;
277
274
 
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;
366
363
 
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;
370
367
 
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;
448
445
 
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;
452
449
 
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;
530
527
 
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;
534
531
 
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);
605
602
 
606
603
drop table t1_1025, t2_1025, t3_1025;
607
 
 
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));
611
 
 
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');
615
 
 
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');
619
 
 
620
 
set @@optimizer_switch=no_semijoin;
621
 
 
622
 
explain extended select bin(a1), bin(a2)
623
 
from t1bit
624
 
where (a1, a2) in (select b1, b2 from t2bit);
625
 
 
626
 
select bin(a1), bin(a2)
627
 
from t1bit
628
 
where (a1, a2) in (select b1, b2 from t2bit);
629
 
 
630
 
drop table t1bit, t2bit;
631
 
 
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));
635
 
 
636
 
insert into t1bb values (b'000', '100');
637
 
insert into t1bb values (b'001', '101');
638
 
insert into t1bb values (b'010', '110');
639
 
 
640
 
insert into t2bb values (b'001', '101');
641
 
insert into t2bb values (b'010', '110');
642
 
insert into t2bb values (b'110', '111');
643
 
 
644
 
explain extended select bin(a1), a2
645
 
from t1bb
646
 
where (a1, a2) in (select b1, b2 from t2bb);
647
 
 
648
 
select bin(a1), a2
649
 
from t1bb
650
 
where (a1, a2) in (select b1, b2 from t2bb);
651
 
 
652
 
drop table t1bb, t2bb;
653
 
drop table t1, t2, t3, t1i, t2i, t3i, columns;
 
604
drop table t1, t2, t3;
654
605
 
655
606
/******************************************************************************
656
607
* Test the cache of the left operand of IN.
658
609
set @@optimizer_switch=no_semijoin;
659
610
 
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;
667
618
 
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;
671
622
 
672
623
# the first outer row has no matching inner row
673
624
insert into t1 values (1,10);