summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-12-16 18:44:17 +0200
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-12-16 18:44:17 +0200
commit74e2520cd94200e326715a7733d2583a185bc6a7 (patch)
treea0d8f4957cf9d256a3cc3445c7db25384f97e249 /sql/item.cc
parent8b1571d80341770818404c9cc9ed4b362ffe5710 (diff)
parent33827e7dbfc177ef52718f63eaf87e005ab3e8b5 (diff)
downloadmariadb-git-74e2520cd94200e326715a7733d2583a185bc6a7.tar.gz
merge mysql-5.5->mysql-5.5-bugteam
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 5645a1bee1c..b1e453121bd 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -7503,9 +7503,19 @@ void Item_cache_datetime::store(Item *item, longlong val_arg)
}
+void Item_cache_datetime::store(Item *item)
+{
+ Item_cache::store(item);
+ str_value_cached= FALSE;
+}
+
String *Item_cache_datetime::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
+
+ if ((value_cached || str_value_cached) && null_value)
+ return NULL;
+
if (!str_value_cached)
{
/*
@@ -7519,6 +7529,8 @@ String *Item_cache_datetime::val_str(String *str)
if (value_cached)
{
MYSQL_TIME ltime;
+ /* Return NULL in case of OOM/conversion error. */
+ null_value= TRUE;
if (str_value.alloc(MAX_DATE_STRING_REP_LENGTH))
return NULL;
if (cached_field_type == MYSQL_TYPE_TIME)
@@ -7541,13 +7553,14 @@ String *Item_cache_datetime::val_str(String *str)
{
int was_cut;
longlong res;
- res= number_to_datetime(val_int(), &ltime, TIME_FUZZY_DATE, &was_cut);
+ res= number_to_datetime(int_value, &ltime, TIME_FUZZY_DATE, &was_cut);
if (res == -1)
return NULL;
}
str_value.length(my_TIME_to_str(&ltime,
const_cast<char*>(str_value.ptr())));
str_value_cached= TRUE;
+ null_value= FALSE;
}
else if (!cache_value())
return NULL;
@@ -7568,7 +7581,7 @@ 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()) || null_value)
return 0.0;
return (double) int_value;
}
@@ -7576,7 +7589,7 @@ double Item_cache_datetime::val_real()
longlong Item_cache_datetime::val_int()
{
DBUG_ASSERT(fixed == 1);
- if (!value_cached && !cache_value_int())
+ if ((!value_cached && !cache_value_int()) || null_value)
return 0;
return int_value;
}