summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-11-23 00:50:54 +0100
committerSergei Golubchik <sergii@pisem.net>2013-11-23 00:50:54 +0100
commitc6d30805db3a1a2a098c3009fde8a42efd9fb9de (patch)
treee55f68e5adf40e1a75e08bda91b712ab6a094643 /sql/item.cc
parent2c032b990e4ec470fad2e9f61cf6267a68b7e937 (diff)
parenteea310e498f3b7ac95a4492d48f04e08d3009412 (diff)
downloadmariadb-git-c6d30805db3a1a2a098c3009fde8a42efd9fb9de.tar.gz
5.5 merge
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index f1968e952be..e665e391042 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -396,6 +396,27 @@ my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
}
+longlong Item::val_int_from_date()
+{
+ DBUG_ASSERT(fixed == 1);
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, 0))
+ return 0;
+ longlong v= TIME_to_ulonglong(&ltime);
+ return ltime.neg ? -v : v;
+}
+
+
+double Item::val_real_from_date()
+{
+ DBUG_ASSERT(fixed == 1);
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, 0))
+ return 0;
+ return TIME_to_double(&ltime);
+}
+
+
double Item::val_real_from_decimal()
{
/* Note that fix_fields may not be called for Item_avg_field items */
@@ -8843,6 +8864,18 @@ Item_cache_temporal::Item_cache_temporal(enum_field_types field_type_arg):
}
+longlong Item_cache_temporal::val_temporal_packed()
+{
+ DBUG_ASSERT(fixed == 1);
+ if ((!value_cached && !cache_value()) || null_value)
+ {
+ null_value= TRUE;
+ return 0;
+ }
+ return value;
+}
+
+
String *Item_cache_temporal::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -8855,6 +8888,42 @@ String *Item_cache_temporal::val_str(String *str)
}
+my_decimal *Item_cache_temporal::val_decimal(my_decimal *decimal_value)
+{
+ DBUG_ASSERT(fixed == 1);
+ if ((!value_cached && !cache_value()) || null_value)
+ {
+ null_value= true;
+ return NULL;
+ }
+ return val_decimal_from_date(decimal_value);
+}
+
+
+longlong Item_cache_temporal::val_int()
+{
+ DBUG_ASSERT(fixed == 1);
+ if ((!value_cached && !cache_value()) || null_value)
+ {
+ null_value= true;
+ return 0;
+ }
+ return val_int_from_date();
+}
+
+
+double Item_cache_temporal::val_real()
+{
+ DBUG_ASSERT(fixed == 1);
+ if ((!value_cached && !cache_value()) || null_value)
+ {
+ null_value= true;
+ return 0;
+ }
+ return val_real_from_date();
+}
+
+
bool Item_cache_temporal::cache_value()
{
if (!example)