Commit b6c33a9a authored by Konstantin Osipov's avatar Konstantin Osipov

Backport of:

------------------------------------------------------------
revno: 2630.6.1
committer: Konstantin Osipov <konstantin@mysql.com>
branch nick: mysql-6.0-3726
timestamp: Tue 2008-05-27 13:45:34 +0400
message:
  Remove an unused argument from release_table_share().
  Remove unused members from TABLE_SHARE struct.
  Review comments in scope of WL#3726 "DDL locking for all metadata 
  objects"
parent 3226c107
......@@ -1216,7 +1216,7 @@ uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
bool tmp_table);
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
uint key_length, uint db_flags, int *error);
void release_table_share(TABLE_SHARE *share, enum release_type type);
void release_table_share(TABLE_SHARE *share);
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
uint lock_flags);
......
......@@ -651,29 +651,17 @@ static TABLE_SHARE
db_flags, error));
}
/*
/**
Mark that we are not using table share anymore.
SYNOPSIS
release_table_share()
share Table share
release_type How the release should be done:
RELEASE_NORMAL
- Release without checking
RELEASE_WAIT_FOR_DROP
- Don't return until we get a signal that the
table is deleted or the thread is killed.
IMPLEMENTATION
If ref_count goes to zero and (we have done a refresh or if we have
already too many open table shares) then delete the definition.
@param share Table share
If type == RELEASE_WAIT_FOR_DROP then don't return until we get a signal
that the table is deleted or the thread is killed.
If the share has no open tables and (we have done a refresh or
if we have already too many open table shares) then delete the
definition.
*/
void release_table_share(TABLE_SHARE *share, enum release_type type)
void release_table_share(TABLE_SHARE *share)
{
bool to_be_deleted= 0;
DBUG_ENTER("release_table_share");
......@@ -818,7 +806,7 @@ void close_handle_and_leave_table_as_lock(TABLE *table)
table->file->close();
table->db_stat= 0; // Mark file closed
table_def_change_share(table, share);
release_table_share(table->s, RELEASE_NORMAL);
release_table_share(table->s);
table->s= share;
table->file->change_table_ptr(table, table->s);
......@@ -2568,7 +2556,7 @@ bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists)
void table_share_release_hook(void *share)
{
pthread_mutex_lock(&LOCK_open);
release_table_share((TABLE_SHARE*)share, RELEASE_NORMAL);
release_table_share((TABLE_SHARE*) share);
broadcast_refresh();
pthread_mutex_unlock(&LOCK_open);
}
......@@ -2902,7 +2890,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
goto err_unlock;
/* TODO: Don't free this */
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
if (flags & OPEN_VIEW_NO_PARSE)
{
......@@ -2978,7 +2966,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{
if (action)
*action= OT_BACK_OFF_AND_RETRY;
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0);
}
......@@ -2991,7 +2979,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table= share->free_tables.head();
table_def_use_table(thd, table);
/* We need to release share as we have EXTRA reference to it in our hands. */
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
}
else
{
......@@ -3095,7 +3083,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
DBUG_RETURN(table);
err_unlock:
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
err_unlock2:
pthread_mutex_unlock(&LOCK_open);
mdl_release_lock(&thd->mdl_context, mdl_lock);
......@@ -3758,13 +3746,13 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias,
flags, thd->open_options, &not_used, table_list,
mem_root))
{
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
pthread_mutex_unlock(&LOCK_open);
return FALSE;
}
my_error(ER_WRONG_OBJECT, MYF(0), share->db.str, share->table_name.str, "VIEW");
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
err:
pthread_mutex_unlock(&LOCK_open);
return TRUE;
......@@ -3838,7 +3826,7 @@ static bool reopen_table_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
goto err;
/* Attempt to reopen view will bring havoc to upper layers anyway. */
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
my_error(ER_WRONG_OBJECT, MYF(0), share->db.str, share->table_name.str,
"BASE TABLE");
DBUG_RETURN(1);
......@@ -3871,7 +3859,7 @@ static bool reopen_table_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
if (share->ref_count != 1)
goto err;
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
if (ha_create_table_from_engine(thd, table_list->db,
table_list->table_name))
......@@ -3887,7 +3875,7 @@ static bool reopen_table_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
entry->s->version= 0;
/* TODO: We don't need to release share here. */
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
pthread_mutex_unlock(&LOCK_open);
error= (int)auto_repair_table(thd, table_list);
pthread_mutex_lock(&LOCK_open);
......@@ -3907,7 +3895,7 @@ static bool reopen_table_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
DBUG_RETURN(0);
err:
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
DBUG_RETURN(1);
}
......@@ -4031,7 +4019,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
pthread_mutex_lock(&LOCK_open);
end_with_lock_open:
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
pthread_mutex_unlock(&LOCK_open);
return result;
}
......
......@@ -62,7 +62,7 @@ class I_P_List
public:
I_P_List() : first(NULL) { };
inline void empty() { first= NULL; }
inline bool is_empty() { return (first == NULL); }
inline bool is_empty() const { return (first == NULL); }
inline void push_front(T* a)
{
*B::next_ptr(a)= first;
......
......@@ -3206,7 +3206,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
}
err_share:
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
err_unlock:
pthread_mutex_unlock(&LOCK_open);
......
......@@ -4469,7 +4469,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE))
{
release_table_share(share, RELEASE_NORMAL);
release_table_share(share);
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0); // Out of memory
}
......
......@@ -1647,7 +1647,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
share->ref_count++;
share->version= 0;
pthread_mutex_unlock(&share->mutex);
release_table_share(share, RELEASE_WAIT_FOR_DROP);
release_table_share(share);
}
query_cache_invalidate3(thd, view, 0);
sp_cache_invalidate();
......
......@@ -321,7 +321,6 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&share->cond, NULL);
}
DBUG_RETURN(share);
}
......@@ -418,16 +417,9 @@ void free_table_share(TABLE_SHARE *share)
*/
if (share->tmp_table == NO_TMP_TABLE)
{
/* share->mutex is locked in release_table_share() */
while (share->waiting_on_cond)
{
pthread_cond_broadcast(&share->cond);
pthread_cond_wait(&share->cond, &share->mutex);
}
/* No thread refers to this anymore */
pthread_mutex_unlock(&share->mutex);
pthread_mutex_destroy(&share->mutex);
pthread_cond_destroy(&share->cond);
}
my_hash_free(&share->name_hash);
......@@ -2001,7 +1993,7 @@ int closefrm(register TABLE *table, bool free_share)
if (free_share)
{
if (table->s->tmp_table == NO_TMP_TABLE)
release_table_share(table->s, RELEASE_NORMAL);
release_table_share(table->s);
else
free_table_share(table->s);
}
......
......@@ -313,7 +313,6 @@ struct TABLE_SHARE
TYPELIB fieldnames; /* Pointer to fieldnames */
TYPELIB *intervals; /* pointer to interval info */
pthread_mutex_t mutex; /* For locking the share */
pthread_cond_t cond; /* To signal that share is ready */
TABLE_SHARE *next, **prev; /* Link to unused shares */
/*
......@@ -410,7 +409,6 @@ struct TABLE_SHARE
bool crashed;
bool is_view;
bool name_lock, replace_with_name_lock;
bool waiting_on_cond; /* Protection against free */
ulong table_map_id; /* for row-based replication */
ulonglong table_map_version;
......
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