mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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"
This commit is contained in:
@ -1216,7 +1216,7 @@ uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
|
|||||||
bool tmp_table);
|
bool tmp_table);
|
||||||
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
|
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
|
||||||
uint key_length, uint db_flags, int *error);
|
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_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,
|
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
|
||||||
uint lock_flags);
|
uint lock_flags);
|
||||||
|
@ -651,29 +651,17 @@ static TABLE_SHARE
|
|||||||
db_flags, error));
|
db_flags, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Mark that we are not using table share anymore.
|
||||||
|
|
||||||
/*
|
@param share Table share
|
||||||
Mark that we are not using table share anymore.
|
|
||||||
|
|
||||||
SYNOPSIS
|
If the share has no open tables and (we have done a refresh or
|
||||||
release_table_share()
|
if we have already too many open table shares) then delete the
|
||||||
share Table share
|
definition.
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void release_table_share(TABLE_SHARE *share, enum release_type type)
|
void release_table_share(TABLE_SHARE *share)
|
||||||
{
|
{
|
||||||
bool to_be_deleted= 0;
|
bool to_be_deleted= 0;
|
||||||
DBUG_ENTER("release_table_share");
|
DBUG_ENTER("release_table_share");
|
||||||
@ -818,7 +806,7 @@ void close_handle_and_leave_table_as_lock(TABLE *table)
|
|||||||
table->file->close();
|
table->file->close();
|
||||||
table->db_stat= 0; // Mark file closed
|
table->db_stat= 0; // Mark file closed
|
||||||
table_def_change_share(table, share);
|
table_def_change_share(table, share);
|
||||||
release_table_share(table->s, RELEASE_NORMAL);
|
release_table_share(table->s);
|
||||||
table->s= share;
|
table->s= share;
|
||||||
table->file->change_table_ptr(table, table->s);
|
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)
|
void table_share_release_hook(void *share)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
release_table_share((TABLE_SHARE*)share, RELEASE_NORMAL);
|
release_table_share((TABLE_SHARE*) share);
|
||||||
broadcast_refresh();
|
broadcast_refresh();
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
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;
|
goto err_unlock;
|
||||||
|
|
||||||
/* TODO: Don't free this */
|
/* TODO: Don't free this */
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
|
|
||||||
if (flags & OPEN_VIEW_NO_PARSE)
|
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)
|
if (action)
|
||||||
*action= OT_BACK_OFF_AND_RETRY;
|
*action= OT_BACK_OFF_AND_RETRY;
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0);
|
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= share->free_tables.head();
|
||||||
table_def_use_table(thd, table);
|
table_def_use_table(thd, table);
|
||||||
/* We need to release share as we have EXTRA reference to it in our hands. */
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
@ -3095,7 +3083,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
DBUG_RETURN(table);
|
DBUG_RETURN(table);
|
||||||
|
|
||||||
err_unlock:
|
err_unlock:
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
err_unlock2:
|
err_unlock2:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
mdl_release_lock(&thd->mdl_context, mdl_lock);
|
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, ¬_used, table_list,
|
flags, thd->open_options, ¬_used, table_list,
|
||||||
mem_root))
|
mem_root))
|
||||||
{
|
{
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_error(ER_WRONG_OBJECT, MYF(0), share->db.str, share->table_name.str, "VIEW");
|
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:
|
err:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -3838,7 +3826,7 @@ retry:
|
|||||||
if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
|
if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
|
||||||
goto err;
|
goto err;
|
||||||
/* Attempt to reopen view will bring havoc to upper layers anyway. */
|
/* 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,
|
my_error(ER_WRONG_OBJECT, MYF(0), share->db.str, share->table_name.str,
|
||||||
"BASE TABLE");
|
"BASE TABLE");
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
@ -3871,7 +3859,7 @@ retry:
|
|||||||
if (share->ref_count != 1)
|
if (share->ref_count != 1)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
|
|
||||||
if (ha_create_table_from_engine(thd, table_list->db,
|
if (ha_create_table_from_engine(thd, table_list->db,
|
||||||
table_list->table_name))
|
table_list->table_name))
|
||||||
@ -3887,7 +3875,7 @@ retry:
|
|||||||
entry->s->version= 0;
|
entry->s->version= 0;
|
||||||
|
|
||||||
/* TODO: We don't need to release share here. */
|
/* TODO: We don't need to release share here. */
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
error= (int)auto_repair_table(thd, table_list);
|
error= (int)auto_repair_table(thd, table_list);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
@ -3907,7 +3895,7 @@ retry:
|
|||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4031,7 +4019,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
end_with_lock_open:
|
end_with_lock_open:
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class I_P_List
|
|||||||
public:
|
public:
|
||||||
I_P_List() : first(NULL) { };
|
I_P_List() : first(NULL) { };
|
||||||
inline void empty() { 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)
|
inline void push_front(T* a)
|
||||||
{
|
{
|
||||||
*B::next_ptr(a)= first;
|
*B::next_ptr(a)= first;
|
||||||
|
@ -3206,7 +3206,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
err_share:
|
err_share:
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share);
|
||||||
|
|
||||||
err_unlock:
|
err_unlock:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
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))
|
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);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0); // Out of memory
|
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->ref_count++;
|
||||||
share->version= 0;
|
share->version= 0;
|
||||||
pthread_mutex_unlock(&share->mutex);
|
pthread_mutex_unlock(&share->mutex);
|
||||||
release_table_share(share, RELEASE_WAIT_FOR_DROP);
|
release_table_share(share);
|
||||||
}
|
}
|
||||||
query_cache_invalidate3(thd, view, 0);
|
query_cache_invalidate3(thd, view, 0);
|
||||||
sp_cache_invalidate();
|
sp_cache_invalidate();
|
||||||
|
10
sql/table.cc
10
sql/table.cc
@ -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));
|
memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
|
||||||
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
|
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&share->cond, NULL);
|
|
||||||
}
|
}
|
||||||
DBUG_RETURN(share);
|
DBUG_RETURN(share);
|
||||||
}
|
}
|
||||||
@ -418,16 +417,9 @@ void free_table_share(TABLE_SHARE *share)
|
|||||||
*/
|
*/
|
||||||
if (share->tmp_table == NO_TMP_TABLE)
|
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 */
|
/* No thread refers to this anymore */
|
||||||
pthread_mutex_unlock(&share->mutex);
|
pthread_mutex_unlock(&share->mutex);
|
||||||
pthread_mutex_destroy(&share->mutex);
|
pthread_mutex_destroy(&share->mutex);
|
||||||
pthread_cond_destroy(&share->cond);
|
|
||||||
}
|
}
|
||||||
my_hash_free(&share->name_hash);
|
my_hash_free(&share->name_hash);
|
||||||
|
|
||||||
@ -2001,7 +1993,7 @@ int closefrm(register TABLE *table, bool free_share)
|
|||||||
if (free_share)
|
if (free_share)
|
||||||
{
|
{
|
||||||
if (table->s->tmp_table == NO_TMP_TABLE)
|
if (table->s->tmp_table == NO_TMP_TABLE)
|
||||||
release_table_share(table->s, RELEASE_NORMAL);
|
release_table_share(table->s);
|
||||||
else
|
else
|
||||||
free_table_share(table->s);
|
free_table_share(table->s);
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,6 @@ struct TABLE_SHARE
|
|||||||
TYPELIB fieldnames; /* Pointer to fieldnames */
|
TYPELIB fieldnames; /* Pointer to fieldnames */
|
||||||
TYPELIB *intervals; /* pointer to interval info */
|
TYPELIB *intervals; /* pointer to interval info */
|
||||||
pthread_mutex_t mutex; /* For locking the share */
|
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 */
|
TABLE_SHARE *next, **prev; /* Link to unused shares */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -410,7 +409,6 @@ struct TABLE_SHARE
|
|||||||
bool crashed;
|
bool crashed;
|
||||||
bool is_view;
|
bool is_view;
|
||||||
bool name_lock, replace_with_name_lock;
|
bool name_lock, replace_with_name_lock;
|
||||||
bool waiting_on_cond; /* Protection against free */
|
|
||||||
ulong table_map_id; /* for row-based replication */
|
ulong table_map_id; /* for row-based replication */
|
||||||
ulonglong table_map_version;
|
ulonglong table_map_version;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user