summaryrefslogtreecommitdiff
path: root/sql/my_decimal.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/my_decimal.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/my_decimal.cc')
-rw-r--r--sql/my_decimal.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 1bd16940b47..f33609e0168 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h"
+#include <time.h>
+
#ifndef MYSQL_CLIENT
/*
@@ -190,6 +192,23 @@ int str2my_decimal(uint mask, const char *from, uint length,
}
+my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec)
+{
+ longlong date;
+ date = (ltime->year*100L + ltime->month)*100L + ltime->day;
+ if (ltime->time_type > MYSQL_TIMESTAMP_DATE)
+ date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
+ if (int2my_decimal(E_DEC_FATAL_ERROR, date, FALSE, dec))
+ return dec;
+ if (ltime->second_part)
+ {
+ dec->buf[(dec->intg-1) / 9 + 1]= ltime->second_part * 1000;
+ dec->frac= 6;
+ }
+ return dec;
+}
+
+
#ifndef DBUG_OFF
/* routines for debugging print */