mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
BKA join cache buffer is employed despite join_cache_level=3 (flat BNLH)
In the `check_join_cache_usage()` function there is a branching issue where an accidental fall-through to BKA/BKAH buffers may occur, even when the join_cache_level setting does not permit their use. This patch corrects the condition to ensure that BKA/BKAH join caching is only enabled when explicitly allowed by join_cache_level Reviewer: Sergei Petrunia <sergey@mariadb.com>
This commit is contained in:
parent
937ae4137e
commit
733852d4c3
3 changed files with 54 additions and 1 deletions
|
|
@ -6443,3 +6443,29 @@ DROP TABLE t1, t2;
|
|||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
#
|
||||
# MDEV-36165: BKA join cache buffer is employed despite join_cache_level=3 (flat BNLH)
|
||||
#
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
CREATE TABLE t2(a INT, b INT);
|
||||
INSERT INTO t2 SELECT a, a from t1;
|
||||
CREATE TABLE t3(a INT, b INT, c INT, key (a,b));
|
||||
INSERT INTO t3 select a, a, a FROM t1;
|
||||
SET optimizer_switch = 'join_cache_hashed=off,join_cache_bka=on,mrr=on';
|
||||
SET join_cache_level = 3;
|
||||
EXPLAIN SELECT * FROM t2, t3 WHERE t2.a=t3.a AND (t3.b+1 <= t2.b+1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t3 ref a a 5 test.t2.a 1 Using index condition
|
||||
SET join_cache_level = 4;
|
||||
EXPLAIN SELECT * FROM t2, t3 WHERE t2.a=t3.a AND (t3.b+1 <= t2.b+1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t3 ref a a 5 test.t2.a 1 Using index condition
|
||||
SET join_cache_level = default;
|
||||
SET optimizer_switch = default;
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# End of 10.11 tests
|
||||
#
|
||||
|
|
|
|||
|
|
@ -4321,3 +4321,30 @@ DROP TABLE t1, t2;
|
|||
--echo #
|
||||
--echo # End of 10.5 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-36165: BKA join cache buffer is employed despite join_cache_level=3 (flat BNLH)
|
||||
--echo #
|
||||
--source include/have_sequence.inc
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
CREATE TABLE t2(a INT, b INT);
|
||||
INSERT INTO t2 SELECT a, a from t1;
|
||||
CREATE TABLE t3(a INT, b INT, c INT, key (a,b));
|
||||
INSERT INTO t3 select a, a, a FROM t1;
|
||||
|
||||
SET optimizer_switch = 'join_cache_hashed=off,join_cache_bka=on,mrr=on';
|
||||
|
||||
SET join_cache_level = 3;
|
||||
EXPLAIN SELECT * FROM t2, t3 WHERE t2.a=t3.a AND (t3.b+1 <= t2.b+1);
|
||||
|
||||
SET join_cache_level = 4;
|
||||
EXPLAIN SELECT * FROM t2, t3 WHERE t2.a=t3.a AND (t3.b+1 <= t2.b+1);
|
||||
|
||||
SET join_cache_level = default;
|
||||
SET optimizer_switch = default;
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.11 tests
|
||||
--echo #
|
||||
|
|
|
|||
|
|
@ -14769,7 +14769,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
|
|||
}
|
||||
goto no_join_cache;
|
||||
}
|
||||
if (cache_level > 4 && no_bka_cache)
|
||||
if (cache_level < 5 || no_bka_cache)
|
||||
goto no_join_cache;
|
||||
|
||||
if ((flags & HA_MRR_NO_ASSOCIATION) &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue