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

Function handle_delayed_insert

sql/sql_insert.cc:3507–3817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3505*/
3506
3507pthread_handler_t handle_delayed_insert(void *arg)
3508{
3509 Delayed_insert *di=(Delayed_insert*) arg;
3510 THD *thd= &di->thd;
3511
3512 pthread_detach_this_thread();
3513 /* Add thread to THD list so that's it's visible in 'show processlist' */
3514 thd->set_start_time();
3515 server_threads.insert(thd);
3516 if (abort_loop)
3517 thd->set_killed(KILL_CONNECTION);
3518 else
3519 thd->reset_killed();
3520
3521 mysql_thread_set_psi_id(thd->thread_id);
3522
3523 /*
3524 Wait until the client runs into mysql_cond_wait(),
3525 where we free it after the table is opened and di linked in the list.
3526 If we did not wait here, the client might detect the opened table
3527 before it is linked to the list. It would release LOCK_delayed_create
3528 and allow another thread to create another handler for the same table,
3529 since it does not find one in the list.
3530 */
3531 mysql_mutex_lock(&di->mutex);
3532 if (my_thread_init())
3533 {
3534 /* Can't use my_error since store_globals has not yet been called */
3535 thd->get_stmt_da()->set_error_status(ER_OUT_OF_RESOURCES);
3536 di->handler_thread_initialized= TRUE;
3537 }
3538 else
3539 {
3540 DBUG_ENTER("handle_delayed_insert");
3541 if (init_thr_lock())
3542 {
3543 thd->get_stmt_da()->set_error_status(ER_OUT_OF_RESOURCES);
3544 di->handler_thread_initialized= TRUE;
3545 thd->fatal_error();
3546 goto err;
3547 }
3548
3549 thd->store_globals();
3550
3551 thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock()
3552
3553 /*
3554 INSERT DELAYED has to go to row-based format because the time
3555 at which rows are inserted cannot be determined in mixed mode.
3556 */
3557 thd->set_current_stmt_binlog_format_row_if_mixed();
3558 /* Don't annotate insert delayed binlog events */
3559 thd->variables.binlog_annotate_row_events= 0;
3560
3561 /*
3562 Clone tickets representing protection against GRL and the lock on
3563 the target table for the insert and add them to the list of granted
3564 metadata locks held by the handler thread. This is safe since the

Callers

nothing calls this directly

Calls 15

my_thread_initFunction · 0.85
init_thr_lockFunction · 0.85
next_query_idFunction · 0.85
bitmap_set_allFunction · 0.85
mysql_audit_releaseFunction · 0.85
my_sleepFunction · 0.85
mysql_lock_tablesFunction · 0.85
mysql_unlock_tablesFunction · 0.85
trans_commit_stmtFunction · 0.85
close_thread_tablesFunction · 0.85
my_thread_endFunction · 0.85

Tested by

no test coverage detected