diff options
author | unknown <msvensson@neptunus.(none)> | 2006-11-24 12:04:58 +0100 |
---|---|---|
committer | unknown <msvensson@neptunus.(none)> | 2006-11-24 12:04:58 +0100 |
commit | de9980f4c61c3fdfe7547789ec4b0a86dc49c6a0 (patch) | |
tree | 7703708b9b49ef7763dad81c0d6b4a4b567c521c | |
parent | 7695cab8aad6fd44273cc7185252c6422e175bbb (diff) | |
parent | a865876b1d65f32e31d40fc55217bb0a03266a10 (diff) | |
download | mariadb-git-de9980f4c61c3fdfe7547789ec4b0a86dc49c6a0.tar.gz |
Merge bk-internal:/home/bk/mysql-4.1-maint
into neptunus.(none):/home/msvensson/mysql/mysql-4.1-maint
-rw-r--r-- | mysql-test/r/date_formats.result | 66 | ||||
-rw-r--r-- | mysql-test/t/date_formats.test | 8 | ||||
-rw-r--r-- | sql-common/my_time.c | 5 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 8 |
4 files changed, 64 insertions, 23 deletions
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 035d98d2b74..d4f9a4f0c56 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -181,12 +181,12 @@ date format datetime 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 10:20:10 -10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 -10:20:10 %T 0000-00-00 10:20:10 -10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 -10:20:10AM %r 0000-00-00 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 +10:20:10 %H:%i:%s 0000-00-00 00:00:00 +10:20:10 %h:%i:%s.%f 0000-00-00 00:00:00 +10:20:10 %T 0000-00-00 00:00:00 +10:20:10AM %h:%i:%s%p 0000-00-00 00:00:00 +10:20:10AM %r 0000-00-00 00:00:00 +10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 00:00:00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 @@ -203,6 +203,13 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 @@ -243,12 +250,12 @@ date format time 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -265,6 +272,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 @@ -274,12 +288,12 @@ date format time2 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -296,6 +310,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 @@ -530,4 +551,13 @@ DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896) NULL Warnings: Warning 1292 Truncated incorrect datetime value: '%Y-%m-%d %H:%i:%s' +select str_to_date('04 /30/2004', '%m /%d/%Y'); +str_to_date('04 /30/2004', '%m /%d/%Y') +2004-04-30 +select str_to_date('04/30 /2004', '%m /%d /%Y'); +str_to_date('04/30 /2004', '%m /%d /%Y') +2004-04-30 +select str_to_date('04/30/2004 ', '%m/%d/%Y '); +str_to_date('04/30/2004 ', '%m/%d/%Y ') +2004-04-30 "End of 4.1 tests" diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 922d047eac8..7e74c128dee 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -317,4 +317,12 @@ SELECT TIME_FORMAT("25:00:00", '%l %p'); # SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); +# +# Bug #22029: str_to_date returning NULL +# + +select str_to_date('04 /30/2004', '%m /%d/%Y'); +select str_to_date('04/30 /2004', '%m /%d /%Y'); +select str_to_date('04/30/2004 ', '%m/%d/%Y '); + --echo "End of 4.1 tests" diff --git a/sql-common/my_time.c b/sql-common/my_time.c index baf9a3902d9..86b533ce9b3 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -350,7 +350,10 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, l_time->year > 9999 || l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || l_time->minute > 59 || l_time->second > 59 || - (!(flags & TIME_FUZZY_DATE) && (l_time->month == 0 || l_time->day == 0))) + (!(flags & TIME_FUZZY_DATE) && + (l_time->month == 0 || l_time->day == 0)) || + (l_time->year == 0 && l_time->month == 0 && l_time->day == 0 && + (l_time->hour != 0 || l_time->minute != 0 || l_time->second != 0))) { /* Only give warning for a zero date if there is some garbage after */ if (!not_zero_date) /* If zero date */ diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index ec424910f54..62005e2b65c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -289,15 +289,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, for (; ptr != end && val != val_end; ptr++) { + /* Skip pre-space between each argument */ + while (val != val_end && my_isspace(cs, *val)) + val++; + if (*ptr == '%' && ptr+1 != end) { int val_len; char *tmp; - /* Skip pre-space between each argument */ - while (val != val_end && my_isspace(cs, *val)) - val++; - val_len= (uint) (val_end - val); switch (*++ptr) { /* Year */ |