mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug #52593 SHOW CREATE TABLE is blocked if table is locked
for write by another connection The problem was that if a table was locked in one connection by LOCK TABLES ... WRITE, REPAIR TABLE or OPTIMIZE TABLE, SHOW CREATE TABLE from another connection would be blocked. As SHOW CREATE TABLE only reads metadata about the table, such blocking is not needed. The problem was that when SHOW CREATE TABLE tried to get a metadata lock on the table in order to open it, it used the wrong type of metadata lock request. It used MDL_SHARED_READ which is used when the intent is to read both table metadata and table data. Instead it should have used MDL_SHARED_HIGH_PRIO which signifies an intent to only read metadata. This patch fixes the problem by making sure SHOW CREATE TABLE uses the MDL_SHARED_HIGH_PRIO metadata lock request type when trying to open the table. The patch also fixes a similar problem with the mysql_list_fields API call. Test case added to show_check.test.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||
/* Copyright 2000, 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
/* Function with list databases, tables or fields */
|
||||
@ -641,7 +641,9 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
|
||||
{
|
||||
Show_create_error_handler view_error_suppressor(thd, table_list);
|
||||
thd->push_internal_handler(&view_error_suppressor);
|
||||
bool error= open_normal_and_derived_tables(thd, table_list, 0);
|
||||
bool error=
|
||||
open_normal_and_derived_tables(thd, table_list,
|
||||
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL);
|
||||
thd->pop_internal_handler();
|
||||
if (error && (thd->killed || thd->is_error()))
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -815,7 +817,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
|
||||
DBUG_ENTER("mysqld_list_fields");
|
||||
DBUG_PRINT("enter",("table: %s",table_list->table_name));
|
||||
|
||||
if (open_normal_and_derived_tables(thd, table_list, 0))
|
||||
if (open_normal_and_derived_tables(thd, table_list,
|
||||
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
|
||||
DBUG_VOID_RETURN;
|
||||
table= table_list->table;
|
||||
|
||||
|
Reference in New Issue
Block a user