mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.5 into 10.6
This commit is contained in:
@ -396,7 +396,9 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
|
||||
bool result= TRUE;
|
||||
String stmt_query;
|
||||
bool lock_upgrade_done= FALSE;
|
||||
bool backup_of_table_list_done= 0;;
|
||||
MDL_ticket *mdl_ticket= NULL;
|
||||
MDL_request mdl_request_for_trn;
|
||||
Query_tables_list backup;
|
||||
DBUG_ENTER("mysql_create_or_drop_trigger");
|
||||
|
||||
@ -446,6 +448,16 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
/* Protect against concurrent create/drop */
|
||||
MDL_REQUEST_INIT(&mdl_request_for_trn, MDL_key::TABLE,
|
||||
create ? tables->db.str : thd->lex->spname->m_db.str,
|
||||
thd->lex->spname->m_name.str,
|
||||
MDL_EXCLUSIVE, MDL_EXPLICIT);
|
||||
if (thd->mdl_context.acquire_lock(&mdl_request_for_trn,
|
||||
thd->variables.lock_wait_timeout))
|
||||
goto end;
|
||||
|
||||
|
||||
if (!create)
|
||||
{
|
||||
bool if_exists= thd->lex->if_exists();
|
||||
@ -454,6 +466,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
|
||||
Protect the query table list from the temporary and potentially
|
||||
destructive changes necessary to open the trigger's table.
|
||||
*/
|
||||
backup_of_table_list_done= 1;
|
||||
thd->lex->reset_n_backup_query_tables_list(&backup);
|
||||
/*
|
||||
Restore Query_tables_list::sql_command, which was
|
||||
@ -623,7 +636,7 @@ end:
|
||||
mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
|
||||
|
||||
/* Restore the query table list. Used only for drop trigger. */
|
||||
if (!create)
|
||||
if (backup_of_table_list_done)
|
||||
thd->lex->restore_backup_query_tables_list(&backup);
|
||||
|
||||
if (!result)
|
||||
@ -635,6 +648,9 @@ end:
|
||||
thd->lex->spname->m_name.str, static_cast<uint>(thd->lex->spname->m_name.length));
|
||||
}
|
||||
|
||||
if (mdl_request_for_trn.ticket)
|
||||
thd->mdl_context.release_lock(mdl_request_for_trn.ticket);
|
||||
|
||||
DBUG_RETURN(result);
|
||||
#ifdef WITH_WSREP
|
||||
wsrep_error_label:
|
||||
|
Reference in New Issue
Block a user