mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -612,7 +612,7 @@ date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
|
||||
2003-01-03 01:01:01
|
||||
select date_add(date,INTERVAL "1" WEEK) from t1;
|
||||
date_add(date,INTERVAL "1" WEEK)
|
||||
2003-01-09 00:00:00
|
||||
2003-01-09
|
||||
select date_add(date,INTERVAL "1" QUARTER) from t1;
|
||||
date_add(date,INTERVAL "1" QUARTER)
|
||||
2003-04-02
|
||||
@ -621,7 +621,7 @@ timestampadd(MINUTE, 1, date)
|
||||
2003-01-02 00:01:00
|
||||
select timestampadd(WEEK, 1, date) from t1;
|
||||
timestampadd(WEEK, 1, date)
|
||||
2003-01-09 00:00:00
|
||||
2003-01-09
|
||||
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
|
||||
timestampadd(SQL_TSI_SECOND, 1, date)
|
||||
2003-01-02 00:00:01
|
||||
|
Reference in New Issue
Block a user