diff options
author | evgen@sunlight.local <> | 2007-09-22 11:49:27 +0400 |
---|---|---|
committer | evgen@sunlight.local <> | 2007-09-22 11:49:27 +0400 |
commit | 36bf417b40c553f1704528022858293b71942d76 (patch) | |
tree | 354465c5c2b1cc824b9633a001e2a7af0fd7657e /sql/sql_insert.cc | |
parent | 56c927e69622f24ddd04b9fcd76c4f02a3bb7674 (diff) | |
download | mariadb-git-36bf417b40c553f1704528022858293b71942d76.tar.gz |
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
There are several functions that accept parameters of different types.
The result field type of such functions was determined based on
the aggregated result type of its arguments. As the DATE and the DATETIME
types are represented by the STRING type, the result field type
of the affected functions was always STRING for DATE/DATETIME arguments.
The affected functions are COALESCE, IF, IFNULL, CASE, LEAST/GREATEST, CASE.
Now the affected functions aggregate the field types of their arguments rather
than their result types and return the result of aggregation as their result
field type.
The cached_field_type member variable is added to the number of classes to
hold the aggregated result field type.
The str_to_date() function's result field type now defaults to the
MYSQL_TYPE_DATETIME.
The agg_field_type() function is added. It aggregates field types with help
of the Field::field_type_merge() function.
The create_table_from_items() function now uses the
item->tmp_table_field_from_field_type() function to get the proper field
when the item is a function with a STRING result type.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f07af393070..fc403132240 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3129,7 +3129,10 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, create_field *cr_field; Field *field, *def_field; if (item->type() == Item::FUNC_ITEM) - field= item->tmp_table_field(&tmp_table); + if (item->result_type() != STRING_RESULT) + field= item->tmp_table_field(&tmp_table); + else + field= item->tmp_table_field_from_field_type(&tmp_table); else field= create_tmp_field(thd, &tmp_table, item, item->type(), (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, |