MDEV-4786 merge 10.0-monty -> 10.0
use get_table_def_key() instead of create_table_def_key() where appropriate
This commit is contained in:
parent
055e9cb49c
commit
eafb11c821
@ -132,8 +132,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
DBUG_RETURN(0);
|
||||
has_mdl_lock= TRUE;
|
||||
|
||||
share= get_table_share(thd, table_list->db, table_list->table_name,
|
||||
GTS_TABLE);
|
||||
share= get_table_share_shortlived(thd, table_list, GTS_TABLE);
|
||||
if (share == NULL)
|
||||
DBUG_RETURN(0); // Can't open frm file
|
||||
|
||||
|
@ -3859,8 +3859,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= get_table_share(thd, table_list->db, table_list->table_name,
|
||||
GTS_TABLE)))
|
||||
if (!(share= get_table_share_shortlived(thd, table_list, GTS_TABLE)))
|
||||
goto end_free;
|
||||
|
||||
DBUG_ASSERT(! share->is_view);
|
||||
|
@ -136,6 +136,17 @@ static inline TABLE_SHARE *get_table_share(THD *thd, const char *db,
|
||||
return get_table_share(thd, db, table_name, key, key_length, flags);
|
||||
}
|
||||
|
||||
// convenience helper: call get_table_share() reusing the MDL cache key.
|
||||
// NOTE: lifetime of the returned TABLE_SHARE is limited by the
|
||||
// lifetime of the TABLE_LIST object!!!
|
||||
static inline TABLE_SHARE *get_table_share_shortlived(THD *thd, TABLE_LIST *tl,
|
||||
uint flags)
|
||||
{
|
||||
const char *key;
|
||||
uint key_length= get_table_def_key(tl, &key);
|
||||
return get_table_share(thd, tl->db, tl->table_name, key, key_length, flags);
|
||||
}
|
||||
|
||||
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
|
||||
uint lock_flags);
|
||||
|
||||
@ -365,9 +376,8 @@ static inline bool tdc_open_view(THD *thd, TABLE_LIST *table_list,
|
||||
const char *alias, MEM_ROOT *mem_root,
|
||||
uint flags)
|
||||
{
|
||||
char key[MAX_DBKEY_LENGTH];
|
||||
uint key_length;
|
||||
key_length= create_table_def_key(key, table_list->db, table_list->table_name);
|
||||
const char *key;
|
||||
uint key_length= get_table_def_key(table_list, &key);
|
||||
return tdc_open_view(thd, table_list, alias, key, key_length, mem_root, flags);
|
||||
}
|
||||
|
||||
|
@ -3204,11 +3204,9 @@ void Query_cache::invalidate_table(THD *thd, TABLE_LIST *table_list)
|
||||
invalidate_table(thd, table_list->table); // Table is open
|
||||
else
|
||||
{
|
||||
char key[MAX_DBKEY_LENGTH];
|
||||
const char *key;
|
||||
uint key_length;
|
||||
|
||||
key_length= create_table_def_key(key, table_list->db,
|
||||
table_list->table_name);
|
||||
key_length= get_table_def_key(table_list, &key);
|
||||
|
||||
// We don't store temporary tables => no key_length+=4 ...
|
||||
invalidate_table(thd, (uchar *)key, key_length);
|
||||
@ -3321,13 +3319,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
|
||||
(*block_table)->n= n;
|
||||
if (tables_used->view)
|
||||
{
|
||||
char key[MAX_DBKEY_LENGTH];
|
||||
const char *key;
|
||||
uint key_length;
|
||||
DBUG_PRINT("qcache", ("view: %s db: %s",
|
||||
tables_used->view_name.str,
|
||||
tables_used->view_db.str));
|
||||
key_length= create_table_def_key(key, tables_used->view_db.str,
|
||||
tables_used->view_name.str);
|
||||
key_length= get_table_def_key(tables_used, &key);
|
||||
/*
|
||||
There are not callback function for for VIEWs
|
||||
*/
|
||||
@ -3416,7 +3413,7 @@ my_bool Query_cache::register_all_tables(THD *thd,
|
||||
*/
|
||||
|
||||
my_bool
|
||||
Query_cache::insert_table(uint key_len, char *key,
|
||||
Query_cache::insert_table(uint key_len, const char *key,
|
||||
Query_cache_block_table *node,
|
||||
uint32 db_length, uint8 suffix_length_arg,
|
||||
uint8 cache_type,
|
||||
|
@ -491,7 +491,7 @@ protected:
|
||||
const char *packet,
|
||||
ulong length,
|
||||
unsigned pkt_nr);
|
||||
my_bool insert_table(uint key_len, char *key,
|
||||
my_bool insert_table(uint key_len, const char *key,
|
||||
Query_cache_block_table *node,
|
||||
uint32 db_length, uint8 suffix_length_arg,
|
||||
uint8 cache_type,
|
||||
|
@ -4424,8 +4424,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
|
||||
goto end;
|
||||
}
|
||||
|
||||
share= get_table_share(thd, table_list.db, table_list.table_name,
|
||||
GTS_TABLE | GTS_VIEW);
|
||||
share= get_table_share_shortlived(thd, &table_list, GTS_TABLE | GTS_VIEW);
|
||||
if (!share)
|
||||
{
|
||||
res= 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user