diff options
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/sp.cc | 13 | ||||
-rw-r--r-- | sql/sql_acl.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 |
5 files changed, 17 insertions, 3 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 225be6e7ffd..0d7878301b9 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -867,6 +867,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 fa1b80f007e..9ef283581f2 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1335,7 +1335,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 dca67f803a4..87a741d4779 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -56,6 +56,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, char *name, uint namelen, @@ -67,6 +69,14 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen, DBUG_ENTER("db_find_routine_aux"); DBUG_PRINT("enter", ("type: %d name: %*s", type, namelen, name)); + /* + 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 memset(key, (int)' ', 64); // QQ Empty db for now keylen= namelen; @@ -93,10 +103,12 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen, 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, @@ -718,6 +730,7 @@ sp_function_exists(THD *thd, LEX_STRING *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 2feb9594715..6d66ac38591 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 diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b0381ae1d30..a8f72ecc943 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -169,7 +169,7 @@ static int find_keyword(LEX *lex, uint len, bool function) LEX_STRING ls; ls.str = (char *)tok; ls.length= len; - if (function && sp_function_exists(current_thd, &ls)) // QQ temp fix + if (function && sp_function_exists(lex->thd, &ls)) // QQ temp fix { lex->safe_to_cache_query= 0; lex->yylval->lex_str.str= lex->thd->strmake((char*)lex->tok_start, len); |