~mysql/mysql-server/mysql-next-mr-bugfixing

« back to all changes in this revision

Viewing changes to mysql-test/r/subquery_sj_mat_nosj.result

  • Committer: Tor Didriksen
  • Date: 2010-11-11 14:30:15 UTC
  • mfrom: (2914.73.250 next-mr-opt-team)
  • Revision ID: tor.didriksen@oracle.com-20101111143015-wechfh3nif8dyyva
Automerge next-mr-opt-team => next-mr-bugfixing

Show diffs side-by-side

added added

removed removed

Lines of Context:
2415
2415
17
2416
2416
18
2417
2417
19
 
2418
explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20;
 
2419
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2420
1       PRIMARY t3      ALL     NULL    NULL    NULL    NULL    100     Using where
 
2421
2       SUBQUERY        t1      range   kp1     kp1     5       NULL    48      Using where; Using index
 
2422
select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20;
 
2423
a
 
2424
0
 
2425
1
 
2426
2
 
2427
3
 
2428
4
 
2429
5
 
2430
6
 
2431
7
 
2432
8
 
2433
9
 
2434
10
 
2435
11
 
2436
12
 
2437
13
 
2438
14
 
2439
15
 
2440
16
 
2441
17
 
2442
18
 
2443
19
2418
2444
create table t4 (pk int primary key);
2419
2445
insert into t4 select a from t3;
2420
2446
explain select * from t3 where a in 
2798
2824
2       SUBQUERY        t3      ref     a       a       5       test.t1.a       1       Using index
2799
2825
drop table t0, t1,t2,t3;
2800
2826
 
2801
 
Test that MaterializeLookup strategy for semijoin,
 
2827
Test that neither MaterializeLookup strategy for semijoin,
2802
2828
nor subquery materialization is used when BLOBs are involved 
2803
2829
(except when arguments of some functions).
2804
 
Note: Due to Bug#52068, wrong may occur below if MaterializeScan 
2805
 
strategy is used instead, 
2806
2830
 
2807
2831
set @prefix_len = 6;
2808
2832
set @blob_len = 16;
5407
5431
1 - 12  2 - 22
5408
5432
DROP TABLE t1,t2a,t2b,t2c;
5409
5433
# End BUG#52329
 
5434
#
 
5435
# Bug#45174: Incorrectly applied equality propagation caused wrong
 
5436
# result on a query with a materialized semi-join.
 
5437
#
 
5438
CREATE TABLE t1 (
 
5439
varchar_nokey varchar(1) NOT NULL
 
5440
);
 
5441
INSERT INTO t1 VALUES
 
5442
('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'),
 
5443
('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u');
 
5444
CREATE TABLE t2 (
 
5445
pk int NOT NULL,
 
5446
varchar_key varchar(1) NOT NULL,
 
5447
varchar_nokey varchar(1) NOT NULL,
 
5448
PRIMARY KEY(pk),
 
5449
KEY varchar_key(varchar_key)
 
5450
);
 
5451
INSERT INTO t2 VALUES
 
5452
(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''),
 
5453
(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'),
 
5454
(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p');
 
5455
SELECT varchar_nokey
 
5456
FROM t1
 
5457
WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey
 
5458
FROM t2  
 
5459
WHERE varchar_nokey < 'n' XOR pk);
 
5460
varchar_nokey
 
5461
explain SELECT varchar_nokey
 
5462
FROM t1
 
5463
WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey
 
5464
FROM t2  
 
5465
WHERE varchar_nokey < 'n' XOR pk);
 
5466
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
5467
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    18      Using where
 
5468
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    15      Using where
 
5469
DROP TABLE t1, t2;
 
5470
# End of the test for bug#45174.
 
5471
#
 
5472
# Bug#50019: Wrong result for IN-query with materialization
 
5473
#
 
5474
CREATE TABLE t1(i INT);
 
5475
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
 
5476
CREATE TABLE t2(i INT);
 
5477
INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
 
5478
CREATE TABLE t3(i INT);
 
5479
INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
 
5480
SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i
 
5481
FROM t2 JOIN t3
 
5482
WHERE t2.i + t3.i = 5);
 
5483
i
 
5484
1
 
5485
2
 
5486
3
 
5487
4
 
5488
explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i
 
5489
FROM t2 JOIN t3
 
5490
WHERE t2.i + t3.i = 5);
 
5491
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
5492
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    10      Using where
 
5493
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    10      
 
5494
2       SUBQUERY        t3      ALL     NULL    NULL    NULL    NULL    10      Using where; Using join buffer (BNL, regular buffers)
 
5495
DROP TABLE t1,t2,t3;
 
5496
# End of the test for bug#50019.
 
5497
#
 
5498
# Bug#52068: Optimizer generates invalid semijoin materialization plan
 
5499
#
 
5500
CREATE TABLE ot1(a INTEGER);
 
5501
INSERT INTO ot1 VALUES(5), (8);
 
5502
CREATE TABLE it2(a INTEGER);
 
5503
INSERT INTO it2 VALUES(9), (5), (1), (8);
 
5504
CREATE TABLE it3(a INTEGER);
 
5505
INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4);
 
5506
CREATE TABLE ot4(a INTEGER);
 
5507
INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1);
 
5508
SELECT * FROM ot1,ot4
 
5509
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
 
5510
FROM it2,it3);
 
5511
a       a
 
5512
5       1
 
5513
8       1
 
5514
5       5
 
5515
8       5
 
5516
5       7
 
5517
8       7
 
5518
5       7
 
5519
8       7
 
5520
5       1
 
5521
8       1
 
5522
explain SELECT * FROM ot1,ot4
 
5523
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
 
5524
FROM it2,it3);
 
5525
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
5526
1       PRIMARY ot1     ALL     NULL    NULL    NULL    NULL    2       
 
5527
1       PRIMARY ot4     ALL     NULL    NULL    NULL    NULL    8       Using where; Using join buffer (BNL, regular buffers)
 
5528
2       SUBQUERY        it2     ALL     NULL    NULL    NULL    NULL    4       
 
5529
2       SUBQUERY        it3     ALL     NULL    NULL    NULL    NULL    6       Using join buffer (BNL, regular buffers)
 
5530
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
 
5531
# End of the test for bug#52068.
5410
5532
set optimizer_switch=default;