List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:August 2 2005 8:31pm
Subject:bk commit into 4.1 tree (jimw:1.2372) BUG#7308
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2372 05/08/02 11:31:01 jimw@stripped +3 -0
  Fix parsing of dates with 'T' between date and time, as in ISO-8601
  date format. (Bug #7308)

  sql-common/my_time.c
    1.13 05/08/02 11:30:58 jimw@stripped +7 -5
    Fix handling of field_length for each field in date, especially
    for dates not in the internal_format.

  mysql-test/t/type_datetime.test
    1.17 05/08/02 11:30:58 jimw@stripped +10 -0
    Add new test

  mysql-test/r/type_datetime.result
    1.24 05/08/02 11:30:58 jimw@stripped +10 -0
    Add new results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-7308

--- 1.12/sql-common/my_time.c	2004-12-30 12:44:13 -08:00
+++ 1.13/sql-common/my_time.c	2005-08-02 11:30:58 -07:00
@@ -147,7 +147,7 @@
   {
     /* 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 @@
         start_loop= 5;                         /* Start with first date part */
       }
     }
+
+    field_length= format_position[0] == 0 ? 4 : 2;
   }
 
   /*
@@ -201,7 +203,7 @@
     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 @@
     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 @@
       if (*str == '.')                          /* Followed by part seconds */
       {
         str++;
-        field_length= 5;                        /* 5 digits after first (=6) */
+        field_length= 6;                        /* 6 digits */
       }
       continue;
 

--- 1.23/mysql-test/r/type_datetime.result	2004-12-30 10:37:29 -08:00
+++ 1.24/mysql-test/r/type_datetime.result	2005-08-02 11:30:58 -07:00
@@ -153,3 +153,13 @@
 0000-00-00 00:00:00
 0000-00-00 00:00:00
 drop table t1;
+create table t1 (dt datetime);
+insert into t1 values ("20010101T010101");
+insert into t1 values ("2001-01-01T01:01:01");
+insert into t1 values ("2001-1-1T1:01:01");
+select * from t1;
+dt
+2001-01-01 01:01:01
+2001-01-01 01:01:01
+2001-01-01 01:01:01
+drop table t1;

--- 1.16/mysql-test/t/type_datetime.test	2005-07-27 17:21:50 -07:00
+++ 1.17/mysql-test/t/type_datetime.test	2005-08-02 11:30:58 -07:00
@@ -102,4 +102,14 @@
 select * from t1;
 drop table t1;
 
+#
+# Bug #7308: ISO-8601 date format not handled correctly
+#
+create table t1 (dt datetime);
+insert into t1 values ("20010101T010101");
+insert into t1 values ("2001-01-01T01:01:01");
+insert into t1 values ("2001-1-1T1:01:01");
+select * from t1;
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (jimw:1.2372) BUG#7308Jim Winstead2 Aug