Commit 136a1615 authored by Konstantin Osipov's avatar Konstantin Osipov

Backport of:

------------------------------------------------------------
revno: 2630.4.33
committer: Dmitry Lenev <dlenev@mysql.com>
branch nick: mysql-6.0-3726-w2
timestamp: Fri 2008-06-20 17:11:20 +0400
message:
  WL#3726 "DDL locking for all metadata objects".

  After-review fixes in progress.

  Minimized dependency of mdl.cc on other modules (particularly
  made it independant of mysql_priv.h) in order to be able
  write unit tests for metadata locking subsystem.


sql/ha_ndbcluster_binlog.cc:
  Use newly introduced MAX_MDLKEY_LENGTH constant for allocating
  buffer for object key for metadata locking subsystem.
sql/log_event.cc:
  Use newly introduced MAX_MDLKEY_LENGTH constant for allocating
  buffer for object key for metadata locking subsystem.
sql/mdl.cc:
  Removed dependency on THD class (and thus on mysql_priv.h)
  by using direct access to members of st_my_thread_var instead
  of accessing THD::killed/enter_cond()/exit_cond().
sql/mdl.h:
  Added MAX_MDLKEY_LENGTH constant to be used for allocating
  buffers for key for metadata locking subsystem.
  Added declarations of server kernel functions used by metadata
  locking subsystem to mdl.h in order to decrease dependency of
  mdl.cc on other files.
sql/mysql_priv.h:
  Moved declaration of notify_thread_having_shared_lock() to the
  mdl.h (also renamed it to make clear in metadata locking code
  that it is a callback to SQL-layer).
sql/sql_base.cc:
  Renamed notify_thread_having_shared_lock() to make it clear
  in metadata locking subsystem code that it is a callback
  to SQL layer.
sql/sql_handler.cc:
  Use newly introduced MAX_MDLKEY_LENGTH constant for allocating
  buffer for object key for metadata locking subsystem.
sql/sql_show.cc:
  Use newly introduced MAX_MDLKEY_LENGTH constant for allocating
  buffer for object key for metadata locking subsystem.
parent b70c389f
......@@ -141,7 +141,7 @@ static Uint64 *p_latest_trans_gci= 0;
static TABLE *ndb_binlog_index= 0;
static TABLE_LIST binlog_tables;
static MDL_LOCK_DATA binlog_mdl_lock_data;
static char binlog_mdlkey[MAX_DBKEY_LENGTH];
static char binlog_mdlkey[MAX_MDLKEY_LENGTH];
/*
Helper functions
......
......@@ -8074,7 +8074,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
&db_mem, (uint) NAME_LEN + 1,
&tname_mem, (uint) NAME_LEN + 1,
&mdl_lock_data, sizeof(MDL_LOCK_DATA),
&mdlkey, MAX_DBKEY_LENGTH,
&mdlkey, MAX_MDLKEY_LENGTH,
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
#include "sql_plist.h"
#include <my_sys.h>
#include <m_string.h>
#include <mysql_com.h>
class THD;
......@@ -148,6 +149,9 @@ 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_merge(MDL_CONTEXT *target, MDL_CONTEXT *source);
/** Maximal length of key for metadata locking subsystem. */
#define MAX_MDLKEY_LENGTH (4 + NAME_LEN + 1 + NAME_LEN + 1)
void mdl_init_lock(MDL_LOCK_DATA *lock_data, char *key, int type,
const char *db, const char *name);
MDL_LOCK_DATA *mdl_alloc_lock(int type, const char *db, const char *name,
......@@ -237,4 +241,19 @@ void* mdl_get_cached_object(MDL_LOCK_DATA *lock_data);
void mdl_set_cached_object(MDL_LOCK_DATA *lock_data, void *cached_object,
mdl_cached_object_release_hook release_hook);
/*
Functions in the server's kernel used by metadata locking subsystem.
*/
extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use);
extern void mysql_ha_flush(THD *thd);
extern "C" const char *set_thd_proc_info(THD *thd, const char *info,
const char *calling_function,
const char *calling_file,
const unsigned int calling_line);
#ifndef DBUG_OFF
extern pthread_mutex_t LOCK_open;
#endif
#endif
......@@ -1534,8 +1534,6 @@ char *generate_partition_syntax(partition_info *part_info,
Alter_info *alter_info);
#endif
bool notify_thread_having_shared_lock(THD *thd, THD *in_use);
enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN,
TDC_RT_REMOVE_UNUSED};
void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
......
......@@ -1275,7 +1275,7 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
/*
We need to hold LOCK_open while changing the open_tables
list, since another thread may work on it.
@sa notify_thread_having_shared_lock()
@sa mysql_notify_thread_having_shared_lock()
*/
pthread_mutex_lock(&LOCK_open);
......@@ -1455,7 +1455,7 @@ void close_thread_tables(THD *thd,
/*
Note that we need to hold LOCK_open while changing the
open_tables list. Another thread may work on it.
(See: notify_thread_having_shared_lock())
(See: mysql_notify_thread_having_shared_lock())
Closing a MERGE child before the parent would be fatal if the
other thread tries to abort the MERGE lock in between.
*/
......@@ -7956,7 +7956,7 @@ void flush_tables()
rest of the server is broken.
*/
bool notify_thread_having_shared_lock(THD *thd, THD *in_use)
bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use)
{
bool signalled= FALSE;
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
......@@ -8501,7 +8501,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
/*
Note that we need to hold LOCK_open while changing the
open_tables list. Another thread may work on it.
(See: notify_thread_having_shared_lock())
(See: mysql_notify_thread_having_shared_lock())
Closing a MERGE child before the parent would be fatal if the
other thread tries to abort the MERGE lock in between.
*/
......
......@@ -247,7 +247,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
&name, (uint) namelen,
&alias, (uint) aliaslen,
&mdl_lock_data, sizeof(MDL_LOCK_DATA),
&mdlkey, MAX_DBKEY_LENGTH,
&mdlkey, MAX_MDLKEY_LENGTH,
NullS)))
{
DBUG_PRINT("exit",("ERROR"));
......
......@@ -3084,7 +3084,7 @@ uint get_table_open_method(TABLE_LIST *tables,
@param mdlkey Pointer to the buffer for key for the lock request
(should be at least strlen(db) + strlen(name) + 2
bytes, or, if the lengths are not known,
MAX_DBNAME_LENGTH)
MAX_MDLKEY_LENGTH)
@param table Table list element for the table
@note This is an auxiliary function to be used in cases when we want to
......@@ -3157,7 +3157,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
uint key_length;
char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
MDL_LOCK_DATA mdl_lock_data;
char mdlkey[MAX_DBKEY_LENGTH];
char mdlkey[MAX_MDLKEY_LENGTH];
bzero((char*) &table_list, sizeof(TABLE_LIST));
bzero((char*) &tbl, sizeof(TABLE));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment