diff options
author | monty@work.mysql.com <> | 2001-09-02 18:38:33 +0200 |
---|---|---|
committer | monty@work.mysql.com <> | 2001-09-02 18:38:33 +0200 |
commit | 447c18954e904e5770d64ae3b0817a16b9060b74 (patch) | |
tree | 4689ffbe50e97ce9a47deb58fa2b9e7decdfc6a8 /sql/sql_insert.cc | |
parent | 102cabfe4acd9c78fe321829bd168342b3fbd68a (diff) | |
parent | 759cf54a9e70013d92fe18a84b3e4c56244de7da (diff) | |
download | mariadb-git-447c18954e904e5770d64ae3b0817a16b9060b74.tar.gz |
merge with 3.23.42
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c21e7668a02..14dc54bf159 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -483,7 +483,7 @@ public: COPY_INFO info; I_List<delayed_row> rows; uint group_count; - TABLE_LIST *table_list; // Argument + TABLE_LIST table_list; // Argument delayed_insert() :locks_in_memory(0), @@ -512,10 +512,12 @@ public: delayed_row *row; while ((row=rows.get())) delete row; - pthread_mutex_destroy(&mutex); if (table) close_thread_tables(&thd); VOID(pthread_mutex_lock(&LOCK_thread_count)); + pthread_mutex_destroy(&mutex); + pthread_cond_destroy(&cond); + pthread_cond_destroy(&cond_client); thd.unlink(); // Must be unlinked under lock x_free(thd.query); thd.user=thd.host=0; @@ -610,7 +612,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) pthread_mutex_unlock(&LOCK_delayed_create); DBUG_RETURN(0); } - tmp->table_list=table_list; // Needed to open table + tmp->table_list= *table_list; // Needed to open table + tmp->table_list.db= tmp->thd.db; + tmp->table_list.name= tmp->table_list.real_name=tmp->thd.query; tmp->lock(); pthread_mutex_lock(&tmp->mutex); if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib, @@ -843,13 +847,11 @@ void kill_delayed_threads(void) if (tmp->thd.mysys_var) { pthread_mutex_lock(&tmp->thd.mysys_var->mutex); - if (tmp->thd.mysys_var->current_mutex) + if (tmp->thd.mysys_var->current_cond) { - if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) - pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); + pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); pthread_cond_broadcast(tmp->thd.mysys_var->current_cond); - if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) - pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); + pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); } pthread_mutex_unlock(&tmp->thd.mysys_var->mutex); } @@ -874,10 +876,11 @@ static pthread_handler_decl(handle_delayed_insert,arg) thd->thread_id=thread_id++; thd->end_time(); threads.append(thd); + thd->killed=abort_loop; pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_lock(&di->mutex); -#ifndef __WIN__ /* Win32 calls this in pthread_create */ +#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */ if (my_thread_init()) { strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES)); @@ -896,7 +899,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) } thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); @@ -904,7 +907,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) /* open table */ - if (!(di->table=open_ltable(thd,di->table_list,TL_WRITE_DELAYED))) + if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED))) { thd->fatal_error=1; // Abort waiting inserts goto end; @@ -912,7 +915,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) if (di->table->file->has_transactions()) { thd->fatal_error=1; - my_error(ER_ILLEGAL_HA, MYF(0), di->table_list->real_name); + my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name); goto end; } di->table->copy_blobs=1; @@ -964,14 +967,12 @@ static pthread_handler_decl(handle_delayed_insert,arg) #endif /* Information for pthread_kill */ - pthread_mutex_lock(&di->thd.mysys_var->mutex); di->thd.mysys_var->current_mutex= &di->mutex; di->thd.mysys_var->current_cond= &di->cond; - pthread_mutex_unlock(&di->thd.mysys_var->mutex); di->thd.proc_info=0; DBUG_PRINT("info",("Waiting for someone to insert rows")); - for ( ; ;) + while (!thd->killed) { int error; #if (defined(HAVE_BROKEN_COND_TIMEDWAIT) || defined(HAVE_LINUXTHREADS)) @@ -995,10 +996,13 @@ static pthread_handler_decl(handle_delayed_insert,arg) break; } } + /* We can't lock di->mutex and mysys_var->mutex at the same time */ + pthread_mutex_unlock(&di->mutex); pthread_mutex_lock(&di->thd.mysys_var->mutex); di->thd.mysys_var->current_mutex= 0; di->thd.mysys_var->current_cond= 0; pthread_mutex_unlock(&di->thd.mysys_var->mutex); + pthread_mutex_lock(&di->mutex); } if (di->tables_in_use && ! thd->lock) |