diff options
author | evgen@moonbone.local <> | 2005-08-17 23:53:12 +0400 |
---|---|---|
committer | evgen@moonbone.local <> | 2005-08-17 23:53:12 +0400 |
commit | 6d8bd17c3a8d11ad5404c4d80723fc0cb8a8496b (patch) | |
tree | a88613ed7af96f0e01281160b240e5116d565b2e /sql/sql_select.cc | |
parent | 1664e31f12d443fa73d11a23950977e047e381d9 (diff) | |
download | mariadb-git-6d8bd17c3a8d11ad5404c4d80723fc0cb8a8496b.tar.gz |
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.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9984cb4138f..73cfe153b9b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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, |