summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-03-26 13:14:40 +0200
committerunknown <monty@mysql.com>2004-03-26 13:14:40 +0200
commitbfa269c27dcc0463e30b44f796b73c5837ccd24c (patch)
treedc3cf5c5d9be31f0906d6781853af07672bac4eb /sql/sp.cc
parentd4898d174c7e728a66831a299b8dddfd5ca6e802 (diff)
downloadmariadb-git-bfa269c27dcc0463e30b44f796b73c5837ccd24c.tar.gz
Speed up things if mysql.proc doesn't exists
sql/mysql_priv.h: Added mysql_proc_table_exists sql/opt_range.cc: Simple fix sql/sql_acl.cc: Added mysql_proc_table_exists sql/sql_lex.cc: Simple optimization
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc13
1 files changed, 13 insertions, 0 deletions
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);
}