Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
1d9532cd
Commit
1d9532cd
authored
Dec 27, 2019
by
Alexander Barkov
Committed by
Marko Mäkelä
Dec 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
After-merge cleanup
parent
5ab70e7f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
19 deletions
+23
-19
sql/item_timefunc.cc
sql/item_timefunc.cc
+7
-16
sql/item_timefunc.h
sql/item_timefunc.h
+2
-3
sql/sql_type.h
sql/sql_type.h
+14
-0
No files found.
sql/item_timefunc.cc
View file @
1d9532cd
...
...
@@ -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
(
&
ltime
,
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
;
...
...
sql/item_timefunc.h
View file @
1d9532cd
...
...
@@ -426,12 +426,12 @@ class Item_func_year :public Item_long_func_date_field
};
class
Item_func_weekday
:
public
Item_
int
_func
class
Item_func_weekday
:
public
Item_
long
_func
{
bool
odbc_type
;
public:
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
();
const
char
*
func_name
()
const
{
...
...
@@ -441,7 +441,6 @@ class Item_func_weekday :public Item_int_func
{
return
type_handler
()
->
Item_get_date
(
this
,
ltime
,
fuzzydate
);
}
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_long
;
}
bool
fix_length_and_dec
()
{
decimals
=
0
;
...
...
sql/sql_type.h
View file @
1d9532cd
...
...
@@ -292,6 +292,15 @@ class Temporal_with_date: protected MYSQL_TIME
{
protected:
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
)
{
make_from_item
(
thd
,
item
,
flags
);
...
...
@@ -389,6 +398,11 @@ class Datetime: public Temporal_with_date
DBUG_ASSERT
(
is_valid_datetime_slow
());
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
{
DBUG_ASSERT
(
is_valid_datetime_slow
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment