Commit eafb11c8 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4786 merge 10.0-monty -> 10.0

use get_table_def_key() instead of create_table_def_key() where appropriate
parent 055e9cb4
...@@ -132,8 +132,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, ...@@ -132,8 +132,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(0); DBUG_RETURN(0);
has_mdl_lock= TRUE; has_mdl_lock= TRUE;
share= get_table_share(thd, table_list->db, table_list->table_name, share= get_table_share_shortlived(thd, table_list, GTS_TABLE);
GTS_TABLE);
if (share == NULL) if (share == NULL)
DBUG_RETURN(0); // Can't open frm file DBUG_RETURN(0); // Can't open frm file
......
...@@ -3859,8 +3859,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list) ...@@ -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)))) if (!(entry= (TABLE*)my_malloc(sizeof(TABLE), MYF(MY_WME))))
return result; return result;
if (!(share= get_table_share(thd, table_list->db, table_list->table_name, if (!(share= get_table_share_shortlived(thd, table_list, GTS_TABLE)))
GTS_TABLE)))
goto end_free; goto end_free;
DBUG_ASSERT(! share->is_view); DBUG_ASSERT(! share->is_view);
......
...@@ -136,6 +136,17 @@ static inline TABLE_SHARE *get_table_share(THD *thd, const char *db, ...@@ -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); 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, TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
uint lock_flags); uint lock_flags);
...@@ -365,9 +376,8 @@ static inline bool tdc_open_view(THD *thd, TABLE_LIST *table_list, ...@@ -365,9 +376,8 @@ static inline bool tdc_open_view(THD *thd, TABLE_LIST *table_list,
const char *alias, MEM_ROOT *mem_root, const char *alias, MEM_ROOT *mem_root,
uint flags) uint flags)
{ {
char key[MAX_DBKEY_LENGTH]; const char *key;
uint key_length; uint key_length= get_table_def_key(table_list, &key);
key_length= create_table_def_key(key, table_list->db, table_list->table_name);
return tdc_open_view(thd, table_list, alias, key, key_length, mem_root, flags); 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) ...@@ -3204,11 +3204,9 @@ void Query_cache::invalidate_table(THD *thd, TABLE_LIST *table_list)
invalidate_table(thd, table_list->table); // Table is open invalidate_table(thd, table_list->table); // Table is open
else else
{ {
char key[MAX_DBKEY_LENGTH]; const char *key;
uint key_length; uint key_length;
key_length= get_table_def_key(table_list, &key);
key_length= create_table_def_key(key, table_list->db,
table_list->table_name);
// We don't store temporary tables => no key_length+=4 ... // We don't store temporary tables => no key_length+=4 ...
invalidate_table(thd, (uchar *)key, key_length); invalidate_table(thd, (uchar *)key, key_length);
...@@ -3321,13 +3319,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, ...@@ -3321,13 +3319,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
(*block_table)->n= n; (*block_table)->n= n;
if (tables_used->view) if (tables_used->view)
{ {
char key[MAX_DBKEY_LENGTH]; const char *key;
uint key_length; uint key_length;
DBUG_PRINT("qcache", ("view: %s db: %s", DBUG_PRINT("qcache", ("view: %s db: %s",
tables_used->view_name.str, tables_used->view_name.str,
tables_used->view_db.str)); tables_used->view_db.str));
key_length= create_table_def_key(key, tables_used->view_db.str, key_length= get_table_def_key(tables_used, &key);
tables_used->view_name.str);
/* /*
There are not callback function for for VIEWs There are not callback function for for VIEWs
*/ */
...@@ -3416,7 +3413,7 @@ my_bool Query_cache::register_all_tables(THD *thd, ...@@ -3416,7 +3413,7 @@ my_bool Query_cache::register_all_tables(THD *thd,
*/ */
my_bool 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, Query_cache_block_table *node,
uint32 db_length, uint8 suffix_length_arg, uint32 db_length, uint8 suffix_length_arg,
uint8 cache_type, uint8 cache_type,
......
...@@ -491,7 +491,7 @@ protected: ...@@ -491,7 +491,7 @@ protected:
const char *packet, const char *packet,
ulong length, ulong length,
unsigned pkt_nr); 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, Query_cache_block_table *node,
uint32 db_length, uint8 suffix_length_arg, uint32 db_length, uint8 suffix_length_arg,
uint8 cache_type, uint8 cache_type,
......
...@@ -4424,8 +4424,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, ...@@ -4424,8 +4424,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
goto end; goto end;
} }
share= get_table_share(thd, table_list.db, table_list.table_name, share= get_table_share_shortlived(thd, &table_list, GTS_TABLE | GTS_VIEW);
GTS_TABLE | GTS_VIEW);
if (!share) if (!share)
{ {
res= 0; res= 0;
......
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