diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e17847ebe24..706c8235e4a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -878,6 +878,7 @@ extern bool using_update_log, opt_large_files; extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log; extern bool opt_disable_networking, opt_skip_show_db; extern bool volatile abort_loop, shutdown_in_progress, grant_option; +extern bool mysql_proc_table_exists; extern uint volatile thread_count, thread_running, global_read_lock; extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index be1e764ddba..2a89c0ef147 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1347,7 +1347,7 @@ static int get_index_merge_params(PARAM *param, key_map& needed_reg, else { double n_blocks= - ceil((double)(longlong)param->table->file->data_file_length / IO_SIZE); + ceil((double) ((longlong)param->table->file->data_file_length / IO_SIZE)); double busy_blocks= n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, (double) records_for_unique)); diff --git a/sql/sp.cc b/sql/sp.cc index 2be9ceeaad3..2e36f985832 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -57,6 +57,8 @@ enum MYSQL_PROC_FIELD_COUNT }; +bool mysql_proc_table_exists= 1; + /* *opened=true means we opened ourselves */ static int db_find_routine_aux(THD *thd, int type, sp_name *name, @@ -69,6 +71,14 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, DBUG_PRINT("enter", ("type: %d name: %*s", type, name->m_name.length, name->m_name.str)); + /* + Speed up things if mysql.proc doesn't exists + mysql_proc_table_exists is set when on creates a stored procedure + or on flush privileges + */ + if (!mysql_proc_table_exists && ltype == TL_READ) + DBUG_RETURN(SP_OPEN_TABLE_FAILED); + // Put the key used to read the row together keylen= name->m_db.length; if (keylen > 64) @@ -99,10 +109,12 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, if (! (table= open_ltable(thd, &tables, ltype))) { *tablep= NULL; + mysql_proc_table_exists= 0; DBUG_RETURN(SP_OPEN_TABLE_FAILED); } *opened= TRUE; } + mysql_proc_table_exists= 1; if (table->file->index_read_idx(table->record[0], 0, key, keylen, @@ -852,6 +864,7 @@ sp_function_exists(THD *thd, sp_name *name) ret= TRUE; if (opened) close_thread_tables(thd, 0, 1); + thd->clear_error(); DBUG_RETURN(ret); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d294055ff8a..858e7af5b1e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -140,7 +140,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) MYSQL_LOCK *lock; my_bool return_val=1; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; - DBUG_ENTER("acl_init"); if (!acl_cache) @@ -153,6 +152,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) } priv_version++; /* Privileges updated */ + mysql_proc_table_exists= 1; // Assume mysql.proc exists /* To be able to run this from boot, we allocate a temporary THD