mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
After-merge cleanup
This commit is contained in:
committed by
Marko Mäkelä
parent
5ab70e7f68
commit
1d9532cd8b
@ -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()
|
longlong Item_func_weekday::val_int()
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
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()
|
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)
|
String* Item_func_dayname::val_str(String* str)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
uint weekday= weekday_from_item(args[0], &null_value, false);
|
|
||||||
const char *day_name;
|
const char *day_name;
|
||||||
uint err;
|
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;
|
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,
|
str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8_bin,
|
||||||
collation.collation, &err);
|
collation.collation, &err);
|
||||||
return str;
|
return str;
|
||||||
|
@ -426,12 +426,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Item_func_weekday :public Item_int_func
|
class Item_func_weekday :public Item_long_func
|
||||||
{
|
{
|
||||||
bool odbc_type;
|
bool odbc_type;
|
||||||
public:
|
public:
|
||||||
Item_func_weekday(THD *thd, Item *a, bool type_arg):
|
Item_func_weekday(THD *thd, Item *a, bool type_arg):
|
||||||
Item_int_func(thd, a), odbc_type(type_arg) { }
|
Item_long_func(thd, a), odbc_type(type_arg) { }
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
const char *func_name() const
|
const char *func_name() const
|
||||||
{
|
{
|
||||||
@ -441,7 +441,6 @@ public:
|
|||||||
{
|
{
|
||||||
return type_handler()->Item_get_date(this, ltime, fuzzydate);
|
return type_handler()->Item_get_date(this, ltime, fuzzydate);
|
||||||
}
|
}
|
||||||
const Type_handler *type_handler() const { return &type_handler_long; }
|
|
||||||
bool fix_length_and_dec()
|
bool fix_length_and_dec()
|
||||||
{
|
{
|
||||||
decimals= 0;
|
decimals= 0;
|
||||||
|
@ -292,6 +292,15 @@ class Temporal_with_date: protected MYSQL_TIME
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void make_from_item(THD *thd, Item *item, sql_mode_t flags);
|
void make_from_item(THD *thd, Item *item, sql_mode_t flags);
|
||||||
|
|
||||||
|
ulong daynr() const
|
||||||
|
{
|
||||||
|
return (ulong) ::calc_daynr((uint) year, (uint) month, (uint) day);
|
||||||
|
}
|
||||||
|
int weekday(bool sunday_first_day_of_week) const
|
||||||
|
{
|
||||||
|
return ::calc_weekday(daynr(), sunday_first_day_of_week);
|
||||||
|
}
|
||||||
Temporal_with_date(THD *thd, Item *item, sql_mode_t flags)
|
Temporal_with_date(THD *thd, Item *item, sql_mode_t flags)
|
||||||
{
|
{
|
||||||
make_from_item(thd, item, flags);
|
make_from_item(thd, item, flags);
|
||||||
@ -389,6 +398,11 @@ public:
|
|||||||
DBUG_ASSERT(is_valid_datetime_slow());
|
DBUG_ASSERT(is_valid_datetime_slow());
|
||||||
return hour == 0 && minute == 0 && second == 0 && second_part == 0;
|
return hour == 0 && minute == 0 && second == 0 && second_part == 0;
|
||||||
}
|
}
|
||||||
|
int weekday(bool sunday_first_day_of_week) const
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(is_valid_datetime_slow());
|
||||||
|
return Temporal_with_date::weekday(sunday_first_day_of_week);
|
||||||
|
}
|
||||||
const MYSQL_TIME *get_mysql_time() const
|
const MYSQL_TIME *get_mysql_time() const
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(is_valid_datetime_slow());
|
DBUG_ASSERT(is_valid_datetime_slow());
|
||||||
|
Reference in New Issue
Block a user