diff options
-rw-r--r-- | sql/sql_base.cc | 37 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 13 |
3 files changed, 20 insertions, 32 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3baca81c2d5..262b0148dfb 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4174,12 +4174,6 @@ end: DBUG_RETURN(error); } -extern "C" uchar *schema_set_get_key(const TABLE_LIST *table, size_t *length, - my_bool not_used __attribute__((unused))) -{ - *length= table->db_length; - return (uchar*) table->db; -} /** Acquire upgradable (SNW, SNRW) metadata locks on tables used by @@ -4217,7 +4211,6 @@ lock_table_names(THD *thd, const DDL_options_st &options, MDL_request_list mdl_requests; TABLE_LIST *table; MDL_request global_request; - Hash_set<TABLE_LIST> schema_set(schema_set_get_key); ulong org_lock_wait_timeout= lock_wait_timeout; /* Check if we are using CREATE TABLE ... IF NOT EXISTS */ bool create_table; @@ -4243,9 +4236,17 @@ lock_table_names(THD *thd, const DDL_options_st &options, DBUG_RETURN(true); } - if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) && - schema_set.insert(table)) - DBUG_RETURN(TRUE); + /* Scoped locks: Take intention exclusive locks on all involved schemas. */ + if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) + { + MDL_request *schema_request= new (thd->mem_root) MDL_request; + if (schema_request == NULL) + DBUG_RETURN(TRUE); + schema_request->init(MDL_key::SCHEMA, table->db, "", + MDL_INTENTION_EXCLUSIVE, + MDL_TRANSACTION); + mdl_requests.push_front(schema_request); + } mdl_requests.push_front(&table->mdl_request); } @@ -4260,22 +4261,6 @@ lock_table_names(THD *thd, const DDL_options_st &options, if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) { /* - Scoped locks: Take intention exclusive locks on all involved - schemas. - */ - Hash_set<TABLE_LIST>::Iterator it(schema_set); - while ((table= it++)) - { - MDL_request *schema_request= new (thd->mem_root) MDL_request; - if (schema_request == NULL) - DBUG_RETURN(TRUE); - schema_request->init(MDL_key::SCHEMA, table->db, "", - MDL_INTENTION_EXCLUSIVE, - MDL_TRANSACTION); - mdl_requests.push_front(schema_request); - } - - /* Protect this statement against concurrent global read lock by acquiring global intention exclusive lock with statement duration. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e5d261e02d4..775f462687c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -562,7 +562,7 @@ void lex_end(LEX *lex) lex->sphead= NULL; } - lex->mi.reset(); + lex->mi.reset(lex->sql_command == SQLCOM_CHANGE_MASTER); DBUG_VOID_RETURN; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 64b07b1927d..7a149a09c1b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -260,12 +260,15 @@ struct LEX_MASTER_INFO my_init_dynamic_array(&repl_ignore_domain_ids, sizeof(ulong), 0, 16, MYF(0)); } - void reset() + void reset(bool is_change_master) { - delete_dynamic(&repl_ignore_server_ids); - /* Free all the array elements. */ - delete_dynamic(&repl_do_domain_ids); - delete_dynamic(&repl_ignore_domain_ids); + if (unlikely(is_change_master)) + { + delete_dynamic(&repl_ignore_server_ids); + /* Free all the array elements. */ + delete_dynamic(&repl_do_domain_ids); + delete_dynamic(&repl_ignore_domain_ids); + } host= user= password= log_file_name= ssl_key= ssl_cert= ssl_ca= ssl_capath= ssl_cipher= relay_log_name= 0; |