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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
43e45226
Commit
43e45226
authored
Jun 15, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8205 timediff returns null when comparing decimal time to time string value
parent
f69f3db7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
10 deletions
+85
-10
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+42
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+41
-0
sql-common/my_time.c
sql-common/my_time.c
+2
-10
No files found.
mysql-test/r/func_time.result
View file @
43e45226
...
...
@@ -2701,3 +2701,45 @@ id date1 date2 DATE_ADD(a.date1,INTERVAL -10 DAY) TO_DAYS(a.date1)-10
17 NULL NULL NULL NULL
18 2010-10-13 2010-10-03 2010-10-03 734413
DROP TABLE t1;
#
# Start of 10.0 tests
#
#
# MDEV-8205 timediff returns null when comparing decimal time to time string value
#
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140101010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140101010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-01-01 01:00:00' ) AS dec_str;
str_str str_dec dec_dec dec_str
-01:00:00 -01:00:00.000 -01:00:00.000 -01:00:00.000
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140102010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140102010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-01-02 01:00:00' ) AS dec_str;
str_str str_dec dec_dec dec_str
-25:00:00 -25:00:00.000 -25:00:00.000 -25:00:00.000
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-02-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140202010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140202010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-02-02 01:00:00' ) AS dec_str;
str_str str_dec dec_dec dec_str
-769:00:00 -769:00:00.000 -769:00:00.000 -769:00:00.000
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-03-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140302010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140302010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-03-02 01:00:00' ) AS dec_str;
str_str str_dec dec_dec dec_str
-838:59:59 -838:59:59.999 -838:59:59.999 -838:59:59.999
Warnings:
Warning 1292 Truncated incorrect time value: '-1441:00:00'
Warning 1292 Truncated incorrect time value: '-1441:00:00'
Warning 1292 Truncated incorrect time value: '-1441:00:00'
Warning 1292 Truncated incorrect time value: '-1441:00:00'
#
# End of 10.0 tests
#
mysql-test/t/func_time.test
View file @
43e45226
...
...
@@ -1649,3 +1649,44 @@ INSERT INTO t1 VALUES (17, NULL);
INSERT
INTO
t1
VALUES
(
18
,
'2010-10-13'
);
SELECT
a
.
id
,
a
.
date1
,
FROM_DAYS
(
TO_DAYS
(
a
.
date1
)
-
10
)
as
date2
,
DATE_ADD
(
a
.
date1
,
INTERVAL
-
10
DAY
),
TO_DAYS
(
a
.
date1
)
-
10
FROM
t1
a
ORDER
BY
a
.
id
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Start of 10.0 tests
--
echo
#
--
echo
#
--
echo
# MDEV-8205 timediff returns null when comparing decimal time to time string value
--
echo
#
# 1h difference
SELECT
TIMEDIFF
(
'2014-01-01 00:00:00'
,
'2014-01-01 01:00:00'
)
AS
str_str
,
TIMEDIFF
(
'2014-01-01 00:00:00'
,
20140101010000.000
)
AS
str_dec
,
TIMEDIFF
(
20140101000000.000
,
20140101010000.000
)
AS
dec_dec
,
TIMEDIFF
(
20140101000000.000
,
'2014-01-01 01:00:00'
)
AS
dec_str
;
# 1D1h difference
SELECT
TIMEDIFF
(
'2014-01-01 00:00:00'
,
'2014-01-02 01:00:00'
)
AS
str_str
,
TIMEDIFF
(
'2014-01-01 00:00:00'
,
20140102010000.000
)
AS
str_dec
,
TIMEDIFF
(
20140101000000.000
,
20140102010000.000
)
AS
dec_dec
,
TIMEDIFF
(
20140101000000.000
,
'2014-01-02 01:00:00'
)
AS
dec_str
;
# 1M1D1h difference
SELECT
TIMEDIFF
(
'2014-01-01 00:00:00'
,
'2014-02-02 01:00:00'
)
AS
str_str
,
TIMEDIFF
(
'2014-01-01 00:00:00'
,
20140202010000.000
)
AS
str_dec
,
TIMEDIFF
(
20140101000000.000
,
20140202010000.000
)
AS
dec_dec
,
TIMEDIFF
(
20140101000000.000
,
'2014-02-02 01:00:00'
)
AS
dec_str
;
# 2M1D1h difference
SELECT
TIMEDIFF
(
'2014-01-01 00:00:00'
,
'2014-03-02 01:00:00'
)
AS
str_str
,
TIMEDIFF
(
'2014-01-01 00:00:00'
,
20140302010000.000
)
AS
str_dec
,
TIMEDIFF
(
20140101000000.000
,
20140302010000.000
)
AS
dec_dec
,
TIMEDIFF
(
20140101000000.000
,
'2014-03-02 01:00:00'
)
AS
dec_str
;
--
echo
#
--
echo
# End of 10.0 tests
--
echo
#
sql-common/my_time.c
View file @
43e45226
...
...
@@ -1314,16 +1314,8 @@ int number_to_time(my_bool neg, ulonglong nr, ulong sec_part,
MYSQL_TIME
*
ltime
,
int
*
was_cut
)
{
if
(
nr
>
9999999
&&
nr
<
99991231235959ULL
&&
neg
==
0
)
{
if
(
number_to_datetime
(
nr
,
sec_part
,
ltime
,
TIME_INVALID_DATES
,
was_cut
)
<
0
)
return
-
1
;
ltime
->
year
=
ltime
->
month
=
ltime
->
day
=
0
;
ltime
->
time_type
=
MYSQL_TIMESTAMP_TIME
;
*
was_cut
=
MYSQL_TIME_NOTE_TRUNCATED
;
return
0
;
}
return
number_to_datetime
(
nr
,
sec_part
,
ltime
,
TIME_INVALID_DATES
,
was_cut
)
<
0
?
-
1
:
0
;
*
was_cut
=
0
;
ltime
->
year
=
ltime
->
month
=
ltime
->
day
=
0
;
...
...
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