public static string GetShowCreateStoreFunctionSql(this MySqlStoreFuncInfo storeFunc, MySqlConnection conn) { var cmd = new MySqlCommand("show create function " + storeFunc.Name, conn); var reader = cmd.ExecuteReader(); string createTableSql = null; int ord_createFunc = reader.GetOrdinal("Create Function"); while (reader.Read()) { createTableSql = reader.GetString(ord_createFunc); } reader.Close(); return(createTableSql); }
public static void ReloadStoreFuncList(this MySqlDatabaseInfo db, MySqlConnection conn, bool readDetail = false) { Use(db, conn); //----------------------------------- //To find out what tables the default database contains var cmd = new MySqlCommand("show function status where db=?db", conn); List <MySqlStoreFuncInfo> storeFuncList = new List <MySqlStoreFuncInfo>(); cmd.Parameters.AddWithValue("?db", db.Name); var reader = cmd.ExecuteReader(); int ord_name = reader.GetOrdinal("Name"); int ord_type = reader.GetOrdinal("Type"); int ord_definer = reader.GetOrdinal("Definer"); int ord_modifed = reader.GetOrdinal("Modified"); int ord_created = reader.GetOrdinal("Created"); while (reader.Read()) { MySqlStoreFuncInfo storeProc = new MySqlStoreFuncInfo(reader.GetString("Name")); storeProc.OwnerDatabase = db; storeFuncList.Add(storeProc); } reader.Close(); //------------- db.StoreFuncs = storeFuncList; //------------ if (readDetail) { foreach (MySqlStoreFuncInfo func in storeFuncList) { func.Sql = func.GetShowCreateStoreFunctionSql(conn); } } }