List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:August 3 2010 4:04pm
Subject:bzr commit into connector-net-trunk branch (vvaintroub:914)
View as plain text  
#At file:///H:/connector_net/trunk/ based on revid:vvaintroub@stripped

  914 Vladislav Vaintroub	2010-08-03 [merge]
      merge

    modified:
      CHANGES
      MySql.Data/Provider/Source/Types/MySqlDouble.cs
      MySql.Data/Tests/Source/DataTypeTests.cs
=== modified file 'CHANGES'
--- a/CHANGES	2010-07-28 21:03:55 +0000
+++ b/CHANGES	2010-08-03 16:04:09 +0000
@@ -1,9 +1,17 @@
+- Handle cases where server returns unparsable (out-of-range) double values
+  (Bug#55644)
 - Fix DataAdapter.Update() slowdown due to many superfluous DataTable.AcceptChanges() calls (Bug #55609)
 - fixed visual studio plugin so that stored procedure editing works on older versions of MySQL (bug #55170)
 - Improve performance of write operaitons (e.g insert) if compression is enabled (Bug #48243)
 
 Version 6.3.3 (beta 2)
 - fix "There is already an open DataReader..." after exceptions in DataReader.Close()
+- fix "There is already an open DataReader..." after exceptions in DataReader.Close()
+ (bug#55558)
+- Improve performance of MySqlHelper.EscapeString()
+- Improve performance of write operations (e.g insert) if compression is enabled
+  (Bug #48243)
+- Improve performance of MySqlHelper.EscapeString()
 - Fix membership provider creation failure, when default database character set is different from latin1 (Bug #53174)
 - Fix "Connection must be valid and open" exception When UpdateBatchSize > 1 
   and MySqlDataAdapter is not using an open connection (Bug #38411)

=== modified file 'MySql.Data/Provider/Source/Types/MySqlDouble.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlDouble.cs	2010-02-26 21:18:30 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlDouble.cs	2010-08-03 15:55:53 +0000
@@ -101,8 +101,23 @@ namespace MySql.Data.Types
                 packet.Read(b, 0, 8);
 				return new MySqlDouble(BitConverter.ToDouble(b, 0));
 			}
-            return new MySqlDouble(Double.Parse(packet.ReadString(length),
-					 CultureInfo.InvariantCulture));
+            string s = packet.ReadString();
+            double d;
+            try
+            {
+                d =  Double.Parse(s, CultureInfo.InvariantCulture);
+            }
+            catch (OverflowException)
+            {
+                // MySQL server < 5.5 can return values not compatible with
+                // Double.Parse(), i.e out of range for double.
+                
+                if (s.StartsWith("-"))
+                    d = double.MinValue;
+                else
+                    d = double.MaxValue;
+            }
+            return new MySqlDouble(d);
 		}
 
 		void IMySqlValue.SkipValue(MySqlPacket packet)

=== modified file 'MySql.Data/Tests/Source/DataTypeTests.cs'
--- a/MySql.Data/Tests/Source/DataTypeTests.cs	2010-02-12 18:58:16 +0000
+++ b/MySql.Data/Tests/Source/DataTypeTests.cs	2010-08-03 16:04:09 +0000
@@ -1058,5 +1058,33 @@ namespace MySql.Data.MySqlClient.Tests
                 Assert.AreEqual(36, columnDefinition[SchemaTableColumn.NumericPrecision]);
             }
         }
+
+        /// <summary>
+        /// Bug #55644 Value was either too large or too small for a Double 
+        /// </summary>
+        [Test]
+        public void DoubleMinValue()
+        {
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test(dbl double)");
+            MySqlCommand cmd = new MySqlCommand("insert into test values(?param1)");
+            cmd.Connection = conn;
+            cmd.Parameters.Add(new MySqlParameter("?param1", MySqlDbType.Double));
+            cmd.Parameters["?param1"].Value = Double.MinValue;
+            cmd.ExecuteNonQuery();
+            cmd.Parameters["?param1"].Value = Double.MaxValue;
+            cmd.ExecuteNonQuery();
+
+            cmd = new MySqlCommand("SELECT * FROM test", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                reader.Read();
+                double d = reader.GetDouble(0);
+                Assert.AreEqual(d, double.MinValue);
+                reader.Read();
+                d = reader.GetDouble(0);
+                Assert.AreEqual(d, double.MaxValue);
+            }
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20100803160409-82f4266ib3fofyaf.bundle
Thread
bzr commit into connector-net-trunk branch (vvaintroub:914) Vladislav Vaintroub3 Aug