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

Function open_ltable

sql/sql_base.cc:5683–5769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5681*/
5682
5683TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type,
5684 uint lock_flags)
5685{
5686 TABLE *table;
5687 Open_table_context ot_ctx(thd, lock_flags);
5688 bool error;
5689 DBUG_ENTER("open_ltable");
5690
5691 /* Ignore temporary tables as they have already been opened. */
5692 if (table_list->table)
5693 DBUG_RETURN(table_list->table);
5694
5695 THD_STAGE_INFO(thd, stage_opening_tables);
5696 thd->current_tablenr= 0;
5697 /* open_ltable can be used only for BASIC TABLEs */
5698 table_list->required_type= TABLE_TYPE_NORMAL;
5699
5700 /* This function can't properly handle requests for such metadata locks. */
5701 DBUG_ASSERT(lock_flags & MYSQL_OPEN_HAS_MDL_LOCK ||
5702 table_list->mdl_request.type < MDL_SHARED_UPGRADABLE);
5703
5704 while ((error= open_table(thd, table_list, &ot_ctx)) &&
5705 ot_ctx.can_recover_from_failed_open())
5706 {
5707 /*
5708 Even though we have failed to open table we still need to
5709 call release_transactional_locks() to release metadata locks which
5710 might have been acquired successfully.
5711 */
5712 thd->mdl_context.rollback_to_savepoint(ot_ctx.start_of_statement_svp());
5713 table_list->mdl_request.ticket= 0;
5714 if (ot_ctx.recover_from_failed_open())
5715 break;
5716 }
5717
5718 if (likely(!error))
5719 {
5720 /*
5721 We can't have a view or some special "open_strategy" in this function
5722 so there should be a TABLE instance.
5723 */
5724 DBUG_ASSERT(table_list->table);
5725 table= table_list->table;
5726 if (table->file->ha_table_flags() & HA_CAN_MULTISTEP_MERGE)
5727 {
5728 /* A MERGE table must not come here. */
5729 /* purecov: begin tested */
5730 my_error(ER_WRONG_OBJECT, MYF(0), table->s->db.str,
5731 table->s->table_name.str, "BASE TABLE");
5732 table= 0;
5733 goto end;
5734 /* purecov: end */
5735 }
5736
5737 table_list->lock_type= lock_type;
5738 table->grant= table_list->grant;
5739 if (thd->locked_tables_mode)
5740 {

Callers 11

insert_serverFunction · 0.85
drop_server_internalFunction · 0.85
update_serverFunction · 0.85
mysql_install_pluginFunction · 0.85
mysql_uninstall_pluginFunction · 0.85
open_udf_func_tableFunction · 0.85
mysql_admin_tableFunction · 0.85
open_log_tableFunction · 0.85
spider_sys_open_tableFunction · 0.85

Calls 10

my_errorFunction · 0.85
mysql_lock_tablesFunction · 0.85
trans_rollback_stmtFunction · 0.85
close_thread_tablesFunction · 0.85
ha_table_flagsMethod · 0.80
open_tableFunction · 0.70
rollback_to_savepointMethod · 0.45

Tested by

no test coverage detected