Commit e8cc98c8 authored by unknown's avatar unknown
Browse files

Bug#21811 Odd casting with date + INTERVAL arithmetic

- The definition of the result type of a type_date function didn't
  include INTERVAL_WEEK
- This patch adds an explicit test for INTERVAL_WEEK which results 
  in the result type for an item_date_add_intervall operation 
  being DATE rather than DATETIME when one parameter is
  INTERVAL_WEEK.


sql/item_timefunc.cc:
  Added explicit test for INTERVAL_WEEK to evaluate as MYSQL_TYPE_DATE
parent 49342315
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1876,7 +1876,7 @@ void Item_date_add_interval::fix_length_and_dec()
    cached_field_type= MYSQL_TYPE_DATETIME;
  else if (arg0_field_type == MYSQL_TYPE_DATE)
  {
    if (int_type <= INTERVAL_DAY || int_type == INTERVAL_YEAR_MONTH)
    if (int_type <= INTERVAL_DAY || int_type == INTERVAL_YEAR_MONTH || int_type == INTERVAL_WEEK )
      cached_field_type= arg0_field_type;
    else
      cached_field_type= MYSQL_TYPE_DATETIME;