Skip to content

Commit 617d34a

Browse files
committed
Fixed wrong reset of join_cache_level in join_outer*test
1 parent 592dc59 commit 617d34a

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

mysql-test/main/join_outer.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,7 @@ INSERT INTO t2 VALUES
20002000
CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ;
20012001
INSERT INTO t3 VALUES
20022002
(0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25);
2003+
set @save_join_cache_level= @@join_cache_level;
20032004
SET SESSION join_cache_level=4;
20042005
EXPLAIN EXTENDED
20052006
SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b;
@@ -2018,7 +2019,7 @@ EXECUTE stmt;
20182019
b b a b
20192020
10 10 0 10
20202021
DEALLOCATE PREPARE stmt;
2021-
SET SESSION join_cache_level=default;
2022+
SET SESSION join_cache_level=@save_join_cache_level;
20222023
DROP TABLE t1,t2,t3;
20232024
#
20242025
# LP bug #943543: LEFT JOIN converted to JOIN with

mysql-test/main/join_outer.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,7 @@ CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ;
15751575
INSERT INTO t3 VALUES
15761576
(0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25);
15771577

1578+
set @save_join_cache_level= @@join_cache_level;
15781579
SET SESSION join_cache_level=4;
15791580

15801581
EXPLAIN EXTENDED
@@ -1588,7 +1589,7 @@ EXECUTE stmt;
15881589

15891590
DEALLOCATE PREPARE stmt;
15901591

1591-
SET SESSION join_cache_level=default;
1592+
SET SESSION join_cache_level=@save_join_cache_level;
15921593

15931594
DROP TABLE t1,t2,t3;
15941595

