summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2013-07-10 18:46:33 +0400
committerAlexander Barkov <bar@mariadb.org>2013-07-10 18:46:33 +0400
commita057b504904c3e6ab1e3006c081b4fb23faaf1d4 (patch)
tree338485c4cb052eba8d60f8c9d1a6077ef4c377b0 /sql/field.cc
parent5b0774ee1c5a32ef694ce18413fa003bc6646c48 (diff)
parentd98584f56a5ec46d6258bba6250c6c797a678afd (diff)
downloadmariadb-git-a057b504904c3e6ab1e3006c081b4fb23faaf1d4.tar.gz
Merging temporal literals
added: mysql-test/r/temporal_literal.result mysql-test/t/temporal_literal.test modified: client/mysqlbinlog.cc include/my_time.h mysql-test/r/cast.result mysql-test/r/partition_innodb.result mysql-test/t/cast.test mysql-test/t/partition_innodb.test sql-common/my_time.c sql/field.cc sql/item.cc sql/item.h sql/item_cmpfunc.cc sql/item_create.cc sql/item_create.h sql/item_strfunc.cc sql/item_timefunc.cc sql/item_timefunc.h sql/sql_select.cc sql/sql_time.cc sql/sql_time.h sql/sql_yacc.yy storage/spider/spd_db_mysql.cc pending merges: Alexander Barkov 2013-07-10 Adding support for the SQL-standard temporal...
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc43
1 files changed, 21 insertions, 22 deletions
diff --git a/sql/field.cc b/sql/field.cc
index c51a04ba140..e6cab7184fd 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1900,7 +1900,7 @@ bool Field::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
if (!(res=val_str(&tmp)) ||
str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(),
- ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
+ ltime, fuzzydate))
return 1;
return 0;
}
@@ -4647,18 +4647,18 @@ int Field_timestamp::store_time_dec(MYSQL_TIME *ltime, uint dec)
int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{
MYSQL_TIME l_time;
- int error;
- int have_smth_to_conv;
+ MYSQL_TIME_STATUS status;
+ bool have_smth_to_conv;
ErrConvString str(from, len, cs);
THD *thd= get_thd();
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
- have_smth_to_conv= (str_to_datetime(cs, from, len, &l_time,
+ have_smth_to_conv= !str_to_datetime(cs, from, len, &l_time,
(thd->variables.sql_mode &
MODE_NO_ZERO_DATE) |
- MODE_NO_ZERO_IN_DATE, &error) >
- MYSQL_TIMESTAMP_ERROR);
- return store_TIME_with_warning(thd, &l_time, &str, error, have_smth_to_conv);
+ MODE_NO_ZERO_IN_DATE, &status);
+ return store_TIME_with_warning(thd, &l_time, &str,
+ status.warnings, have_smth_to_conv);
}
@@ -5154,18 +5154,16 @@ int Field_temporal_with_date::store_TIME_with_warning(MYSQL_TIME *ltime,
int Field_temporal_with_date::store(const char *from, uint len, CHARSET_INFO *cs)
{
MYSQL_TIME ltime;
- int error;
- enum enum_mysql_timestamp_type func_res;
+ MYSQL_TIME_STATUS status;
THD *thd= get_thd();
ErrConvString str(from, len, cs);
-
- func_res= str_to_datetime(cs, from, len, &ltime,
- (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))),
- &error);
- return store_TIME_with_warning(&ltime, &str, error, func_res > MYSQL_TIMESTAMP_ERROR);
+ bool func_res= !str_to_datetime(cs, from, len, &ltime,
+ (TIME_FUZZY_DATE |
+ (thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))),
+ &status);
+ return store_TIME_with_warning(&ltime, &str, status.warnings, func_res);
}
@@ -5280,16 +5278,17 @@ void Field_time::store_TIME(MYSQL_TIME *ltime)
int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{
MYSQL_TIME ltime;
+ MYSQL_TIME_STATUS status;
ErrConvString str(from, len, cs);
- int was_cut;
- int have_smth_to_conv=
- str_to_time(cs, from, len, &ltime,
+ bool have_smth_to_conv=
+ !str_to_time(cs, from, len, &ltime,
get_thd()->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES),
- &was_cut) > MYSQL_TIMESTAMP_ERROR;
+ &status);
- return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
+ return store_TIME_with_warning(&ltime, &str,
+ status.warnings, have_smth_to_conv);
}