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
a4848e97
Commit
a4848e97
authored
Jun 08, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-9972 Least function retuns date in date time format
parent
b31976f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
mysql-test/r/type_date.result
mysql-test/r/type_date.result
+4
-3
mysql-test/t/type_date.test
mysql-test/t/type_date.test
+1
-0
sql/item_func.cc
sql/item_func.cc
+3
-2
No files found.
mysql-test/r/type_date.result
View file @
a4848e97
...
...
@@ -442,6 +442,7 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
drop table t1;
#
# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
# MDEV-9972 Least function retuns date in date time format
#
CREATE TABLE t1 (
id BIGINT NOT NULL,
...
...
@@ -465,9 +466,9 @@ LEAST(IFNULL(t2.date_fin, IFNULL(t1.date_fin, NULL)),
IFNULL(t1.date_fin, IFNULL(t2.date_fin, NULL))) AS date_fin
FROM t1 LEFT JOIN t2 ON (t1.id=t2.id);
id date_debut date_fin
1 2016-01-01 2016-01-31
00:00:00
2 2016-02-01 2016-01-28
00:00:00
3 2016-03-01 2016-03-31
00:00:00
1 2016-01-01 2016-01-31
2 2016-02-01 2016-01-28
3 2016-03-01 2016-03-31
4 2016-04-01 NULL
DROP TABLE t1,t2;
SELECT
...
...
mysql-test/t/type_date.test
View file @
a4848e97
...
...
@@ -388,6 +388,7 @@ drop table t1;
--
echo
#
--
echo
# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
--
echo
# MDEV-9972 Least function retuns date in date time format
--
echo
#
CREATE
TABLE
t1
(
id
BIGINT
NOT
NULL
,
...
...
sql/item_func.cc
View file @
a4848e97
...
...
@@ -2939,12 +2939,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
}
unpack_time
(
min_max
,
ltime
);
if
(
compare_as_dates
->
field_type
()
==
MYSQL_TYPE_DATE
)
enum_field_types
ftype
=
compare_as_dates
->
field_type
();
if
(
ftype
==
MYSQL_TYPE_DATE
||
ftype
==
MYSQL_TYPE_NEWDATE
)
{
ltime
->
time_type
=
MYSQL_TIMESTAMP_DATE
;
ltime
->
hour
=
ltime
->
minute
=
ltime
->
second
=
ltime
->
second_part
=
0
;
}
else
if
(
compare_as_dates
->
field_type
()
==
MYSQL_TYPE_TIME
)
else
if
(
ftype
==
MYSQL_TYPE_TIME
)
{
ltime
->
time_type
=
MYSQL_TIMESTAMP_TIME
;
ltime
->
hour
+=
(
ltime
->
month
*
32
+
ltime
->
day
)
*
24
;
...
...
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