1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-15563: Allow instant VARCHAR extension from <128 bytes

For up to 127 bytes length, InnoDB would use 1 byte for length, and
that byte would always be less than 128. If the maximum length is
longer than 255 bytes, InnoDB would use a variable-length encoding
for the length, using 1 byte for lengths up to 127 bytes, and
2 bytes for longer lengths.

Thus, 1-byte lengths are always compatible when the maximum size
changes from less than 128 bytes to anything longer.

Field_varstring::is_equal(): Return IS_EQUAL_PACK_LENGTH also when
converting from VARCHAR less than 128 bytes to any longer VARCHAR.
This commit is contained in:
Marko Mäkelä
2019-02-13 15:46:52 +02:00
parent 8ef4105a89
commit ad17875c0d
3 changed files with 37 additions and 4 deletions

View File

@ -7901,17 +7901,21 @@ Field *Field_varstring::new_key_field(MEM_ROOT *root, TABLE *new_table,
uint Field_varstring::is_equal(Create_field *new_field)
{
if (new_field->length < field_length)
return IS_EQUAL_NO;
if (new_field->type_handler() == type_handler() &&
new_field->charset == field_charset &&
!new_field->compression_method() == !compression_method())
{
if (new_field->length == field_length)
return IS_EQUAL_YES;
if (new_field->length > field_length &&
((new_field->length <= 255 && field_length <= 255) ||
(new_field->length > 255 && field_length > 255)))
return IS_EQUAL_PACK_LENGTH; // VARCHAR, longer variable length
if (field_length <= 127 ||
new_field->length <= 255 ||
field_length > 255)
return IS_EQUAL_PACK_LENGTH; // VARCHAR, longer length
}
return IS_EQUAL_NO;
}