mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-19524 Server crashes in Bitmap<64u>::is_clear_all / Field_longstr::csinfo_change_allows_instant_alter
compare_keys_but_name(): reorder checks to ensure that new_field->field != NULL inside Field::is_equal()
This commit is contained in:
committed by
Alexander Barkov
parent
dafe41edea
commit
fae1319450
@ -6540,8 +6540,16 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
|
||||
*new_part= new_key->key_part;
|
||||
key_part < end; key_part++, new_part++)
|
||||
{
|
||||
/*
|
||||
For prefix keys KEY_PART_INFO::field points to cloned Field
|
||||
object with adjusted length. So below we have to check field
|
||||
indexes instead of simply comparing pointers to Field objects.
|
||||
*/
|
||||
Create_field *new_field= alter_info->create_list.elem(new_part->fieldnr);
|
||||
const Field *old_field= table->field[key_part->fieldnr - 1];
|
||||
if (!new_field->field ||
|
||||
new_field->field->field_index != key_part->fieldnr - 1)
|
||||
return Compare_keys::NotEqual;
|
||||
|
||||
/*
|
||||
If there is a change in index length due to column expansion
|
||||
like varchar(X) changed to varchar(X + N) and has a compatible
|
||||
@ -6551,6 +6559,7 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
|
||||
Key definition has changed if we are using a different field or
|
||||
if the user key part length is different.
|
||||
*/
|
||||
const Field *old_field= table->field[key_part->fieldnr - 1];
|
||||
auto old_field_len= old_field->pack_length();
|
||||
|
||||
if (old_field->type() == MYSQL_TYPE_VARCHAR)
|
||||
@ -6568,15 +6577,6 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
|
||||
}
|
||||
else if (key_part->length != new_part->length)
|
||||
return Compare_keys::NotEqual;
|
||||
|
||||
/*
|
||||
For prefix keys KEY_PART_INFO::field points to cloned Field
|
||||
object with adjusted length. So below we have to check field
|
||||
indexes instead of simply comparing pointers to Field objects.
|
||||
*/
|
||||
if (!new_field->field ||
|
||||
new_field->field->field_index != key_part->fieldnr - 1)
|
||||
return Compare_keys::NotEqual;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user