Commit d3af8942 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-9488 - Table cache cleanups

tdc_assign_new_table_id() does not relate to table cache, move it out of
table_cache.cc.
parent 90c9641a
...@@ -63,6 +63,8 @@ LEX_STRING SLOW_LOG_NAME= {C_STRING_WITH_LEN("slow_log")}; ...@@ -63,6 +63,8 @@ LEX_STRING SLOW_LOG_NAME= {C_STRING_WITH_LEN("slow_log")};
*/ */
LEX_STRING parse_vcol_keyword= { C_STRING_WITH_LEN("PARSE_VCOL_EXPR ") }; LEX_STRING parse_vcol_keyword= { C_STRING_WITH_LEN("PARSE_VCOL_EXPR ") };
static int64 last_table_id;
/* Functions defined in this file */ /* Functions defined in this file */
static void fix_type_pointers(const char ***array, TYPELIB *point_to_type, static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
...@@ -327,7 +329,16 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, ...@@ -327,7 +329,16 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
&share->LOCK_share, MY_MUTEX_INIT_SLOW); &share->LOCK_share, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data, mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data,
&share->LOCK_ha_data, MY_MUTEX_INIT_FAST); &share->LOCK_ha_data, MY_MUTEX_INIT_FAST);
tdc_assign_new_table_id(share);
/*
There is one reserved number that cannot be used. Remember to
change this when 6-byte global table id's are introduced.
*/
do
{
share->table_map_id= my_atomic_add64_explicit(&last_table_id, 1,
MY_MEMORY_ORDER_RELAXED);
} while (unlikely(share->table_map_id == ~0UL));
} }
DBUG_RETURN(share); DBUG_RETURN(share);
} }
......
...@@ -67,7 +67,6 @@ I_P_List <TDC_element, ...@@ -67,7 +67,6 @@ I_P_List <TDC_element,
I_P_List_fast_push_back<TDC_element> > unused_shares; I_P_List_fast_push_back<TDC_element> > unused_shares;
static int64 tdc_version; /* Increments on each reload */ static int64 tdc_version; /* Increments on each reload */
static int64 last_table_id;
static bool tdc_inited; static bool tdc_inited;
static int32 tc_count; /**< Number of TABLE objects in table cache. */ static int32 tc_count; /**< Number of TABLE objects in table cache. */
...@@ -1091,56 +1090,3 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument, ...@@ -1091,56 +1090,3 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
} }
return res; return res;
} }
/*
Function to assign a new table map id to a table share.
PARAMETERS
share - Pointer to table share structure
DESCRIPTION
We are intentionally not checking that share->mutex is locked
since this function should only be called when opening a table
share and before it is entered into the table definition cache
(meaning that it cannot be fetched by another thread, even
accidentally).
PRE-CONDITION(S)
share is non-NULL
last_table_id_lock initialized (tdc_inited)
POST-CONDITION(S)
share->table_map_id is given a value that with a high certainty is
not used by any other table (the only case where a table id can be
reused is on wrap-around, which means more than 4 billion table
share opens have been executed while one table was open all the
time).
share->table_map_id is not ~0UL.
*/
void tdc_assign_new_table_id(TABLE_SHARE *share)
{
ulong tid;
DBUG_ENTER("assign_new_table_id");
DBUG_ASSERT(share);
DBUG_ASSERT(tdc_inited);
/*
There is one reserved number that cannot be used. Remember to
change this when 6-byte global table id's are introduced.
*/
do
{
tid= my_atomic_add64_explicit(&last_table_id, 1, MY_MEMORY_ORDER_RELAXED);
} while (unlikely(tid == ~0UL));
share->table_map_id= tid;
DBUG_PRINT("info", ("table_id= %lu", share->table_map_id));
DBUG_VOID_RETURN;
}
...@@ -220,7 +220,6 @@ extern int tdc_wait_for_old_version(THD *thd, const char *db, ...@@ -220,7 +220,6 @@ extern int tdc_wait_for_old_version(THD *thd, const char *db,
ulong refresh_version= ULONG_MAX); ulong refresh_version= ULONG_MAX);
extern ulong tdc_refresh_version(void); extern ulong tdc_refresh_version(void);
extern ulong tdc_increment_refresh_version(void); extern ulong tdc_increment_refresh_version(void);
extern void tdc_assign_new_table_id(TABLE_SHARE *share);
extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument, extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
bool no_dups= false); bool no_dups= false);
......
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