~mysql-clr-team/connectornet/5.2

« back to all changes in this revision

Viewing changes to MySql.Data/Tests/Source/TimeoutAndCancel.cs

  • Committer: Reggie Burnett
  • Date: 2009-08-21 18:49:35 UTC
  • Revision ID: reggie.burnett@sun.com-20090821184935-ejcugel9cisz8v6j
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)

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
                }
266
266
            }
267
267
        }
 
268
 
 
269
        /// <summary>
 
270
        /// Bug #45978  Silent problem when net_write_timeout is exceeded
 
271
        /// </summary>
 
272
        [Test]
 
273
        public void NetWriteTimeoutExpiring()
 
274
        {
 
275
            execSQL("CREATE TABLE Test(id int, blob1 longblob)");
 
276
 
 
277
            byte[] b1 = Utils.CreateBlob(5000);
 
278
            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (@id, @b1)", conn);
 
279
            cmd.Parameters.Add("@id", MySqlDbType.Int32);
 
280
            cmd.Parameters.AddWithValue("@name", b1);
 
281
            for (int i = 0; i < 10000; i++)
 
282
            {
 
283
                cmd.Parameters[0].Value = i;
 
284
                cmd.ExecuteNonQuery();
 
285
            }
 
286
 
 
287
            string connStr = GetConnectionString(true);
 
288
            using (MySqlConnection c = new MySqlConnection(connStr))
 
289
            {
 
290
                c.Open();
 
291
                cmd.Connection = c;
 
292
                cmd.Parameters.Clear();
 
293
                cmd.CommandText = "SET net_write_timeout = 1";
 
294
                cmd.ExecuteNonQuery();
 
295
 
 
296
                cmd.CommandText = "SELECT * FROM Test LIMIT 100000";
 
297
                using (MySqlDataReader reader = cmd.ExecuteReader())
 
298
                {
 
299
                    Thread.Sleep(2000);
 
300
                    // after this several cycles of DataReader.Read() are executed 
 
301
                    // normally and then the problem, described above, occurs
 
302
                    int i = 0;
 
303
                    try
 
304
                    {
 
305
                        while (reader.Read())
 
306
                        {
 
307
                            object o = reader[0];
 
308
                            Assert.AreEqual(i++, o);
 
309
                        }
 
310
                        Assert.Fail("This should have failed");
 
311
                    }
 
312
                    catch (Exception ex)
 
313
                    {
 
314
                        string s = ex.Message;
 
315
                    }
 
316
                }
 
317
            }
 
318
        }
268
319
    }
269
320
}