diff options
author | jani@a193-229-222-105.elisa-laajakaista.fi <> | 2005-07-22 23:43:59 +0300 |
---|---|---|
committer | jani@a193-229-222-105.elisa-laajakaista.fi <> | 2005-07-22 23:43:59 +0300 |
commit | 2657e48c64e62580e479f01ceda5f1b6a9fde4c3 (patch) | |
tree | 02552074434f0ff47a06118e8d54f309fe6a2cad /sql/field.cc | |
parent | 5eab6ddcd6d88c97dbe7d9b4123551e3cd8e74b4 (diff) | |
download | mariadb-git-2657e48c64e62580e479f01ceda5f1b6a9fde4c3.tar.gz |
Faster alter table code for 5.1.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index 73eb267ce89..6c109e933f2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -65,6 +65,7 @@ inline int field_type2index (enum_field_types field_type) ((int)FIELDTYPE_TEAR_FROM) + (field_type - FIELDTYPE_TEAR_TO) - 1); } + static enum_field_types field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM]= { /* MYSQL_TYPE_DECIMAL -> */ @@ -5920,6 +5921,26 @@ int Field_str::store(double nr) } +uint Field::is_equal(create_field *new_field) +{ + return (new_field->sql_type == type()); +} + + +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 */ + + return ((new_field->sql_type == type()) && + new_field->charset == field_charset && + new_field->length == max_length()); +} + + int Field_string::store(longlong nr) { char buff[64]; @@ -6676,6 +6697,22 @@ Field *Field_varstring::new_key_field(MEM_ROOT *root, } +uint Field_varstring::is_equal(create_field *new_field) +{ + if (new_field->sql_type == type() && + new_field->charset == field_charset) + { + if (new_field->length == max_length()) + return IS_EQUAL_YES; + if (new_field->length > max_length() && + ((new_field->length <= 255 && max_length() <= 255) || + (new_field->length > 255 && max_length() > 255))) + return IS_EQUAL_PACK_LENGTH; // VARCHAR, longer variable length + } + return IS_EQUAL_NO; +} + + /**************************************************************************** ** blob type ** A blob is saved as a length and a pointer. The length is stored in the @@ -7777,6 +7814,17 @@ bool Field_num::eq_def(Field *field) } +uint Field_num::is_equal(create_field *new_field) +{ + return ((new_field->sql_type == type()) && + ((new_field->flags & UNSIGNED_FLAG) == (uint) (flags & + UNSIGNED_FLAG)) && + ((new_field->flags & AUTO_INCREMENT_FLAG) == + (uint) (flags & AUTO_INCREMENT_FLAG)) && + (new_field->length >= max_length())); +} + + /* Bit field. |