diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sql/field.cc b/sql/field.cc index 74a5e742c06..54e5c362f0d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5338,27 +5338,30 @@ void Field_date::sql_type(String &res) const int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) { TIME l_time; - long tmp; int error; THD *thd= table ? table->in_use : current_thd; - if (str_to_datetime(from, len, &l_time, - (TIME_FUZZY_DATE | - (thd->variables.sql_mode & - (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), - &error) <= MYSQL_TIMESTAMP_ERROR) + enum enum_mysql_timestamp_type ret; + if ((ret= str_to_datetime(from, len, &l_time, + (TIME_FUZZY_DATE | + (thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), + &error)) <= MYSQL_TIMESTAMP_ERROR) { - tmp= 0L; + int3store(ptr,0L); error= 2; } else - tmp= l_time.day + l_time.month*32 + l_time.year*16*32; + { + int3store(ptr, l_time.day + l_time.month*32 + l_time.year*16*32); + if(!error && (ret != MYSQL_TIMESTAMP_DATE)) + return 2; + } if (error) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_DATE, 1); - int3store(ptr,tmp); return error; } |