MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:August 21 2009 6:49pm
Subject:bzr commit into connector-net-5.2 branch (reggie.burnett:708) Bug#45978
View as plain text  
#At file:///D:/bzr-connector-net/5.2/ based on revid:reggie.burnett@stripped

  708 Reggie Burnett	2009-08-21
      changed MySqlStream.Read to throw an exception if the stream end is reached.  This is not ideal
        but we can't change it too much here in 5.2.8.  We'll look at a bigger change in 6.2. (bug #45978)

    modified:
      CHANGES
      MySql.Data/Provider/Source/MySqlStream.cs
      MySql.Data/Provider/Source/NativeDriver.cs
      MySql.Data/Tests/Source/TimeoutAndCancel.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2009-08-10 17:57:08 +0000
+++ b/CHANGES	2009-08-21 18:49:35 +0000
@@ -12,6 +12,8 @@
   on Mono 2.0 (bug #46375)
 - fixed a small documentation bug related to our server compatibility
 - fixed GetSByte method to actually return an sbyte  (bug #46620)
+- changed MySqlStream.Read to throw an exception if the stream end is reached.  This is not ideal
+  but we can't change it too much here in 5.2.8.  We'll look at a bigger change in 6.2. (bug #45978)
 
 Version 5.2.7 7/13/09
 - fixed procedure parameters collection so that an exception is thrown if we can't get the 

=== modified file 'MySql.Data/Provider/Source/MySqlStream.cs'
--- a/MySql.Data/Provider/Source/MySqlStream.cs	2008-07-18 19:51:08 +0000
+++ b/MySql.Data/Provider/Source/MySqlStream.cs	2009-08-21 18:49:35 +0000
@@ -357,8 +357,8 @@
 					// we don't throw an exception here even though this probably
 					// indicates a broken connection.  We leave that to the 
 					// caller.
-					if (read == 0)
-						break;
+                    if (read == 0)
+                        throw new MySqlException(Resources.ReadFromStreamFailed, true, null);
 
 					count -= read;
 					offset += read;

=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
--- a/MySql.Data/Provider/Source/NativeDriver.cs	2009-05-14 19:53:26 +0000
+++ b/MySql.Data/Provider/Source/NativeDriver.cs	2009-08-21 18:49:35 +0000
@@ -596,6 +596,8 @@
 
         public override bool SkipDataRow()
         {
+            if (stream == null) return false;
+
             bool result = true;
             if (!stream.HasMoreData)
                 result = FetchDataRow(-1, 0, 0);

=== modified file 'MySql.Data/Tests/Source/TimeoutAndCancel.cs'
--- a/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2008-11-11 21:58:18 +0000
+++ b/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2009-08-21 18:49:35 +0000
@@ -265,5 +265,56 @@
                 }
             }
         }
+
+        /// <summary>
+        /// Bug #45978	Silent problem when net_write_timeout is exceeded
+        /// </summary>
+        [Test]
+        public void NetWriteTimeoutExpiring()
+        {
+            execSQL("CREATE TABLE Test(id int, blob1 longblob)");
+
+            byte[] b1 = Utils.CreateBlob(5000);
+            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (@id, @b1)", conn);
+            cmd.Parameters.Add("@id", MySqlDbType.Int32);
+            cmd.Parameters.AddWithValue("@name", b1);
+            for (int i = 0; i < 10000; i++)
+            {
+                cmd.Parameters[0].Value = i;
+                cmd.ExecuteNonQuery();
+            }
+
+            string connStr = GetConnectionString(true);
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                cmd.Connection = c;
+                cmd.Parameters.Clear();
+                cmd.CommandText = "SET net_write_timeout = 1";
+                cmd.ExecuteNonQuery();
+
+                cmd.CommandText = "SELECT * FROM Test LIMIT 100000";
+                using (MySqlDataReader reader = cmd.ExecuteReader())
+                {
+                    Thread.Sleep(2000);
+                    // after this several cycles of DataReader.Read() are executed 
+                    // normally and then the problem, described above, occurs
+                    int i = 0;
+                    try
+                    {
+                        while (reader.Read())
+                        {
+                            object o = reader[0];
+                            Assert.AreEqual(i++, o);
+                        }
+                        Assert.Fail("This should have failed");
+                    }
+                    catch (Exception ex)
+                    {
+                        string s = ex.Message;
+                    }
+                }
+            }
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20090821184935-ejcugel9cisz8v6j.bundle
Thread
bzr commit into connector-net-5.2 branch (reggie.burnett:708) Bug#45978Reggie Burnett21 Aug