summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorunknown <evgen@sunlight.local>2007-09-22 11:49:27 +0400
committerunknown <evgen@sunlight.local>2007-09-22 11:49:27 +0400
commitebaa05efa757c475161cb5c7f0a1adcbe9f59ff3 (patch)
tree354465c5c2b1cc824b9633a001e2a7af0fd7657e /sql/item_timefunc.cc
parentffdc5b93025c487297635848d9f791822fdf09b5 (diff)
downloadmariadb-git-ebaa05efa757c475161cb5c7f0a1adcbe9f59ff3.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. libmysql/libmysql.c: Bug#27216: functions with parameters of different date types may return wrong type of the result. The client library now accepts the NEWDATE type as a string. sql/item_cmpfunc.cc: Bug#27216: functions with parameters of different date types may return wrong type of the result. Now the fix_length_and_dec functions of the Item_func_ifnull,Item_func_if, Item_func_case, Item_func_coalesce classes are use agg_field_type function to find out the type of their result field. sql/item_cmpfunc.h: Bug#27216: functions with parameters of different date types may return wrong type of the result. The cached_field type is added to the Item_func_case, Item_func_if and Item_func_coalesce classes. The field_type function is added to the Item_func_ifnull, Item_func_if, Item_func_coalesce, Item_func_case classes. sql/item_func.cc: Bug#27216: functions with parameters of different date types may return wrong type of the result. The Item_func_min_max::fix_length_and_dec function now uses the agg_field_type function to find out the correct type of the result field. sql/item_func.h: Bug#27216: functions with parameters of different date types may return wrong type of the result. The cached_field_type variable is added to the Item_func_min_max class. sql/item_timefunc.cc: Bug#27216: functions with parameters of different date types may return wrong type of the result. The result of the str_to_date function now defaults to the DATETIME type. sql/mysql_priv.h: Bug#27216: functions with parameters of different date types may return wrong type of the result. The prototype of the agg_field_type function is added. sql/protocol.cc: Bug#27216: functions with parameters of different date types may return wrong type of the result. The Protocol_simple::store function is now used to store fields of NEWDATE type. sql/sql_insert.cc: Bug#27216: functions with parameters of different date types may return wrong type of the result. The create_table_from_items function now uses the tmp_table_field_from_field_type function to get field for items with the STRING result type. mysql-test/r/date_formats.result: A test case result corrected after fixing bug#27216. mysql-test/r/type_datetime.result: Added a test case for the bug#27216: functions with parameters of different date types may return wrong type of the result. mysql-test/t/type_datetime.test: Added a test case for the bug#27216: functions with parameters of different date types may return wrong type of the result.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index ae18e4786d7..b7c9086c127 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -3310,7 +3310,7 @@ void Item_func_str_to_date::fix_length_and_dec()
String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format;
maybe_null= 1;
decimals=0;
- cached_field_type= MYSQL_TYPE_STRING;
+ cached_field_type= MYSQL_TYPE_DATETIME;
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
format= args[1]->val_str(&format_str);