From 669786164e82a7ba332bab5e040139735abbb459 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Mar 2005 15:18:14 +0200 Subject: [PATCH] ha_innodb.cc: Fix bug: InnoDB created all indexes on true VARCHARs as column prefix keys because field->pack_length() for a true VARCHAR is bigger than key_part->length; FOREIGN KEYs could not be created on true VARCHARs then sql/ha_innodb.cc: Fix bug: InnoDB created all indexes on true VARCHARs as column prefix keys because field->pack_length() for a true VARCHAR is bigger than key_part->length; FOREIGN KEYs could not be created on true VARCHARs then --- sql/ha_innodb.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f33931c6645..870ad1af52b 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4037,7 +4037,11 @@ create_index( col_type = get_innobase_type_from_mysql_type(key_part->field); if (DATA_BLOB == col_type - || key_part->length < field->pack_length()) { + || (key_part->length < field->pack_length() + && field->type() != MYSQL_TYPE_VARCHAR) + || (field->type() == MYSQL_TYPE_VARCHAR + && key_part->length < field->pack_length() + - ((Field_varstring*)field)->length_bytes)) { prefix_len = key_part->length;