summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 8e75ea42f7d..06f538a2a03 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -874,6 +874,8 @@ end:
int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
{
TABLE *table;
+ TABLE_SHARE *share;
+ char *key_buff;
char key[MAX_DBKEY_LENGTH];
char *db= table_list->db;
uint key_length;
@@ -903,17 +905,18 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
}
/*
Create a table entry with the right key and with an old refresh version
- Note that we must use my_malloc() here as this is freed by the table
- cache
+ Note that we must use my_multi_malloc() here as this is freed by the
+ table cache
*/
- if (!(table= (TABLE*) my_malloc(sizeof(*table)+ sizeof(TABLE_SHARE)+
- key_length, MYF(MY_WME | MY_ZEROFILL))))
+ if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &table, sizeof(*table),
+ &share, sizeof(*share),
+ &key_buff, key_length,
+ NULL))
DBUG_RETURN(-1);
- table->s= (TABLE_SHARE*) (table+1);
- memcpy((table->s->table_cache_key.str= (char*) (table->s+1)), key,
- key_length);
- table->s->table_cache_key.length= key_length;
- table->s->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table
+ table->s= share;
+ share->set_table_cache_key(key_buff, key, key_length);
+ share->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table
table->in_use= thd;
table->locked_by_name=1;
table_list->table=table;