Commit 852e1383 authored by Marko Mäkelä's avatar Marko Mäkelä Committed by Daniel Black

MDEV-21245 InnoDB: Using a partial-field key prefix in search

ha_innobase::compare_key_parts(): If a full column index is
being replaced with a column prefix index, return Compare_keys::NotEqual.
parent b4712242
......@@ -90,3 +90,19 @@ worklog5743;
col_1_text = REPEAT("a", 3500) col_2_text = REPEAT("o", 3500)
1 1
DROP TABLE worklog5743;
#
# MDEV-21245 InnoDB: Using a partial-field key prefix in search
#
CREATE TABLE t1 (a VARCHAR(255), KEY k(a)) DEFAULT CHARSET=utf8mb3
ENGINE=InnoDB;
INSERT INTO t1 set a='';
alter table t1 change a a varchar(3000);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Note 1071 Specified key was too long; max key length is 3072 bytes
SELECT * FROM t1 WHERE a IN ('');
a
DROP TABLE t1;
# End of 10.4 tests
......@@ -93,3 +93,17 @@ SELECT col_1_text = REPEAT("a", 3500) , col_2_text = REPEAT("o", 3500) FROM
worklog5743;
DROP TABLE worklog5743;
--echo #
--echo # MDEV-21245 InnoDB: Using a partial-field key prefix in search
--echo #
CREATE TABLE t1 (a VARCHAR(255), KEY k(a)) DEFAULT CHARSET=utf8mb3
ENGINE=InnoDB;
INSERT INTO t1 set a='';
--enable_info
alter table t1 change a a varchar(3000);
--disable_info
SELECT * FROM t1 WHERE a IN ('');
DROP TABLE t1;
--echo # End of 10.4 tests
......@@ -21199,6 +21199,10 @@ Compare_keys ha_innobase::compare_key_parts(
if (old_part.length >= new_part.length)
return Compare_keys::NotEqual;
if (old_part.length == old_field.key_length() &&
new_part.length != new_field.key_length)
return Compare_keys::NotEqual;
return Compare_keys::EqualButKeyPartLength;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment