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
25ad38ab
Commit
25ad38ab
authored
Sep 25, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-17288 Replace Item_func::get_arg0_date() to Date/Datetime methods
parent
50003a95
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
96 deletions
+139
-96
sql/item_func.h
sql/item_func.h
+0
-6
sql/item_timefunc.cc
sql/item_timefunc.cc
+57
-88
sql/sql_time.cc
sql/sql_time.cc
+1
-1
sql/sql_time.h
sql/sql_time.h
+1
-1
sql/sql_type.h
sql/sql_type.h
+80
-0
No files found.
sql/item_func.h
View file @
25ad38ab
...
...
@@ -177,12 +177,6 @@ class Item_func :public Item_func_or_sum,
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
void
print_op
(
String
*
str
,
enum_query_type
query_type
);
void
print_args
(
String
*
str
,
uint
from
,
enum_query_type
query_type
);
inline
bool
get_arg0_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
)
{
DBUG_ASSERT
(
!
(
fuzzy_date
&
TIME_TIME_ONLY
));
Datetime
dt
(
current_thd
,
args
[
0
],
fuzzy_date
);
return
(
null_value
=
dt
.
copy_to_mysql_time
(
ltime
));
}
bool
is_null
()
{
update_null_value
();
return
null_value
;
...
...
sql/item_timefunc.cc
View file @
25ad38ab
This diff is collapsed.
Click to expand it.
sql/sql_time.cc
View file @
25ad38ab
...
...
@@ -175,7 +175,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week)
next week is week 1.
*/
uint
calc_week
(
MYSQL_TIME
*
l_time
,
uint
week_behaviour
,
uint
*
year
)
uint
calc_week
(
const
MYSQL_TIME
*
l_time
,
uint
week_behaviour
,
uint
*
year
)
{
uint
days
;
ulong
daynr
=
calc_daynr
(
l_time
->
year
,
l_time
->
month
,
l_time
->
day
);
...
...
sql/sql_time.h
View file @
25ad38ab
...
...
@@ -120,7 +120,7 @@ int my_time_compare(const MYSQL_TIME *a, const MYSQL_TIME *b);
void
localtime_to_TIME
(
MYSQL_TIME
*
to
,
struct
tm
*
from
);
void
calc_time_from_sec
(
MYSQL_TIME
*
to
,
ulong
seconds
,
ulong
microseconds
);
uint
calc_week
(
MYSQL_TIME
*
l_time
,
uint
week_behaviour
,
uint
*
year
);
uint
calc_week
(
const
MYSQL_TIME
*
l_time
,
uint
week_behaviour
,
uint
*
year
);
int
calc_weekday
(
long
daynr
,
bool
sunday_first_day_of_week
);
bool
parse_date_time_format
(
timestamp_type
format_type
,
...
...
sql/sql_type.h
View file @
25ad38ab
...
...
@@ -920,6 +920,31 @@ class Temporal_with_date: public Temporal
void
check_date_or_invalidate
(
int
*
warn
,
sql_mode_t
flags
);
void
make_from_item
(
THD
*
thd
,
Item
*
item
,
sql_mode_t
flags
);
void
make_from_item
(
THD
*
thd
,
Item
*
item
);
ulong
daynr
()
const
{
return
(
ulong
)
::
calc_daynr
((
uint
)
year
,
(
uint
)
month
,
(
uint
)
day
);
}
ulong
dayofyear
()
const
{
return
(
ulong
)
(
daynr
()
-
::
calc_daynr
(
year
,
1
,
1
)
+
1
);
}
uint
quarter
()
const
{
return
(
month
+
2
)
/
3
;
}
uint
week
(
uint
week_behaviour
)
const
{
uint
year
;
return
calc_week
(
this
,
week_behaviour
,
&
year
);
}
uint
yearweek
(
uint
week_behaviour
)
const
{
uint
year
;
uint
week
=
calc_week
(
this
,
week_behaviour
,
&
year
);
return
week
+
year
*
100
;
}
Temporal_with_date
()
{
time_type
=
MYSQL_TIMESTAMP_NONE
;
...
...
@@ -1025,6 +1050,32 @@ class Date: public Temporal_with_date
*
ltime
=
*
this
;
return
false
;
}
ulong
daynr
()
const
{
DBUG_ASSERT
(
is_valid_date_slow
());
return
Temporal_with_date
::
daynr
();
}
ulong
dayofyear
()
const
{
DBUG_ASSERT
(
is_valid_date_slow
());
return
Temporal_with_date
::
dayofyear
();
}
uint
quarter
()
const
{
DBUG_ASSERT
(
is_valid_date_slow
());
return
Temporal_with_date
::
quarter
();
}
uint
week
(
uint
week_behaviour
)
const
{
DBUG_ASSERT
(
is_valid_date_slow
());
return
Temporal_with_date
::
week
(
week_behaviour
);
}
uint
yearweek
(
uint
week_behaviour
)
const
{
DBUG_ASSERT
(
is_valid_date_slow
());
return
Temporal_with_date
::
yearweek
(
week_behaviour
);
}
longlong
to_longlong
()
const
{
return
is_valid_date
()
?
(
longlong
)
TIME_to_ulonglong_date
(
this
)
:
0LL
;
...
...
@@ -1175,11 +1226,40 @@ class Datetime: public Temporal_with_date
DBUG_ASSERT
(
is_valid_value_slow
());
return
time_type
==
MYSQL_TIMESTAMP_DATETIME
;
}
bool
check_date
(
longlong
flags
,
int
*
warnings
)
const
{
DBUG_ASSERT
(
is_valid_datetime_slow
());
return
::
check_date
(
this
,
(
year
||
month
||
day
),
flags
,
warnings
);
}
bool
check_date
(
longlong
flags
)
const
{
int
dummy
;
/* unused */
return
check_date
(
flags
,
&
dummy
);
}
bool
hhmmssff_is_zero
()
const
{
DBUG_ASSERT
(
is_valid_datetime_slow
());
return
hour
==
0
&&
minute
==
0
&&
second
==
0
&&
second_part
==
0
;
}
ulong
daynr
()
const
{
DBUG_ASSERT
(
is_valid_datetime_slow
());
return
Temporal_with_date
::
daynr
();
}
longlong
hhmmss_to_seconds_abs
()
const
{
DBUG_ASSERT
(
is_valid_datetime_slow
());
return
hour
*
3600L
+
minute
*
60
+
second
;
}
longlong
hhmmss_to_seconds
()
const
{
return
neg
?
-
hhmmss_to_seconds_abs
()
:
hhmmss_to_seconds_abs
();
}
longlong
to_seconds
()
const
{
return
hhmmss_to_seconds
()
+
(
longlong
)
daynr
()
*
24L
*
3600L
;
}
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