mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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 type was DATETIME and not DATE as is the norm. - By changing the order of the date internal enumerations the deviant type casting is resolved (Item_date_add_interval::fix_length_and_dec() which determines result type for this operation assumes that addition of any interval with value <= INTERVAL_DAY to date value will result in date). There are two independant places to change: interval_names[] and interval_type. mysql-test/r/func_date_add.result: Updated result file for type casting test mysql-test/r/func_time.result: Updated result file for type casting test mysql-test/t/func_date_add.test: Added test for type casting when adding intervals to date. sql/item_timefunc.cc: Changed order of "week" key word to match the date interval enumeration. sql/item_timefunc.h: Changed the order of the enumeration to better follow interval sizes.
This commit is contained in:
@@ -630,18 +630,21 @@ public:
|
||||
};
|
||||
|
||||
/*
|
||||
The following must be sorted so that simple intervals comes first.
|
||||
(get_interval_value() depends on this)
|
||||
'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)
|
||||
*/
|
||||
|
||||
enum interval_type
|
||||
{
|
||||
INTERVAL_YEAR, INTERVAL_QUARTER, INTERVAL_MONTH, INTERVAL_DAY, INTERVAL_HOUR,
|
||||
INTERVAL_MINUTE, INTERVAL_WEEK, 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,
|
||||
INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_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, INTERVAL_MINUTE_MICROSECOND,
|
||||
INTERVAL_SECOND_MICROSECOND
|
||||
};
|
||||
|
||||
class Item_date_add_interval :public Item_date_func
|
||||
|
Reference in New Issue
Block a user