Commit f6000782 authored by Sergei Golubchik's avatar Sergei Golubchik

mysql_prepare_create_table() inconsistency

sql_field->key_length was 0 for blob fields when a field was
being added, but Field_blob::character_octet_length() on
subsequent ALTER TABLE's (when the Field object in the old table
already existed). This means mysql_prepare_create_table() couldn't
reliably detect if the keyseg was a prefix.
parent d00f19e8
......@@ -4135,7 +4135,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
key_info->flags|= HA_PACK_KEY;
}
/* Check if the key segment is partial, set the key flag accordingly */
if (key_part_length != sql_field->key_length)
if (key_part_length != sql_field->key_length &&
key_part_length != sql_field->type_handler()->max_octet_length())
key_info->flags|= HA_KEY_HAS_PART_KEY_SEG;
key_length+= key_part_length;
......@@ -4482,7 +4483,7 @@ bool Column_definition::prepare_blob_field(THD *thd)
set_handler(Type_handler::blob_type_handler((uint) length));
pack_length= type_handler()->calc_pack_length(0);
}
length= 0;
length= key_length= 0;
}
DBUG_RETURN(0);
}
......
......@@ -3228,6 +3228,7 @@ class Type_handler
{
return false;
}
virtual uint max_octet_length() const { return 0; }
/**
Prepared statement long data:
Check whether this parameter data type is compatible with long data.
......@@ -5864,6 +5865,7 @@ class Type_handler_tiny_blob: public Type_handler_blob_common
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
uint max_octet_length() const { return UINT_MAX8; }
};
......@@ -5879,6 +5881,7 @@ class Type_handler_medium_blob: public Type_handler_blob_common
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
uint max_octet_length() const { return UINT_MAX24; }
};
......@@ -5896,6 +5899,7 @@ class Type_handler_long_blob: public Type_handler_blob_common
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
uint max_octet_length() const { return UINT_MAX32; }
};
......@@ -5911,6 +5915,7 @@ class Type_handler_blob: public Type_handler_blob_common
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
uint max_octet_length() const { return UINT_MAX16; }
};
......
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