diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 901d35844e3..f4804303e9d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -381,7 +381,7 @@ THD::THD() current_linfo = 0; slave_thread = 0; bzero(&variables, sizeof(variables)); - thread_id= variables.pseudo_thread_id= 0; + thread_id= 0; one_shot_set= 0; file_id = 0; query_id= 0; @@ -498,6 +498,12 @@ void THD::init(void) variables.date_format); variables.datetime_format= date_time_format_copy((THD*) 0, variables.datetime_format); + /* + variables= global_system_variables above has reset + variables.pseudo_thread_id to 0. We need to correct it here to + avoid temporary tables replication failure. + */ + variables.pseudo_thread_id= thread_id; pthread_mutex_unlock(&LOCK_global_system_variables); server_status= SERVER_STATUS_AUTOCOMMIT; if (variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)