diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 13:05:06 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 15:14:48 +0200 |
commit | 5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2 (patch) | |
tree | cde569f712505f981e7a43f01e82c600e282c88c /sql/item_timefunc.cc | |
parent | ee9a19fb054085fcea006a25ec957e0d5cb01ce8 (diff) | |
parent | 16bce0f6fe6bcad0091dc45a97a8ac7b33fe9d44 (diff) | |
download | mariadb-git-5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 06214918693..a560dbd7876 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1091,17 +1091,22 @@ longlong Item_func_yearweek::val_int() } -longlong Item_func_weekday::val_int() +static uint weekday_from_item(Item *item, bool *null_value, bool week_starts_on_sunday) { - DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - - if (get_arg0_date(<ime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE)) + 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); +} - return (longlong) calc_weekday(calc_daynr(ltime.year, ltime.month, - ltime.day), - odbc_type) + MY_TEST(odbc_type); + +longlong Item_func_weekday::val_int() +{ + DBUG_ASSERT(fixed == 1); + return (longlong) weekday_from_item(args[0], &null_value, odbc_type); } bool Item_func_dayname::fix_length_and_dec() @@ -1120,7 +1125,7 @@ bool Item_func_dayname::fix_length_and_dec() String* Item_func_dayname::val_str(String* str) { DBUG_ASSERT(fixed == 1); - uint weekday=(uint) val_int(); // Always Item_func_weekday() + uint weekday= weekday_from_item(args[0], &null_value, false); const char *day_name; uint err; |