Commit 4575f703 authored by Alexander Nozdrin's avatar Alexander Nozdrin

Remove handle_delayed_insert_impl().

parent 26cd9abe
......@@ -2291,9 +2291,42 @@ void kill_delayed_threads(void)
}
static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di)
/*
* Create a new delayed insert thread
*/
pthread_handler_t handle_delayed_insert(void *arg)
{
DBUG_ENTER("handle_delayed_insert_impl");
Delayed_insert *di=(Delayed_insert*) arg;
THD *thd= &di->thd;
pthread_detach_this_thread();
/* Add thread to THD list so that's it's visible in 'show processlist' */
pthread_mutex_lock(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
thd->set_current_time();
threads.append(thd);
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
pthread_mutex_unlock(&LOCK_thread_count);
/*
Wait until the client runs into pthread_cond_wait(),
where we free it after the table is opened and di linked in the list.
If we did not wait here, the client might detect the opened table
before it is linked to the list. It would release LOCK_delayed_create
and allow another thread to create another handler for the same table,
since it does not find one in the list.
*/
pthread_mutex_lock(&di->mutex);
if (my_thread_init())
{
/* Can't use my_error since store_globals has not yet been called */
thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
ER(ER_OUT_OF_RESOURCES), NULL);
}
else
{
DBUG_ENTER("handle_delayed_insert");
thd->thread_stack= (char*) &thd;
if (init_thr_lock() || thd->store_globals())
{
......@@ -2468,7 +2501,7 @@ static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di)
pthread_cond_broadcast(&di->cond_client); // If waiting clients
}
err:
err:
/*
mysql_lock_tables() can potentially start a transaction and write
a table map. In the event of an error, that transaction has to be
......@@ -2482,47 +2515,9 @@ err:
*/
ha_autocommit_or_rollback(thd, 1);
DBUG_VOID_RETURN;
}
/*
* Create a new delayed insert thread
*/
pthread_handler_t handle_delayed_insert(void *arg)
{
Delayed_insert *di=(Delayed_insert*) arg;
THD *thd= &di->thd;
pthread_detach_this_thread();
/* Add thread to THD list so that's it's visible in 'show processlist' */
pthread_mutex_lock(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
thd->set_current_time();
threads.append(thd);
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
pthread_mutex_unlock(&LOCK_thread_count);
/*
Wait until the client runs into pthread_cond_wait(),
where we free it after the table is opened and di linked in the list.
If we did not wait here, the client might detect the opened table
before it is linked to the list. It would release LOCK_delayed_create
and allow another thread to create another handler for the same table,
since it does not find one in the list.
*/
pthread_mutex_lock(&di->mutex);
if (my_thread_init())
{
/* Can't use my_error since store_globals has not yet been called */
thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
ER(ER_OUT_OF_RESOURCES), NULL);
goto end;
DBUG_LEAVE;
}
handle_delayed_insert_impl(thd, di);
end:
/*
di should be unlinked from the thread handler list and have no active
clients
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment