mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Backport of:
---------------------------------------------------------- revno: 2617.23.20 committer: Konstantin Osipov <kostja@sun.com> branch nick: mysql-6.0-runtime timestamp: Wed 2009-03-04 16:31:31 +0300 message: WL#4284 "Transactional DDL locking" Review comments: "Objectify" the MDL API. MDL_request and MDL_context still need manual construction and destruction, since they are used in environment that is averse to constructors/destructors.
This commit is contained in:
@ -3050,7 +3050,7 @@ uint get_table_open_method(TABLE_LIST *tables,
|
||||
Acquire high priority share metadata lock on a table.
|
||||
|
||||
@param thd Thread context.
|
||||
@param mdl_lock_req Pointer to memory to be used for MDL_LOCK_REQUEST
|
||||
@param mdl_request Pointer to memory to be used for MDL_request
|
||||
object for a lock request.
|
||||
@param table Table list element for the table
|
||||
|
||||
@ -3065,23 +3065,23 @@ uint get_table_open_method(TABLE_LIST *tables,
|
||||
*/
|
||||
|
||||
static bool
|
||||
acquire_high_prio_shared_mdl_lock(THD *thd, MDL_LOCK_REQUEST *mdl_lock_req,
|
||||
acquire_high_prio_shared_mdl_lock(THD *thd, MDL_request *mdl_request,
|
||||
TABLE_LIST *table)
|
||||
{
|
||||
bool retry;
|
||||
|
||||
mdl_request_init(mdl_lock_req, 0, table->db, table->table_name);
|
||||
table->mdl_lock_request= mdl_lock_req;
|
||||
mdl_request_add(&thd->mdl_context, mdl_lock_req);
|
||||
mdl_request_set_type(mdl_lock_req, MDL_SHARED_HIGH_PRIO);
|
||||
mdl_request->init(0, table->db, table->table_name);
|
||||
table->mdl_request= mdl_request;
|
||||
thd->mdl_context.add_request(mdl_request);
|
||||
mdl_request->set_type(MDL_SHARED_HIGH_PRIO);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (mdl_acquire_shared_lock(&thd->mdl_context, mdl_lock_req, &retry))
|
||||
if (thd->mdl_context.acquire_shared_lock(mdl_request, &retry))
|
||||
{
|
||||
if (!retry || mdl_wait_for_locks(&thd->mdl_context))
|
||||
if (!retry || thd->mdl_context.wait_for_locks())
|
||||
{
|
||||
mdl_request_remove_all(&thd->mdl_context);
|
||||
thd->mdl_context.remove_all_requests();
|
||||
return TRUE;
|
||||
}
|
||||
continue;
|
||||
@ -3123,7 +3123,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
||||
char key[MAX_DBKEY_LENGTH];
|
||||
uint key_length;
|
||||
char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
|
||||
MDL_LOCK_REQUEST mdl_lock_request;
|
||||
MDL_request mdl_request;
|
||||
|
||||
bzero((char*) &table_list, sizeof(TABLE_LIST));
|
||||
bzero((char*) &tbl, sizeof(TABLE));
|
||||
@ -3153,7 +3153,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
||||
simply obtaining internal lock of data-dictionary (ATM it
|
||||
is LOCK_open) instead of obtaning full-blown metadata lock.
|
||||
*/
|
||||
if (acquire_high_prio_shared_mdl_lock(thd, &mdl_lock_request, &table_list))
|
||||
if (acquire_high_prio_shared_mdl_lock(thd, &mdl_request, &table_list))
|
||||
{
|
||||
/*
|
||||
Some error occured (most probably we have been killed while
|
||||
@ -3213,9 +3213,8 @@ err_share:
|
||||
err_unlock:
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
|
||||
err:
|
||||
mdl_ticket_release(&thd->mdl_context, mdl_lock_request.ticket);
|
||||
mdl_request_remove(&thd->mdl_context, &mdl_lock_request);
|
||||
thd->mdl_context.release_lock(mdl_request.ticket);
|
||||
thd->mdl_context.remove_request(&mdl_request);
|
||||
thd->clear_error();
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user