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

Method handle_table

sql/sql_base.cc:5266–5342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5264*/
5265
5266bool DML_prelocking_strategy::handle_table(THD *thd,
5267 Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
5268 bool *need_prelocking)
5269{
5270 DBUG_ENTER("handle_table");
5271 TABLE *table= table_list->table;
5272 bool trigger_prelocking_needed=
5273 (table_list->lock_type >= TL_FIRST_WRITE) ? TRUE : FALSE;
5274 /* We rely on a caller to check that table is going to be changed. */
5275 DBUG_ASSERT(table_list->lock_type >= TL_FIRST_WRITE ||
5276 ((sql_command_flags[thd->lex->sql_command] & CF_INSERTS_DATA)
5277 && table_list->lock_type == TL_READ) ||
5278 thd->lex->default_used);
5279
5280#ifdef WITH_WSREP
5281 /*
5282 Only do trigger prelocking for tables that are doing to be modified (with
5283 a write lock), but ignore rest for Galera additional keys for the
5284 referenced/foreign table are needed to avoid potential MDL conflicts with
5285 concurrent update and DDLs.
5286 */
5287 if (WSREP(thd) && !thd->wsrep_applier &&
5288 wsrep_is_active(thd) &&
5289 (sql_command_flags[thd->lex->sql_command] & CF_INSERTS_DATA) &&
5290 table_list->trg_event_map && !table->triggers)
5291 {
5292 trigger_prelocking_needed= TRUE;
5293 }
5294#endif // WITH_WSREP
5295
5296 if (table_list->trg_event_map && trigger_prelocking_needed)
5297 {
5298 if (table->triggers)
5299 {
5300 *need_prelocking= TRUE;
5301
5302 if (table->triggers->
5303 add_tables_and_routines_for_triggers(thd, prelocking_ctx, table_list))
5304 return TRUE;
5305 }
5306
5307 if (prepare_fk_prelocking_list(thd, prelocking_ctx, table_list,
5308 need_prelocking,
5309 table_list->trg_event_map))
5310 return TRUE;
5311 }
5312 else if (table_list->slave_fk_event_map)
5313 {
5314 if (prepare_fk_prelocking_list(thd, prelocking_ctx, table_list,
5315 need_prelocking,
5316 table_list->slave_fk_event_map))
5317 return TRUE;
5318 }
5319
5320 /* Open any tables used by DEFAULT (like sequence tables) */
5321 DBUG_PRINT("info", ("table: %p name: %s db: %s flags: %u",
5322 table_list, table_list->table_name.str,
5323 table_list->db.str, table_list->for_insert_data));

Callers 1

extend_table_listFunction · 0.45

Calls 5

wsrep_is_activeFunction · 0.85
add_internal_tablesFunction · 0.85
restore_active_arenaMethod · 0.80

Tested by

no test coverage detected