Bug#25431, Adding index to table with BLOB is not done on-line

add a new method is_equal in class Field_blob to compare BLOB field when alter table
parent 9b41ce38
...@@ -6099,13 +6099,21 @@ uint Field::is_equal(create_field *new_field) ...@@ -6099,13 +6099,21 @@ uint Field::is_equal(create_field *new_field)
} }
uint Field_str::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)
{ {
if (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && return (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
!(flags & (BINCMP_FLAG | BINARY_FLAG))) || !(flags & (BINCMP_FLAG | BINARY_FLAG))) ||
(!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && (!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
(flags & (BINCMP_FLAG | BINARY_FLAG)))) (flags & (BINCMP_FLAG | BINARY_FLAG))));
return 0; /* One of the fields is binary and the other one isn't */ }
uint Field_str::is_equal(create_field *new_field)
{
if (compare_str_field_flags(new_field, flags))
return 0;
return ((new_field->sql_type == real_type()) && return ((new_field->sql_type == real_type()) &&
new_field->charset == field_charset && new_field->charset == field_charset &&
...@@ -7611,6 +7619,18 @@ uint Field_blob::max_packed_col_length(uint max_length) ...@@ -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 #ifdef HAVE_SPATIAL
void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg) void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg)
......
...@@ -476,6 +476,7 @@ public: ...@@ -476,6 +476,7 @@ public:
friend class create_field; friend class create_field;
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
virtual bool str_needs_quotes() { return TRUE; } 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); uint is_equal(create_field *new_field);
}; };
...@@ -1328,6 +1329,7 @@ public: ...@@ -1328,6 +1329,7 @@ public:
bool has_charset(void) const bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; } { return charset() == &my_charset_bin ? FALSE : TRUE; }
uint32 max_display_length(); uint32 max_display_length();
uint is_equal(create_field *new_field);
}; };
......
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