diff options
author | unknown <jimw@mysql.com> | 2005-06-09 19:29:55 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-06-09 19:29:55 -0700 |
commit | 5b81b2dc87261d55b8f18bc89c24a426c35c5603 (patch) | |
tree | 7b9f0710e776850ddf034f4f8038ccf75689465e /sql/sql_table.cc | |
parent | a3fe14096397ddd8ce7095aad9361c25090569ca (diff) | |
parent | dd8e174fa6a07ebf21a3b0a03883d2be694b827b (diff) | |
download | mariadb-git-5b81b2dc87261d55b8f18bc89c24a426c35c5603.tar.gz |
Merge mysql.com:/home/jimw/my/mysql-5.0-10543
into mysql.com:/home/jimw/my/mysql-5.0-clean
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/sql_table.cc:
Auto merged
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2cf9386d0e4..8a29c481dc1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3398,12 +3398,25 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, continue; // Field is removed uint key_part_length=key_part->length; if (cfield->field) // Not new field - { // Check if sub key - if (cfield->field->type() != FIELD_TYPE_BLOB && - (cfield->field->pack_length() == key_part_length || - cfield->length <= key_part_length / - key_part->field->charset()->mbmaxlen)) - key_part_length=0; // Use whole field + { + /* + If the field can't have only a part used in a key according to its + new type, or should not be used partially according to its + previous type, or the field length is less than the key part + length, unset the key part length. + + We also unset the key part length if it is the same as the + old field's length, so the whole new field will be used. + + BLOBs may have cfield->length == 0, which is why we test it before + checking whether cfield->length < key_part_length (in chars). + */ + if (!Field::type_can_have_key_part(cfield->field->type()) || + !Field::type_can_have_key_part(cfield->sql_type) || + cfield->field->field_length == key_part_length || + (cfield->length && (cfield->length < key_part_length / + key_part->field->charset()->mbmaxlen))) + key_part_length= 0; // Use whole field } key_part_length /= key_part->field->charset()->mbmaxlen; key_parts.push_back(new key_part_spec(cfield->field_name, |