From: Date: November 17 2008 10:19pm Subject: Connector/NET commit: r1461 - in branches/5.2: . MySql.Data/Provider/Properties MySql.Data/Provider/Source MySql.Data/Tests/Source List-Archive: http://lists.mysql.com/commits/59008 X-Bug: 40139 Message-Id: <200811172119.mAHLJ2LX027238@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/5.2/CHANGES branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs branches/5.2/MySql.Data/Provider/Properties/Resources.resx branches/5.2/MySql.Data/Provider/Source/ISSchemaProvider.cs branches/5.2/MySql.Data/Provider/Source/MySqlError.cs branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs branches/5.2/MySql.Data/Tests/Source/StoredProcedure.cs Log: - cleaned up how stored procedure execution operated when the user does or does not have execute privs on the routine (bug #40139) Modified: branches/5.2/CHANGES =================================================================== --- branches/5.2/CHANGES 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/CHANGES 2008-11-17 21:19:02 UTC (rev 1461) @@ -1,3 +1,7 @@ +Version 5.2.6 +- cleaned up how stored procedure execution operated when the user does or does not have execute privs + on the routine (bug #40139) + Version 5.2.5 - 11/14/2008 - fixed problem with package registration that kept the DDEX provider from working (bug #40726) Modified: branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs 2008-11-17 21:19:02 UTC (rev 1461) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1434 +// Runtime Version:2.0.50727.3053 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -592,6 +592,15 @@ } /// + /// Looks up a localized string similar to Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine.. + /// + public static string RoutineNotFound { + get { + return ResourceManager.GetString("RoutineNotFound", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Socket streams do not support seeking. /// public static string SocketNoSeek { Modified: branches/5.2/MySql.Data/Provider/Properties/Resources.resx =================================================================== --- branches/5.2/MySql.Data/Provider/Properties/Resources.resx 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Provider/Properties/Resources.resx 2008-11-17 21:19:02 UTC (rev 1461) @@ -339,4 +339,7 @@ Fatal error encountered attempting to read the resultset. + + Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine. + \ No newline at end of file Modified: branches/5.2/MySql.Data/Provider/Source/ISSchemaProvider.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Source/ISSchemaProvider.cs 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Provider/Source/ISSchemaProvider.cs 2008-11-17 21:19:02 UTC (rev 1461) @@ -189,7 +189,17 @@ // if the user has said that we have access to mysql.proc then // we use that as it is a lot faster if (connection.Settings.UseProcedureBodies) - return base.GetProcedures(restrictions); + { + try + { + return base.GetProcedures(restrictions); + } + catch (MySqlException ex) + { + if (ex.Number == (int)MySqlErrorCode.TableAccessDenied) + throw new InvalidOperationException(Resources.UnableToRetrieveSProcData, ex); + } + } string[] keys = new string[4]; keys[0] = "ROUTINE_CATALOG"; Modified: branches/5.2/MySql.Data/Provider/Source/MySqlError.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Source/MySqlError.cs 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Provider/Source/MySqlError.cs 2008-11-17 21:19:02 UTC (rev 1461) @@ -245,8 +245,10 @@ ER_INVALID_USE_OF_NULL 1138 ER_REGEXP_ERROR 1139 ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140 - ER_NONEXISTING_GRANT 1141 - ER_TABLEACCESS_DENIED_ERROR 1142 + ER_NONEXISTING_GRANT 1141 */ + TableAccessDenied = 1142, + + /* ER_TABLEACCESS_DENIED_ERROR 1142 ER_COLUMNACCESS_DENIED_ERROR 1143 ER_ILLEGAL_GRANT_FOR_TABLE 1144 ER_GRANT_WRONG_HOST_OR_USER 1145 */ Modified: branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs 2008-11-17 21:19:02 UTC (rev 1461) @@ -135,6 +135,9 @@ DataTable procTable = ds.Tables["procedures"]; parametersTable = ds.Tables["procedure parameters"]; + if (procTable.Rows.Count == 0) + throw new InvalidOperationException(String.Format(Resources.RoutineNotFound, spName)); + StringBuilder sqlStr = new StringBuilder(); StringBuilder setStr = new StringBuilder(); outSelect = String.Empty; Modified: branches/5.2/MySql.Data/Tests/Source/StoredProcedure.cs =================================================================== --- branches/5.2/MySql.Data/Tests/Source/StoredProcedure.cs 2008-11-14 18:40:32 UTC (rev 1460) +++ branches/5.2/MySql.Data/Tests/Source/StoredProcedure.cs 2008-11-17 21:19:02 UTC (rev 1461) @@ -1441,5 +1441,63 @@ Assert.AreEqual(22, cmd.Parameters[1].Value); } } + + /// + /// Bug #40139 ExecuteNonQuery hangs + /// + [Test] + public void CallingStoredProcWithOnlyExecPrivs() + { + if (version < new Version(5, 0)) return; + + + execSQL("CREATE PROCEDURE spTest() BEGIN SELECT 1; END"); + execSQL("CREATE PROCEDURE spTest2() BEGIN SELECT 1; END"); + suExecSQL("CREATE USER abc IDENTIFIED BY 'abc'"); + try + { + suExecSQL(String.Format("GRANT SELECT ON `{0}`.* TO 'abc'@'%'", database0)); + suExecSQL(String.Format("GRANT EXECUTE ON PROCEDURE `{0}`.spTest TO abc", database0)); + + string connStr = GetConnectionStringEx("abc", "abc", true); + connStr = connStr.Replace("use procedure bodies=false", ""); + using (MySqlConnection c = new MySqlConnection(connStr)) + { + c.Open(); + MySqlCommand cmd = new MySqlCommand("spTest", c); + cmd.CommandType = CommandType.StoredProcedure; + try + { + object o = cmd.ExecuteScalar(); + Assert.Fail(); + } + catch (InvalidOperationException) + { + } + catch (Exception) + { + Assert.Fail(); + } + + try + { + cmd.CommandText = "spTest2"; + cmd.ExecuteScalar(); + } + catch (InvalidOperationException) + { + } + catch (Exception) + { + Assert.Fail(); + } + + } + } + finally + { + suExecSQL("DROP USER abc"); + } + } } }