From 5466618420b2710e11f2f61482696d22e64313c5 Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Mon, 14 Dec 2009 17:17:41 +0300 Subject: [PATCH] Post-merge fix. --- sql/item.cc | 21 +++++++++++---------- sql/item.h | 2 +- sql/item_sum.cc | 3 ++- sql/item_timefunc.cc | 7 +------ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index f6ce117a41f..f4b2e549667 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7275,16 +7275,17 @@ longlong Item_cache_int::val_int() return value; } -void Item_cache_datetime::cache_value_int() +bool Item_cache_datetime::cache_value_int() { if (!example) - return; + return FALSE; value_cached= TRUE; /* Assume here that the underlying item will do correct conversion.*/ int_value= example->val_int_result(); null_value= example->null_value; unsigned_flag= example->unsigned_flag; + return TRUE; } @@ -7316,8 +7317,8 @@ void Item_cache_datetime::store(Item *item, longlong val_arg) String *Item_cache_datetime::val_str(String *str) { DBUG_ASSERT(fixed == 1); - if (!str_value_cached) - cache_value(); + if (!str_value_cached && !cache_value()) + return NULL; return &str_value; } @@ -7325,8 +7326,8 @@ String *Item_cache_datetime::val_str(String *str) my_decimal *Item_cache_datetime::val_decimal(my_decimal *decimal_val) { DBUG_ASSERT(fixed == 1); - if (!value_cached) - cache_value_int(); + if (!value_cached && !cache_value_int()) + return NULL; int2my_decimal(E_DEC_FATAL_ERROR, int_value, unsigned_flag, decimal_val); return decimal_val; } @@ -7334,16 +7335,16 @@ my_decimal *Item_cache_datetime::val_decimal(my_decimal *decimal_val) double Item_cache_datetime::val_real() { DBUG_ASSERT(fixed == 1); - if (!value_cached) - cache_value_int(); + if (!value_cached && !cache_value_int()) + return 0.0; return (double) int_value; } longlong Item_cache_datetime::val_int() { DBUG_ASSERT(fixed == 1); - if (!value_cached) - cache_value_int(); + if (!value_cached && !cache_value_int()) + return 0; return int_value; } diff --git a/sql/item.h b/sql/item.h index 699cc8db35a..c6ef5bd349a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3177,7 +3177,7 @@ public: completely relies on the ability of the underlying item to do the correct conversion. */ - void cache_value_int(); + bool cache_value_int(); bool cache_value(); }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index d925c68e66c..831f0287266 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1207,7 +1207,8 @@ void Item_sum_hybrid::setup(Item *item, Item *value_arg) { value= Item_cache::get_cache(item); value->setup(item); - value->store(value_arg); + if (value_arg) + value->store(value_arg); cmp= new Arg_comparator(); cmp->set_cmp_func(this, args, (Item**)&value, FALSE); collation.set(item->collation); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index e4644aa6436..56c46efb1a8 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -876,12 +876,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, const char *start= str; for (value=0; str != end && my_isdigit(cs,*str) ; str++) value= value*LL(10) + (longlong) (*str - '0'); - if (transform_msec && i == count - 1) // microseconds always last - { - int msec_length= 6 - (str - start); - if (msec_length > 0) - value*= (long)log_10_int[msec_length]; - } + msec_length= 6 - (str - start); values[i]= value; while (str != end && !my_isdigit(cs,*str)) str++;