summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@mysql.com/deer.(none)>2006-10-25 20:14:39 +0500
committerunknown <holyfoot/hf@mysql.com/deer.(none)>2006-10-25 20:14:39 +0500
commit01a0be193d8344e1b20c366b30a7ca75a0a9bd44 (patch)
tree248f0c5b988b23156208cb6f1d2014539218eb9d /sql/item.cc
parent3f4964394c0f3bb75a4c02549b70b728aa1ddd90 (diff)
downloadmariadb-git-01a0be193d8344e1b20c366b30a7ca75a0a9bd44.tar.gz
bug #19491 (CAST do DATETIME wrong result)
mysql-test/r/type_datetime.result: result fixed mysql-test/r/type_newdecimal.result: result fixed mysql-test/t/type_datetime.test: testcase mysql-test/t/type_newdecimal.test: testcase sql/field.cc: Field_new_decimal::store_time implemented sql/field.h: Field_new_decimal::store_time added sql/item.cc: auxiliary methods implemented to operate with datatimes sql/item.h: auxiliary methods declared in Item to operate with datatimes sql/item_timefunc.cc: Item_date::save_in_field old implementation removed sql/item_timefunc.h: my_decimal and save_in_field methods implemented for datetime items sql/my_decimal.cc: date2my_decimal implemented sql/my_decimal.h: date2my_decimal declared
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 96b20d0f0bb..1e70788d9f4 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),