List:Commits« Previous MessageNext Message »
From:rburnett Date:January 15 2007 9:45pm
Subject:Connector/NET commit: r554 - in branches/5.0: . Driver/Source TestSuite
View as plain text  
Modified:
   branches/5.0/CHANGES
   branches/5.0/Driver/Source/ISSchemaProvider.cs
   branches/5.0/Driver/Source/Resources.Designer.cs
   branches/5.0/Driver/Source/Resources.resx
   branches/5.0/TestSuite/StoredProcedure.cs
Log:
Bug #25625 Crashes when calling with CommandType set to StoredProcedure 

We added some code to detect the case where the user does not have access to mysql.proc and we throw an InvalidOperationException with a better message.


Modified: branches/5.0/CHANGES
===================================================================
--- branches/5.0/CHANGES	2007-01-15 21:39:09 UTC (rev 553)
+++ branches/5.0/CHANGES	2007-01-15 21:45:15 UTC (rev 554)
@@ -5,6 +5,7 @@
   Bug #25443 ExecuteScalar() hangs when more than one bad result 
   Bug #24802 Error Handling 
   Bug #25614 After connection is closed, and opened again UTF-8 characters are not read well 
+  Bug #25625 Crashes when calling with CommandType set to StoredProcedure 
   
   Other changes
   -------------

Modified: branches/5.0/Driver/Source/ISSchemaProvider.cs
===================================================================
--- branches/5.0/Driver/Source/ISSchemaProvider.cs	2007-01-15 21:39:09 UTC (rev 553)
+++ branches/5.0/Driver/Source/ISSchemaProvider.cs	2007-01-15 21:45:15 UTC (rev 554)
@@ -25,6 +25,7 @@
 using System.Globalization;
 using System.Diagnostics;
 using System.Collections;
+using System.Data.SqlTypes;
 
 namespace MySql.Data.MySqlClient
 {
@@ -366,6 +367,11 @@
                     ParseProcedureBody(parametersTable, reader.GetString(2),
                         routine, nameToRestrict);
                 }
+                catch (SqlNullValueException snex)
+                {
+                    throw new InvalidOperationException(
+                        Resources.UnableToRetrieveSProcData, snex);
+                }
                 catch (Exception)
                 {
                     throw;

Modified: branches/5.0/Driver/Source/Resources.Designer.cs
===================================================================
--- branches/5.0/Driver/Source/Resources.Designer.cs	2007-01-15 21:39:09 UTC (rev 553)
+++ branches/5.0/Driver/Source/Resources.Designer.cs	2007-01-15 21:45:15 UTC (rev 554)
@@ -583,6 +583,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Unable to retrieve stored procedure metadata.  Either grant SELECTprivilege to mysql.proc for this user or use &quot;noAccessToProcedureBody=true&quot; with  your connection string..
+        /// </summary>
+        internal static string UnableToRetrieveSProcData {
+            get {
+                return ResourceManager.GetString("UnableToRetrieveSProcData", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Unix sockets are not supported on Windows.
         /// </summary>
         internal static string UnixSocketsNotSupported {

Modified: branches/5.0/Driver/Source/Resources.resx
===================================================================
--- branches/5.0/Driver/Source/Resources.resx	2007-01-15 21:39:09 UTC (rev 553)
+++ branches/5.0/Driver/Source/Resources.resx	2007-01-15 21:45:15 UTC (rev 554)
@@ -300,4 +300,7 @@
   <data name="UnableToConnectToHost" xml:space="preserve">
     <value>Unable to connect to any of the specified MySQL hosts.</value>
   </data>
+  <data name="UnableToRetrieveSProcData" xml:space="preserve">
+    <value>Unable to retrieve stored procedure metadata.  Either grant SELECTprivilege to mysql.proc for this user or use "noAccessToProcedureBody=true" with  your connection string.</value>
+  </data>
 </root>
\ No newline at end of file

Modified: branches/5.0/TestSuite/StoredProcedure.cs
===================================================================
--- branches/5.0/TestSuite/StoredProcedure.cs	2007-01-15 21:39:09 UTC (rev 553)
+++ branches/5.0/TestSuite/StoredProcedure.cs	2007-01-15 21:45:15 UTC (rev 554)
@@ -1000,5 +1000,57 @@
             Assert.AreEqual(1, cmd.Parameters.Count);
             Assert.AreEqual("?RETURN_VALUE", cmd.Parameters[0].ParameterName);
         }
+
+        /// <summary>
+        /// Bug #25625 Crashes when calling with CommandType set to StoredProcedure 
+        /// </summary>
+        [Test]
+        public void RunWithoutSelectPrivsThrowException()
+        {
+            suExecSQL(String.Format(
+                "GRANT ALL ON {0}.* to 'testuser'@'%' identified by 'testuser'",
+                databases[0]));
+            suExecSQL(String.Format(
+                "GRANT ALL ON {0}.* to 'testuser'@'localhost' identified by 'testuser'",
+                databases[0]));
+
+            execSQL("DROP PROCEDURE IF EXISTS spTest");
+            execSQL("CREATE PROCEDURE spTest(id int, OUT outid int, INOUT inoutid int) " +
+                "BEGIN SET outid=id+inoutid; SET inoutid=inoutid+id; END");
+
+            string s = GetConnectionStringEx("testuser", "testuser", true);
+            MySqlConnection c = new MySqlConnection(s);
+            c.Open();
+
+            try
+            {
+
+                MySqlCommand cmd = new MySqlCommand("spTest", c);
+                cmd.CommandType = CommandType.StoredProcedure;
+                cmd.Parameters.Add("?id", 2);
+                cmd.Parameters.Add("?outid", MySqlDbType.Int32);
+                cmd.Parameters[1].Direction = ParameterDirection.Output;
+                cmd.Parameters.Add("?inoutid", 4);
+                cmd.Parameters[2].Direction = ParameterDirection.InputOutput;
+                cmd.ExecuteNonQuery();
+
+                Assert.AreEqual(6, cmd.Parameters[1].Value);
+                Assert.AreEqual(6, cmd.Parameters[2].Value);
+            }
+            catch (InvalidOperationException iex)
+            {
+                Assert.IsTrue(iex.Message.StartsWith("Unable to retrieve"));
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail(ex.Message);
+            }
+            finally
+            {
+                if (c != null)
+                    c.Close();
+                suExecSQL("DELETE FROM mysql.user WHERE user = 'testuser'");
+            }
+        }
 	}
 }

Thread
Connector/NET commit: r554 - in branches/5.0: . Driver/Source TestSuiterburnett15 Jan