MCPcopy Create free account
hub / github.com/MariaDB/server / open_and_lock_internal_tables

Function open_and_lock_internal_tables

sql/sql_base.cc:5353–5395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5351*/
5352
5353bool open_and_lock_internal_tables(TABLE *table, bool lock_table)
5354{
5355 THD *thd= table->in_use;
5356 TABLE_LIST *tl;
5357 MYSQL_LOCK *save_lock,*new_lock;
5358 DBUG_ENTER("open_and_lock_internal_tables");
5359
5360 /* remove pointer to old select_lex which is already destroyed */
5361 for (tl= table->internal_tables ; tl ; tl= tl->next_global)
5362 tl->select_lex= 0;
5363
5364 uint counter;
5365 MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
5366 TABLE_LIST *tmp= table->internal_tables;
5367 DML_prelocking_strategy prelocking_strategy;
5368
5369 if (open_tables(thd, thd->lex->create_info, &tmp, &counter, 0,
5370 &prelocking_strategy))
5371 goto err;
5372
5373 if (lock_table)
5374 {
5375 save_lock= thd->lock;
5376 thd->lock= 0;
5377 if (lock_tables(thd, table->internal_tables, counter,
5378 MYSQL_LOCK_USE_MALLOC))
5379 goto err;
5380
5381 if (!(new_lock= mysql_lock_merge(save_lock, thd->lock)))
5382 {
5383 thd->lock= save_lock;
5384 mysql_unlock_tables(thd, save_lock, 1);
5385 /* We don't have to close tables as caller will do that */
5386 goto err;
5387 }
5388 thd->lock= new_lock;
5389 }
5390 DBUG_RETURN(0);
5391
5392err:
5393 thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
5394 DBUG_RETURN(1);
5395}
5396
5397
5398/**

Callers 2

Calls 6

lock_tablesFunction · 0.85
mysql_lock_mergeFunction · 0.85
mysql_unlock_tablesFunction · 0.85
mdl_savepointMethod · 0.80
open_tablesFunction · 0.70
rollback_to_savepointMethod · 0.45

Tested by

no test coverage detected