private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName) { string text = string.Empty; string text2 = spName; int num = spName.IndexOf("."); if (num != -1) { text = spName.Substring(0, num); text2 = spName.Substring(num + 1, spName.Length - num - 1); } string[] array = new string[4]; array[1] = ((text.Length > 0) ? text : connection.CurrentDatabase()); array[2] = text2; MySqlSchemaCollection schemaCollection = connection.GetSchemaCollection("procedures", array); if (schemaCollection.Rows.Count > 1) { throw new MySqlException(Resources.ProcAndFuncSameName); } if (schemaCollection.Rows.Count == 0) { throw new MySqlException(string.Format(Resources.InvalidProcName, text2, text)); } ProcedureCacheEntry procedureCacheEntry = new ProcedureCacheEntry(); procedureCacheEntry.procedure = schemaCollection; ISSchemaProvider iSSchemaProvider = new ISSchemaProvider(connection); string[] restrictions = iSSchemaProvider.CleanRestrictions(array); MySqlSchemaCollection procedureParameters = iSSchemaProvider.GetProcedureParameters(restrictions, schemaCollection); procedureCacheEntry.parameters = procedureParameters; return(procedureCacheEntry); }
private static DataSet GetProcData(MySqlConnection connection, string spName) { string schema = String.Empty; string name = spName; int dotIndex = spName.IndexOf("."); if (dotIndex != -1) { schema = spName.Substring(0, dotIndex); name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1); } string[] restrictions = new string[4]; restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase(); restrictions[2] = name; DataTable procTable = connection.GetSchema("procedures", restrictions); if (procTable.Rows.Count > 1) { throw new MySqlException(Resources.ProcAndFuncSameName); } if (procTable.Rows.Count == 0) { throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema)); } DataSet ds = new DataSet(); ds.Tables.Add(procTable); // we don't use GetSchema here because that would cause another // query of procedures and we don't need that since we already // know the procedure we care about. ISSchemaProvider isp = new ISSchemaProvider(connection); string[] rest = isp.CleanRestrictions(restrictions); try { DataTable parametersTable = isp.GetProcedureParameters(rest, procTable); ds.Tables.Add(parametersTable); } catch (Exception) { } return(ds); }
private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName) { string schema = string.Empty; string name = spName; int dotIndex = spName.IndexOf("`.`"); if (dotIndex != -1) { schema = spName.Substring(1, dotIndex - 1); name = spName.Substring(dotIndex + 3, spName.Length - dotIndex - 4); } string[] restrictions = new string[4]; restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase(); restrictions[2] = name; MySqlSchemaCollection proc = connection.GetSchemaCollection("procedures", restrictions); if (proc.Rows.Count > 1) { throw new MySqlException(Resources.ProcAndFuncSameName); } if (proc.Rows.Count == 0) { string msg = string.Format(Resources.InvalidProcName, name, schema) + " " + string.Format(Resources.ExecuteProcedureUnauthorized, connection.Settings.UserID, connection.Settings.Server); throw new MySqlException(msg); } ProcedureCacheEntry entry = new ProcedureCacheEntry(); entry.procedure = proc; // we don't use GetSchema here because that would cause another // query of procedures and we don't need that since we already // know the procedure we care about. ISSchemaProvider isp = new ISSchemaProvider(connection); string[] rest = isp.CleanRestrictions(restrictions); MySqlSchemaCollection parameters = isp.GetProcedureParameters(rest, proc); entry.parameters = parameters; return(entry); }
private static DataSet GetProcData(MySqlConnection connection, string spName) { string schema = String.Empty; string name = spName; int dotIndex = spName.IndexOf("."); if (dotIndex != -1) { schema = spName.Substring(0, dotIndex); name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1); } string[] restrictions = new string[4]; restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase(); restrictions[2] = name; DataTable procTable = connection.GetSchema("procedures", restrictions); if (procTable.Rows.Count > 1) throw new MySqlException(Resources.ProcAndFuncSameName); if (procTable.Rows.Count == 0) throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema)); DataSet ds = new DataSet(); ds.Tables.Add(procTable); // we don't use GetSchema here because that would cause another // query of procedures and we don't need that since we already // know the procedure we care about. ISSchemaProvider isp = new ISSchemaProvider(connection); string[] rest = isp.CleanRestrictions(restrictions); try { DataTable parametersTable = isp.GetProcedureParameters(rest, procTable); ds.Tables.Add(parametersTable); } catch (Exception) { } return ds; }
public void GetProcedureParametersDoesNotRequireSelectFromMySqlProceduresTable() { if (Version < new Version(5, 5, 3)) return; suExecSQL(String.Format("GRANT ALL ON `{0}`.* to 'simpleuser' identified by 'simpleuser'", database0)); execSQL("DROP PROCEDURE IF EXISTS spTest"); execSQL(@"CREATE PROCEDURE spTest(id INT, name VARCHAR(20)) BEGIN SELECT name; END"); string connStr = GetConnectionString("simpleuser", "simpleuser", true) + ";use procedure bodies=false"; using (MySqlConnection c = new MySqlConnection(connStr)) { c.Open(); string[] restrictions = new string[4]; restrictions[1] = c.Database; restrictions[2] = "spTest"; DataTable procTable = c.GetSchema("procedures", restrictions); ISSchemaProvider isp = new ISSchemaProvider(c); string[] rest = isp.CleanRestrictions(restrictions); MySqlSchemaCollection parametersTable = isp.GetProcedureParameters(rest, new MySqlSchemaCollection( procTable )); Assert.IsNotNull(parametersTable); } }
private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName) { string schema = String.Empty; string name = spName; int dotIndex = spName.IndexOf("."); if (dotIndex != -1) { schema = spName.Substring(0, dotIndex); name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1); } string[] restrictions = new string[4]; restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase(); restrictions[2] = name; MySqlSchemaCollection proc = connection.GetSchemaCollection("procedures", restrictions); if (proc.Rows.Count > 1) throw new MySqlException(Resources.ProcAndFuncSameName); if (proc.Rows.Count == 0) throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema)); ProcedureCacheEntry entry = new ProcedureCacheEntry(); entry.procedure = proc; // we don't use GetSchema here because that would cause another // query of procedures and we don't need that since we already // know the procedure we care about. ISSchemaProvider isp = new ISSchemaProvider(connection); string[] rest = isp.CleanRestrictions(restrictions); MySqlSchemaCollection parameters = isp.GetProcedureParameters(rest, proc); entry.parameters = parameters; return entry; }