Modified:
branches/5.1/CHANGES
branches/5.1/Driver/Source/command.cs
branches/5.1/TestSuite/Source/DataReaderTests.cs
Log:
fixed problem where failing ExecuteReader with CommandBehavior set to SchemaOnly leaves
connection in a bad state, limiting number of rows for each subsequent query to 0
(bug #30518)
Modified: branches/5.1/CHANGES
===================================================================
--- branches/5.1/CHANGES 2009-07-02 17:59:18 UTC (rev 1668)
+++ branches/5.1/CHANGES 2009-07-07 13:40:06 UTC (rev 1669)
@@ -1,3 +1,6 @@
+ - fixed problem where failing ExecuteReader with CommandBehavior set to SchemaOnly leaves
+ connection in a bad state ,limiting number of rows for each subsequent query to 0
+ (bug #30518)
Version 5.1.8
- Defaulting max allowed packet to 1024 to account for the possible case where the
value doesn't come in as a server variable
Modified: branches/5.1/Driver/Source/command.cs
===================================================================
--- branches/5.1/Driver/Source/command.cs 2009-07-02 17:59:18 UTC (rev 1668)
+++ branches/5.1/Driver/Source/command.cs 2009-07-07 13:40:06 UTC (rev 1669)
@@ -308,7 +308,14 @@
{
if (statement != null)
statement.Close();
+ ResetSqlSelectLimit();
+ }
+ /// <summary>
+ /// Reset SQL_SELECT_LIMIT that could have been modified by CommandBehavior.
+ /// </summary>
+ internal void ResetSqlSelectLimit()
+ {
// if we are supposed to reset the sql select limit, do that here
if (resetSqlSelect)
new MySqlCommand("SET SQL_SELECT_LIMIT=-1", connection).ExecuteNonQuery();
@@ -412,6 +419,13 @@
}
catch (MySqlException ex)
{
+ try
+ {
+ ResetSqlSelectLimit();
+ }
+ catch (Exception)
+ {
+ }
// if we caught an exception because of a cancel, then just return null
if (ex.Number == 1317)
{
Modified: branches/5.1/TestSuite/Source/DataReaderTests.cs
===================================================================
--- branches/5.1/TestSuite/Source/DataReaderTests.cs 2009-07-02 17:59:18 UTC (rev 1668)
+++ branches/5.1/TestSuite/Source/DataReaderTests.cs 2009-07-07 13:40:06 UTC (rev 1669)
@@ -902,5 +902,50 @@
c2.Dispose();
}
}
+
+ /// <summary>
+ /// Test that using command behavior SchemaOnly does not hose the connection
+ /// by leaving SQL_SELECT_LIMIT set to 0 after the error (and in normal
+ /// case too)
+ ///
+ /// Bug#30518
+ /// </summary>
+ [Test]
+ public void CommandBehaviorSchemaOnly()
+ {
+
+ MySqlConnection c = new MySqlConnection(conn.ConnectionString);
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand("select * from doesnotexist",c);
+ MySqlDataReader reader;
+ try
+ {
+ reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
+ Assert.Fail("should have failed");
+ }
+ catch(MySqlException)
+ {
+ }
+
+ // Check that failed ExecuteReader did not leave SQL_SELECT_LIMIT
+ // set to 0.
+ cmd.CommandText = "select now()";
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ reader.Close();
+
+
+ // Check that CommandBehavior.SchemaOnly does not return rows
+ reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
+ Assert.IsFalse(reader.Read());
+ reader.Close();
+
+
+ reader = cmd.ExecuteReader();
+ // Check that prior setting of CommandBehavior did not
+ // leave SQL_SELECT_LIMIT set to 0
+ Assert.IsTrue(reader.Read());
+ reader.Close();
+ }
}
}
| Thread |
|---|
| • Connector/NET commit: r1669 - in branches/5.1: . Driver/Source TestSuite/Source | vvaintroub | 7 Jul |