diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/sql/item.cc b/sql/item.cc index 2d4f9138a51..7aaa678ddb0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2047,12 +2047,14 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) case MYSQL_TYPE_ENUM: case MYSQL_TYPE_SET: case MYSQL_TYPE_VAR_STRING: - if (max_length > 255) + DBUG_ASSERT(collation.collation); + if (max_length/collation.collation->mbmaxlen > 255) break; // If blob return new Field_varstring(max_length, maybe_null, name, table, collation.collation); case MYSQL_TYPE_STRING: - if (max_length > 255) // If blob + DBUG_ASSERT(collation.collation); + if (max_length/collation.collation->mbmaxlen > 255) // If blob break; return new Field_string(max_length, maybe_null, name, table, collation.collation); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b676cbb1fea..e7af2a1aa75 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4899,6 +4899,8 @@ static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, item->name, table, item->unsigned_flag); break; case STRING_RESULT: + DBUG_ASSERT(item->collation.collation); + enum enum_field_types type; /* DATE/TIME fields have STRING_RESULT result type. To preserve @@ -4907,7 +4909,7 @@ static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE) new_field= item->tmp_table_field_from_field_type(table); - else if (item->max_length > 255) + else if (item->max_length/item->collation.collation->mbmaxlen > 255) { if (convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, |