summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorjimw@mysql.com <>2005-08-02 11:31:01 -0700
committerjimw@mysql.com <>2005-08-02 11:31:01 -0700
commit4340fa114ec0c5173d6236e8b85580dc6e60688a (patch)
tree43828566cdece6c3c9202f5a496d399ebbe6bffb /sql-common
parent1e2e10afac432c3f68e04d840cac366f4d389707 (diff)
downloadmariadb-git-4340fa114ec0c5173d6236e8b85580dc6e60688a.tar.gz
Fix parsing of dates with 'T' between date and time, as in ISO-8601
date format. (Bug #7308)
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/my_time.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 8dd4801b562..1726a9a6e78 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -147,7 +147,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
{
/* Found date in internal format (only numbers like YYYYMMDD) */
year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;
- field_length=year_length-1;
+ field_length= year_length;
is_internal_format= 1;
format_position= internal_format_positions;
}
@@ -177,6 +177,8 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
start_loop= 5; /* Start with first date part */
}
}
+
+ field_length= format_position[0] == 0 ? 4 : 2;
}
/*
@@ -201,7 +203,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
const char *start= str;
ulong tmp_value= (uint) (uchar) (*str++ - '0');
while (str != end && my_isdigit(&my_charset_latin1,str[0]) &&
- (!is_internal_format || field_length--))
+ --field_length)
{
tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0');
str++;
@@ -215,8 +217,8 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
date[i]=tmp_value;
not_zero_date|= tmp_value;
- /* Length-1 of next field */
- field_length= format_position[i+1] == 0 ? 3 : 1;
+ /* Length of next field */
+ field_length= format_position[i+1] == 0 ? 4 : 2;
if ((last_field_pos= str) == end)
{
@@ -234,7 +236,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
if (*str == '.') /* Followed by part seconds */
{
str++;
- field_length= 5; /* 5 digits after first (=6) */
+ field_length= 6; /* 6 digits */
}
continue;