diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-10-28 18:22:36 +0100 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-10-28 18:22:36 +0100 |
commit | 072c13d9395b6a3f3a472633d6e817db9215d81e (patch) | |
tree | 0891f6df26609fa66b89a4cc8faa8079ec21f6f3 /sql/item_timefunc.cc | |
parent | cd6e15989044e5d4a708a6ee191bcd3c13dc0071 (diff) | |
parent | 10fed1aca0096acb135c2065233e84d61b00b9cf (diff) | |
download | mariadb-git-072c13d9395b6a3f3a472633d6e817db9215d81e.tar.gz |
Merged WL#3352 into mysql-next-mr
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index eefc8429f5e..84ddc88487d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -936,6 +936,48 @@ longlong Item_func_to_days::val_int() } +longlong Item_func_to_seconds::val_int_endpoint(bool left_endp, + bool *incl_endp) +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + longlong seconds; + longlong days; + int dummy; /* unused */ + if (get_arg0_date(<ime, TIME_FUZZY_DATE)) + { + /* got NULL, leave the incl_endp intact */ + return LONGLONG_MIN; + } + seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second; + seconds= ltime.neg ? -seconds : seconds; + days= (longlong) calc_daynr(ltime.year, ltime.month, ltime.day); + seconds+= days * 24L * 3600L; + /* Set to NULL if invalid date, but keep the value */ + null_value= check_date(<ime, + (ltime.year || ltime.month || ltime.day), + (TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE), + &dummy); + /* + Even if the evaluation return NULL, seconds is useful for pruning + */ + return seconds; +} + +longlong Item_func_to_seconds::val_int() +{ + DBUG_ASSERT(fixed == 1); + MYSQL_TIME ltime; + longlong seconds; + longlong days; + if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) + return 0; + seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second; + seconds=ltime.neg ? -seconds : seconds; + days= (longlong) calc_daynr(ltime.year, ltime.month, ltime.day); + return seconds + days * 24L * 3600L; +} + /* Get information about this Item tree monotonicity @@ -962,6 +1004,17 @@ enum_monotonicity_info Item_func_to_days::get_monotonicity_info() const return NON_MONOTONIC; } +enum_monotonicity_info Item_func_to_seconds::get_monotonicity_info() const +{ + if (args[0]->type() == Item::FIELD_ITEM) + { + if (args[0]->field_type() == MYSQL_TYPE_DATE || + args[0]->field_type() == MYSQL_TYPE_DATETIME) + return MONOTONIC_STRICT_INCREASING_NOT_NULL; + } + return NON_MONOTONIC; +} + longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp) { |