diff --git a/sql/field.cc b/sql/field.cc index 82f8283ba56..0225e24b195 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6099,13 +6099,21 @@ uint Field::is_equal(create_field *new_field) } +/* If one of the fields is binary and the other one isn't return 1 else 0 */ + +bool Field_str::compare_str_field_flags(create_field *new_field, uint32 flags) +{ + return (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && + !(flags & (BINCMP_FLAG | BINARY_FLAG))) || + (!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && + (flags & (BINCMP_FLAG | BINARY_FLAG)))); +} + + uint Field_str::is_equal(create_field *new_field) { - if (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && - !(flags & (BINCMP_FLAG | BINARY_FLAG))) || - (!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && - (flags & (BINCMP_FLAG | BINARY_FLAG)))) - return 0; /* One of the fields is binary and the other one isn't */ + if (compare_str_field_flags(new_field, flags)) + return 0; return ((new_field->sql_type == real_type()) && new_field->charset == field_charset && @@ -7611,6 +7619,18 @@ uint Field_blob::max_packed_col_length(uint max_length) } +uint Field_blob::is_equal(create_field *new_field) +{ + if (compare_str_field_flags(new_field, flags)) + return 0; + + return ((new_field->sql_type == get_blob_type_from_length(max_data_length())) + && new_field->charset == field_charset && + ((Field_blob *)new_field->field)->max_data_length() == + max_data_length()); +} + + #ifdef HAVE_SPATIAL void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg) diff --git a/sql/field.h b/sql/field.h index 441ff9079c1..8df52abffd4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -476,6 +476,7 @@ public: friend class create_field; my_decimal *val_decimal(my_decimal *); virtual bool str_needs_quotes() { return TRUE; } + bool compare_str_field_flags(create_field *new_field, uint32 flags); uint is_equal(create_field *new_field); }; @@ -1328,6 +1329,7 @@ public: bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } uint32 max_display_length(); + uint is_equal(create_field *new_field); };