diff options
author | Kristofer.Pettersson@naruto. <> | 2006-10-02 12:37:01 +0200 |
---|---|---|
committer | Kristofer.Pettersson@naruto. <> | 2006-10-02 12:37:01 +0200 |
commit | 887f3b9d420ba6e2bb38bd5ddefc9e7d125a9810 (patch) | |
tree | 8955a3f30d196b0cff68e0960fc8cacce24207cd /sql/item_timefunc.h | |
parent | 5a912955d53ffd18c18cc0d0552c53955f6eabf0 (diff) | |
download | mariadb-git-887f3b9d420ba6e2bb38bd5ddefc9e7d125a9810.tar.gz |
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.
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r-- | sql/item_timefunc.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index d5d3efeeab4..e79c62e6ffb 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -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 |