List:Commits« Previous MessageNext Message »
From:Alex Ivanov Date:December 15 2005 3:48pm
Subject:bk commit into 4.1 tree (aivanov:1.2461) BUG#12440
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of alexi. When alexi 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.2461 05/12/15 18:48:08 aivanov@stripped +3 -0
  Fixed BUG #12440: "Incorrect processing of time values containing
   long fraction and/or large exponent part".

  sql-common/my_time.c
    1.15 05/12/15 18:48:01 aivanov@stripped +22 -6
    Fixed bug #12440: "Incorrect processing of time values containing
     long fraction and/or large exponent part".
     Modified str_to_time(). Process properly fraction part containing
     more than 6 digits. Check for existence of exponent part which
     may result from %g formatting applied to time value specified as
     large real number.

  mysql-test/t/type_time.test
    1.7 05/12/15 18:48:01 aivanov@stripped +14 -0
    Added testcases for bug #12440

  mysql-test/r/type_time.result
    1.13 05/12/15 18:48:01 aivanov@stripped +24 -0
    Fixed testcases results (bug #12440)

# 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:	aivanov
# Host:	mysql.creware.com
# Root:	/home/alexi/dev/mysql-4.1-12440

--- 1.14/sql-common/my_time.c	2005-08-09 01:13:46 +04:00
+++ 1.15/sql-common/my_time.c	2005-12-15 18:48:01 +03:00
@@ -514,18 +514,34 @@
   /* Get fractional second part */
   if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_latin1,str[1]))
   {
-    uint field_length=5;
+    int field_length= 5;
     str++; value=(uint) (uchar) (*str - '0');
-    while (++str != end && 
-           my_isdigit(&my_charset_latin1,str[0]) && 
-           field_length--)
-      value=value*10 + (uint) (uchar) (*str - '0');
-    if (field_length)
+    while (++str != end && my_isdigit(&my_charset_latin1, *str))
+    {
+      if (field_length-- > 0)
+        value= value*10 + (uint) (uchar) (*str - '0');
+    }
+    if (field_length > 0)
       value*= (long) log_10_int[field_length];
+    else if (field_length < 0)
+      *was_cut= 1;
     date[4]=value;
   }
   else
     date[4]=0;
+    
+  /* Check for exponent part: E<gigit> | E<sign><digit> */
+  /* (may occur as result of %g formatting of time value) */
+  if ((end - str) > 1 &&
+      (*str == 'e' || *str == 'E') &&
+      (my_isdigit(&my_charset_latin1, str[1]) ||
+       ((str[1] == '-' || str[1] == '+') &&
+        (end - str) > 2 &&
+        my_isdigit(&my_charset_latin1, str[2]))))
+  {
+    *was_cut= 1;
+    return 1;
+  }
 
   if (internal_format_positions[7] != 255)
   {

--- 1.12/mysql-test/r/type_time.result	2004-06-18 10:10:32 +04:00
+++ 1.13/mysql-test/r/type_time.result	2005-12-15 18:48:01 +03:00
@@ -85,3 +85,27 @@
 13:00:00
 09:00:00
 drop table t1;
+SELECT CAST(235959.123456 AS TIME);
+CAST(235959.123456 AS TIME)
+23:59:59.123456
+SELECT CAST(0.235959123456e+6 AS TIME);
+CAST(0.235959123456e+6 AS TIME)
+23:59:59.123456
+SELECT CAST(235959123456e-6 AS TIME);
+CAST(235959123456e-6 AS TIME)
+23:59:59.123456
+SELECT CAST(235959.1234567 AS TIME);
+CAST(235959.1234567 AS TIME)
+23:59:59.123456
+Warnings:
+Warning	1292	Truncated incorrect time value: '235959.1234567'
+SELECT CAST(0.2359591234567e6 AS TIME);
+CAST(0.2359591234567e6 AS TIME)
+23:59:59.123456
+Warnings:
+Warning	1292	Truncated incorrect time value: '235959.1234567'
+SELECT CAST(0.2359591234567e+30 AS TIME);
+CAST(0.2359591234567e+30 AS TIME)
+NULL
+Warnings:
+Warning	1292	Truncated incorrect time value: '2.359591234567e+29'

--- 1.6/mysql-test/t/type_time.test	2005-07-28 04:21:50 +04:00
+++ 1.7/mysql-test/t/type_time.test	2005-12-15 18:48:01 +03:00
@@ -21,4 +21,18 @@
 select sec_to_time(time_to_sec(t)) from t1;
 drop table t1;
 
+#
+# BUG #12440: Incorrect processing of time values containing
+# long fraction part and/or large exponent part.
+#
+# These must return normal result:
+SELECT CAST(235959.123456 AS TIME);
+SELECT CAST(0.235959123456e+6 AS TIME);
+SELECT CAST(235959123456e-6 AS TIME);
+# These must cut fraction part and produce warning:
+SELECT CAST(235959.1234567 AS TIME);
+SELECT CAST(0.2359591234567e6 AS TIME);
+# This must return NULL and produce warning:
+SELECT CAST(0.2359591234567e+30 AS TIME);
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (aivanov:1.2461) BUG#12440Alex Ivanov15 Dec