diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-09-18 13:07:31 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-09-18 13:07:31 +0200 |
commit | 4ec2e9d7eda78d409d1b017ef4d8928fe9055438 (patch) | |
tree | 6c3a74a740d3c1c5f3a7d1f8154d8a791b435b3f /sql/item_timefunc.h | |
parent | 1a2a9d74fe1256554eceb09bbc6752a6376df87d (diff) | |
parent | 197bdbae4db78ba65f3668803bebd3c4a4509ae5 (diff) | |
download | mariadb-git-4ec2e9d7eda78d409d1b017ef4d8928fe9055438.tar.gz |
5.5 merge and fixes for compiler/test errors
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r-- | sql/item_timefunc.h | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 8bea068357b..9abcff2e1bd 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -30,19 +30,17 @@ enum date_time_format_types TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND }; -static inline enum enum_mysql_timestamp_type -mysql_type_to_time_type(enum enum_field_types mysql_type) + +static inline uint +mysql_temporal_int_part_length(enum enum_field_types mysql_type) { - switch(mysql_type) { - case MYSQL_TYPE_TIME: return MYSQL_TIMESTAMP_TIME; - case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_DATETIME: return MYSQL_TIMESTAMP_DATETIME; - case MYSQL_TYPE_NEWDATE: - case MYSQL_TYPE_DATE: return MYSQL_TIMESTAMP_DATE; - default: return MYSQL_TIMESTAMP_ERROR; - } + static uint max_time_type_width[5]= + { MAX_DATETIME_WIDTH, MAX_DATETIME_WIDTH, MAX_DATE_WIDTH, + MAX_DATETIME_WIDTH, MIN_TIME_WIDTH }; + return max_time_type_width[mysql_type_to_time_type(mysql_type)+2]; } + bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval); class Item_func_period_add :public Item_int_func @@ -410,26 +408,32 @@ class Item_func_dayname :public Item_func_weekday class Item_func_seconds_hybrid: public Item_func_numhybrid { +protected: + virtual enum_field_types arg0_expected_type() const = 0; public: Item_func_seconds_hybrid() :Item_func_numhybrid() {} Item_func_seconds_hybrid(Item *a) :Item_func_numhybrid(a) {} void fix_num_length_and_dec() { if (arg_count) - decimals= args[0]->decimals; + decimals= args[0]->temporal_precision(arg0_expected_type()); set_if_smaller(decimals, TIME_SECOND_PART_DIGITS); max_length=17 + (decimals ? decimals + 1 : 0); set_persist_maybe_null(1); } - void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; } + void find_num_type() + { cached_result_type= decimals ? DECIMAL_RESULT : INT_RESULT; } double real_op() { DBUG_ASSERT(0); return 0; } String *str_op(String *str) { DBUG_ASSERT(0); return 0; } + bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; } }; class Item_func_unix_timestamp :public Item_func_seconds_hybrid { bool get_timestamp_value(my_time_t *seconds, ulong *second_part); +protected: + enum_field_types arg0_expected_type() const { return MYSQL_TYPE_DATETIME; } public: Item_func_unix_timestamp() :Item_func_seconds_hybrid() {} Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {} @@ -461,6 +465,8 @@ public: class Item_func_time_to_sec :public Item_func_seconds_hybrid { +protected: + enum_field_types arg0_expected_type() const { return MYSQL_TYPE_TIME; } public: Item_func_time_to_sec(Item *item) :Item_func_seconds_hybrid(item) {} const char *func_name() const { return "time_to_sec"; } @@ -860,7 +866,7 @@ public: void fix_length_and_dec() { if (decimals == NOT_FIXED_DEC) - decimals= args[0]->decimals; + decimals= args[0]->temporal_precision(field_type()); Item_temporal_func::fix_length_and_dec(); } }; @@ -934,7 +940,8 @@ public: const char *func_name() const { return "timediff"; } void fix_length_and_dec() { - decimals= max(args[0]->decimals, args[1]->decimals); + decimals= max(args[0]->temporal_precision(MYSQL_TYPE_TIME), + args[1]->temporal_precision(MYSQL_TYPE_TIME)); Item_timefunc::fix_length_and_dec(); } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); @@ -946,6 +953,11 @@ public: Item_func_maketime(Item *a, Item *b, Item *c) :Item_timefunc(a, b, c) {} + void fix_length_and_dec() + { + decimals= min(args[2]->decimals, TIME_SECOND_PART_DIGITS); + Item_timefunc::fix_length_and_dec(); + } const char *func_name() const { return "maketime"; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); }; |