1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
unknown
2005-06-09 19:29:55 -07:00
7 changed files with 126 additions and 6 deletions

View File

@ -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,