diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-07-01 15:53:46 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-07-01 15:53:46 +0200 |
commit | 9ff272fbbd9f8e8bb412cf8ddc12d6e97242ef63 (patch) | |
tree | c9d08724cb81d3b7ffd2f6515930d6df9e4b5bf1 /sql/sql_help.cc | |
parent | 29e9130d60d79b88b9e6593a111ced4363e9225e (diff) | |
download | mariadb-git-9ff272fbbd9f8e8bb412cf8ddc12d6e97242ef63.tar.gz |
A 5.5 version of the fix for Bug #54360 "Deadlock DROP/ALTER/CREATE
DATABASE with open HANDLER"
Remove LOCK_create_db, database name locks, and use metadata locks instead.
This exposes CREATE/DROP/ALTER DATABASE statements to the graph-based
deadlock detector in MDL, and paves the way for a safe, deadlock-free
implementation of RENAME DATABASE.
Database DDL statements will now take exclusive metadata locks on
the database name, while table/view/routine DDL statements take
intention exclusive locks on the database name. This prevents race
conditions between database DDL and table/view/routine DDL.
(e.g. DROP DATABASE with concurrent CREATE/ALTER/DROP TABLE)
By adding database name locks, this patch implements
WL#4450 "DDL locking: CREATE/DROP DATABASE must use database locks" and
WL#4985 "DDL locking: namespace/hierarchical locks".
The patch also changes code to use init_one_table() where appropriate.
The new lock_table_names() function requires TABLE_LIST::db_length to
be set correctly, and this is taken care of by init_one_table().
This patch also adds a simple template to help work with
the mysys HASH data structure.
Most of the patch was written by Konstantin Osipov.
Diffstat (limited to 'sql/sql_help.cc')
-rw-r--r-- | sql/sql_help.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 7bea236269a..4e3df950134 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -643,23 +643,24 @@ bool mysqld_help(THD *thd, const char *mask) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_help"); - bzero((uchar*)tables,sizeof(tables)); - tables[0].alias= tables[0].table_name= (char*) "help_topic"; - tables[0].lock_type= TL_READ; + tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), + C_STRING_WITH_LEN("help_topic"), + "help_topic", TL_READ); + tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), + C_STRING_WITH_LEN("help_category"), + "help_category", TL_READ); + tables[2].init_one_table(C_STRING_WITH_LEN("mysql"), + C_STRING_WITH_LEN("help_relation"), + "help_relation", TL_READ); + tables[3].init_one_table(C_STRING_WITH_LEN("mysql"), + C_STRING_WITH_LEN("help_keyword"), + "help_keyword", TL_READ); tables[0].next_global= tables[0].next_local= tables[0].next_name_resolution_table= &tables[1]; - tables[1].alias= tables[1].table_name= (char*) "help_category"; - tables[1].lock_type= TL_READ; tables[1].next_global= tables[1].next_local= tables[1].next_name_resolution_table= &tables[2]; - tables[2].alias= tables[2].table_name= (char*) "help_relation"; - tables[2].lock_type= TL_READ; tables[2].next_global= tables[2].next_local= tables[2].next_name_resolution_table= &tables[3]; - tables[3].alias= tables[3].table_name= (char*) "help_keyword"; - tables[3].lock_type= TL_READ; - tables[0].db= tables[1].db= tables[2].db= tables[3].db= (char*) "mysql"; - init_mdl_requests(tables); /* HELP must be available under LOCK TABLES. |