1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-5619: CREATE OR REPLACE does not release MDL_EXCLUSIVE upon failure

mysql-test/r/create_or_replace.result:
  Added test of releasing of metadata locks
mysql-test/t/create_or_replace.test:
  Added test of releasing of metadata locks
sql/handler.h:
  Added marker if table was deleted as part of CREATE OR REPLACE
sql/sql_base.cc:
  Added Locked_tables_list::unlock_locked_table()
sql/sql_class.h:
  New prototypes
sql/sql_insert.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
sql/sql_table.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
This commit is contained in:
Michael Widenius
2014-03-12 11:26:40 +02:00
parent 49ca12a107
commit f320b12ca5
7 changed files with 157 additions and 3 deletions

View File

@ -2722,6 +2722,38 @@ Locked_tables_list::unlock_locked_tables(THD *thd)
reset();
}
/**
Remove all meta data locks associated with table and release locked
table mode if there is no locked tables anymore
*/
void
Locked_tables_list::unlock_locked_table(THD *thd, MDL_ticket *mdl_ticket)
{
/*
Ensure we are in locked table mode.
As this function is only called on error condition it's better
to check this condition here than in the caller.
*/
if (thd->locked_tables_mode != LTM_LOCK_TABLES)
return;
if (mdl_ticket)
{
/*
Under LOCK TABLES we may have several instances of table open
and locked and therefore have to remove several metadata lock
requests associated with them.
*/
thd->mdl_context.release_all_locks_for_name(mdl_ticket);
}
if (thd->lock->table_count == 0)
unlock_locked_tables(thd);
}
/*
Free memory allocated for storing locks
*/