From e9db0da787996c1244f579bbc313c82ecde95d2f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 8 Aug 2013 12:58:28 +0400 Subject: [PATCH] MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') --- mysql-test/r/timezone2.result | 19 +++++++++++++++++++ mysql-test/t/timezone2.test | 16 ++++++++++++++++ sql/item_timefunc.cc | 8 ++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index e2e337628ce..70f5ef9edc1 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -309,3 +309,22 @@ CONVERT_TZ(1, 1, a) NULL DROP TABLE t1; End of 5.1 tests +# +# Start of 5.3 tests +# +# +# MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +# +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +# +# End of 5.3 tests +# diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index c4445da107c..7764b39bf33 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -284,3 +284,19 @@ SELECT CONVERT_TZ(1, 1, a) FROM t1; DROP TABLE t1; --echo End of 5.1 tests + + +--echo # +--echo # Start of 5.3 tests +--echo # + +--echo # +--echo # MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +--echo # + +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); + +--echo # +--echo # End of 5.3 tests +--echo # diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 3322863a76d..d89cd01d26a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1923,7 +1923,9 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { INTERVAL interval; - if (args[0]->get_date(ltime, 0) || + if (args[0]->get_date(ltime, + cached_field_type == MYSQL_TYPE_TIME ? + TIME_TIME_ONLY : 0) || get_interval_value(args[1], int_type, &value, &interval)) return (null_value=1); @@ -2301,7 +2303,9 @@ bool Item_time_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date) if (ltime->time_type != MYSQL_TIMESTAMP_TIME) ltime->year= ltime->month= ltime->day= 0; ltime->time_type= MYSQL_TIMESTAMP_TIME; - return 0; + return (fuzzy_date & TIME_TIME_ONLY) ? 0 : + (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); }