Commit 034a2f35 authored by monty@mysql.com's avatar monty@mysql.com

Speed up things if mysql.proc doesn't exists

parent f9e2c6cd
...@@ -867,6 +867,7 @@ extern bool using_update_log, opt_large_files; ...@@ -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_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
extern bool opt_disable_networking, opt_skip_show_db; extern bool opt_disable_networking, opt_skip_show_db;
extern bool volatile abort_loop, shutdown_in_progress, grant_option; 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 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_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; extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names;
......
...@@ -1335,7 +1335,7 @@ static int get_index_merge_params(PARAM *param, key_map& needed_reg, ...@@ -1335,7 +1335,7 @@ static int get_index_merge_params(PARAM *param, key_map& needed_reg,
else else
{ {
double n_blocks= 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= double busy_blocks=
n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, (double) records_for_unique)); n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, (double) records_for_unique));
......
...@@ -56,6 +56,8 @@ enum ...@@ -56,6 +56,8 @@ enum
MYSQL_PROC_FIELD_COUNT MYSQL_PROC_FIELD_COUNT
}; };
bool mysql_proc_table_exists= 1;
/* *opened=true means we opened ourselves */ /* *opened=true means we opened ourselves */
static int static int
db_find_routine_aux(THD *thd, int type, char *name, uint namelen, 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, ...@@ -67,6 +69,14 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen,
DBUG_ENTER("db_find_routine_aux"); DBUG_ENTER("db_find_routine_aux");
DBUG_PRINT("enter", ("type: %d name: %*s", type, namelen, name)); 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 // Put the key used to read the row together
memset(key, (int)' ', 64); // QQ Empty db for now memset(key, (int)' ', 64); // QQ Empty db for now
keylen= namelen; keylen= namelen;
...@@ -93,10 +103,12 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen, ...@@ -93,10 +103,12 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen,
if (! (table= open_ltable(thd, &tables, ltype))) if (! (table= open_ltable(thd, &tables, ltype)))
{ {
*tablep= NULL; *tablep= NULL;
mysql_proc_table_exists= 0;
DBUG_RETURN(SP_OPEN_TABLE_FAILED); DBUG_RETURN(SP_OPEN_TABLE_FAILED);
} }
*opened= TRUE; *opened= TRUE;
} }
mysql_proc_table_exists= 1;
if (table->file->index_read_idx(table->record[0], 0, if (table->file->index_read_idx(table->record[0], 0,
key, keylen, key, keylen,
...@@ -718,6 +730,7 @@ sp_function_exists(THD *thd, LEX_STRING *name) ...@@ -718,6 +730,7 @@ sp_function_exists(THD *thd, LEX_STRING *name)
ret= TRUE; ret= TRUE;
if (opened) if (opened)
close_thread_tables(thd, 0, 1); close_thread_tables(thd, 0, 1);
thd->clear_error();
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
......
...@@ -140,7 +140,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ...@@ -140,7 +140,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
MYSQL_LOCK *lock; MYSQL_LOCK *lock;
my_bool return_val=1; my_bool return_val=1;
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
DBUG_ENTER("acl_init"); DBUG_ENTER("acl_init");
if (!acl_cache) if (!acl_cache)
...@@ -153,6 +152,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ...@@ -153,6 +152,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
} }
priv_version++; /* Privileges updated */ 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 To be able to run this from boot, we allocate a temporary THD
......
...@@ -169,7 +169,7 @@ static int find_keyword(LEX *lex, uint len, bool function) ...@@ -169,7 +169,7 @@ static int find_keyword(LEX *lex, uint len, bool function)
LEX_STRING ls; LEX_STRING ls;
ls.str = (char *)tok; ls.length= len; 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->safe_to_cache_query= 0;
lex->yylval->lex_str.str= lex->thd->strmake((char*)lex->tok_start, len); lex->yylval->lex_str.str= lex->thd->strmake((char*)lex->tok_start, len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment