diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-12-27 18:22:16 +0400 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 18:22:16 +0400 |
commit | 1d9532cd8b8bfffa0708b690894d4ae23b12bc22 (patch) | |
tree | 0d7e396ba8068f9e621c760518451b56e11091ff /sql/item_timefunc.cc | |
parent | 5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2 (diff) | |
download | mariadb-git-1d9532cd8b8bfffa0708b690894d4ae23b12bc22.tar.gz |
After-merge cleanup
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a560dbd7876..34b12ee9b55 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1091,22 +1091,13 @@ longlong Item_func_yearweek::val_int() } -static uint weekday_from_item(Item *item, bool *null_value, bool week_starts_on_sunday) -{ - MYSQL_TIME ltime; - if ((*null_value= Datetime(current_thd, item, - TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE). - copy_to_mysql_time(<ime, MYSQL_TIMESTAMP_DATETIME))) - return 0; - return calc_weekday(calc_daynr(ltime.year, ltime.month, ltime.day), week_starts_on_sunday) + - MY_TEST(week_starts_on_sunday); -} - - longlong Item_func_weekday::val_int() { DBUG_ASSERT(fixed == 1); - return (longlong) weekday_from_item(args[0], &null_value, odbc_type); + Datetime dt(current_thd, args[0], TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE); + if ((null_value= !dt.is_valid_datetime())) + return 0; + return dt.weekday(odbc_type) + MY_TEST(odbc_type); } bool Item_func_dayname::fix_length_and_dec() @@ -1125,14 +1116,14 @@ bool Item_func_dayname::fix_length_and_dec() String* Item_func_dayname::val_str(String* str) { DBUG_ASSERT(fixed == 1); - uint weekday= weekday_from_item(args[0], &null_value, false); const char *day_name; uint err; + Datetime dt(current_thd, args[0], TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE); - if (null_value) + if ((null_value= !dt.is_valid_datetime())) return (String*) 0; - day_name= locale->day_names->type_names[weekday]; + day_name= locale->day_names->type_names[dt.weekday(false)]; str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8_bin, collation.collation, &err); return str; |