Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/PreparedStatements.cs
branches/1.0/TestSuite/StoredProcedure.cs
branches/1.0/mysqlclient/Driver.cs
branches/1.0/mysqlclient/command.cs
Log:
Bug #25609 MySqlDataAdapter.FillSchema
Fixed this by keeping track of what the current value of SQL_SELECT_LIMIT is and by
issuing a command to set it appropriate every time ExecuteReader is called.
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2007-01-23 21:33:39 UTC (rev 566)
+++ branches/1.0/CHANGES 2007-01-23 22:35:17 UTC (rev 567)
@@ -23,6 +23,7 @@
Bug #25625 Crashes when calling with CommandType set to StoredProcedure
Bug #25651 SELECT does not work properly when WHERE contains UTF-8 characters
Bug #25726 MySqlConnection throws NullReferenceException and ArgumentNullException
+ Bug #25609 MySqlDataAdapter.FillSchema
Other changes
-------------
Modified: branches/1.0/TestSuite/PreparedStatements.cs
===================================================================
--- branches/1.0/TestSuite/PreparedStatements.cs 2007-01-23 21:33:39 UTC (rev 566)
+++ branches/1.0/TestSuite/PreparedStatements.cs 2007-01-23 22:35:17 UTC (rev 567)
@@ -714,6 +714,20 @@
{
}
}
+
+ [Test]
+ public void SchemaOnly()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id INT, name VARCHAR(50))");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
+ cmd.Prepare();
+ using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly))
+ {
+ reader.Read();
+ }
+ }
}
#region Configs
Modified: branches/1.0/TestSuite/StoredProcedure.cs
===================================================================
--- branches/1.0/TestSuite/StoredProcedure.cs 2007-01-23 21:33:39 UTC (rev 566)
+++ branches/1.0/TestSuite/StoredProcedure.cs 2007-01-23 22:35:17 UTC (rev 567)
@@ -1069,5 +1069,28 @@
Assert.Fail(ex.Message);
}
}
+
+ /// <summary>
+ /// Bug #25609 MySqlDataAdapter.FillSchema
+ /// </summary>
+ [Test]
+ public void GetSchema()
+ {
+ try
+ {
+ execSQL("CREATE PROCEDURE spTest() BEGIN SELECT * FROM test; END");
+
+ MySqlCommand cmd = new MySqlCommand("spTest", conn);
+ cmd.CommandType = CommandType.StoredProcedure;
+ MySqlDataAdapter da = new MySqlDataAdapter(cmd);
+ DataTable schema = new DataTable();
+ da.FillSchema(schema, SchemaType.Source);
+ Assert.AreEqual(2, schema.Columns.Count);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ }
}
}
Modified: branches/1.0/mysqlclient/Driver.cs
===================================================================
--- branches/1.0/mysqlclient/Driver.cs 2007-01-23 21:33:39 UTC (rev 566)
+++ branches/1.0/mysqlclient/Driver.cs 2007-01-23 22:35:17 UTC (rev 567)
@@ -45,12 +45,14 @@
protected Hashtable charSets;
protected bool hasWarnings;
protected long maxPacketSize;
+ internal int selectLimit;
public Driver(MySqlConnectionString settings)
{
encoding = System.Text.Encoding.GetEncoding("latin1");
connectionString = settings;
threadId = -1;
+ selectLimit = -1;
}
#region Properties
Modified: branches/1.0/mysqlclient/command.cs
===================================================================
--- branches/1.0/mysqlclient/command.cs 2007-01-23 21:33:39 UTC (rev 566)
+++ branches/1.0/mysqlclient/command.cs 2007-01-23 22:35:17 UTC (rev 567)
@@ -402,16 +402,6 @@
string sql = TrimSemicolons(cmdText);
- if (0 != (behavior & CommandBehavior.SchemaOnly))
- {
- sql = "SET SQL_SELECT_LIMIT=0;" + sql + ";SET sql_select_limit=-1";
- }
-
- if (0 != (behavior & CommandBehavior.SingleRow))
- {
- sql = "SET SQL_SELECT_LIMIT=1;" + sql + ";SET sql_select_limit=-1";
- }
-
updateCount = -1;
MySqlDataReader reader = new MySqlDataReader(this, behavior);
@@ -421,6 +411,8 @@
else
preparedStatement.ExecutionCount = 0;
+ HandleCommandBehaviors(behavior);
+
reader.NextResult();
connection.Reader = reader;
return reader;
@@ -492,6 +484,34 @@
#region Private Methods
+ private void HandleCommandBehaviors(CommandBehavior behavior)
+ {
+ MySqlCommand cmd = new MySqlCommand("", connection);
+ int selectLimit = -1;
+
+ // if we are asked to provide only schema or single row resultsets, then
+ // set SQL_SELECT_LIMIT to optimize the process
+ if (0 != (behavior & CommandBehavior.SchemaOnly))
+ selectLimit = 0;
+ else if (0 != (behavior & CommandBehavior.SingleRow))
+ selectLimit = 1;
+ else if (connection.driver.selectLimit != -1)
+ selectLimit = -1;
+ else
+ return;
+
+ try
+ {
+ cmd.CommandText = String.Format("SET SQL_SELECT_LIMIT={0}", selectLimit);
+ cmd.ExecuteNonQuery();
+ connection.driver.selectLimit = selectLimit;
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ }
+
private string TrimSemicolons(string sql)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(sql);
| Thread |
|---|
| • Connector/NET commit: r567 - in branches/1.0: . TestSuite mysqlclient | rburnett | 23 Jan |