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
357cb12d
Commit
357cb12d
authored
Dec 16, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEV-7221 from_days fails after null value
parent
5257d71e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+24
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+18
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+3
-4
No files found.
mysql-test/r/func_time.result
View file @
357cb12d
...
...
@@ -2561,3 +2561,27 @@ Warning 1292 Truncated incorrect time value: '9336:00:00'
Warning 1292 Truncated incorrect time value: '2952:00:00'
Warning 1292 Truncated incorrect time value: '2952:00:00'
DROP TABLE t1;
#
# MDEV-7221 from_days fails after null value
#
CREATE TABLE t1 (
id INT(11) NOT NULL PRIMARY KEY,
date1 DATE NULL DEFAULT NULL
);
INSERT INTO t1 VALUES (12, '2011-05-12');
INSERT INTO t1 VALUES (13, NULL);
INSERT INTO t1 VALUES (14, '2009-10-23');
INSERT INTO t1 VALUES (15, '2014-10-30');
INSERT INTO t1 VALUES (16, NULL);
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;
id date1 date2 DATE_ADD(a.date1,INTERVAL -10 DAY) TO_DAYS(a.date1)-10
12 2011-05-12 2011-05-02 2011-05-02 734624
13 NULL NULL NULL NULL
14 2009-10-23 2009-10-13 2009-10-13 734058
15 2014-10-30 2014-10-20 2014-10-20 735891
16 NULL NULL NULL NULL
17 NULL NULL NULL NULL
18 2010-10-13 2010-10-03 2010-10-03 734413
DROP TABLE t1;
mysql-test/t/func_time.test
View file @
357cb12d
...
...
@@ -1561,3 +1561,21 @@ CREATE TABLE t1 ( d DATE, t TIME );
INSERT
INTO
t1
VALUES
(
'2008-12-05'
,
'22:34:09'
),(
'2005-03-27'
,
'14:26:02'
);
SELECT
EXTRACT
(
DAY_MINUTE
FROM
GREATEST
(
t
,
d
)),
GREATEST
(
t
,
d
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-7221 from_days fails after null value
--
echo
#
CREATE
TABLE
t1
(
id
INT
(
11
)
NOT
NULL
PRIMARY
KEY
,
date1
DATE
NULL
DEFAULT
NULL
);
INSERT
INTO
t1
VALUES
(
12
,
'2011-05-12'
);
INSERT
INTO
t1
VALUES
(
13
,
NULL
);
INSERT
INTO
t1
VALUES
(
14
,
'2009-10-23'
);
INSERT
INTO
t1
VALUES
(
15
,
'2014-10-30'
);
INSERT
INTO
t1
VALUES
(
16
,
NULL
);
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
;
sql/item_timefunc.cc
View file @
357cb12d
...
...
@@ -1488,10 +1488,9 @@ String *Item_temporal_func::val_str(String *str)
bool
Item_func_from_days
::
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
)
{
longlong
value
=
args
[
0
]
->
val_int
();
if
(
args
[
0
]
->
null_value
)
return
(
null_value
=
1
);
if
((
fuzzy_date
&
TIME_NO_ZERO_DATE
)
&&
value
==
0
)
return
(
null_value
=
1
);
if
((
null_value
=
(
args
[
0
]
->
null_value
||
((
fuzzy_date
&
TIME_NO_ZERO_DATE
)
&&
value
==
0
))))
return
true
;
bzero
(
ltime
,
sizeof
(
MYSQL_TIME
));
if
(
get_date_from_daynr
((
long
)
value
,
&
ltime
->
year
,
&
ltime
->
month
,
&
ltime
->
day
))
...
...
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