1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Remove handle_delayed_insert_impl().

This commit is contained in:
Alexander Nozdrin
2009-11-24 09:27:16 +03:00
parent e46eaca0f5
commit e57a745499

View File

@@ -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; thd->thread_stack= (char*) &thd;
if (init_thr_lock() || thd->store_globals()) if (init_thr_lock() || thd->store_globals())
{ {
@@ -2482,47 +2515,9 @@ err:
*/ */
ha_autocommit_or_rollback(thd, 1); ha_autocommit_or_rollback(thd, 1);
DBUG_VOID_RETURN; DBUG_LEAVE;
} }
/*
* 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;
}
handle_delayed_insert_impl(thd, di);
end:
/* /*
di should be unlinked from the thread handler list and have no active di should be unlinked from the thread handler list and have no active
clients clients