@@ -4256,7 +4256,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
4256
4256
if (stab->temp )
4257
4257
continue ;
4258
4258
4259
- if (!(tab_buff= (char *)thd->calloc (ALIGN_SIZE (sizeof (TABLE_LIST)) *
4259
+ if (!(tab_buff= (char *)thd->alloc (ALIGN_SIZE (sizeof (TABLE_LIST)) *
4260
4260
stab->lock_count )) ||
4261
4261
!(key_buff= (char *)thd->memdup (stab->qname .str ,
4262
4262
stab->qname .length )))
@@ -4265,32 +4265,11 @@ sp_head::add_used_tables_to_table_list(THD *thd,
4265
4265
for (uint j= 0 ; j < stab->lock_count ; j++)
4266
4266
{
4267
4267
table= (TABLE_LIST *)tab_buff;
4268
-
4269
- table->db = key_buff;
4270
- table->db_length = stab->db_length ;
4271
- table->table_name = table->db + table->db_length + 1 ;
4272
- table->table_name_length = stab->table_name_length ;
4273
- table->alias = table->table_name + table->table_name_length + 1 ;
4274
- table->lock_type = stab->lock_type ;
4275
- table->cacheable_table = 1 ;
4276
- table->prelocking_placeholder = 1 ;
4277
- table->belong_to_view = belong_to_view;
4278
- table->trg_event_map = stab->trg_event_map ;
4279
- /*
4280
- Since we don't allow DDL on base tables in prelocked mode it
4281
- is safe to infer the type of metadata lock from the type of
4282
- table lock.
4283
- */
4284
- table->mdl_request .init (MDL_key::TABLE, table->db , table->table_name ,
4285
- table->lock_type >= TL_WRITE_ALLOW_WRITE ?
4286
- MDL_SHARED_WRITE : MDL_SHARED_READ,
4287
- MDL_TRANSACTION);
4288
-
4289
- /* Everyting else should be zeroed */
4290
-
4291
- **query_tables_last_ptr= table;
4292
- table->prev_global = *query_tables_last_ptr;
4293
- *query_tables_last_ptr= &table->next_global ;
4268
+ table->init_one_table_for_prelocking (key_buff, stab->db_length ,
4269
+ key_buff + stab->db_length + 1 , stab->table_name_length ,
4270
+ key_buff + stab->db_length + stab->table_name_length + 2 ,
4271
+ stab->lock_type , belong_to_view, stab->trg_event_map ,
4272
+ query_tables_last_ptr);
4294
4273
4295
4274
tab_buff+= ALIGN_SIZE (sizeof (TABLE_LIST));
4296
4275
result= TRUE ;
0 commit comments