diff options
author | unknown <kroki/tomash@moonlight.home> | 2007-03-09 13:17:46 +0300 |
---|---|---|
committer | unknown <kroki/tomash@moonlight.home> | 2007-03-09 13:17:46 +0300 |
commit | b311d870523b6c1bae7e3a49e9d04d2c30bef5b2 (patch) | |
tree | 6197d95ef12f5c0b810b541f1b32c7955b0b1d7b /sql/sp.cc | |
parent | 1b198eeb6893b4095c70df224eafb2c823f8970f (diff) | |
parent | 0ea47f3ed46011263d696f9852190c6a2edf4772 (diff) | |
download | mariadb-git-b311d870523b6c1bae7e3a49e9d04d2c30bef5b2.tar.gz |
Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1
into moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1-bug9953
mysql-test/r/sp-error.result:
Auto merged
mysql-test/r/view.result:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/lock.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/sp.cc:
Auto merged
sql/sql_base.cc:
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_show.cc:
Auto merged
sql/sql_view.cc:
Auto merged
sql/table.cc:
Auto merged
sql/tztime.cc:
Auto merged
storage/myisam/ha_myisam.cc:
Auto merged
sql/sql_yacc.yy:
SCCS merged
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 88 |
1 files changed, 19 insertions, 69 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 0c0bc8e8869..4eea35eeafb 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, ¬_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, ¬_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)); } @@ -364,7 +314,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, @@ -373,7 +323,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); } @@ -1147,7 +1097,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; } |