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

Fix bug #11718 query with function, join and order by returns wrong type.

create_tmp_field_from_item() was creating tmp field without regard to
original field type of Item. This results in wrong type being reported to
client.

To create_tmp_field_from_item() added special handling for Items with 
DATE/TIME field types to preserve their type.


sql/sql_select.cc:
  Fix bug #11718 query with function, join and order by returns wrong type.
tests/mysql_client_test.c:
  Test case for bug #11718: query with function, join and order by returns wrong type
This commit is contained in:
unknown
2005-08-17 23:53:12 +04:00
parent 99cf8c38e0
commit e80aa01087
2 changed files with 44 additions and 1 deletions

View File

@ -4899,7 +4899,15 @@ 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)
enum enum_field_types type;
/*
DATE/TIME fields have STRING_RESULT result type. To preserve
type they needed to be handled separately.
*/
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)
{
if (convert_blob_length)
new_field= new Field_varstring(convert_blob_length, maybe_null,