1
0
mirror of https://github.com/MariaDB/server.git synced 2025-10-27 05:56:07 +03:00

MDEV-11172: EXPLAIN shows non-sensical value for key_len with type=index

The issue happens when the secondary keys are extended with primary
key parts. Inside the function TABLE_SHARE::init_from_binary_frm_image()
adds the length bytes for the primary key key parts to the length of the
secondary key. This is not needed because when the extended keys are
used we recalculate the length for the used key parts.

Also removed TABLE_SHARE::total_key_length as it is not used in the code

Apporved-by: Monty <monty@mariadb.org>
This commit is contained in:
Varun Gupta
2021-01-29 00:27:19 +05:30
parent 0921656734
commit b87c342da5
5 changed files with 45 additions and 4 deletions

View File

@@ -790,3 +790,19 @@ EXPLAIN
}
drop table t1;
SET optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
#
# MDEV-11172: EXPLAIN shows non-sensical value for key_len with type=index
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t2 (
pk VARCHAR(50),
a VARCHAR(20),
KEY k1(a),
PRIMARY KEY(pk)
)ENGINE=INNODB;
INSERT INTO t2 SELECT a,a FROM t1;
EXPLAIN SELECT pk FROM t2 FORCE INDEX(k1);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL k1 23 NULL 10 Using index
DROP TABLE t1,t2;