summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorunknown <Kristofer.Pettersson@naruto.>2006-10-02 12:37:01 +0200
committerunknown <Kristofer.Pettersson@naruto.>2006-10-02 12:37:01 +0200
commit5e71afcbe79091f9113e66e161cb15c3c35f3f67 (patch)
tree8955a3f30d196b0cff68e0960fc8cacce24207cd /sql/item_timefunc.h
parenta4b1695376eeb3707fd1f42dc231067209faa58b (diff)
downloadmariadb-git-5e71afcbe79091f9113e66e161cb15c3c35f3f67.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. 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.
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h19
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