mysql-test/main/join_outer_jcl6.result

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,7 @@ INSERT INTO t2 VALUES
20112011
CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ;
20122012
INSERT INTO t3 VALUES
20132013
(0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25);
2014+
set @save_join_cache_level= @@join_cache_level;
20142015
SET SESSION join_cache_level=4;
20152016
EXPLAIN EXTENDED
20162017
SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b;
@@ -2029,7 +2030,7 @@ EXECUTE stmt;
20292030
b b a b
20302031
10 10 0 10
20312032
DEALLOCATE PREPARE stmt;
2032-
SET SESSION join_cache_level=default;
2033+
SET SESSION join_cache_level=@save_join_cache_level;
20332034
DROP TABLE t1,t2,t3;
20342035
#
20352036
# LP bug #943543: LEFT JOIN converted to JOIN with
@@ -2086,34 +2087,34 @@ WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5
20862087
ORDER BY t1.b;
20872088
id select_type table type possible_keys key key_len ref rows filtered Extra
20882089
1 SIMPLE t1 ref idx idx 4 const 2 100.00 Using where
2089-
1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00
2090+
1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
20902091
Warnings:
20912092
Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b`
20922093
SELECT t1.b, t2.c, t2.d FROM t2 JOIN t1 ON t2.c = t1.a
20932094
WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5
20942095
ORDER BY t1.b;
20952096
b c d
20962097
5 8 88
2097-
5 8 81
20982098
5 8 88
20992099
5 8 81
2100+
5 8 81
21002101
EXPLAIN EXTENDED
21012102
SELECT t1.b, t2.c, t2.d FROM t2 LEFT JOIN t1 ON t2.c = t1.a
21022103
WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5
21032104
ORDER BY t1.b;
21042105
id select_type table type possible_keys key key_len ref rows filtered Extra
21052106
1 SIMPLE t1 ref PRIMARY,idx idx 4 const 2 100.00 Using where
2106-
1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00
2107+
1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
21072108
Warnings:
21082109
Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b`
21092110
SELECT t1.b, t2.c, t2.d FROM t2 LEFT JOIN t1 ON t2.c = t1.a
21102111
WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5
21112112
ORDER BY t1.b;
21122113
b c d
21132114
5 8 88
2114-
5 8 81
21152115
5 8 88
21162116
5 8 81
2117+
5 8 81
21172118
DROP TABLE t1,t2;
21182119
#
21192120
# Bug mdev-4336: LEFT JOIN with disjunctive
@@ -2229,10 +2230,10 @@ SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
22292230
WHERE d3 IS NULL;
22302231
id select_type table type possible_keys key key_len ref rows filtered Extra
22312232
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
2232-
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2233-
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
2233+
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 100.00 Using where; Using join buffer (flat, BNLH join)
2234+
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 100.00 Using where; Using join buffer (incremental, BNLH join)
22342235
Warnings:
2235-
Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`i2` = `test`.`t1`.`i1` and `test`.`t3`.`i3` = `test`.`t1`.`i1`) where `test`.`t3`.`d3` = 0 or `test`.`t3`.`d3` is null
2236+
Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`i2` = `test`.`t1`.`i1` and `test`.`t3`.`i3` = `test`.`t1`.`i1` and `test`.`t1`.`i1` is not null and `test`.`t1`.`i1` is not null) where `test`.`t3`.`d3` = 0 or `test`.`t3`.`d3` is null
22362237
DROP TABLE t1,t2,t3;
22372238
#
22382239
# Bug mdev-6705: wrong on expression after constant row substitution
@@ -2250,9 +2251,9 @@ WHERE b IN (1,2,3) OR b = d;
22502251
id select_type table type possible_keys key key_len ref rows filtered Extra
22512252
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
22522253
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2253-
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2254+
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 const 2 100.00 Using where; Using join buffer (flat, BNLH join)
22542255
Warnings:
2255-
Note 1003 select 10 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t3`.`d` AS `d` from `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`d` = 10) where `test`.`t2`.`c` = 8 and `test`.`t3`.`d` = 8
2256+
Note 1003 select 10 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t3`.`d` AS `d` from `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`d` = 10 and 10 is not null) where `test`.`t2`.`c` = 8 and `test`.`t3`.`d` = 8
22562257
SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
22572258
WHERE b IN (1,2,3) OR b = d;
22582259
a b c d
@@ -2279,11 +2280,11 @@ id select_type table type possible_keys key key_len ref rows Extra
22792280
explain select * from t1 left join t2 on t2.b is null;
22802281
id select_type table type possible_keys key key_len ref rows Extra
22812282
1 SIMPLE t1 ALL NULL NULL NULL NULL 9
2282-
1 SIMPLE t2 ref b b 5 const 780 Using where
2283+
1 SIMPLE t2 ref b b 5 const 780 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
22832284
explain select * from t1 left join t2 on t2.c is null;
22842285
id select_type table type possible_keys key key_len ref rows Extra
22852286
1 SIMPLE t1 ALL NULL NULL NULL NULL 9
2286-
1 SIMPLE t2 ref c c 5 const 393 Using where
2287+
1 SIMPLE t2 ref c c 5 const 393 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
22872288
drop table t1,t2;
22882289
#
22892290
# MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause
@@ -2325,8 +2326,8 @@ LEFT JOIN t3 on t2.i2 = t3.i3
23252326
WHERE v3 = 4;
23262327
id select_type table type possible_keys key key_len ref rows filtered Extra
23272328
1 SIMPLE t3 ref PRIMARY,v3 v3 5 const 1 100.00
2328-
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00
2329-
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00
2329+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
2330+
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
23302331
Warnings:
23312332
Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`v1` AS `v1`,`test`.`t2`.`i2` AS `i2`,`test`.`t2`.`v2` AS `v2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`v3` AS `v3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`v3` = 4 and `test`.`t1`.`i1` = `test`.`t3`.`i3` and `test`.`t2`.`i2` = `test`.`t3`.`i3`
23322333
# This should have the same join order like the query above:
@@ -2343,8 +2344,8 @@ AND 1 = 1
23432344
WHERE v3 = 4;
23442345
id select_type table type possible_keys key key_len ref rows filtered Extra
23452346
1 SIMPLE t3 ref PRIMARY,v3 v3 5 const 1 100.00
2346-
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00
2347-
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00
2347+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
2348+
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.i3 1 100.00 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
23482349
Warnings:
23492350
Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`v1` AS `v1`,`test`.`t2`.`i2` AS `i2`,`test`.`t2`.`v2` AS `v2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`v3` AS `v3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`v3` = 4 and `test`.`t1`.`i1` = `test`.`t3`.`i3` and `test`.`t2`.`i2` = `test`.`t3`.`i3`
23502351
drop table t1,t2,t3;
@@ -2367,9 +2368,9 @@ ON t1.x = t2.x
23672368
WHERE IFNULL(t2.x,0)=0;
23682369
id select_type table type possible_keys key key_len ref rows filtered Extra
23692370
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
2370-
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2371+
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 100.00 Using where; Using join buffer (flat, BNLH join)
23712372
Warnings:
2372-
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x`) where ifnull(`test`.`t2`.`x`,0) = 0
2373+
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`x` is not null) where ifnull(`test`.`t2`.`x`,0) = 0
23732374
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
23742375
FROM t t1 LEFT JOIN t t2
23752376
ON t1.x = t2.x
@@ -2383,9 +2384,9 @@ ON t1.x = t2.x
23832384
WHERE f(t2.x,0)=0;
23842385
id select_type table type possible_keys key key_len ref rows filtered Extra
23852386
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
2386-
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2387+
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 100.00 Using where; Using join buffer (flat, BNLH join)
23872388
Warnings:
2388-
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x`) where `f`(`test`.`t2`.`x`,0) = 0
2389+
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`x` is not null) where `f`(`test`.`t2`.`x`,0) = 0
23892390
drop function f;
23902391
drop table t;
23912392
CREATE TABLE t1 (
@@ -2423,9 +2424,9 @@ FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
24232424
WHERE IFNULL(t2.col3,0) = 0;
24242425
id select_type table type possible_keys key key_len ref rows filtered Extra
24252426
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
2426-
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2427+
1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 100.00 Using where; Using join buffer (flat, BNLH join)
24272428
Warnings:
2428-
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1`) where ifnull(`test`.`t2`.`col3`,0) = 0
2429+
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1` and `test`.`t1`.`col1` is not null) where ifnull(`test`.`t2`.`col3`,0) = 0
24292430
SELECT t1.col1, t2.col1, t2.col3
24302431
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
24312432
WHERE f1(t2.col3,0) = 0;
@@ -2437,9 +2438,9 @@ FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
24372438
WHERE f1(t2.col3,0) = 0;
24382439
id select_type table type possible_keys key key_len ref rows filtered Extra
24392440
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
2440-
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2441+
1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 100.00 Using where; Using join buffer (flat, BNLH join)
24412442
Warnings:
2442-
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1`) where `f1`(`test`.`t2`.`col3`,0) = 0
2443+
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1` and `test`.`t1`.`col1` is not null) where `f1`(`test`.`t2`.`col3`,0) = 0
24432444
DROP FUNCTION f1;
24442445
DROP TABLE t1,t2;
24452446
#

0 commit comments

Comments
 (0)