summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorevgen@sunlight.local <>2007-09-22 11:49:27 +0400
committerevgen@sunlight.local <>2007-09-22 11:49:27 +0400
commit36bf417b40c553f1704528022858293b71942d76 (patch)
tree354465c5c2b1cc824b9633a001e2a7af0fd7657e /sql/item_func.h
parent56c927e69622f24ddd04b9fcd76c4f02a3bb7674 (diff)
downloadmariadb-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/item_func.h')
-rw-r--r--sql/item_func.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 56b5e75652c..57e33daf0c4 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -692,7 +692,8 @@ class Item_func_min_max :public Item_func
/* An item used for issuing warnings while string to DATETIME conversion. */
Item *datetime_item;
THD *thd;
-
+protected:
+ enum_field_types cached_field_type;
public:
Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE),
@@ -705,6 +706,7 @@ public:
enum Item_result result_type () const { return cmp_type; }
bool result_as_longlong() { return compare_as_dates; };
uint cmp_datetimes(ulonglong *value);
+ enum_field_types field_type() const { return cached_field_type; }
};
class Item_func_min :public Item_func_min_max