Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24

Consider double values as legal date{time} function's arguments
(i.e. allow dates in internal format YYYYMMDDHHMMSS.XXXXXX).
parent 26c0934e
...@@ -229,9 +229,7 @@ a ...@@ -229,9 +229,7 @@ a
10000 10000
select microsecond(19971231235959.01) as a; select microsecond(19971231235959.01) as a;
a a
0 10000
Warnings:
Warning 1292 Truncated incorrect time value: '19971231235959.01'
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a a
1997-12-31 00:00:10.090000 1997-12-31 00:00:10.090000
......
...@@ -854,4 +854,8 @@ H ...@@ -854,4 +854,8 @@ H
select last_day('0000-00-00'); select last_day('0000-00-00');
last_day('0000-00-00') last_day('0000-00-00')
NULL 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 End of 4.1 tests
...@@ -492,4 +492,11 @@ union ...@@ -492,4 +492,11 @@ union
select last_day('0000-00-00'); 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 --echo End of 4.1 tests
...@@ -145,7 +145,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, ...@@ -145,7 +145,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
digits= (uint) (pos-str); digits= (uint) (pos-str);
start_loop= 0; /* Start of scan loop */ start_loop= 0; /* Start of scan loop */
date_len[format_position[0]]= 0; /* Length of year field */ 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) */ /* Found date in internal format (only numbers like YYYYMMDD) */
year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment