summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorholyfoot/hf@mysql.com/deer.(none) <>2006-11-06 11:10:08 +0400
committerholyfoot/hf@mysql.com/deer.(none) <>2006-11-06 11:10:08 +0400
commit50d199848b13ccb0b1d3d5faa0e6e23bd9ccd435 (patch)
tree2116e7b1ac8f88ec7e01e57470d2c65c1a8385a4 /sql/item.cc
parent79abdb38f89913041c52cbacfb225cec5ec4cc4a (diff)
parent5f42ec19b760931864e6e7b28a1cff9aff06d1ad (diff)
downloadmariadb-git-50d199848b13ccb0b1d3d5faa0e6e23bd9ccd435.tar.gz
Merge bk@192.168.21.1:mysql-5.0-opt
into mysql.com:/home/hf/work/19491/my50-19491
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index d0777f8f2a2..b26f65ead69 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -272,6 +272,34 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value)
}
+my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
+{
+ DBUG_ASSERT(fixed == 1);
+ TIME ltime;
+ longlong date;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
+ {
+ my_decimal_set_zero(decimal_value);
+ return 0;
+ }
+ return date2my_decimal(&ltime, decimal_value);
+}
+
+
+my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
+{
+ DBUG_ASSERT(fixed == 1);
+ TIME ltime;
+ longlong date;
+ if (get_time(&ltime))
+ {
+ my_decimal_set_zero(decimal_value);
+ return 0;
+ }
+ return date2my_decimal(&ltime, decimal_value);
+}
+
+
double Item::val_real_from_decimal()
{
/* Note that fix_fields may not be called for Item_avg_field items */
@@ -295,6 +323,25 @@ longlong Item::val_int_from_decimal()
return result;
}
+int Item::save_time_in_field(Field *field)
+{
+ TIME ltime;
+ if (get_time(&ltime))
+ return set_field_to_null(field);
+ field->set_notnull();
+ return field->store_time(&ltime, MYSQL_TIMESTAMP_TIME);
+}
+
+
+int Item::save_date_in_field(Field *field)
+{
+ TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
+ return set_field_to_null(field);
+ field->set_notnull();
+ return field->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
+}
+
Item::Item():
rsize(0), name(0), orig_name(0), name_length(0), fixed(0),