diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-11-30 22:11:32 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-11-30 22:11:32 +0300 |
commit | 40d98edd220d1ec7a317d3c1cbcbf58c5748388b (patch) | |
tree | cb0f4c87110d9fd6443823f603e64f3dd5aa03cd /sql | |
parent | aeebede1954d12b80f4c4aea016460501bfc2f5a (diff) | |
download | mariadb-git-40d98edd220d1ec7a317d3c1cbcbf58c5748388b.tar.gz |
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"
sql/mysql_priv.h:
Update declaration.
sql/sql_base.cc:
Upate declaration and the comment (release_share()).
sql/sql_plist.h:
A cosmetic change, is_empty() is a const method.
sql/sql_table.cc:
Update to use the new declaration of release_table_share().
sql/sql_view.cc:
Update to use the new declaration of release_table_share().
sql/table.cc:
Update to use the new declaration of release_table_share().
Remove dead code.
sql/table.h:
Remove unused members of TABLE.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 52 | ||||
-rw-r--r-- | sql/sql_plist.h | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 10 | ||||
-rw-r--r-- | sql/table.h | 2 |
8 files changed, 26 insertions, 48 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index ab692c3ab22..063b36c4ddc 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -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); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6b0efadb712..f963d74102b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -651,29 +651,17 @@ static TABLE_SHARE db_flags, error)); } +/** + Mark that we are not using table share anymore. -/* - Mark that we are not using table share anymore. + @param share Table share - 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. - - 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, ¬_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 @@ retry: 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 @@ retry: 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 @@ retry: 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 @@ retry: 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; } diff --git a/sql/sql_plist.h b/sql/sql_plist.h index af2ed227ea1..b05a6318f0f 100644 --- a/sql/sql_plist.h +++ b/sql/sql_plist.h @@ -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; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c83a6981166..236bca76c7d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -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); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f91bae8b76c..640cd71fc62 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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 } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index a0acde600c7..3dc5ca4e09c 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -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(); diff --git a/sql/table.cc b/sql/table.cc index 181014df9f4..b232ba23a89 100644 --- a/sql/table.cc +++ b/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)); 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); } diff --git a/sql/table.h b/sql/table.h index b0598e07299..016a99e5452 100644 --- a/sql/table.h +++ b/sql/table.h @@ -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; |