diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-08-12 14:17:51 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-08-12 14:17:51 +0200 |
commit | eafb11c821dedf5fb5509875b4fb553417ef1ea5 (patch) | |
tree | 5263e3bcc243c88a8dc89bd3c471496a6d7b353b /sql | |
parent | 055e9cb49c18460efcb0bba83f5e4da63ede0cdc (diff) | |
download | mariadb-git-eafb11c821dedf5fb5509875b4fb553417ef1ea5.tar.gz |
MDEV-4786 merge 10.0-monty -> 10.0
use get_table_def_key() instead of create_table_def_key() where appropriate
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_admin.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.h | 16 | ||||
-rw-r--r-- | sql/sql_cache.cc | 13 | ||||
-rw-r--r-- | sql/sql_cache.h | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 3 |
6 files changed, 22 insertions, 18 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 8f3ea0fedb1..fe423191d1f 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -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 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c39786c7c45..0934b12511a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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); diff --git a/sql/sql_base.h b/sql/sql_base.h index cff7432d00f..9bfc55ebc64 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -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); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 007a1b3b585..d70113c28e4 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -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, diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 15848dabd33..69520d668ac 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -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, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 587d4b6ebdb..14e89fd0ef8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -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; |