1
0
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:
unknown
2006-10-02 12:37:01 +02:00
parent a4b1695376
commit 5e71afcbe7
5 changed files with 47 additions and 13 deletions

View File

@@ -2151,11 +2151,15 @@ bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
(date_sub_interval == other->date_sub_interval));
}
/*
'interval_names' reflects the order of the enumeration interval_type.
See item_timefunc.h
*/
static const char *interval_names[]=
{
"year", "quarter", "month", "day", "hour",
"minute", "week", "second", "microsecond",
"year", "quarter", "month", "week", "day",
"hour", "minute", "second", "microsecond",
"year_month", "day_hour", "day_minute",
"day_second", "hour_minute", "hour_second",
"minute_second", "day_microsecond",