mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
Backport of:
------------------------------------------------------------ revno: 2630.4.17 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w2 timestamp: Thu 2008-05-29 16:52:56 +0400 message: WL#3726 "DDL locking for all metadata objects". After review fixes in progress. "The great correction of names". Renamed MDL_LOCK and MDL_LOCK_DATA classes to make usage of these names in metadata locking subsystem consistent with other parts of server (i.e. thr_lock.cc). Now we MDL_LOCK_DATA corresponds to request for a lock and MDL_LOCK to the lock itself. Adjusted code in MDL subsystem and other places using these classes accordingly. Did similar thing for GLOBAL_MDL_LOCK_DATA class and also changed name of its members to correspond to names of MDL_LOCK_DATA members. Finally got rid of usage of one letter variables in MDL code since it makes code harder to search in (according to reviewer).
This commit is contained in:
parent
f56cc2a335
commit
a9dbad1afd
14 changed files with 484 additions and 460 deletions
|
@ -140,8 +140,8 @@ static Uint64 *p_latest_trans_gci= 0;
|
||||||
*/
|
*/
|
||||||
static TABLE *ndb_binlog_index= 0;
|
static TABLE *ndb_binlog_index= 0;
|
||||||
static TABLE_LIST binlog_tables;
|
static TABLE_LIST binlog_tables;
|
||||||
static MDL_LOCK binlog_mdl_lock;
|
static MDL_LOCK_DATA binlog_mdl_lock_data;
|
||||||
static char binlog_mdlkey[MAX_DBKEY_LENGTH];
|
static char binlog_mdlkey[MAX_DBKEY_LENGTH];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Helper functions
|
Helper functions
|
||||||
|
@ -2343,9 +2343,9 @@ static int open_ndb_binlog_index(THD *thd, TABLE **ndb_binlog_index)
|
||||||
tables->alias= tables->table_name= reptable;
|
tables->alias= tables->table_name= reptable;
|
||||||
tables->lock_type= TL_WRITE;
|
tables->lock_type= TL_WRITE;
|
||||||
thd->proc_info= "Opening " NDB_REP_DB "." NDB_REP_TABLE;
|
thd->proc_info= "Opening " NDB_REP_DB "." NDB_REP_TABLE;
|
||||||
mdl_init_lock(&binlog_mdl_lock, binlog_mdlkey, 0, tables->db,
|
mdl_init_lock(&binlog_mdl_lock_data, binlog_mdlkey, 0, tables->db,
|
||||||
tables->table_name);
|
tables->table_name);
|
||||||
tables->mdl_lock= &binlog_mdl_lock;
|
tables->mdl_lock_data= &binlog_mdl_lock_data;
|
||||||
tables->required_type= FRMTYPE_TABLE;
|
tables->required_type= FRMTYPE_TABLE;
|
||||||
uint counter;
|
uint counter;
|
||||||
thd->clear_error();
|
thd->clear_error();
|
||||||
|
|
11
sql/lock.cc
11
sql/lock.cc
|
@ -966,15 +966,16 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
|
||||||
bool lock_table_names(THD *thd, TABLE_LIST *table_list)
|
bool lock_table_names(THD *thd, TABLE_LIST *table_list)
|
||||||
{
|
{
|
||||||
TABLE_LIST *lock_table;
|
TABLE_LIST *lock_table;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
|
|
||||||
for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
|
for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
|
||||||
{
|
{
|
||||||
if (!(mdl_lock= mdl_alloc_lock(0, lock_table->db, lock_table->table_name,
|
if (!(mdl_lock_data= mdl_alloc_lock(0, lock_table->db,
|
||||||
thd->mem_root)))
|
lock_table->table_name,
|
||||||
|
thd->mem_root)))
|
||||||
goto end;
|
goto end;
|
||||||
mdl_set_lock_type(mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, mdl_lock);
|
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
}
|
}
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -8058,7 +8058,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
|
||||||
{
|
{
|
||||||
RPL_TABLE_LIST *table_list;
|
RPL_TABLE_LIST *table_list;
|
||||||
char *db_mem, *tname_mem, *mdlkey;
|
char *db_mem, *tname_mem, *mdlkey;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
size_t dummy_len;
|
size_t dummy_len;
|
||||||
void *memory;
|
void *memory;
|
||||||
DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)");
|
DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)");
|
||||||
|
@ -8073,7 +8073,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
|
||||||
&table_list, (uint) sizeof(RPL_TABLE_LIST),
|
&table_list, (uint) sizeof(RPL_TABLE_LIST),
|
||||||
&db_mem, (uint) NAME_LEN + 1,
|
&db_mem, (uint) NAME_LEN + 1,
|
||||||
&tname_mem, (uint) NAME_LEN + 1,
|
&tname_mem, (uint) NAME_LEN + 1,
|
||||||
&mdl_lock, sizeof(MDL_LOCK),
|
&mdl_lock_data, sizeof(MDL_LOCK_DATA),
|
||||||
&mdlkey, MAX_DBKEY_LENGTH,
|
&mdlkey, MAX_DBKEY_LENGTH,
|
||||||
NullS)))
|
NullS)))
|
||||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||||
|
@ -8087,8 +8087,9 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
|
||||||
table_list->updating= 1;
|
table_list->updating= 1;
|
||||||
strmov(table_list->db, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len));
|
strmov(table_list->db, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len));
|
||||||
strmov(table_list->table_name, m_tblnam);
|
strmov(table_list->table_name, m_tblnam);
|
||||||
mdl_init_lock(mdl_lock, mdlkey, 0, table_list->db, table_list->table_name);
|
mdl_init_lock(mdl_lock_data, mdlkey, 0, table_list->db,
|
||||||
table_list->mdl_lock= mdl_lock;
|
table_list->table_name);
|
||||||
|
table_list->mdl_lock_data= mdl_lock_data;
|
||||||
|
|
||||||
int error= 0;
|
int error= 0;
|
||||||
|
|
||||||
|
|
624
sql/mdl.cc
624
sql/mdl.cc
File diff suppressed because it is too large
Load diff
94
sql/mdl.h
94
sql/mdl.h
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
class THD;
|
class THD;
|
||||||
|
|
||||||
struct MDL_LOCK;
|
|
||||||
struct MDL_LOCK_DATA;
|
struct MDL_LOCK_DATA;
|
||||||
|
struct MDL_LOCK;
|
||||||
struct MDL_CONTEXT;
|
struct MDL_CONTEXT;
|
||||||
|
|
||||||
/** Type of metadata lock request. */
|
/** Type of metadata lock request. */
|
||||||
|
@ -54,7 +54,7 @@ enum enum_mdl_prio {MDL_NORMAL_PRIO=0, MDL_HIGH_PRIO};
|
||||||
"key" or "name".
|
"key" or "name".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct MDL_LOCK
|
struct MDL_LOCK_DATA
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
uint key_length;
|
uint key_length;
|
||||||
|
@ -72,17 +72,17 @@ private:
|
||||||
/**
|
/**
|
||||||
Pointers for participating in the list of lock requests for this context.
|
Pointers for participating in the list of lock requests for this context.
|
||||||
*/
|
*/
|
||||||
MDL_LOCK *next_context;
|
MDL_LOCK_DATA *next_context;
|
||||||
MDL_LOCK **prev_context;
|
MDL_LOCK_DATA **prev_context;
|
||||||
/**
|
/**
|
||||||
Pointers for participating in the list of satisfied/pending requests
|
Pointers for participating in the list of satisfied/pending requests
|
||||||
for the lock.
|
for the lock.
|
||||||
*/
|
*/
|
||||||
MDL_LOCK *next_lock;
|
MDL_LOCK_DATA *next_lock;
|
||||||
MDL_LOCK **prev_lock;
|
MDL_LOCK_DATA **prev_lock;
|
||||||
|
|
||||||
friend struct MDL_LOCK_context;
|
friend struct MDL_LOCK_DATA_context;
|
||||||
friend struct MDL_LOCK_lock;
|
friend struct MDL_LOCK_DATA_lock;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
|
@ -90,23 +90,23 @@ public:
|
||||||
request is satisified or is present in the list of pending lock requests
|
request is satisified or is present in the list of pending lock requests
|
||||||
for particular lock.
|
for particular lock.
|
||||||
*/
|
*/
|
||||||
MDL_LOCK_DATA *lock_data;
|
MDL_LOCK *lock;
|
||||||
MDL_CONTEXT *ctx;
|
MDL_CONTEXT *ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper class which specifies which members of MDL_LOCK are used for
|
Helper class which specifies which members of MDL_LOCK_DATA are used for
|
||||||
participation in the list lock requests belonging to one context.
|
participation in the list lock requests belonging to one context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct MDL_LOCK_context
|
struct MDL_LOCK_DATA_context
|
||||||
{
|
{
|
||||||
static inline MDL_LOCK **next_ptr(MDL_LOCK *l)
|
static inline MDL_LOCK_DATA **next_ptr(MDL_LOCK_DATA *l)
|
||||||
{
|
{
|
||||||
return &l->next_context;
|
return &l->next_context;
|
||||||
}
|
}
|
||||||
static inline MDL_LOCK ***prev_ptr(MDL_LOCK *l)
|
static inline MDL_LOCK_DATA ***prev_ptr(MDL_LOCK_DATA *l)
|
||||||
{
|
{
|
||||||
return &l->prev_context;
|
return &l->prev_context;
|
||||||
}
|
}
|
||||||
|
@ -114,17 +114,17 @@ struct MDL_LOCK_context
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper class which specifies which members of MDL_LOCK are used for
|
Helper class which specifies which members of MDL_LOCK_DATA are used for
|
||||||
participation in the list of satisfied/pending requests for the lock.
|
participation in the list of satisfied/pending requests for the lock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct MDL_LOCK_lock
|
struct MDL_LOCK_DATA_lock
|
||||||
{
|
{
|
||||||
static inline MDL_LOCK **next_ptr(MDL_LOCK *l)
|
static inline MDL_LOCK_DATA **next_ptr(MDL_LOCK_DATA *l)
|
||||||
{
|
{
|
||||||
return &l->next_lock;
|
return &l->next_lock;
|
||||||
}
|
}
|
||||||
static inline MDL_LOCK ***prev_ptr(MDL_LOCK *l)
|
static inline MDL_LOCK_DATA ***prev_ptr(MDL_LOCK_DATA *l)
|
||||||
{
|
{
|
||||||
return &l->prev_lock;
|
return &l->prev_lock;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ struct MDL_LOCK_lock
|
||||||
|
|
||||||
struct MDL_CONTEXT
|
struct MDL_CONTEXT
|
||||||
{
|
{
|
||||||
I_P_List <MDL_LOCK, MDL_LOCK_context> locks;
|
I_P_List <MDL_LOCK_DATA, MDL_LOCK_DATA_context> locks;
|
||||||
bool has_global_shared_lock;
|
bool has_global_shared_lock;
|
||||||
THD *thd;
|
THD *thd;
|
||||||
};
|
};
|
||||||
|
@ -153,21 +153,21 @@ void mdl_context_backup_and_reset(MDL_CONTEXT *ctx, MDL_CONTEXT *backup);
|
||||||
void mdl_context_restore(MDL_CONTEXT *ctx, MDL_CONTEXT *backup);
|
void mdl_context_restore(MDL_CONTEXT *ctx, MDL_CONTEXT *backup);
|
||||||
void mdl_context_merge(MDL_CONTEXT *target, MDL_CONTEXT *source);
|
void mdl_context_merge(MDL_CONTEXT *target, MDL_CONTEXT *source);
|
||||||
|
|
||||||
void mdl_init_lock(MDL_LOCK *mdl, char *key, int type, const char *db,
|
void mdl_init_lock(MDL_LOCK_DATA *lock_data, char *key, int type,
|
||||||
const char *name);
|
const char *db, const char *name);
|
||||||
MDL_LOCK *mdl_alloc_lock(int type, const char *db, const char *name,
|
MDL_LOCK_DATA *mdl_alloc_lock(int type, const char *db, const char *name,
|
||||||
MEM_ROOT *root);
|
MEM_ROOT *root);
|
||||||
void mdl_add_lock(MDL_CONTEXT *context, MDL_LOCK *lock);
|
void mdl_add_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data);
|
||||||
void mdl_remove_all_locks(MDL_CONTEXT *context);
|
void mdl_remove_all_locks(MDL_CONTEXT *context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set type of lock request. Can be only applied to pending locks.
|
Set type of lock request. Can be only applied to pending locks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void mdl_set_lock_type(MDL_LOCK *lock, enum_mdl_type lock_type)
|
inline void mdl_set_lock_type(MDL_LOCK_DATA *lock_data, enum_mdl_type lock_type)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(lock->state == MDL_PENDING);
|
DBUG_ASSERT(lock_data->state == MDL_PENDING);
|
||||||
lock->type= lock_type;
|
lock_data->type= lock_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,10 +175,10 @@ inline void mdl_set_lock_type(MDL_LOCK *lock, enum_mdl_type lock_type)
|
||||||
for shared locks.
|
for shared locks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void mdl_set_lock_priority(MDL_LOCK *lock, enum_mdl_prio prio)
|
inline void mdl_set_lock_priority(MDL_LOCK_DATA *lock_data, enum_mdl_prio prio)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(lock->type == MDL_SHARED && lock->state == MDL_PENDING);
|
DBUG_ASSERT(lock_data->type == MDL_SHARED && lock_data->state == MDL_PENDING);
|
||||||
lock->prio= prio;
|
lock_data->prio= prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,24 +186,25 @@ inline void mdl_set_lock_priority(MDL_LOCK *lock, enum_mdl_prio prio)
|
||||||
to pending locks.
|
to pending locks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void mdl_set_upgradable(MDL_LOCK *lock)
|
inline void mdl_set_upgradable(MDL_LOCK_DATA *lock_data)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(lock->type == MDL_SHARED && lock->state == MDL_PENDING);
|
DBUG_ASSERT(lock_data->type == MDL_SHARED && lock_data->state == MDL_PENDING);
|
||||||
lock->is_upgradable= TRUE;
|
lock_data->is_upgradable= TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mdl_acquire_shared_lock(MDL_LOCK *l, bool *retry);
|
bool mdl_acquire_shared_lock(MDL_LOCK_DATA *lock_data, bool *retry);
|
||||||
bool mdl_acquire_exclusive_locks(MDL_CONTEXT *context);
|
bool mdl_acquire_exclusive_locks(MDL_CONTEXT *context);
|
||||||
bool mdl_upgrade_shared_lock_to_exclusive(MDL_CONTEXT *context, int type,
|
bool mdl_upgrade_shared_lock_to_exclusive(MDL_CONTEXT *context, int type,
|
||||||
const char *db, const char *name);
|
const char *db, const char *name);
|
||||||
bool mdl_try_acquire_exclusive_lock(MDL_CONTEXT *context, MDL_LOCK *lock);
|
bool mdl_try_acquire_exclusive_lock(MDL_CONTEXT *context,
|
||||||
|
MDL_LOCK_DATA *lock_data);
|
||||||
bool mdl_acquire_global_shared_lock(MDL_CONTEXT *context);
|
bool mdl_acquire_global_shared_lock(MDL_CONTEXT *context);
|
||||||
|
|
||||||
bool mdl_wait_for_locks(MDL_CONTEXT *context);
|
bool mdl_wait_for_locks(MDL_CONTEXT *context);
|
||||||
|
|
||||||
void mdl_release_locks(MDL_CONTEXT *context);
|
void mdl_release_locks(MDL_CONTEXT *context);
|
||||||
void mdl_release_exclusive_locks(MDL_CONTEXT *context);
|
void mdl_release_exclusive_locks(MDL_CONTEXT *context);
|
||||||
void mdl_release_lock(MDL_CONTEXT *context, MDL_LOCK *lock);
|
void mdl_release_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data);
|
||||||
void mdl_downgrade_exclusive_locks(MDL_CONTEXT *context);
|
void mdl_downgrade_exclusive_locks(MDL_CONTEXT *context);
|
||||||
void mdl_release_global_shared_lock(MDL_CONTEXT *context);
|
void mdl_release_global_shared_lock(MDL_CONTEXT *context);
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ bool mdl_is_exclusive_lock_owner(MDL_CONTEXT *context, int type, const char *db,
|
||||||
bool mdl_is_lock_owner(MDL_CONTEXT *context, int type, const char *db,
|
bool mdl_is_lock_owner(MDL_CONTEXT *context, int type, const char *db,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
bool mdl_has_pending_conflicting_lock(MDL_LOCK *l);
|
bool mdl_has_pending_conflicting_lock(MDL_LOCK_DATA *lock_data);
|
||||||
|
|
||||||
inline bool mdl_has_locks(MDL_CONTEXT *context)
|
inline bool mdl_has_locks(MDL_CONTEXT *context)
|
||||||
{
|
{
|
||||||
|
@ -224,9 +225,10 @@ inline bool mdl_has_locks(MDL_CONTEXT *context)
|
||||||
Get iterator for walking through all lock requests in the context.
|
Get iterator for walking through all lock requests in the context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline I_P_List_iterator<MDL_LOCK, MDL_LOCK_context> mdl_get_locks(MDL_CONTEXT *ctx)
|
inline I_P_List_iterator<MDL_LOCK_DATA, MDL_LOCK_DATA_context>
|
||||||
|
mdl_get_locks(MDL_CONTEXT *ctx)
|
||||||
{
|
{
|
||||||
I_P_List_iterator<MDL_LOCK, MDL_LOCK_context> result(ctx->locks);
|
I_P_List_iterator<MDL_LOCK_DATA, MDL_LOCK_DATA_context> result(ctx->locks);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,9 +236,9 @@ inline I_P_List_iterator<MDL_LOCK, MDL_LOCK_context> mdl_get_locks(MDL_CONTEXT *
|
||||||
Give metadata lock request object for the table get table definition
|
Give metadata lock request object for the table get table definition
|
||||||
cache key corresponding to it.
|
cache key corresponding to it.
|
||||||
|
|
||||||
@param l [in] Lock request object for the table.
|
@param lock_data [in] Lock request object for the table.
|
||||||
@param key [out] LEX_STRING object where table definition cache key
|
@param key [out] LEX_STRING object where table definition cache key
|
||||||
should be put.
|
should be put.
|
||||||
|
|
||||||
@note This key will have the same life-time as this lock request object.
|
@note This key will have the same life-time as this lock request object.
|
||||||
|
|
||||||
|
@ -245,16 +247,16 @@ inline I_P_List_iterator<MDL_LOCK, MDL_LOCK_context> mdl_get_locks(MDL_CONTEXT *
|
||||||
and memory by avoiding generating these TDC keys from table list.
|
and memory by avoiding generating these TDC keys from table list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void mdl_get_tdc_key(MDL_LOCK *l, LEX_STRING *key)
|
inline void mdl_get_tdc_key(MDL_LOCK_DATA *lock_data, LEX_STRING *key)
|
||||||
{
|
{
|
||||||
key->str= l->key + 4;
|
key->str= lock_data->key + 4;
|
||||||
key->length= l->key_length - 4;
|
key->length= lock_data->key_length - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef void (* mdl_cached_object_release_hook)(void *);
|
typedef void (* mdl_cached_object_release_hook)(void *);
|
||||||
void* mdl_get_cached_object(MDL_LOCK *l);
|
void* mdl_get_cached_object(MDL_LOCK_DATA *lock_data);
|
||||||
void mdl_set_cached_object(MDL_LOCK *l, void *cached_object,
|
void mdl_set_cached_object(MDL_LOCK_DATA *lock_data, void *cached_object,
|
||||||
mdl_cached_object_release_hook release_hook);
|
mdl_cached_object_release_hook release_hook);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3984,9 +3984,10 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||||
table->prelocking_placeholder= 1;
|
table->prelocking_placeholder= 1;
|
||||||
table->belong_to_view= belong_to_view;
|
table->belong_to_view= belong_to_view;
|
||||||
table->trg_event_map= stab->trg_event_map;
|
table->trg_event_map= stab->trg_event_map;
|
||||||
table->mdl_lock= mdl_alloc_lock(0, table->db, table->table_name,
|
table->mdl_lock_data= mdl_alloc_lock(0, table->db, table->table_name,
|
||||||
thd->mdl_el_root ? thd->mdl_el_root :
|
thd->mdl_el_root ?
|
||||||
thd->mem_root);
|
thd->mdl_el_root :
|
||||||
|
thd->mem_root);
|
||||||
|
|
||||||
/* Everyting else should be zeroed */
|
/* Everyting else should be zeroed */
|
||||||
|
|
||||||
|
@ -4028,9 +4029,9 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
|
||||||
table->lock_type= locktype;
|
table->lock_type= locktype;
|
||||||
table->select_lex= lex->current_select;
|
table->select_lex= lex->current_select;
|
||||||
table->cacheable_table= 1;
|
table->cacheable_table= 1;
|
||||||
table->mdl_lock= mdl_alloc_lock(0, table->db, table->table_name,
|
table->mdl_lock_data= mdl_alloc_lock(0, table->db, table->table_name,
|
||||||
thd->mdl_el_root ? thd->mdl_el_root :
|
thd->mdl_el_root ? thd->mdl_el_root :
|
||||||
thd->mem_root);
|
thd->mem_root);
|
||||||
lex->add_to_query_tables(table);
|
lex->add_to_query_tables(table);
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr)
|
||||||
if (table->child_l || table->parent)
|
if (table->child_l || table->parent)
|
||||||
detach_merge_children(table, TRUE);
|
detach_merge_children(table, TRUE);
|
||||||
|
|
||||||
table->mdl_lock= 0;
|
table->mdl_lock_data= 0;
|
||||||
if (table->needs_reopen() ||
|
if (table->needs_reopen() ||
|
||||||
thd->version != refresh_version || !table->db_stat)
|
thd->version != refresh_version || !table->db_stat)
|
||||||
{
|
{
|
||||||
|
@ -2535,7 +2535,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
char key[MAX_DBKEY_LENGTH];
|
char key[MAX_DBKEY_LENGTH];
|
||||||
uint key_length;
|
uint key_length;
|
||||||
char *alias= table_list->alias;
|
char *alias= table_list->alias;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
int error;
|
int error;
|
||||||
TABLE_SHARE *share;
|
TABLE_SHARE *share;
|
||||||
DBUG_ENTER("open_table");
|
DBUG_ENTER("open_table");
|
||||||
|
@ -2717,8 +2717,8 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
This is the normal use case.
|
This is the normal use case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mdl_lock= table_list->mdl_lock;
|
mdl_lock_data= table_list->mdl_lock_data;
|
||||||
mdl_add_lock(&thd->mdl_context, mdl_lock);
|
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
|
|
||||||
if (table_list->open_type)
|
if (table_list->open_type)
|
||||||
{
|
{
|
||||||
|
@ -2731,7 +2731,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
shared locks. This invariant is preserved here and is also
|
shared locks. This invariant is preserved here and is also
|
||||||
enforced by asserts in metadata locking subsystem.
|
enforced by asserts in metadata locking subsystem.
|
||||||
*/
|
*/
|
||||||
mdl_set_lock_type(mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
@ -2740,10 +2740,10 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
bool retry;
|
bool retry;
|
||||||
|
|
||||||
if (table_list->mdl_upgradable)
|
if (table_list->mdl_upgradable)
|
||||||
mdl_set_upgradable(mdl_lock);
|
mdl_set_upgradable(mdl_lock_data);
|
||||||
mdl_set_lock_priority(mdl_lock, (flags & MYSQL_LOCK_IGNORE_FLUSH) ?
|
mdl_set_lock_priority(mdl_lock_data, (flags & MYSQL_LOCK_IGNORE_FLUSH) ?
|
||||||
MDL_HIGH_PRIO : MDL_NORMAL_PRIO);
|
MDL_HIGH_PRIO : MDL_NORMAL_PRIO);
|
||||||
if (mdl_acquire_shared_lock(mdl_lock, &retry))
|
if (mdl_acquire_shared_lock(mdl_lock_data, &retry))
|
||||||
{
|
{
|
||||||
if (retry)
|
if (retry)
|
||||||
*action= OT_BACK_OFF_AND_RETRY;
|
*action= OT_BACK_OFF_AND_RETRY;
|
||||||
|
@ -2792,7 +2792,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(share= (TABLE_SHARE *)mdl_get_cached_object(mdl_lock)))
|
if (!(share= (TABLE_SHARE *)mdl_get_cached_object(mdl_lock_data)))
|
||||||
{
|
{
|
||||||
if (!(share= get_table_share_with_create(thd, table_list, key,
|
if (!(share= get_table_share_with_create(thd, table_list, key,
|
||||||
key_length, OPEN_VIEW,
|
key_length, OPEN_VIEW,
|
||||||
|
@ -2867,7 +2867,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
so we need to increase reference counter;
|
so we need to increase reference counter;
|
||||||
*/
|
*/
|
||||||
reference_table_share(share);
|
reference_table_share(share);
|
||||||
mdl_set_cached_object(mdl_lock, share, table_share_release_hook);
|
mdl_set_cached_object(mdl_lock_data, share, table_share_release_hook);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2978,7 +2978,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
||||||
if (table_list->open_type == TABLE_LIST::OPEN_OR_CREATE)
|
if (table_list->open_type == TABLE_LIST::OPEN_OR_CREATE)
|
||||||
mdl_downgrade_exclusive_locks(&thd->mdl_context);
|
mdl_downgrade_exclusive_locks(&thd->mdl_context);
|
||||||
|
|
||||||
table->mdl_lock= mdl_lock;
|
table->mdl_lock_data= mdl_lock_data;
|
||||||
|
|
||||||
table->next=thd->open_tables; /* Link into simple list */
|
table->next=thd->open_tables; /* Link into simple list */
|
||||||
thd->open_tables=table;
|
thd->open_tables=table;
|
||||||
|
@ -3025,7 +3025,7 @@ err_unlock:
|
||||||
release_table_share(share);
|
release_table_share(share);
|
||||||
err_unlock2:
|
err_unlock2:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3167,7 +3167,7 @@ bool reopen_table(TABLE *table)
|
||||||
(void) closefrm(&tmp, 1); // close file, free everything
|
(void) closefrm(&tmp, 1); // close file, free everything
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
tmp.mdl_lock= table->mdl_lock;
|
tmp.mdl_lock_data= table->mdl_lock_data;
|
||||||
|
|
||||||
table_def_change_share(table, tmp.s);
|
table_def_change_share(table, tmp.s);
|
||||||
/* Avoid wiping out TABLE's position in new share's used tables list. */
|
/* Avoid wiping out TABLE's position in new share's used tables list. */
|
||||||
|
@ -3981,8 +3981,8 @@ static bool handle_failed_open_table_attempt(THD *thd, TABLE_LIST *table,
|
||||||
mdl_remove_all_locks(&thd->mdl_context);
|
mdl_remove_all_locks(&thd->mdl_context);
|
||||||
break;
|
break;
|
||||||
case OT_DISCOVER:
|
case OT_DISCOVER:
|
||||||
mdl_set_lock_type(table->mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(table->mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, table->mdl_lock);
|
mdl_add_lock(&thd->mdl_context, table->mdl_lock_data);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
@ -3995,8 +3995,8 @@ static bool handle_failed_open_table_attempt(THD *thd, TABLE_LIST *table,
|
||||||
mdl_release_exclusive_locks(&thd->mdl_context);
|
mdl_release_exclusive_locks(&thd->mdl_context);
|
||||||
break;
|
break;
|
||||||
case OT_REPAIR:
|
case OT_REPAIR:
|
||||||
mdl_set_lock_type(table->mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(table->mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, table->mdl_lock);
|
mdl_add_lock(&thd->mdl_context, table->mdl_lock_data);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
@ -8518,7 +8518,7 @@ void expel_table_from_cache(THD *leave_thd, const char *db, const char *table_na
|
||||||
|
|
||||||
static bool tdc_wait_for_old_versions(THD *thd, MDL_CONTEXT *context)
|
static bool tdc_wait_for_old_versions(THD *thd, MDL_CONTEXT *context)
|
||||||
{
|
{
|
||||||
MDL_LOCK *l;
|
MDL_LOCK_DATA *lock_data;
|
||||||
TABLE_SHARE *share;
|
TABLE_SHARE *share;
|
||||||
const char *old_msg;
|
const char *old_msg;
|
||||||
LEX_STRING key;
|
LEX_STRING key;
|
||||||
|
@ -8534,17 +8534,18 @@ static bool tdc_wait_for_old_versions(THD *thd, MDL_CONTEXT *context)
|
||||||
mysql_ha_flush(thd);
|
mysql_ha_flush(thd);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
I_P_List_iterator<MDL_LOCK, MDL_LOCK_context> it= mdl_get_locks(context);
|
I_P_List_iterator<MDL_LOCK_DATA,
|
||||||
while ((l= it++))
|
MDL_LOCK_DATA_context> it= mdl_get_locks(context);
|
||||||
|
while ((lock_data= it++))
|
||||||
{
|
{
|
||||||
mdl_get_tdc_key(l, &key);
|
mdl_get_tdc_key(lock_data, &key);
|
||||||
if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache, (uchar*) key.str,
|
if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache, (uchar*) key.str,
|
||||||
key.length)) &&
|
key.length)) &&
|
||||||
share->version != refresh_version &&
|
share->version != refresh_version &&
|
||||||
!share->used_tables.is_empty())
|
!share->used_tables.is_empty())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!l)
|
if (!lock_data)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1089,7 +1089,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
bool error;
|
bool error;
|
||||||
uint path_length;
|
uint path_length;
|
||||||
MDL_LOCK *mdl_lock= 0;
|
MDL_LOCK_DATA *mdl_lock_data= 0;
|
||||||
DBUG_ENTER("mysql_truncate");
|
DBUG_ENTER("mysql_truncate");
|
||||||
|
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
bzero((char*) &create_info,sizeof(create_info));
|
||||||
|
@ -1164,10 +1164,10 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
|
||||||
tries to get table enging and therefore accesses table in some way
|
tries to get table enging and therefore accesses table in some way
|
||||||
without holding any kind of meta-data lock.
|
without holding any kind of meta-data lock.
|
||||||
*/
|
*/
|
||||||
mdl_lock= mdl_alloc_lock(0, table_list->db, table_list->table_name,
|
mdl_lock_data= mdl_alloc_lock(0, table_list->db, table_list->table_name,
|
||||||
thd->mem_root);
|
thd->mem_root);
|
||||||
mdl_set_lock_type(mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, mdl_lock);
|
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
@ -1197,13 +1197,13 @@ end:
|
||||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||||
my_ok(thd); // This should return record count
|
my_ok(thd); // This should return record count
|
||||||
}
|
}
|
||||||
if (mdl_lock)
|
if (mdl_lock_data)
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
}
|
}
|
||||||
else if (error)
|
else if (error)
|
||||||
{
|
{
|
||||||
if (mdl_lock)
|
if (mdl_lock_data)
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ static void mysql_ha_hash_free(TABLE_LIST *tables)
|
||||||
static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
|
static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
|
||||||
{
|
{
|
||||||
TABLE **table_ptr;
|
TABLE **table_ptr;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Though we could take the table pointer from hash_tables->table,
|
Though we could take the table pointer from hash_tables->table,
|
||||||
|
@ -141,7 +141,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
|
||||||
if (*table_ptr)
|
if (*table_ptr)
|
||||||
{
|
{
|
||||||
(*table_ptr)->file->ha_index_or_rnd_end();
|
(*table_ptr)->file->ha_index_or_rnd_end();
|
||||||
mdl_lock= (*table_ptr)->mdl_lock;
|
mdl_lock_data= (*table_ptr)->mdl_lock_data;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
if (close_thread_table(thd, table_ptr))
|
if (close_thread_table(thd, table_ptr))
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
|
||||||
broadcast_refresh();
|
broadcast_refresh();
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
mdl_release_lock(&thd->handler_mdl_context, mdl_lock);
|
mdl_release_lock(&thd->handler_mdl_context, mdl_lock_data);
|
||||||
}
|
}
|
||||||
else if (tables->table)
|
else if (tables->table)
|
||||||
{
|
{
|
||||||
|
@ -189,7 +189,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
|
||||||
bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
|
bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
|
||||||
{
|
{
|
||||||
TABLE_LIST *hash_tables = NULL;
|
TABLE_LIST *hash_tables = NULL;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
char *db, *name, *alias, *mdlkey;
|
char *db, *name, *alias, *mdlkey;
|
||||||
uint dblen, namelen, aliaslen, counter;
|
uint dblen, namelen, aliaslen, counter;
|
||||||
int error;
|
int error;
|
||||||
|
@ -245,7 +245,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
|
||||||
&db, (uint) dblen,
|
&db, (uint) dblen,
|
||||||
&name, (uint) namelen,
|
&name, (uint) namelen,
|
||||||
&alias, (uint) aliaslen,
|
&alias, (uint) aliaslen,
|
||||||
&mdl_lock, sizeof(MDL_LOCK),
|
&mdl_lock_data, sizeof(MDL_LOCK_DATA),
|
||||||
&mdlkey, MAX_DBKEY_LENGTH,
|
&mdlkey, MAX_DBKEY_LENGTH,
|
||||||
NullS)))
|
NullS)))
|
||||||
{
|
{
|
||||||
|
@ -260,8 +260,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
|
||||||
memcpy(hash_tables->db, tables->db, dblen);
|
memcpy(hash_tables->db, tables->db, dblen);
|
||||||
memcpy(hash_tables->table_name, tables->table_name, namelen);
|
memcpy(hash_tables->table_name, tables->table_name, namelen);
|
||||||
memcpy(hash_tables->alias, tables->alias, aliaslen);
|
memcpy(hash_tables->alias, tables->alias, aliaslen);
|
||||||
mdl_init_lock(mdl_lock, mdlkey, 0, db, name);
|
mdl_init_lock(mdl_lock_data, mdlkey, 0, db, name);
|
||||||
hash_tables->mdl_lock= mdl_lock;
|
hash_tables->mdl_lock_data= mdl_lock_data;
|
||||||
|
|
||||||
/* add to hash */
|
/* add to hash */
|
||||||
if (my_hash_insert(&thd->handler_tables_hash, (uchar*) hash_tables))
|
if (my_hash_insert(&thd->handler_tables_hash, (uchar*) hash_tables))
|
||||||
|
@ -798,10 +798,12 @@ void mysql_ha_flush(THD *thd)
|
||||||
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
|
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
|
||||||
{
|
{
|
||||||
hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
|
hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
|
||||||
/* TABLE::mdl_lock is 0 for temporary tables so we need extra check. */
|
/*
|
||||||
|
TABLE::mdl_lock_data is 0 for temporary tables so we need extra check.
|
||||||
|
*/
|
||||||
if (hash_tables->table &&
|
if (hash_tables->table &&
|
||||||
(hash_tables->table->mdl_lock &&
|
(hash_tables->table->mdl_lock_data &&
|
||||||
mdl_has_pending_conflicting_lock(hash_tables->table->mdl_lock) ||
|
mdl_has_pending_conflicting_lock(hash_tables->table->mdl_lock_data) ||
|
||||||
hash_tables->table->needs_reopen()))
|
hash_tables->table->needs_reopen()))
|
||||||
mysql_ha_close_table(thd, hash_tables);
|
mysql_ha_close_table(thd, hash_tables);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6534,9 +6534,9 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||||
ptr->next_name_resolution_table= NULL;
|
ptr->next_name_resolution_table= NULL;
|
||||||
/* Link table in global list (all used tables) */
|
/* Link table in global list (all used tables) */
|
||||||
lex->add_to_query_tables(ptr);
|
lex->add_to_query_tables(ptr);
|
||||||
ptr->mdl_lock= mdl_alloc_lock(0 , ptr->db, ptr->table_name,
|
ptr->mdl_lock_data= mdl_alloc_lock(0 , ptr->db, ptr->table_name,
|
||||||
thd->mdl_el_root ? thd->mdl_el_root :
|
thd->mdl_el_root ? thd->mdl_el_root :
|
||||||
thd->mem_root);
|
thd->mem_root);
|
||||||
DBUG_RETURN(ptr);
|
DBUG_RETURN(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3106,7 +3106,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
||||||
char key[MAX_DBKEY_LENGTH];
|
char key[MAX_DBKEY_LENGTH];
|
||||||
uint key_length;
|
uint key_length;
|
||||||
char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
|
char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
|
||||||
MDL_LOCK mdl_lock;
|
MDL_LOCK_DATA mdl_lock_data;
|
||||||
char mdlkey[MAX_DBKEY_LENGTH];
|
char mdlkey[MAX_DBKEY_LENGTH];
|
||||||
bool retry;
|
bool retry;
|
||||||
|
|
||||||
|
@ -3133,10 +3133,10 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
||||||
table_list.db= db_name->str;
|
table_list.db= db_name->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdl_init_lock(&mdl_lock, mdlkey, 0, db_name->str, table_name->str);
|
mdl_init_lock(&mdl_lock_data, mdlkey, 0, db_name->str, table_name->str);
|
||||||
table_list.mdl_lock= &mdl_lock;
|
table_list.mdl_lock_data= &mdl_lock_data;
|
||||||
mdl_add_lock(&thd->mdl_context, &mdl_lock);
|
mdl_add_lock(&thd->mdl_context, &mdl_lock_data);
|
||||||
mdl_set_lock_priority(&mdl_lock, MDL_HIGH_PRIO);
|
mdl_set_lock_priority(&mdl_lock_data, MDL_HIGH_PRIO);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: investigate if in this particular situation we can get by
|
TODO: investigate if in this particular situation we can get by
|
||||||
|
@ -3145,7 +3145,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
||||||
*/
|
*/
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (mdl_acquire_shared_lock(&mdl_lock, &retry))
|
if (mdl_acquire_shared_lock(&mdl_lock_data, &retry))
|
||||||
{
|
{
|
||||||
if (!retry || mdl_wait_for_locks(&thd->mdl_context))
|
if (!retry || mdl_wait_for_locks(&thd->mdl_context))
|
||||||
{
|
{
|
||||||
|
@ -3212,7 +3212,7 @@ err_unlock:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
mdl_release_lock(&thd->mdl_context, &mdl_lock);
|
mdl_release_lock(&thd->mdl_context, &mdl_lock_data);
|
||||||
thd->clear_error();
|
thd->clear_error();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4043,15 +4043,15 @@ warn:
|
||||||
|
|
||||||
static bool lock_table_name_if_not_cached(THD *thd, const char *db,
|
static bool lock_table_name_if_not_cached(THD *thd, const char *db,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
MDL_LOCK **lock)
|
MDL_LOCK_DATA **lock_data)
|
||||||
{
|
{
|
||||||
if (!(*lock= mdl_alloc_lock(0, db, table_name, thd->mem_root)))
|
if (!(*lock_data= mdl_alloc_lock(0, db, table_name, thd->mem_root)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
mdl_set_lock_type(*lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(*lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, *lock);
|
mdl_add_lock(&thd->mdl_context, *lock_data);
|
||||||
if (mdl_try_acquire_exclusive_lock(&thd->mdl_context, *lock))
|
if (mdl_try_acquire_exclusive_lock(&thd->mdl_context, *lock_data))
|
||||||
{
|
{
|
||||||
*lock= 0;
|
*lock_data= 0;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -4067,7 +4067,7 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
||||||
bool internal_tmp_table,
|
bool internal_tmp_table,
|
||||||
uint select_field_count)
|
uint select_field_count)
|
||||||
{
|
{
|
||||||
MDL_LOCK *target_lock= 0;
|
MDL_LOCK_DATA *target_lock_data= 0;
|
||||||
bool result;
|
bool result;
|
||||||
DBUG_ENTER("mysql_create_table");
|
DBUG_ENTER("mysql_create_table");
|
||||||
|
|
||||||
|
@ -4090,12 +4090,12 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
||||||
|
|
||||||
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
||||||
{
|
{
|
||||||
if (lock_table_name_if_not_cached(thd, db, table_name, &target_lock))
|
if (lock_table_name_if_not_cached(thd, db, table_name, &target_lock_data))
|
||||||
{
|
{
|
||||||
result= TRUE;
|
result= TRUE;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
if (!target_lock)
|
if (!target_lock_data)
|
||||||
{
|
{
|
||||||
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
|
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
|
||||||
{
|
{
|
||||||
|
@ -4121,7 +4121,7 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
||||||
select_field_count);
|
select_field_count);
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
if (target_lock)
|
if (target_lock_data)
|
||||||
mdl_release_exclusive_locks(&thd->mdl_context);
|
mdl_release_exclusive_locks(&thd->mdl_context);
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
pthread_mutex_lock(&LOCK_lock_db);
|
||||||
if (!--creating_table && creating_database)
|
if (!--creating_table && creating_database)
|
||||||
|
@ -4359,7 +4359,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
|
||||||
static int prepare_for_restore(THD* thd, TABLE_LIST* table,
|
static int prepare_for_restore(THD* thd, TABLE_LIST* table,
|
||||||
HA_CHECK_OPT *check_opt)
|
HA_CHECK_OPT *check_opt)
|
||||||
{
|
{
|
||||||
MDL_LOCK *mdl_lock= 0;
|
MDL_LOCK_DATA *mdl_lock_data= 0;
|
||||||
DBUG_ENTER("prepare_for_restore");
|
DBUG_ENTER("prepare_for_restore");
|
||||||
|
|
||||||
if (table->table) // do not overwrite existing tables on restore
|
if (table->table) // do not overwrite existing tables on restore
|
||||||
|
@ -4383,10 +4383,10 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
|
||||||
build_table_filename(dst_path, sizeof(dst_path) - 1,
|
build_table_filename(dst_path, sizeof(dst_path) - 1,
|
||||||
db, table_name, reg_ext, 0);
|
db, table_name, reg_ext, 0);
|
||||||
|
|
||||||
mdl_lock= mdl_alloc_lock(0, table->db, table->table_name,
|
mdl_lock_data= mdl_alloc_lock(0, table->db, table->table_name,
|
||||||
thd->mem_root);
|
thd->mem_root);
|
||||||
mdl_set_lock_type(mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, mdl_lock);
|
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
@ -4395,13 +4395,13 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
|
||||||
|
|
||||||
if (my_copy(src_path, dst_path, MYF(MY_WME)))
|
if (my_copy(src_path, dst_path, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
||||||
"Failed copying .frm file"));
|
"Failed copying .frm file"));
|
||||||
}
|
}
|
||||||
if (mysql_truncate(thd, table, 1))
|
if (mysql_truncate(thd, table, 1))
|
||||||
{
|
{
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
||||||
"Failed generating table from .frm file"));
|
"Failed generating table from .frm file"));
|
||||||
}
|
}
|
||||||
|
@ -4415,8 +4415,8 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
|
||||||
if (reopen_name_locked_table(thd, table))
|
if (reopen_name_locked_table(thd, table))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
if (mdl_lock)
|
if (mdl_lock_data)
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
|
||||||
"Failed to open partially restored table"));
|
"Failed to open partially restored table"));
|
||||||
}
|
}
|
||||||
|
@ -4436,7 +4436,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||||
char from[FN_REFLEN],tmp[FN_REFLEN+32];
|
char from[FN_REFLEN],tmp[FN_REFLEN+32];
|
||||||
const char **ext;
|
const char **ext;
|
||||||
MY_STAT stat_info;
|
MY_STAT stat_info;
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
DBUG_ENTER("prepare_for_repair");
|
DBUG_ENTER("prepare_for_repair");
|
||||||
|
|
||||||
if (!(check_opt->sql_flags & TT_USEFRM))
|
if (!(check_opt->sql_flags & TT_USEFRM))
|
||||||
|
@ -4452,10 +4452,10 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||||
TODO: Check that REPAIR's code also conforms to meta-data
|
TODO: Check that REPAIR's code also conforms to meta-data
|
||||||
locking protocol. Fix if it is not.
|
locking protocol. Fix if it is not.
|
||||||
*/
|
*/
|
||||||
mdl_lock= mdl_alloc_lock(0, table_list->db, table_list->table_name,
|
mdl_lock_data= mdl_alloc_lock(0, table_list->db, table_list->table_name,
|
||||||
thd->mem_root);
|
thd->mem_root);
|
||||||
mdl_set_lock_type(mdl_lock, MDL_EXCLUSIVE);
|
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||||
mdl_add_lock(&thd->mdl_context, mdl_lock);
|
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
|
@ -5303,7 +5303,7 @@ bool mysql_create_like_schema_frm(THD* thd, TABLE_LIST* schema_table,
|
||||||
bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
||||||
HA_CREATE_INFO *create_info)
|
HA_CREATE_INFO *create_info)
|
||||||
{
|
{
|
||||||
MDL_LOCK *target_lock= 0;
|
MDL_LOCK_DATA *target_lock_data= 0;
|
||||||
char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1];
|
char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1];
|
||||||
uint dst_path_length;
|
uint dst_path_length;
|
||||||
char *db= table->db;
|
char *db= table->db;
|
||||||
|
@ -5360,9 +5360,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lock_table_name_if_not_cached(thd, db, table_name, &target_lock))
|
if (lock_table_name_if_not_cached(thd, db, table_name, &target_lock_data))
|
||||||
goto err;
|
goto err;
|
||||||
if (!target_lock)
|
if (!target_lock_data)
|
||||||
goto table_exists;
|
goto table_exists;
|
||||||
dst_path_length= build_table_filename(dst_path, sizeof(dst_path) - 1,
|
dst_path_length= build_table_filename(dst_path, sizeof(dst_path) - 1,
|
||||||
db, table_name, reg_ext, 0);
|
db, table_name, reg_ext, 0);
|
||||||
|
@ -5538,7 +5538,7 @@ binlog:
|
||||||
res= FALSE;
|
res= FALSE;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (target_lock)
|
if (target_lock_data)
|
||||||
mdl_release_exclusive_locks(&thd->mdl_context);
|
mdl_release_exclusive_locks(&thd->mdl_context);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
@ -6477,7 +6477,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||||
uint order_num, ORDER *order, bool ignore)
|
uint order_num, ORDER *order, bool ignore)
|
||||||
{
|
{
|
||||||
TABLE *table, *new_table= 0;
|
TABLE *table, *new_table= 0;
|
||||||
MDL_LOCK *target_lock= 0;
|
MDL_LOCK_DATA *target_lock_data= 0;
|
||||||
int error= 0;
|
int error= 0;
|
||||||
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
|
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
|
||||||
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
|
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
|
||||||
|
@ -6700,9 +6700,10 @@ view_err:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lock_table_name_if_not_cached(thd, new_db, new_name, &target_lock))
|
if (lock_table_name_if_not_cached(thd, new_db, new_name,
|
||||||
|
&target_lock_data))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (!target_lock)
|
if (!target_lock_data)
|
||||||
{
|
{
|
||||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
|
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
@ -7128,7 +7129,7 @@ view_err:
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
if (fast_alter_partition)
|
if (fast_alter_partition)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(!target_lock);
|
DBUG_ASSERT(!target_lock_data);
|
||||||
DBUG_RETURN(fast_alter_partition_table(thd, table, alter_info,
|
DBUG_RETURN(fast_alter_partition_table(thd, table, alter_info,
|
||||||
create_info, table_list,
|
create_info, table_list,
|
||||||
db, table_name,
|
db, table_name,
|
||||||
|
@ -7632,7 +7633,7 @@ err:
|
||||||
alter_info->datetime_field->field_name);
|
alter_info->datetime_field->field_name);
|
||||||
thd->abort_on_warning= save_abort_on_warning;
|
thd->abort_on_warning= save_abort_on_warning;
|
||||||
}
|
}
|
||||||
if (target_lock)
|
if (target_lock_data)
|
||||||
mdl_release_exclusive_locks(&thd->mdl_context);
|
mdl_release_exclusive_locks(&thd->mdl_context);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
|
|
|
@ -4832,8 +4832,9 @@ size_t max_row_length(TABLE *table, const uchar *data)
|
||||||
void alloc_mdl_locks(TABLE_LIST *table_list, MEM_ROOT *root)
|
void alloc_mdl_locks(TABLE_LIST *table_list, MEM_ROOT *root)
|
||||||
{
|
{
|
||||||
for ( ; table_list ; table_list= table_list->next_global)
|
for ( ; table_list ; table_list= table_list->next_global)
|
||||||
table_list->mdl_lock= mdl_alloc_lock(0, table_list->db,
|
table_list->mdl_lock_data= mdl_alloc_lock(0, table_list->db,
|
||||||
table_list->table_name, root);
|
table_list->table_name,
|
||||||
|
root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class st_select_lex;
|
||||||
class partition_info;
|
class partition_info;
|
||||||
class COND_EQUAL;
|
class COND_EQUAL;
|
||||||
class Security_context;
|
class Security_context;
|
||||||
struct MDL_LOCK;
|
struct MDL_LOCK_DATA;
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ public:
|
||||||
partition_info *part_info; /* Partition related information */
|
partition_info *part_info; /* Partition related information */
|
||||||
bool no_partitions_used; /* If true, all partitions have been pruned away */
|
bool no_partitions_used; /* If true, all partitions have been pruned away */
|
||||||
#endif
|
#endif
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
|
|
||||||
bool fill_item_list(List<Item> *item_list) const;
|
bool fill_item_list(List<Item> *item_list) const;
|
||||||
void reset_item_list(List<Item> *item_list) const;
|
void reset_item_list(List<Item> *item_list) const;
|
||||||
|
@ -1423,7 +1423,7 @@ struct TABLE_LIST
|
||||||
uint table_open_method;
|
uint table_open_method;
|
||||||
enum enum_schema_table_state schema_table_state;
|
enum enum_schema_table_state schema_table_state;
|
||||||
|
|
||||||
MDL_LOCK *mdl_lock;
|
MDL_LOCK_DATA *mdl_lock_data;
|
||||||
|
|
||||||
void calc_md5(char *buffer);
|
void calc_md5(char *buffer);
|
||||||
void set_underlying_merge();
|
void set_underlying_merge();
|
||||||
|
|
Loading…
Reference in a new issue