Modified:
trunk/CHANGES
trunk/TestSuite/PreparedStatements.cs
trunk/mysqlclient/Resources.resx
trunk/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: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-09-26 16:16:03 UTC (rev 358)
+++ trunk/CHANGES 2006-09-26 19:54:51 UTC (rev 359)
@@ -75,6 +75,7 @@
Bug #22400 Nested transactions
Bug #11991 ExecuteScalar
Bug #14592 Wrong column length returned for VARCHAR UTF8 columns
+ Bug #18391 Better error handling for the .NET class "MySqlCommand" needed.
Version 1.0.7
Modified: trunk/TestSuite/PreparedStatements.cs
===================================================================
--- trunk/TestSuite/PreparedStatements.cs 2006-09-26 16:16:03 UTC (rev 358)
+++ trunk/TestSuite/PreparedStatements.cs 2006-09-26 19:54:51 UTC (rev 359)
@@ -665,6 +665,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: trunk/mysqlclient/Resources.resx
===================================================================
--- trunk/mysqlclient/Resources.resx 2006-09-26 16:16:03 UTC (rev 358)
+++ trunk/mysqlclient/Resources.resx 2006-09-26 19:54:51 UTC (rev 359)
@@ -270,4 +270,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: trunk/mysqlclient/command.cs
===================================================================
--- trunk/mysqlclient/command.cs 2006-09-26 16:16:03 UTC (rev 358)
+++ trunk/mysqlclient/command.cs 2006-09-26 19:54:51 UTC (rev 359)
@@ -333,6 +333,10 @@
lastInsertedId = -1;
CheckState();
+ if (cmdText == null ||
+ cmdText.Trim().Length == 0)
+ throw new InvalidOperationException(Resources.CommandTextNotInitialized);
+
string sql = TrimSemicolons(cmdText);
//TODO: make these work with prepared statements and stored procedures
@@ -426,6 +430,12 @@
if (! connection.driver.Version.isAtLeast(5,0,0) && cursorPageSize > 0)
throw new InvalidOperationException("Nested commands are only supported on MySQL 5.0
and later");
+ // if the length of the command text is zero, then just return
+ string psSQL = CommandText;
+ if (psSQL == null ||
+ psSQL.Trim().Length == 0)
+ return;
+
PreparedStatement ps = new PreparedStatement(connection, CommandText,
cursorPageSize);
ps.Prepare();
statement = ps;
| Thread |
|---|
| • Connector/NET commit: r359 - in trunk: . TestSuite mysqlclient | rburnett | 26 Sep |