mirror of
https://github.com/MariaDB/server.git
synced 2025-07-02 14:22:51 +03:00
MDEV-9488 - Table cache cleanups
Remove tdc_acquire_share() helpers: they don't actually make things simpler.
This commit is contained in:
@ -5047,7 +5047,9 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
|
||||
Table_exists_error_handler no_such_table_handler;
|
||||
thd->push_internal_handler(&no_such_table_handler);
|
||||
TABLE_SHARE *share= tdc_acquire_share(thd, db, table_name, flags);
|
||||
table.init_one_table(db, strlen(db), table_name, strlen(table_name),
|
||||
table_name, TL_READ);
|
||||
TABLE_SHARE *share= tdc_acquire_share(thd, &table, flags);
|
||||
thd->pop_internal_handler();
|
||||
|
||||
if (hton && share)
|
||||
|
@ -131,7 +131,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
DBUG_RETURN(0);
|
||||
has_mdl_lock= TRUE;
|
||||
|
||||
share= tdc_acquire_share_shortlived(thd, table_list, GTS_TABLE);
|
||||
share= tdc_acquire_share(thd, table_list, GTS_TABLE);
|
||||
if (share == NULL)
|
||||
DBUG_RETURN(0); // Can't open frm file
|
||||
|
||||
|
@ -2419,10 +2419,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
||||
|
||||
retry_share:
|
||||
|
||||
share= tdc_acquire_share(thd, table_list->db, table_list->table_name,
|
||||
key, key_length,
|
||||
table_list->mdl_request.key.tc_hash_value(),
|
||||
gts_flags, &table);
|
||||
share= tdc_acquire_share(thd, table_list, gts_flags, &table);
|
||||
|
||||
if (!share)
|
||||
{
|
||||
@ -3291,8 +3288,7 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias,
|
||||
TABLE_SHARE *share;
|
||||
bool err= TRUE;
|
||||
|
||||
if (!(share= tdc_acquire_share(thd, table_list->db, table_list->table_name,
|
||||
cache_key, cache_key_length, GTS_VIEW)))
|
||||
if (!(share= tdc_acquire_share(thd, table_list, GTS_VIEW)))
|
||||
return TRUE;
|
||||
|
||||
DBUG_ASSERT(share->is_view);
|
||||
@ -3379,7 +3375,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
|
||||
if (!(entry= (TABLE*)my_malloc(sizeof(TABLE), MYF(MY_WME))))
|
||||
return result;
|
||||
|
||||
if (!(share= tdc_acquire_share_shortlived(thd, table_list, GTS_TABLE)))
|
||||
if (!(share= tdc_acquire_share(thd, table_list, GTS_TABLE)))
|
||||
goto end_free;
|
||||
|
||||
DBUG_ASSERT(! share->is_view);
|
||||
@ -3598,8 +3594,7 @@ Open_table_context::recover_from_failed_open()
|
||||
if (open_if_exists)
|
||||
m_thd->push_internal_handler(&no_such_table_handler);
|
||||
|
||||
result= !tdc_acquire_share(m_thd, m_failed_table->db,
|
||||
m_failed_table->table_name,
|
||||
result= !tdc_acquire_share(m_thd, m_failed_table,
|
||||
GTS_TABLE | GTS_FORCE_DISCOVERY | GTS_NOLOCK);
|
||||
if (open_if_exists)
|
||||
{
|
||||
|
@ -4489,7 +4489,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
|
||||
goto end;
|
||||
}
|
||||
|
||||
share= tdc_acquire_share_shortlived(thd, &table_list, GTS_TABLE | GTS_VIEW);
|
||||
share= tdc_acquire_share(thd, &table_list, GTS_TABLE | GTS_VIEW);
|
||||
if (!share)
|
||||
{
|
||||
res= 0;
|
||||
|
@ -598,13 +598,14 @@ void tdc_unlock_share(TDC_element *element)
|
||||
# Share for table
|
||||
*/
|
||||
|
||||
TABLE_SHARE *tdc_acquire_share(THD *thd, const char *db, const char *table_name,
|
||||
const char *key, uint key_length,
|
||||
my_hash_value_type hash_value, uint flags,
|
||||
TABLE_SHARE *tdc_acquire_share(THD *thd, TABLE_LIST *tl, uint flags,
|
||||
TABLE **out_table)
|
||||
{
|
||||
TABLE_SHARE *share;
|
||||
TDC_element *element;
|
||||
const char *key;
|
||||
uint key_length= get_table_def_key(tl, &key);
|
||||
my_hash_value_type hash_value= tl->mdl_request.key.tc_hash_value();
|
||||
bool was_unused;
|
||||
DBUG_ENTER("tdc_acquire_share");
|
||||
|
||||
@ -628,7 +629,7 @@ retry:
|
||||
lf_hash_search_unpin(thd->tdc_hash_pins);
|
||||
DBUG_ASSERT(element);
|
||||
|
||||
if (!(share= alloc_table_share(db, table_name, key, key_length)))
|
||||
if (!(share= alloc_table_share(tl->db, tl->table_name, key, key_length)))
|
||||
{
|
||||
lf_hash_delete(&tdc_hash, thd->tdc_hash_pins, key, key_length);
|
||||
DBUG_RETURN(0);
|
||||
|
@ -205,11 +205,8 @@ extern void tdc_purge(bool all);
|
||||
extern TDC_element *tdc_lock_share(THD *thd, const char *db,
|
||||
const char *table_name);
|
||||
extern void tdc_unlock_share(TDC_element *element);
|
||||
extern TABLE_SHARE *tdc_acquire_share(THD *thd, const char *db,
|
||||
const char *table_name,
|
||||
const char *key, uint key_length,
|
||||
my_hash_value_type hash_value,
|
||||
uint flags, TABLE **out_table);
|
||||
extern TABLE_SHARE *tdc_acquire_share(THD *thd, TABLE_LIST *tl, uint flags,
|
||||
TABLE **out_table= 0);
|
||||
extern void tdc_release_share(TABLE_SHARE *share);
|
||||
extern bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
|
||||
const char *db, const char *table_name,
|
||||
@ -248,50 +245,3 @@ inline uint tdc_create_key(char *key, const char *db, const char *table_name)
|
||||
return (uint) (strmake(strmake(key, db, NAME_LEN) + 1, table_name,
|
||||
NAME_LEN) - key + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Convenience helper: call tdc_acquire_share() without out_table.
|
||||
*/
|
||||
|
||||
static inline TABLE_SHARE *tdc_acquire_share(THD *thd, const char *db,
|
||||
const char *table_name,
|
||||
const char *key,
|
||||
uint key_length, uint flags)
|
||||
{
|
||||
return tdc_acquire_share(thd, db, table_name, key, key_length,
|
||||
my_hash_sort(&my_charset_bin, (uchar*) key,
|
||||
key_length), flags, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convenience helper: call tdc_acquire_share() without precomputed cache key.
|
||||
*/
|
||||
|
||||
static inline TABLE_SHARE *tdc_acquire_share(THD *thd, const char *db,
|
||||
const char *table_name, uint flags)
|
||||
{
|
||||
char key[MAX_DBKEY_LENGTH];
|
||||
uint key_length;
|
||||
key_length= tdc_create_key(key, db, table_name);
|
||||
return tdc_acquire_share(thd, db, table_name, key, key_length, flags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convenience helper: call tdc_acquire_share() reusing the MDL cache key.
|
||||
|
||||
@note lifetime of the returned TABLE_SHARE is limited by the
|
||||
lifetime of the TABLE_LIST object!!!
|
||||
*/
|
||||
|
||||
uint get_table_def_key(const TABLE_LIST *table_list, const char **key);
|
||||
|
||||
static inline TABLE_SHARE *tdc_acquire_share_shortlived(THD *thd, TABLE_LIST *tl,
|
||||
uint flags)
|
||||
{
|
||||
const char *key;
|
||||
uint key_length= get_table_def_key(tl, &key);
|
||||
return tdc_acquire_share(thd, tl->db, tl->table_name, key, key_length,
|
||||
tl->mdl_request.key.tc_hash_value(), flags, 0);
|
||||
}
|
||||
|
@ -1015,10 +1015,7 @@ TABLE_SHARE *mrn_get_table_share(TABLE_LIST *table_list, int *error)
|
||||
share = get_table_share(thd, table_list, key, key_length, 0, error,
|
||||
hash_value);
|
||||
#elif defined(MRN_HAVE_TDC_ACQUIRE_SHARE)
|
||||
share = tdc_acquire_share(thd, table_list->db, table_list->table_name, key,
|
||||
key_length,
|
||||
table_list->mdl_request.key.tc_hash_value(),
|
||||
GTS_TABLE, NULL);
|
||||
share = tdc_acquire_share(thd, table_list, GTS_TABLE);
|
||||
#else
|
||||
share = get_table_share(thd, table_list, key, key_length, 0, error);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user