mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix bug #12537 UNION produces longtext instead of varchar
Item::tmp_table_field_from_field_type() and create_tmp_field_from_item() was converting string field to blob depending on byte-wise length instead of character length, which results in converting valid varchar string with length == 86 to longtext. Made that functions above take into account max width of character when converting string fields to blobs. sql/item.cc: Fix bug #12537 UNION produces longtext instead of varchar Item::tmp_table_field_from_field_type() now taking into account max char width when creating tmp field for string fields. sql/sql_select.cc: Fix bug #12537 UNION produces longtext instead of varchar create_tmp_field_from_item()now taking into account max char width when creating tmp field for string fields. mysql-test/r/create.result: Test case for bug #12537 UNION produces longtext instead of varchar mysql-test/t/create.test: Test case for bug #12537 UNION produces longtext instead of varchar
This commit is contained in:
@ -4899,7 +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:
|
||||
if (item->max_length > 255)
|
||||
DBUG_ASSERT(item->collation.collation);
|
||||
if (item->max_length/item->collation.collation->mbmaxlen > 255)
|
||||
{
|
||||
if (convert_blob_length)
|
||||
new_field= new Field_varstring(convert_blob_length, maybe_null,
|
||||
|
Reference in New Issue
Block a user