summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 09e919d872a..0af690608cc 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2477,6 +2477,13 @@ int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
}
+int Field_new_decimal::store_time(TIME *ltime, timestamp_type t_type)
+{
+ my_decimal decimal_value;
+ return store_value(date2my_decimal(ltime, &decimal_value));
+}
+
+
double Field_new_decimal::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
@@ -5530,7 +5537,21 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type)
long tmp;
int error= 0;
if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
+ {
tmp=ltime->year*16*32+ltime->month*32+ltime->day;
+ if ((my_bool)check_date(ltime, tmp,
+ (TIME_FUZZY_DATE |
+ (current_thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error))
+ {
+ char buff[12];
+ String str(buff, sizeof(buff), &my_charset_latin1);
+ make_date((DATE_TIME_FORMAT *) 0, ltime, &str);
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
+ str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
+ }
+ }
else
{
tmp=0;
@@ -5745,8 +5766,22 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
structure always fit into DATETIME range.
*/
if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
+ {
tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+
(ltime->hour*10000L+ltime->minute*100+ltime->second));
+ if ((my_bool)check_date(ltime, tmp,
+ (TIME_FUZZY_DATE |
+ (current_thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error))
+ {
+ char buff[19];
+ String str(buff, sizeof(buff), &my_charset_latin1);
+ make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
+ str.ptr(), str.length(), MYSQL_TIMESTAMP_DATETIME,1);
+ }
+ }
else
{
tmp=0;