From 3ef5596505bd8d80fa80d1cf7514550434eb1d79 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Jul 2017 15:52:06 +0200 Subject: MDEV-13175 Adding a new enum value at the end of a list triggers a table rebuild Backport of 7e29f2d64fb from 10.1. Create_field does not set BINARY_FLAG, so the check didn't work at all. Also, character sets were already compared, so this check would've been redundant (if it would've worked). --- sql/field.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 7d7fad2d84d..7a44bcadd3c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6403,9 +6403,6 @@ uint Field::is_equal(Create_field *new_field) uint Field_str::is_equal(Create_field *new_field) { - if (field_flags_are_binary() != new_field->field_flags_are_binary()) - return 0; - return ((new_field->sql_type == real_type()) && new_field->charset == field_charset && new_field->length == max_display_length()); @@ -7810,9 +7807,6 @@ uint Field_blob::max_packed_col_length(uint max_length) uint Field_blob::is_equal(Create_field *new_field) { - if (field_flags_are_binary() != new_field->field_flags_are_binary()) - return 0; - return ((new_field->sql_type == get_blob_type_from_length(max_data_length())) && new_field->charset == field_charset && new_field->pack_length == pack_length()); @@ -7933,6 +7927,18 @@ Field::geometry_type Field_geom::geometry_type_merge(geometry_type a, return Field::GEOM_GEOMETRY; } + +uint Field_geom::is_equal(Create_field *new_field) +{ + return new_field->sql_type == MYSQL_TYPE_GEOMETRY && + /* + - Allow ALTER..INPLACE to supertype (GEOMETRY), + e.g. POINT to GEOMETRY or POLYGON to GEOMETRY. + - Allow ALTER..INPLACE to the same geometry type: POINT -> POINT + */ + (new_field->geom_type == geom_type || + new_field->geom_type == GEOM_GEOMETRY); +} #endif /*HAVE_SPATIAL*/ /**************************************************************************** @@ -8336,8 +8342,7 @@ uint Field_enum::is_equal(Create_field *new_field) The fields are compatible if they have the same flags, type, charset and have the same underlying length. */ - if (new_field->field_flags_are_binary() != field_flags_are_binary() || - new_field->sql_type != real_type() || + if (new_field->sql_type != real_type() || new_field->charset != field_charset || new_field->pack_length != pack_length()) return IS_EQUAL_NO; -- cgit v1.2.1