From c2b38529a9ca2ea09dfa73186d9350a0d6dcd6ac Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Sep 2013 15:32:25 +0400 Subject: MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context --- sql/item_timefunc.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sql/item_timefunc.h') diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index b17e1c794ee..b0245e6f743 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -372,9 +372,11 @@ public: max_length=17 + (decimals ? decimals + 1 : 0); set_persist_maybe_null(1); } - void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; } + void find_num_type() + { cached_result_type= decimals ? DECIMAL_RESULT : INT_RESULT; } double real_op() { DBUG_ASSERT(0); return 0; } String *str_op(String *str) { DBUG_ASSERT(0); return 0; } + bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; } }; @@ -451,12 +453,8 @@ public: { return save_date_in_field(field); } void fix_length_and_dec() { - static const uint max_time_type_width[5]= - { MAX_DATETIME_WIDTH, MAX_DATETIME_WIDTH, MAX_DATE_WIDTH, - MAX_DATETIME_WIDTH, MIN_TIME_WIDTH }; - set_persist_maybe_null(1); - max_length= max_time_type_width[mysql_type_to_time_type(field_type())+2]; + max_length= mysql_temporal_int_part_length(field_type()); if (decimals) { if (decimals == NOT_FIXED_DEC) -- cgit v1.2.1