diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 29ceb6ecaa4..124b20e9b46 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -240,9 +240,7 @@ a 10000 select microsecond(19971231235959.01) as a; a -0 -Warnings: -Warning 1292 Truncated incorrect time value: '19971231235959.01' +10000 select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; a 1997-12-31 00:00:10.090000 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 1f52076f3d2..ac0ad0af066 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1050,6 +1050,10 @@ H select last_day('0000-00-00'); last_day('0000-00-00') NULL +select isnull(week(now() + 0)), isnull(week(now() + 0.2)), +week(20061108), week(20061108.01), week(20061108085411.000002); +isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002) +0 0 45 45 45 End of 4.1 tests explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index ebaa6d84bd3..344acf65df3 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -571,6 +571,13 @@ union select last_day('0000-00-00'); +# +# Bug 23616: datetime functions with double argumets +# + +select isnull(week(now() + 0)), isnull(week(now() + 0.2)), + week(20061108), week(20061108.01), week(20061108085411.000002); + --echo End of 4.1 tests explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, diff --git a/sql-common/my_time.c b/sql-common/my_time.c index dcbd2eacdc1..aeb3aaec675 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -207,7 +207,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, digits= (uint) (pos-str); start_loop= 0; /* Start of scan loop */ date_len[format_position[0]]= 0; /* Length of year field */ - if (pos == end) + if (pos == end || *pos == '.') { /* Found date in internal format (only numbers like YYYYMMDD) */ year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;