Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/PreparedStatements.cs
branches/1.0/mysqlclient/Resources.resx
branches/1.0/mysqlclient/command.cs
Log:
Bug #18391 Better error handling for the .NET class "MySqlCommand" needed.
Added code to not execute prepare stage if command text is null or empty string. Also, attempting to execute a command text that is null or zero length will throw an InvalidOperationException which matches what SqlClient does.
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2006-09-26 19:54:51 UTC (rev 359)
+++ branches/1.0/CHANGES 2006-09-26 19:55:18 UTC (rev 360)
@@ -31,6 +31,7 @@
Bug #7248 There is already an open DataReader associated with this Connection which must
Bug #11991 ExecuteScalar
Bug #14592 Wrong column length returned for VARCHAR UTF8 columns
+ Bug #18391 Better error handling for the .NET class "MySqlCommand" needed.
x-xx-05 - Version 1.0.7
Modified: branches/1.0/TestSuite/PreparedStatements.cs
===================================================================
--- branches/1.0/TestSuite/PreparedStatements.cs 2006-09-26 19:54:51 UTC (rev 359)
+++ branches/1.0/TestSuite/PreparedStatements.cs 2006-09-26 19:55:18 UTC (rev 360)
@@ -664,6 +664,28 @@
reader.Close();
}
}
+
+ /// <summary>
+ /// Bug #18391 Better error handling for the .NET class "MySqlCommand" needed.
+ /// </summary>
+ [Test]
+ public void PrepareEmptyString()
+ {
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand("", conn);
+ cmd.Prepare();
+ cmd.ExecuteNonQuery();
+ Assert.Fail("Should not get here");
+ }
+ catch (InvalidOperationException)
+ {
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ }
}
#region Configs
Modified: branches/1.0/mysqlclient/Resources.resx
===================================================================
--- branches/1.0/mysqlclient/Resources.resx 2006-09-26 19:54:51 UTC (rev 359)
+++ branches/1.0/mysqlclient/Resources.resx 2006-09-26 19:55:18 UTC (rev 360)
@@ -237,4 +237,7 @@
<data name="NoNestedTransactions" xml:space="preserve">
<value>Nested transactions are not supported.</value>
</data>
+ <data name="CommandTextNotInitialized" xml:space="preserve">
+ <value>The CommandText property has not been properly initialized.</value>
+ </data>
</root>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/command.cs
===================================================================
--- branches/1.0/mysqlclient/command.cs 2006-09-26 19:54:51 UTC (rev 359)
+++ branches/1.0/mysqlclient/command.cs 2006-09-26 19:55:18 UTC (rev 360)
@@ -340,8 +340,12 @@
{
CheckState();
- updateCount = 0;
+ if (cmdText == null ||
+ cmdText.Trim().Length == 0)
+ throw new InvalidOperationException(Resources.CommandTextNotInitialized);
+ updateCount = 0;
+
if (preparedStatement == null)
sqlBuffers = PrepareSqlBuffers(CommandText);
else
@@ -382,6 +386,10 @@
{
CheckState();
+ if (cmdText == null ||
+ cmdText.Trim().Length == 0)
+ throw new InvalidOperationException(Resources.CommandTextNotInitialized);
+
string sql = TrimSemicolons(cmdText);
if (0 != (behavior & CommandBehavior.SchemaOnly))
@@ -412,8 +420,11 @@
public object ExecuteScalar()
{
// ExecuteReader will check out state
+ if (cmdText == null ||
+ cmdText.Trim().Length == 0)
+ throw new InvalidOperationException(Resources.CommandTextNotInitialized);
- updateCount = -1;
+ updateCount = -1;
object val = null;
MySqlDataReader reader = null;
@@ -447,7 +458,11 @@
return;
// strip out names from parameter markers
+ // if the length of the command text is zero, then just return
string psSQL = CommandText;
+ if (psSQL == null ||
+ psSQL.Trim().Length == 0)
+ return;
if (CommandType == CommandType.StoredProcedure)
{
| Thread |
|---|
| • Connector/NET commit: r360 - in branches/1.0: . TestSuite mysqlclient | rburnett | 26 Sep |