From 63e56390a3f1a4f80642932a790ab74f28de8010 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 10 Sep 2009 03:18:29 -0600 Subject: WL#2110 (SIGNAL) WL#2265 (RESIGNAL) Manual merge of SIGNAL and RESIGNAL to mysql-trunk-signal, plus required dependencies. --- sql/item_timefunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index d79b0b02998..fe938426863 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -602,7 +602,7 @@ err: { char buff[128]; strmake(buff, val_begin, min(length, sizeof(buff)-1)); - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE), date_time_type, buff, "str_to_date"); } -- cgit v1.2.1 From 6942c25e733967e4d3da8aaad3b2e9a2832dc33e Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Tue, 15 Sep 2009 17:07:52 +0200 Subject: WL#3352, Introducing Column list partitioning, makes it possible to partition on most data types, makes it possible to prune on multi-field partitioning --- sql/item_timefunc.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index d79b0b02998..bad9b85b2b6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -941,6 +941,27 @@ longlong Item_func_to_days::val_int() } +longlong Item_func_to_seconds::val_int_endpoint(bool left_endp, + bool *incl_endp) +{ + longlong res= val_int(); + return null_value ? LONGLONG_MIN : res; +} + +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 @@ -967,6 +988,18 @@ 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) + return MONOTONIC_STRICT_INCREASING; + if (args[0]->field_type() == MYSQL_TYPE_DATETIME) + return MONOTONIC_INCREASING; + } + return NON_MONOTONIC; +} + longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp) { -- cgit v1.2.1 From d8c3f2263f3deaadff957a0047460e8058cffccf Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 15 Oct 2009 17:23:43 +0500 Subject: WL#751 Error message construction, backport --- sql/item_timefunc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 6eb733f00d7..3bd35d55f6d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2502,10 +2502,11 @@ String *Item_char_typecast::val_str(String *str) str_value= *res; // Not malloced string res= &str_value; } + ErrConvString err(res); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), char_type, - res->c_ptr_safe()); + err.ptr()); res->length((uint) length); } else if (cast_cs == &my_charset_bin && res->length() < (uint) cast_length) -- cgit v1.2.1 From ec7c4fb442842b46029f28355ece7d0104ea63ac Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 19 Oct 2009 13:40:08 +0200 Subject: port of fixes for bug-20577 and 46362 for TO_SECONDS --- sql/item_timefunc.cc | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 29fab2a38a2..fd05737728e 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -944,8 +944,29 @@ longlong Item_func_to_days::val_int() longlong Item_func_to_seconds::val_int_endpoint(bool left_endp, bool *incl_endp) { - longlong res= val_int(); - return null_value ? LONGLONG_MIN : res; + 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() @@ -956,10 +977,10 @@ longlong Item_func_to_seconds::val_int() longlong days; if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) return 0; - seconds=ltime.hour*3600L+ltime.minute*60+ltime.second; + 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)); + days= (longlong) calc_daynr(ltime.year, ltime.month, ltime.day); + return seconds + days * 24L * 3600L; } /* @@ -992,10 +1013,9 @@ 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) - return MONOTONIC_STRICT_INCREASING; - if (args[0]->field_type() == MYSQL_TYPE_DATETIME) - return MONOTONIC_INCREASING; + if (args[0]->field_type() == MYSQL_TYPE_DATE || + args[0]->field_type() == MYSQL_TYPE_DATETIME) + return MONOTONIC_STRICT_INCREASING_NOT_NULL; } return NON_MONOTONIC; } -- cgit v1.2.1