Skip to content

Commit

Permalink
MDEV-8862 Wrong field type for MAX(COALESCE(datetime_column))
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Sep 28, 2015
1 parent c5922c5 commit a4e5902
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions mysql-test/r/type_time.result
Original file line number Diff line number Diff line change
Expand Up @@ -1206,5 +1206,14 @@ Warning 1292 Incorrect time value: '9000000' for column 'b' at row 4
Warning 1292 Incorrect time value: '9000000' for column 'c' at row 4
DROP TABLE t1;
#
# MDEV-8862 Wrong field type for MAX(COALESCE(datetime_column))
#
CREATE TABLE t1 (a TIME);
INSERT INTO t1 VALUES ('10:10:10'),('10:20:30');
SELECT MAX(a), MAX(COALESCE(a)) FROM t1;
MAX(a) MAX(COALESCE(a))
10:20:30 10:20:30
DROP TABLE t1;
#
# End of 10.1 tests
#
8 changes: 8 additions & 0 deletions mysql-test/t/type_time.test
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ INSERT INTO t1 VALUES (9000000,9000000,9000000);
SELECT a, TIME(a),TIME(b),TIME(c) FROM t1 ORDER BY a;
DROP TABLE t1;

--echo #
--echo # MDEV-8862 Wrong field type for MAX(COALESCE(datetime_column))
--echo #
CREATE TABLE t1 (a TIME);
INSERT INTO t1 VALUES ('10:10:10'),('10:20:30');
SELECT MAX(a), MAX(COALESCE(a)) FROM t1;
DROP TABLE t1;

--echo #
--echo # End of 10.1 tests
--echo #
4 changes: 3 additions & 1 deletion sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,9 @@ bool Item_func_hybrid_result_type::get_date(MYSQL_TIME *ltime,
case STRING_RESULT:
{
if (is_temporal_type(field_type()))
return date_op(ltime, fuzzydate);
return date_op(ltime,
fuzzydate |
(field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0));
char buff[40];
String tmp(buff,sizeof(buff), &my_charset_bin),*res;
if (!(res= str_op(&tmp)) ||
Expand Down

0 comments on commit a4e5902

Please sign in to comment.