summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2013-08-12 16:47:59 +0400
committerAlexander Barkov <bar@mariadb.org>2013-08-12 16:47:59 +0400
commitf1b4718ec894664df221704bb70fed80bdc14070 (patch)
tree2fbf36acef72913f7ae6639f92e01d1ae0ecd694
parent04fd2f18cb9de58d62ec6c860f586b9f81a95300 (diff)
downloadmariadb-git-f1b4718ec894664df221704bb70fed80bdc14070.tar.gz
MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))
-rw-r--r--mysql-test/r/type_time.result9
-rw-r--r--mysql-test/t/type_time.test6
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item_func.cc7
4 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index 5a047f32062..23943c3c848 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -182,5 +182,14 @@ NULL
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
#
+# MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+#
+SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')));
+CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+00:00:01.000000
+SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')));
+CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')))
+768:00:01.000000
+#
# End of 5.3 tests
#
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 26d77ad378e..1c0ba75e274 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -129,5 +129,11 @@ drop table t1;
SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5');
--echo #
+--echo # MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+--echo #
+SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')));
+SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')));
+
+--echo #
--echo # End of 5.3 tests
--echo #
diff --git a/sql/item.cc b/sql/item.cc
index f5687f18cb3..1383500b007 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -252,7 +252,8 @@ String *Item::val_string_from_decimal(String *str)
String *Item::val_string_from_date(String *str)
{
MYSQL_TIME ltime;
- if (get_date(&ltime, 0) ||
+ if (get_date(&ltime,
+ field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) ||
str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e1a2bd44c34..9079de6f06e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2480,6 +2480,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
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)
+ {
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
+ ltime->hour+= (ltime->month * 32 + ltime->day) * 24;
+ ltime->month= ltime->day= 0;
+ }
+
return 0;
}