diff options
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f8a755c8d5e..9817b882bdd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1506,7 +1506,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, { for (Field **vfield_ptr= table->vfield; *vfield_ptr; vfield_ptr++) { - if ((*vfield_ptr)->stored_in_db) + if ((*vfield_ptr)->vcol_info->stored_in_db) { thd->lex->unit.insert_table_with_stored_vcol= table; break; @@ -2068,6 +2068,7 @@ public: delayed_lock= global_system_variables.low_priority_updates ? TL_WRITE_LOW_PRIORITY : TL_WRITE; mysql_mutex_unlock(&LOCK_thread_count); + thread_safe_increment32(&thread_count); DBUG_VOID_RETURN; } ~Delayed_insert() @@ -2081,17 +2082,24 @@ public: close_thread_tables(&thd); thd.mdl_context.release_transactional_locks(); } - mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_destroy(&mutex); mysql_cond_destroy(&cond); mysql_cond_destroy(&cond_client); + + /* + We could use unlink_not_visible_threads() here, but as + delayed_insert_threads also needs to be protected by + the LOCK_thread_count mutex, we open code this. + */ + mysql_mutex_lock(&LOCK_thread_count); thd.unlink(); // Must be unlinked under lock - my_free(thd.query()); - thd.security_ctx->user= thd.security_ctx->host=0; delayed_insert_threads--; mysql_mutex_unlock(&LOCK_thread_count); - thread_safe_decrement32(&thread_count); - mysql_cond_broadcast(&COND_thread_count); /* Tell main we are ready */ + + my_free(thd.query()); + thd.security_ctx->user= 0; + thd.security_ctx->host= 0; + dec_thread_count(); } /* The following is for checking when we can delete ourselves */ @@ -2226,8 +2234,6 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, if (!(di= new Delayed_insert(thd->lex->current_select))) goto end_create; - thread_safe_increment32(&thread_count); - /* Annotating delayed inserts is not supported. */ @@ -2803,15 +2809,13 @@ pthread_handler_t handle_delayed_insert(void *arg) pthread_detach_this_thread(); /* Add thread to THD list so that's it's visible in 'show processlist' */ - mysql_mutex_lock(&LOCK_thread_count); - thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; + thd->thread_id= thd->variables.pseudo_thread_id= next_thread_id(); thd->set_current_time(); - threads.append(thd); + add_to_active_threads(thd); if (abort_loop) thd->killed= KILL_CONNECTION; else thd->reset_killed(); - mysql_mutex_unlock(&LOCK_thread_count); mysql_thread_set_psi_id(thd->thread_id); @@ -3892,8 +3896,8 @@ void select_insert::abort_result_set() { Field *Item::create_field_for_create_select(THD *thd, TABLE *table) { Field *def_field, *tmp_field; - return create_tmp_field(thd, table, this, type(), - (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0); + return ::create_tmp_field(thd, table, this, type(), + (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0); } @@ -4341,8 +4345,9 @@ bool select_create::send_eof() mysql_mutex_lock(&thd->LOCK_wsrep_thd); if (thd->wsrep_conflict_state != NO_CONFLICT) { - WSREP_DEBUG("select_create commit failed, thd: %lu err: %d %s", - thd->thread_id, thd->wsrep_conflict_state, thd->query()); + WSREP_DEBUG("select_create commit failed, thd: %lld err: %d %s", + (longlong) thd->thread_id, thd->wsrep_conflict_state, + thd->query()); mysql_mutex_unlock(&thd->LOCK_wsrep_thd); abort_result_set(); DBUG_RETURN(true); |