summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2007-03-20 00:42:11 +0300
committerunknown <kostja@bodhi.local>2007-03-20 00:42:11 +0300
commite9bb08ac0c3fcb0e3ae042de85fd601fdf07344d (patch)
tree430ad1efea83b67994a7f31aab1a92c249366fb6 /sql/sp.cc
parent6bb4208084654c0e7c1218ff1d70cb6298514ab8 (diff)
parent998260ae5abba5dd07c170548b0aa0b7a2713809 (diff)
downloadmariadb-git-e9bb08ac0c3fcb0e3ae042de85fd601fdf07344d.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into bodhi.local:/opt/local/work/mysql-5.1-runtime include/my_global.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/events_scheduling.result: Auto merged BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8: Auto merged BitKeeper/deleted/.del-mysql_create_system_tables.sh: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/events_scheduling.test: Auto merged mysql-test/t/grant_cache.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/view.test: Auto merged scripts/mysql_system_tables_fix.sql: Auto merged sql/event_db_repository.cc: Auto merged sql/event_queue.cc: Auto merged sql/field.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_subselect.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_help.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/share/errmsg.txt: Auto merged sql/tztime.cc: Auto merged storage/innobase/handler/ha_innodb.cc: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/ha_myisam.h: Auto merged mysql-test/r/skip_grants.result: Manualmerge. mysql-test/r/sp.result: Manualmerge. mysql-test/t/skip_grants.test: Manualmerge. mysql-test/t/sp.test: Manualmerge. sql/event_data_objects.cc: Manualmerge.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc88
1 files changed, 19 insertions, 69 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index eef5dc01912..c1a9aac0c24 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -69,24 +69,6 @@ enum
/*
- Close mysql.proc, opened with open_proc_table_for_read().
-
- SYNOPSIS
- close_proc_table()
- thd Thread context
- backup Pointer to Open_tables_state instance which holds
- information about tables which were open before we
- decided to access mysql.proc.
-*/
-
-void close_proc_table(THD *thd, Open_tables_state *backup)
-{
- close_thread_tables(thd);
- thd->restore_backup_open_tables_state(backup);
-}
-
-
-/*
Open the mysql.proc table for read.
SYNOPSIS
@@ -96,13 +78,6 @@ void close_proc_table(THD *thd, Open_tables_state *backup)
currently open tables will be saved, and from which will be
restored when we will end work with mysql.proc.
- NOTES
- Thanks to restrictions which we put on opening and locking of
- this table for writing, we can open and lock it for reading
- even when we already have some other tables open and locked.
- One must call close_proc_table() to close table opened with
- this call.
-
RETURN
0 Error
# Pointer to TABLE object of mysql.proc
@@ -110,38 +85,18 @@ void close_proc_table(THD *thd, Open_tables_state *backup)
TABLE *open_proc_table_for_read(THD *thd, Open_tables_state *backup)
{
- TABLE_LIST tables;
- TABLE *table;
- bool not_used;
- DBUG_ENTER("open_proc_table");
-
- thd->reset_n_backup_open_tables_state(backup);
-
- bzero((char*) &tables, sizeof(tables));
- tables.db= (char*) "mysql";
- tables.table_name= tables.alias= (char*)"proc";
- if (!(table= open_table(thd, &tables, thd->mem_root, &not_used,
- MYSQL_LOCK_IGNORE_FLUSH)))
- {
- thd->restore_backup_open_tables_state(backup);
- DBUG_RETURN(0);
- }
- table->use_all_columns();
+ DBUG_ENTER("open_proc_table_for_read");
- DBUG_ASSERT(table->s->system_table);
+ TABLE_LIST table;
+ bzero((char*) &table, sizeof(table));
+ table.db= (char*) "mysql";
+ table.table_name= table.alias= (char*)"proc";
+ table.lock_type= TL_READ;
- table->reginfo.lock_type= TL_READ;
- /*
- We have to ensure we are not blocked by a flush tables, as this
- could lead to a deadlock if we have other tables opened.
- */
- if (!(thd->lock= mysql_lock_tables(thd, &table, 1,
- MYSQL_LOCK_IGNORE_FLUSH, &not_used)))
- {
- close_proc_table(thd, backup);
+ if (!open_system_tables_for_read(thd, &table, backup))
+ DBUG_RETURN(table.table);
+ else
DBUG_RETURN(0);
- }
- DBUG_RETURN(table);
}
@@ -162,20 +117,15 @@ TABLE *open_proc_table_for_read(THD *thd, Open_tables_state *backup)
static TABLE *open_proc_table_for_update(THD *thd)
{
- TABLE_LIST tables;
- TABLE *table;
- DBUG_ENTER("open_proc_table");
-
- bzero((char*) &tables, sizeof(tables));
- tables.db= (char*) "mysql";
- tables.table_name= tables.alias= (char*)"proc";
- tables.lock_type= TL_WRITE;
+ DBUG_ENTER("open_proc_table_for_update");
- table= open_ltable(thd, &tables, TL_WRITE);
- if (table)
- table->use_all_columns();
+ TABLE_LIST table;
+ bzero((char*) &table, sizeof(table));
+ table.db= (char*) "mysql";
+ table.table_name= table.alias= (char*)"proc";
+ table.lock_type= TL_WRITE;
- DBUG_RETURN(table);
+ DBUG_RETURN(open_system_table_for_update(thd, &table));
}
@@ -363,7 +313,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
chistics.comment.str= ptr;
chistics.comment.length= length;
- close_proc_table(thd, &open_tables_state_backup);
+ close_system_tables(thd, &open_tables_state_backup);
table= 0;
ret= db_load_routine(thd, type, name, sphp,
@@ -372,7 +322,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
done:
if (table)
- close_proc_table(thd, &open_tables_state_backup);
+ close_system_tables(thd, &open_tables_state_backup);
DBUG_RETURN(ret);
}
@@ -1146,7 +1096,7 @@ sp_routine_exists_in_table(THD *thd, int type, sp_name *name)
{
if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK)
ret= SP_KEY_NOT_FOUND;
- close_proc_table(thd, &open_tables_state_backup);
+ close_system_tables(thd, &open_tables_state_backup);
}
return ret;
}