diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 114 |
1 files changed, 79 insertions, 35 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 510ccdd528f..5dbb3407428 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -697,8 +697,6 @@ mysql_mutex_t mysql_mutex_t LOCK_stats, LOCK_global_user_client_stats, LOCK_global_table_stats, LOCK_global_index_stats; -mysql_mutex_t LOCK_rpl_gtid_state; - /** The below lock protects access to two global server variables: max_prepared_stmt_count and prepared_stmt_count. These variables @@ -867,8 +865,6 @@ PSI_mutex_key key_LOCK_stats, key_LOCK_global_index_stats, key_LOCK_wakeup_ready, key_LOCK_wait_commit; -PSI_mutex_key key_LOCK_rpl_gtid_state; - PSI_mutex_key key_LOCK_prepare_ordered, key_LOCK_commit_ordered; PSI_mutex_key key_TABLE_SHARE_LOCK_share; @@ -912,7 +908,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_global_table_stats, "LOCK_global_table_stats", PSI_FLAG_GLOBAL}, { &key_LOCK_global_index_stats, "LOCK_global_index_stats", PSI_FLAG_GLOBAL}, { &key_LOCK_wakeup_ready, "THD::LOCK_wakeup_ready", 0}, - { &key_LOCK_rpl_gtid_state, "LOCK_rpl_gtid_state", PSI_FLAG_GLOBAL}, { &key_LOCK_wait_commit, "wait_for_commit::LOCK_wait_commit", 0}, { &key_LOCK_thd_data, "THD::LOCK_thd_data", 0}, { &key_LOCK_user_conn, "LOCK_user_conn", PSI_FLAG_GLOBAL}, @@ -1773,11 +1768,12 @@ void kill_mysql(void) if (!kill_in_progress) { pthread_t tmp; + int error; abort_loop=1; - if (mysql_thread_create(0, /* Not instrumented */ - &tmp, &connection_attrib, kill_server_thread, - (void*) 0)) - sql_print_error("Can't create thread to kill server"); + if ((error= mysql_thread_create(0, /* Not instrumented */ + &tmp, &connection_attrib, + kill_server_thread, (void*) 0))) + sql_print_error("Can't create thread to kill server (errno= %d).", error); } #endif DBUG_VOID_RETURN; @@ -2036,7 +2032,9 @@ void clean_up(bool print_message) delete binlog_filter; delete global_rpl_filter; end_ssl(); +#ifndef EMBEDDED_LIBRARY vio_end(); +#endif /*!EMBEDDED_LIBRARY*/ #if defined(ENABLED_DEBUG_SYNC) /* End the debug sync facility. See debug_sync.cc. */ debug_sync_end(); @@ -2116,7 +2114,6 @@ static void clean_up_mutexes() mysql_mutex_destroy(&LOCK_global_user_client_stats); mysql_mutex_destroy(&LOCK_global_table_stats); mysql_mutex_destroy(&LOCK_global_index_stats); - mysql_mutex_destroy(&LOCK_rpl_gtid_state); #ifdef HAVE_OPENSSL mysql_mutex_destroy(&LOCK_des_key_file); #ifndef HAVE_YASSL @@ -3316,10 +3313,12 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) #endif #ifdef USE_ONE_SIGNAL_HAND pthread_t tmp; - if (mysql_thread_create(0, /* Not instrumented */ - &tmp, &connection_attrib, kill_server_thread, - (void*) &sig)) - sql_print_error("Can't create thread to kill server"); + if ((error= mysql_thread_create(0, /* Not instrumented */ + &tmp, &connection_attrib, + kill_server_thread, + (void*) &sig))) + sql_print_error("Can't create thread to kill server (errno= %d)", + error); #else kill_server((void*) sig); // MIT THREAD has a alarm thread #endif @@ -4352,8 +4351,6 @@ static int init_thread_environment() &LOCK_global_table_stats, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_global_index_stats, &LOCK_global_index_stats, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_rpl_gtid_state, - &LOCK_rpl_gtid_state, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_prepare_ordered, &LOCK_prepare_ordered, MY_MUTEX_INIT_SLOW); mysql_cond_init(key_COND_prepare_ordered, &COND_prepare_ordered, NULL); @@ -4954,9 +4951,12 @@ static void create_shutdown_thread() #ifdef __WIN__ hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name); pthread_t hThread; - if (mysql_thread_create(key_thread_handle_shutdown, - &hThread, &connection_attrib, handle_shutdown, 0)) - sql_print_warning("Can't create thread to handle shutdown requests"); + int error; + if ((error= mysql_thread_create(key_thread_handle_shutdown, + &hThread, &connection_attrib, + handle_shutdown, 0))) + sql_print_warning("Can't create thread to handle shutdown requests" + " (errno= %d)", error); // On "Stop Service" we have to do regular shutdown Service.SetShutdownEvent(hEventShutdown); @@ -4970,6 +4970,7 @@ static void create_shutdown_thread() static void handle_connections_methods() { pthread_t hThread; + int error; DBUG_ENTER("handle_connections_methods"); if (hPipe == INVALID_HANDLE_VALUE && (!have_tcpip || opt_disable_networking) && @@ -4985,22 +4986,24 @@ static void handle_connections_methods() if (hPipe != INVALID_HANDLE_VALUE) { handler_count++; - if (mysql_thread_create(key_thread_handle_con_namedpipes, - &hThread, &connection_attrib, - handle_connections_namedpipes, 0)) + if ((error= mysql_thread_create(key_thread_handle_con_namedpipes, + &hThread, &connection_attrib, + handle_connections_namedpipes, 0))) { - sql_print_warning("Can't create thread to handle named pipes"); + sql_print_warning("Can't create thread to handle named pipes" + " (errno= %d)", error); handler_count--; } } if (have_tcpip && !opt_disable_networking) { handler_count++; - if (mysql_thread_create(key_thread_handle_con_sockets, - &hThread, &connection_attrib, - handle_connections_sockets_thread, 0)) + if ((error= mysql_thread_create(key_thread_handle_con_sockets, + &hThread, &connection_attrib, + handle_connections_sockets_thread, 0))) { - sql_print_warning("Can't create thread to handle TCP/IP"); + sql_print_warning("Can't create thread to handle TCP/IP", + " (errno= %d)", error); handler_count--; } } @@ -5008,11 +5011,12 @@ static void handle_connections_methods() if (opt_enable_shared_memory) { handler_count++; - if (mysql_thread_create(key_thread_handle_con_sharedmem, - &hThread, &connection_attrib, - handle_connections_shared_memory, 0)) + if ((error= mysql_thread_create(key_thread_handle_con_sharedmem, + &hThread, &connection_attrib, + handle_connections_shared_memory, 0))) { - sql_print_warning("Can't create thread to handle shared memory"); + sql_print_warning("Can't create thread to handle shared memory", + " (errno= %d)", error); handler_count--; } } @@ -5038,6 +5042,42 @@ void decrement_handler_count() #ifndef EMBEDDED_LIBRARY + +LEX_STRING sql_statement_names[(uint) SQLCOM_END + 1]; + +static void init_sql_statement_names() +{ + char *first_com= (char*) offsetof(STATUS_VAR, com_stat[0]); + char *last_com= (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_END]); + int record_size= (char*) offsetof(STATUS_VAR, com_stat[1]) + - (char*) offsetof(STATUS_VAR, com_stat[0]); + char *ptr; + uint i; + uint com_index; + + for (i= 0; i < ((uint) SQLCOM_END + 1); i++) + sql_statement_names[i]= empty_lex_str; + + SHOW_VAR *var= &com_status_vars[0]; + while (var->name != NULL) + { + ptr= var->value; + if ((first_com <= ptr) && (ptr <= last_com)) + { + com_index= ((int)(ptr - first_com))/record_size; + DBUG_ASSERT(com_index < (uint) SQLCOM_END); + sql_statement_names[com_index].str= const_cast<char *>(var->name); + sql_statement_names[com_index].length= strlen(var->name); + } + var++; + } + + DBUG_ASSERT(strcmp(sql_statement_names[(uint) SQLCOM_SELECT].str, "select") == 0); + DBUG_ASSERT(strcmp(sql_statement_names[(uint) SQLCOM_SIGNAL].str, "signal") == 0); + + sql_statement_names[(uint) SQLCOM_END].str= const_cast<char*>("error"); +} + #ifndef DBUG_OFF /* Debugging helper function to keep the locale database @@ -5116,6 +5156,7 @@ int mysqld_main(int argc, char **argv) /* Must be initialized early for comparison of options name */ system_charset_info= &my_charset_utf8_general_ci; + init_sql_statement_names(); sys_var_init(); #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE @@ -5715,11 +5756,14 @@ static void bootstrap(MYSQL_FILE *file) bootstrap_file=file; #ifndef EMBEDDED_LIBRARY // TODO: Enable this - if (mysql_thread_create(key_thread_bootstrap, - &thd->real_id, &connection_attrib, handle_bootstrap, - (void*) thd)) + int error; + if ((error= mysql_thread_create(key_thread_bootstrap, + &thd->real_id, &connection_attrib, + handle_bootstrap, + (void*) thd))) { - sql_print_warning("Can't create thread to handle bootstrap"); + sql_print_warning("Can't create thread to handle bootstrap (errno= %d)", + error); bootstrap_error=-1; DBUG_VOID_RETURN; } |