BUG#21811 Odd casting with date + INTERVAL arithmetic

- Type casting was not consequent, thus when adding a DATE type with
  a WEEK interval the result tpe was DATETIME and not DATE as is the
  norm.
- By changing the order of the date type enumerations the type casting
  bug is resolved. To comply with the new order the array 
  interval_type_to_name needed to change accordingly.
parent 2f2392c6
......@@ -92,15 +92,25 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to);
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
/*
The following must be sorted so that simple intervals comes first.
(get_interval_value() depends on this)
/*
Available interval types used in any statement.
'interval_type' must be sorted so that simple intervals comes first,
ie year, quarter, month, week, day, hour, etc. The order based on
interval size is also important and the intervals should be kept in a
large to smaller order. (get_interval_value() depends on this)
Note: If you change the order of elements in this enum you should fix
order of elements in 'interval_type_to_name' and 'interval_names'
arrays
See also interval_type_to_name, get_interval_value, interval_names
*/
enum interval_type
{
INTERVAL_YEAR, INTERVAL_QUARTER, INTERVAL_MONTH, INTERVAL_DAY, INTERVAL_HOUR,
INTERVAL_MINUTE, INTERVAL_WEEK, INTERVAL_SECOND, INTERVAL_MICROSECOND ,
INTERVAL_YEAR, INTERVAL_QUARTER, INTERVAL_MONTH, INTERVAL_WEEK, INTERVAL_DAY,
INTERVAL_HOUR, INTERVAL_MINUTE, INTERVAL_SECOND, INTERVAL_MICROSECOND,
INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR, INTERVAL_DAY_MINUTE,
INTERVAL_DAY_SECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND,
INTERVAL_MINUTE_SECOND, INTERVAL_DAY_MICROSECOND, INTERVAL_HOUR_MICROSECOND,
......
......@@ -25,14 +25,25 @@
#ifndef TESTTIME
/*
Name description of interval names used in statements.
'interval_type_to_name' is ordered and sorted on interval size and
interval complexity.
Order of elements in 'interval_type_to_name' should correspond to
the order of elements in 'interval_type' enum
See also interval_type, interval_names
*/
LEX_STRING interval_type_to_name[INTERVAL_LAST] = {
{ C_STRING_WITH_LEN("YEAR")},
{ C_STRING_WITH_LEN("QUARTER")},
{ C_STRING_WITH_LEN("MONTH")},
{ C_STRING_WITH_LEN("WEEK")},
{ C_STRING_WITH_LEN("DAY")},
{ C_STRING_WITH_LEN("HOUR")},
{ C_STRING_WITH_LEN("MINUTE")},
{ C_STRING_WITH_LEN("WEEK")},
{ C_STRING_WITH_LEN("SECOND")},
{ C_STRING_WITH_LEN("MICROSECOND")},
{ C_STRING_WITH_LEN("YEAR_MONTH")},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment