summaryrefslogtreecommitdiff
path: root/sql/mysqld.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r--sql/mysqld.cc1718
1 files changed, 1162 insertions, 556 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 79966f6f5e6..4f83e19f905 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -71,6 +71,11 @@
#include "scheduler.h"
#include <waiting_threads.h>
#include "debug_sync.h"
+#include "wsrep_mysqld.h"
+#include "wsrep_var.h"
+#include "wsrep_thd.h"
+#include "wsrep_sst.h"
+
#include "sql_callback.h"
#include "threadpool.h"
@@ -105,6 +110,8 @@
#include <poll.h>
#endif
+#include <my_systemd.h>
+
#define mysqld_charset &my_charset_latin1
/* We have HAVE_valgrind below as this speeds up the shutdown of MySQL */
@@ -270,6 +277,8 @@ extern "C" sig_handler handle_fatal_signal(int sig);
#define ENABLE_TEMP_POOL 0
#endif
+int init_io_cache_encryption();
+
/* Constants */
#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
@@ -305,6 +314,9 @@ arg_cmp_func Arg_comparator::comparator_matrix[6][2] =
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal},
{&Arg_comparator::compare_datetime, &Arg_comparator::compare_e_datetime}};
+/* Timer info to be used by the SQL layer */
+MY_TIMER_INFO sys_timer_info;
+
/* static variables */
#ifdef HAVE_PSI_INTERFACE
@@ -347,8 +359,9 @@ static bool max_long_data_size_used= false;
static bool volatile select_thread_in_use, signal_thread_in_use;
static volatile bool ready_to_exit;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
-static my_bool opt_short_log_format= 0;
-static uint kill_cached_threads, wake_thread;
+static my_bool opt_short_log_format= 0, opt_silent_startup= 0;
+uint kill_cached_threads;
+static uint wake_thread;
ulong max_used_connections;
static volatile ulong cached_thread_count= 0;
static char *mysqld_user, *mysqld_chroot;
@@ -356,21 +369,24 @@ static char *default_character_set_name;
static char *character_set_filesystem_name;
static char *lc_messages;
static char *lc_time_names_name;
-static char *my_bind_addr_str;
+char *my_bind_addr_str;
static char *default_collation_name;
-char *default_storage_engine;
+char *default_storage_engine, *default_tmp_storage_engine;
+char *enforced_storage_engine=NULL;
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
static I_List<THD> thread_cache;
static bool binlog_format_used= false;
LEX_STRING opt_init_connect, opt_init_slave;
-static mysql_cond_t COND_thread_cache, COND_flush_thread_cache;
-mysql_cond_t COND_slave_init;
+mysql_cond_t COND_thread_cache;
+static mysql_cond_t COND_flush_thread_cache;
+mysql_cond_t COND_slave_background;
static DYNAMIC_ARRAY all_options;
/* Global variables */
bool opt_bin_log, opt_bin_log_used=0, opt_ignore_builtin_innodb= 0;
-my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table= 0, opt_help= 0;
+my_bool opt_log, debug_assert_if_crashed_table= 0, opt_help= 0;
+my_bool disable_log_notes;
static my_bool opt_abort;
ulonglong log_output_options;
my_bool opt_userstat_running;
@@ -421,6 +437,8 @@ my_bool opt_safe_user_create = 0;
my_bool opt_show_slave_auth_info;
my_bool opt_log_slave_updates= 0;
my_bool opt_replicate_annotate_row_events= 0;
+my_bool opt_mysql56_temporal_format=0, strict_password_validation= 1;
+my_bool opt_explicit_defaults_for_timestamp= 0;
char *opt_slave_skip_errors;
/*
@@ -481,9 +499,7 @@ ulong open_files_limit, max_binlog_size;
ulong slave_trans_retries;
uint slave_net_timeout;
ulong slave_exec_mode_options;
-#ifdef RBR_TRIGGERS
ulong slave_run_triggers_for_rbr= 0;
-#endif //RBR_TRIGGERS
ulong slave_ddl_exec_mode_options= SLAVE_EXEC_MODE_IDEMPOTENT;
ulonglong slave_type_conversions_options;
ulong thread_cache_size=0;
@@ -496,11 +512,6 @@ ulonglong query_cache_size=0;
ulong query_cache_limit=0;
ulong executed_events=0;
query_id_t global_query_id;
-my_atomic_rwlock_t global_query_id_lock;
-my_atomic_rwlock_t thread_running_lock;
-my_atomic_rwlock_t thread_count_lock;
-my_atomic_rwlock_t statistics_lock;
-my_atomic_rwlock_t slave_executed_entries_lock;
ulong aborted_threads, aborted_connects;
ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
@@ -510,8 +521,9 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0;
ulong max_connections, max_connect_errors;
ulong extra_max_connections;
-ulong max_digest_length= 0;
+uint max_digest_length= 0;
ulong slave_retried_transactions;
+ulonglong slave_skipped_errors;
ulong feature_files_opened_with_delayed_keys;
ulonglong denied_connections;
my_decimal decimal_zero;
@@ -522,10 +534,6 @@ my_decimal decimal_zero;
*/
ulong max_long_data_size;
-/* Limits for internal temporary tables (MyISAM or Aria) */
-uint internal_tmp_table_max_key_length;
-uint internal_tmp_table_max_key_segments;
-
bool max_user_connections_checking=0;
/**
Limit of the total number of prepared statements in the server.
@@ -557,6 +565,7 @@ ulong stored_program_cache_size= 0;
ulong opt_slave_parallel_threads= 0;
ulong opt_slave_domain_parallel_threads= 0;
+ulong opt_slave_parallel_mode= SLAVE_PARALLEL_CONSERVATIVE;
ulong opt_binlog_commit_wait_count= 0;
ulong opt_binlog_commit_wait_usec= 0;
ulong opt_slave_parallel_max_queued= 131072;
@@ -621,6 +630,9 @@ char server_version[SERVER_VERSION_LENGTH];
char *mysqld_unix_port, *opt_mysql_tmpdir;
ulong thread_handling;
+my_bool encrypt_binlog;
+my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
+
/** name of reference on left expression in rewritten IN subquery */
const char *in_left_expr_name= "<left expr>";
/** name of additional condition */
@@ -703,7 +715,7 @@ mysql_mutex_t
LOCK_crypt,
LOCK_global_system_variables,
LOCK_user_conn, LOCK_slave_list,
- LOCK_connection_count, LOCK_error_messages, LOCK_slave_init;
+ LOCK_connection_count, LOCK_error_messages, LOCK_slave_background;
mysql_mutex_t LOCK_stats, LOCK_global_user_client_stats,
LOCK_global_table_stats, LOCK_global_index_stats;
@@ -836,8 +848,12 @@ static struct my_option pfs_early_options[]=
"Default startup value for the statements_digest consumer.",
&pfs_param.m_consumer_statement_digest_enabled,
&pfs_param.m_consumer_statement_digest_enabled, 0,
- GET_BOOL, OPT_ARG, TRUE, 0, 0, 0, 0, 0}
+ GET_BOOL, OPT_ARG, TRUE, 0, 0, 0, 0, 0},
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
+ {"getopt-prefix-matching", 0,
+ "Recognize command-line options by their unambiguos prefixes.",
+ &my_getopt_prefix_matching, &my_getopt_prefix_matching, 0, GET_BOOL,
+ NO_ARG, 1, 0, 1, 0, 0, 0}
};
#ifdef HAVE_PSI_INTERFACE
@@ -852,6 +868,7 @@ PSI_mutex_key key_LOCK_des_key_file;
PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
key_BINLOG_LOCK_binlog_background_thread,
+ m_key_LOCK_binlog_end_pos,
key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
@@ -881,8 +898,9 @@ PSI_mutex_key key_LOCK_stats,
key_LOCK_wakeup_ready, key_LOCK_wait_commit;
PSI_mutex_key key_LOCK_gtid_waiting;
+PSI_mutex_key key_LOCK_after_binlog_sync;
PSI_mutex_key key_LOCK_prepare_ordered, key_LOCK_commit_ordered,
- key_LOCK_slave_init;
+ key_LOCK_slave_background;
PSI_mutex_key key_TABLE_SHARE_LOCK_share;
static PSI_mutex_info all_server_mutexes[]=
@@ -902,6 +920,7 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_BINLOG_LOCK_index, "MYSQL_BIN_LOG::LOCK_index", 0},
{ &key_BINLOG_LOCK_xid_list, "MYSQL_BIN_LOG::LOCK_xid_list", 0},
{ &key_BINLOG_LOCK_binlog_background_thread, "MYSQL_BIN_LOG::LOCK_binlog_background_thread", 0},
+ { &m_key_LOCK_binlog_end_pos, "MYSQL_BIN_LOG::LOCK_binlog_end_pos", 0 },
{ &key_RELAYLOG_LOCK_index, "MYSQL_RELAY_LOG::LOCK_index", 0},
{ &key_delayed_insert_mutex, "Delayed_insert::mutex", 0},
{ &key_hash_filo_lock, "hash_filo::lock", 0},
@@ -946,8 +965,9 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_TABLE_SHARE_LOCK_share, "TABLE_SHARE::LOCK_share", 0},
{ &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL},
{ &key_LOCK_prepare_ordered, "LOCK_prepare_ordered", PSI_FLAG_GLOBAL},
+ { &key_LOCK_after_binlog_sync, "LOCK_after_binlog_sync", PSI_FLAG_GLOBAL},
{ &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL},
- { &key_LOCK_slave_init, "LOCK_slave_init", PSI_FLAG_GLOBAL},
+ { &key_LOCK_slave_background, "LOCK_slave_background", PSI_FLAG_GLOBAL},
{ &key_LOG_INFO_lock, "LOG_INFO::lock", 0},
{ &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL},
{ &key_LOCK_thread_cache, "LOCK_thread_cache", PSI_FLAG_GLOBAL},
@@ -1002,7 +1022,7 @@ PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy;
PSI_cond_key key_COND_rpl_thread_queue, key_COND_rpl_thread,
key_COND_rpl_thread_stop, key_COND_rpl_thread_pool,
key_COND_parallel_entry, key_COND_group_commit_orderer,
- key_COND_prepare_ordered, key_COND_slave_init;
+ key_COND_prepare_ordered, key_COND_slave_background;
PSI_cond_key key_COND_wait_gtid, key_COND_gtid_ignore_duplicates;
static PSI_cond_info all_server_conds[]=
@@ -1052,7 +1072,7 @@ static PSI_cond_info all_server_conds[]=
{ &key_COND_parallel_entry, "COND_parallel_entry", 0},
{ &key_COND_group_commit_orderer, "COND_group_commit_orderer", 0},
{ &key_COND_prepare_ordered, "COND_prepare_ordered", 0},
- { &key_COND_slave_init, "COND_slave_init", 0},
+ { &key_COND_slave_background, "COND_slave_background", 0},
{ &key_COND_wait_gtid, "COND_wait_gtid", 0},
{ &key_COND_gtid_ignore_duplicates, "COND_gtid_ignore_duplicates", 0}
};
@@ -1060,7 +1080,7 @@ static PSI_cond_info all_server_conds[]=
PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
key_thread_handle_manager, key_thread_main,
key_thread_one_connection, key_thread_signal_hand,
- key_thread_slave_init, key_rpl_parallel_thread;
+ key_thread_slave_background, key_rpl_parallel_thread;
static PSI_thread_info all_server_threads[]=
{
@@ -1086,7 +1106,7 @@ static PSI_thread_info all_server_threads[]=
{ &key_thread_main, "main", PSI_FLAG_GLOBAL},
{ &key_thread_one_connection, "one_connection", 0},
{ &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL},
- { &key_thread_slave_init, "slave_init", PSI_FLAG_GLOBAL},
+ { &key_thread_slave_background, "slave_background", PSI_FLAG_GLOBAL},
{ &key_rpl_parallel_thread, "rpl_parallel_thread", 0}
};
@@ -1402,12 +1422,12 @@ bool mysqld_embedded=0;
bool mysqld_embedded=1;
#endif
-static my_bool plugins_are_initialized= FALSE;
+my_bool plugins_are_initialized= FALSE;
#ifndef DBUG_OFF
static const char* default_dbug_option;
#endif
-static const char *current_dbug_option="disabled";
+const char *current_dbug_option="";
#ifdef HAVE_LIBWRAP
const char *libwrapName= NULL;
int allow_severity = LOG_INFO;
@@ -1529,8 +1549,7 @@ static void close_connections(void)
while (select_thread_in_use)
{
struct timespec abstime;
- int error;
- LINT_INIT(error);
+ int UNINIT_VAR(error);
DBUG_PRINT("info",("Waiting for select thread"));
#ifndef DONT_USE_THR_ALARM
@@ -1625,6 +1644,11 @@ static void close_connections(void)
if (tmp->slave_thread)
continue;
+#ifdef WITH_WSREP
+ /* skip wsrep system threads as well */
+ if (WSREP(tmp) && (tmp->wsrep_exec_mode==REPL_RECV || tmp->wsrep_applier))
+ continue;
+#endif
tmp->killed= KILL_SERVER_HARD;
MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));
mysql_mutex_lock(&tmp->LOCK_thd_data);
@@ -1701,6 +1725,34 @@ static void close_connections(void)
close_connection(tmp,ER_SERVER_SHUTDOWN);
}
#endif
+#ifdef WITH_WSREP
+ /*
+ * WSREP_TODO:
+ * this code block may turn out redundant. wsrep->disconnect()
+ * should terminate slave threads gracefully, and we don't need
+ * to signal them here.
+ * The code here makes sure mysqld will not hang during shutdown
+ * even if wsrep provider has problems in shutting down.
+ */
+ if (WSREP(tmp) && tmp->wsrep_exec_mode==REPL_RECV)
+ {
+ sql_print_information("closing wsrep system thread");
+ tmp->killed= KILL_CONNECTION;
+ MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));
+ if (tmp->mysys_var)
+ {
+ tmp->mysys_var->abort=1;
+ mysql_mutex_lock(&tmp->mysys_var->mutex);
+ if (tmp->mysys_var->current_cond)
+ {
+ mysql_mutex_lock(tmp->mysys_var->current_mutex);
+ mysql_cond_broadcast(tmp->mysys_var->current_cond);
+ mysql_mutex_unlock(tmp->mysys_var->current_mutex);
+ }
+ mysql_mutex_unlock(&tmp->mysys_var->mutex);
+ }
+ }
+#endif
DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
mysql_mutex_unlock(&LOCK_thread_count);
}
@@ -1856,7 +1908,19 @@ static void __cdecl kill_server(int sig_ptr)
}
#endif
+ /* Stop wsrep threads in case they are running. */
+ if (wsrep_running_threads > 0)
+ {
+ wsrep_stop_replication(NULL);
+ }
+
close_connections();
+
+ if (wsrep_inited == 1)
+ wsrep_deinit(true);
+
+ wsrep_thr_deinit();
+
if (sig != MYSQL_KILL_SIGNAL &&
sig != 0)
unireg_abort(1); /* purecov: inspected */
@@ -1935,6 +1999,7 @@ void unireg_end(void)
{
clean_up(1);
my_thread_end();
+ sd_notify(0, "STATUS=MariaDB server is down");
#if defined(SIGNALS_DONT_BREAK_READ)
exit(0);
#else
@@ -1951,11 +2016,46 @@ extern "C" void unireg_abort(int exit_code)
usage();
if (exit_code)
sql_print_error("Aborting\n");
+ /* Don't write more notes to the log to not hide error message */
+ disable_log_notes= 1;
+
+#ifdef WITH_WSREP
+ /* Check if wsrep class is used. If yes, then cleanup wsrep */
+ if (wsrep)
+ {
+ /*
+ This is an abort situation, we cannot expect to gracefully close all
+ wsrep threads here, we can only diconnect from service
+ */
+ wsrep_close_client_connections(FALSE);
+ shutdown_in_progress= 1;
+ wsrep->disconnect(wsrep);
+ WSREP_INFO("Service disconnected.");
+ wsrep_close_threads(NULL); /* this won't close all threads */
+ sleep(1); /* so give some time to exit for those which can */
+ WSREP_INFO("Some threads may fail to exit.");
+
+ /* In bootstrap mode we deinitialize wsrep here. */
+ if (opt_bootstrap && wsrep_inited)
+ wsrep_deinit(true);
+ }
+#endif // WITH_WSREP
+
clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */
DBUG_PRINT("quit",("done with cleanup in unireg_abort"));
mysqld_exit(exit_code);
}
+
+static void cleanup_tls()
+{
+ if (THR_THD)
+ (void)pthread_key_delete(THR_THD);
+ if (THR_MALLOC)
+ (void)pthread_key_delete(THR_MALLOC);
+}
+
+
static void mysqld_exit(int exit_code)
{
DBUG_ENTER("mysqld_exit");
@@ -1974,7 +2074,9 @@ static void mysqld_exit(int exit_code)
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
shutdown_performance_schema(); // we do it as late as possible
#endif
+ cleanup_tls();
DBUG_LEAVE;
+ sd_notify(0, "STATUS=MariaDB server is down");
exit(exit_code); /* purecov: inspected */
}
@@ -1995,12 +2097,6 @@ void clean_up(bool print_message)
stop_handle_manager();
release_ddl_log();
- /*
- make sure that handlers finish up
- what they have that is dependent on the binlog
- */
- ha_binlog_end(current_thd);
-
logger.cleanup_base();
injector::free_instance();
@@ -2029,12 +2125,16 @@ void clean_up(bool print_message)
xid_cache_free();
tdc_deinit();
mdl_destroy();
+ dflt_key_cache= 0;
key_caches.delete_elements((void (*)(const char*, uchar*)) free_key_cache);
wt_end();
multi_keycache_free();
sp_cache_end();
free_status_vars();
end_thr_alarm(1); /* Free allocated memory */
+#ifndef EMBEDDED_LIBRARY
+ end_thr_timer();
+#endif
my_free_open_file_info();
if (defaults_argv)
free_defaults(defaults_argv);
@@ -2068,6 +2168,7 @@ void clean_up(bool print_message)
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname);
cleanup_errmsgs();
MYSQL_CALLBACK(thread_scheduler, end, ());
+ thread_scheduler= 0;
mysql_library_end();
finish_client_errs();
(void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
@@ -2075,11 +2176,6 @@ void clean_up(bool print_message)
/* Tell main we are ready */
logger.cleanup_end();
sys_var_end();
- my_atomic_rwlock_destroy(&global_query_id_lock);
- my_atomic_rwlock_destroy(&thread_running_lock);
- my_atomic_rwlock_destroy(&thread_count_lock);
- my_atomic_rwlock_destroy(&statistics_lock);
- my_atomic_rwlock_destroy(&slave_executed_entries_lock);
free_charsets();
mysql_mutex_lock(&LOCK_thread_count);
DBUG_PRINT("quit", ("got thread count lock"));
@@ -2088,14 +2184,14 @@ void clean_up(bool print_message)
mysql_cond_broadcast(&COND_thread_count);
mysql_mutex_unlock(&LOCK_thread_count);
+ my_free(const_cast<char*>(log_bin_basename));
+ my_free(const_cast<char*>(log_bin_index));
+#ifndef EMBEDDED_LIBRARY
+ my_free(const_cast<char*>(relay_log_basename));
+ my_free(const_cast<char*>(relay_log_index));
+#endif
free_list(opt_plugin_load_list_ptr);
- if (THR_THD)
- (void) pthread_key_delete(THR_THD);
-
- if (THR_MALLOC)
- (void) pthread_key_delete(THR_MALLOC);
-
/*
The following lines may never be executed as the main thread may have
killed us
@@ -2170,9 +2266,10 @@ static void clean_up_mutexes()
mysql_cond_destroy(&COND_server_started);
mysql_mutex_destroy(&LOCK_prepare_ordered);
mysql_cond_destroy(&COND_prepare_ordered);
+ mysql_mutex_destroy(&LOCK_after_binlog_sync);
mysql_mutex_destroy(&LOCK_commit_ordered);
- mysql_mutex_destroy(&LOCK_slave_init);
- mysql_cond_destroy(&COND_slave_init);
+ mysql_mutex_destroy(&LOCK_slave_background);
+ mysql_cond_destroy(&COND_slave_background);
DBUG_VOID_RETURN;
}
@@ -2181,7 +2278,12 @@ static void clean_up_mutexes()
** Init IP and UNIX socket
****************************************************************************/
-#ifndef EMBEDDED_LIBRARY
+#ifdef EMBEDDED_LIBRARY
+static void set_ports()
+{
+}
+
+#else
static void set_ports()
{
char *env;
@@ -2202,10 +2304,13 @@ static void set_ports()
#if MYSQL_PORT_DEFAULT == 0
struct servent *serv_ptr;
if ((serv_ptr= getservbyname("mysql", "tcp")))
- mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
+ SYSVAR_AUTOSIZE(mysqld_port, ntohs((u_short) serv_ptr->s_port));
#endif
if ((env = getenv("MYSQL_TCP_PORT")))
- mysqld_port= (uint) atoi(env); /* purecov: inspected */
+ {
+ mysqld_port= (uint) atoi(env);
+ set_sys_var_value_origin(&mysqld_port, sys_var::ENV);
+ }
}
if (!mysqld_unix_port)
{
@@ -2215,7 +2320,10 @@ static void set_ports()
mysqld_unix_port= (char*) MYSQL_UNIX_ADDR;
#endif
if ((env = getenv("MYSQL_UNIX_PORT")))
- mysqld_unix_port= env; /* purecov: inspected */
+ {
+ mysqld_unix_port= env;
+ set_sys_var_value_origin(&mysqld_unix_port, sys_var::ENV);
+ }
}
}
@@ -2412,6 +2520,12 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
(char*)&arg, sizeof(arg));
}
#endif
+
+#ifdef IP_FREEBIND
+ arg= 1;
+ (void) mysql_socket_setsockopt(ip_sock, IPPROTO_IP, IP_FREEBIND, (char*) &arg,
+ sizeof(arg));
+#endif
/*
Sometimes the port is not released fast enough when stopping and
restarting the server. This happens quite often with the test suite
@@ -2450,6 +2564,11 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
socket_errno);
unireg_abort(1);
}
+
+#ifdef FD_CLOEXEC
+ (void) fcntl(mysql_socket_getfd(ip_sock), F_SETFD, FD_CLOEXEC);
+#endif
+
DBUG_RETURN(ip_sock);
}
@@ -2468,7 +2587,7 @@ static void network_init(void)
if (report_port == 0)
{
- report_port= mysqld_port;
+ SYSVAR_AUTOSIZE(report_port, mysqld_port);
}
#ifndef DBUG_OFF
if (!opt_disable_networking)
@@ -2567,6 +2686,9 @@ static void network_init(void)
if (mysql_socket_listen(unix_sock,(int) back_log) < 0)
sql_print_warning("listen() on Unix socket failed with error %d",
socket_errno);
+#ifdef FD_CLOEXEC
+ (void) fcntl(mysql_socket_getfd(unix_sock), F_SETFD, FD_CLOEXEC);
+#endif
}
#endif
DBUG_PRINT("info",("server started"));
@@ -2641,6 +2763,16 @@ void thd_cleanup(THD *thd)
void dec_connection_count(THD *thd)
{
+#ifdef WITH_WSREP
+ /*
+ Do not decrement when its wsrep system thread. wsrep_applier is set for
+ applier as well as rollbacker threads.
+ */
+ if (thd->wsrep_applier)
+ return;
+#endif /* WITH_WSREP */
+
+ DBUG_ASSERT(*thd->scheduler->connection_count > 0);
mysql_mutex_lock(&LOCK_connection_count);
(*thd->scheduler->connection_count)--;
mysql_mutex_unlock(&LOCK_connection_count);
@@ -2703,7 +2835,7 @@ void unlink_thd(THD *thd)
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
DBUG_VOID_RETURN;
}
@@ -2813,10 +2945,11 @@ static bool cache_thread()
bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
{
DBUG_ENTER("one_thread_per_connection_end");
+ const bool wsrep_applier= IF_WSREP(thd->wsrep_applier, false);
+
unlink_thd(thd);
- /* Mark that current_thd is not valid anymore */
- set_current_thd(0);
- if (put_in_cache && cache_thread())
+
+ if (!wsrep_applier && put_in_cache && cache_thread())
DBUG_RETURN(0); // Thread is reused
signal_thd_deleted();
@@ -3281,7 +3414,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
sql_print_information("Got signal %d to shutdown mysqld",sig);
#endif
/* switch to the old log message processing */
- logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
+ logger.set_handlers(LOG_FILE, global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
opt_log ? LOG_FILE:LOG_NONE);
DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop));
if (!abort_loop)
@@ -3319,13 +3452,15 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
if (log_output_options & LOG_NONE)
{
logger.set_handlers(LOG_FILE,
- opt_slow_log ? LOG_TABLE : LOG_NONE,
+ global_system_variables.sql_log_slow ?
+ LOG_TABLE : LOG_NONE,
opt_log ? LOG_TABLE : LOG_NONE);
}
else
{
logger.set_handlers(LOG_FILE,
- opt_slow_log ? log_output_options : LOG_NONE,
+ global_system_variables.sql_log_slow ?
+ log_output_options : LOG_NONE,
opt_log ? log_output_options : LOG_NONE);
}
break;
@@ -3537,165 +3672,168 @@ static bool init_global_datetime_format(timestamp_type format_type,
return false;
}
+#define COM_STATUS(X) (void*) offsetof(STATUS_VAR, X), SHOW_LONG_STATUS
+#define STMT_STATUS(X) COM_STATUS(com_stat[(uint) X])
+
SHOW_VAR com_status_vars[]= {
- {"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
- {"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
- {"alter_db_upgrade", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB_UPGRADE]), SHOW_LONG_STATUS},
- {"alter_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS},
- {"alter_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_FUNCTION]), SHOW_LONG_STATUS},
- {"alter_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_PROCEDURE]), SHOW_LONG_STATUS},
- {"alter_server", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_SERVER]), SHOW_LONG_STATUS},
- {"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
- {"alter_tablespace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLESPACE]), SHOW_LONG_STATUS},
- {"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
- {"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
- {"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
- {"binlog", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS},
- {"call_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CALL]), SHOW_LONG_STATUS},
- {"change_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
- {"change_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_MASTER]), SHOW_LONG_STATUS},
- {"check", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS},
- {"checksum", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
- {"commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
- {"create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
- {"create_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_EVENT]), SHOW_LONG_STATUS},
- {"create_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_SPFUNCTION]), SHOW_LONG_STATUS},
- {"create_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
- {"create_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_PROCEDURE]), SHOW_LONG_STATUS},
- {"create_role", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_ROLE]), SHOW_LONG_STATUS},
- {"create_server", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_SERVER]), SHOW_LONG_STATUS},
- {"create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
- {"create_trigger", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TRIGGER]), SHOW_LONG_STATUS},
- {"create_udf", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_FUNCTION]), SHOW_LONG_STATUS},
- {"create_user", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_USER]), SHOW_LONG_STATUS},
- {"create_view", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_VIEW]), SHOW_LONG_STATUS},
- {"dealloc_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DEALLOCATE_PREPARE]), SHOW_LONG_STATUS},
- {"delete", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE]), SHOW_LONG_STATUS},
- {"delete_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS},
- {"do", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DO]), SHOW_LONG_STATUS},
- {"drop_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
- {"drop_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_EVENT]), SHOW_LONG_STATUS},
- {"drop_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_FUNCTION]), SHOW_LONG_STATUS},
- {"drop_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
- {"drop_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_PROCEDURE]), SHOW_LONG_STATUS},
- {"drop_role", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_ROLE]), SHOW_LONG_STATUS},
- {"drop_server", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_SERVER]), SHOW_LONG_STATUS},
- {"drop_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
- {"drop_trigger", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_TRIGGER]), SHOW_LONG_STATUS},
- {"drop_user", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_USER]), SHOW_LONG_STATUS},
- {"drop_view", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_VIEW]), SHOW_LONG_STATUS},
- {"empty_query", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
- {"execute_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EXECUTE]), SHOW_LONG_STATUS},
- {"flush", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
- {"get_diagnostics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GET_DIAGNOSTICS]), SHOW_LONG_STATUS},
- {"grant", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GRANT]), SHOW_LONG_STATUS},
- {"grant_role", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GRANT_ROLE]), SHOW_LONG_STATUS},
- {"ha_close", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_CLOSE]), SHOW_LONG_STATUS},
- {"ha_open", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_OPEN]), SHOW_LONG_STATUS},
- {"ha_read", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_READ]), SHOW_LONG_STATUS},
- {"help", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HELP]), SHOW_LONG_STATUS},
- {"insert", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT]), SHOW_LONG_STATUS},
- {"insert_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
- {"install_plugin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSTALL_PLUGIN]), SHOW_LONG_STATUS},
- {"kill", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_KILL]), SHOW_LONG_STATUS},
- {"load", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD]), SHOW_LONG_STATUS},
- {"lock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS},
- {"optimize", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS},
- {"preload_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PRELOAD_KEYS]), SHOW_LONG_STATUS},
- {"prepare_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PREPARE]), SHOW_LONG_STATUS},
- {"purge", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE]), SHOW_LONG_STATUS},
- {"purge_before_date", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BEFORE]), SHOW_LONG_STATUS},
- {"release_savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
- {"rename_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
- {"rename_user", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_USER]), SHOW_LONG_STATUS},
- {"repair", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPAIR]), SHOW_LONG_STATUS},
- {"replace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
- {"replace_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
- {"reset", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESET]), SHOW_LONG_STATUS},
- {"resignal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESIGNAL]), SHOW_LONG_STATUS},
- {"revoke", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE]), SHOW_LONG_STATUS},
- {"revoke_all", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE_ALL]), SHOW_LONG_STATUS},
- {"revoke_role", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE_ROLE]), SHOW_LONG_STATUS},
- {"rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
- {"rollback_to_savepoint",(char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
- {"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
- {"select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
- {"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
- {"show_authors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_AUTHORS]), SHOW_LONG_STATUS},
- {"show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
- {"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
- {"show_charsets", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS},
- {"show_client_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CLIENT_STATS]), SHOW_LONG_STATUS},
- {"show_collations", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS},
- {"show_contributors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CONTRIBUTORS]), SHOW_LONG_STATUS},
- {"show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
- {"show_create_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_EVENT]), SHOW_LONG_STATUS},
- {"show_create_func", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_FUNC]), SHOW_LONG_STATUS},
- {"show_create_proc", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_PROC]), SHOW_LONG_STATUS},
- {"show_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
- {"show_create_trigger", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_TRIGGER]), SHOW_LONG_STATUS},
- {"show_databases", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
- {"show_engine_logs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_LOGS]), SHOW_LONG_STATUS},
- {"show_engine_mutex", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_MUTEX]), SHOW_LONG_STATUS},
- {"show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS},
- {"show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
- {"show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS},
- {"show_explain", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EXPLAIN]), SHOW_LONG_STATUS},
- {"show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
+ {"admin_commands", COM_STATUS(com_other)},
+ {"alter_db", STMT_STATUS(SQLCOM_ALTER_DB)},
+ {"alter_db_upgrade", STMT_STATUS(SQLCOM_ALTER_DB_UPGRADE)},
+ {"alter_event", STMT_STATUS(SQLCOM_ALTER_EVENT)},
+ {"alter_function", STMT_STATUS(SQLCOM_ALTER_FUNCTION)},
+ {"alter_procedure", STMT_STATUS(SQLCOM_ALTER_PROCEDURE)},
+ {"alter_server", STMT_STATUS(SQLCOM_ALTER_SERVER)},
+ {"alter_table", STMT_STATUS(SQLCOM_ALTER_TABLE)},
+ {"alter_tablespace", STMT_STATUS(SQLCOM_ALTER_TABLESPACE)},
+ {"analyze", STMT_STATUS(SQLCOM_ANALYZE)},
+ {"assign_to_keycache", STMT_STATUS(SQLCOM_ASSIGN_TO_KEYCACHE)},
+ {"begin", STMT_STATUS(SQLCOM_BEGIN)},
+ {"binlog", STMT_STATUS(SQLCOM_BINLOG_BASE64_EVENT)},
+ {"call_procedure", STMT_STATUS(SQLCOM_CALL)},
+ {"change_db", STMT_STATUS(SQLCOM_CHANGE_DB)},
+ {"change_master", STMT_STATUS(SQLCOM_CHANGE_MASTER)},
+ {"check", STMT_STATUS(SQLCOM_CHECK)},
+ {"checksum", STMT_STATUS(SQLCOM_CHECKSUM)},
+ {"commit", STMT_STATUS(SQLCOM_COMMIT)},
+ {"compound_sql", STMT_STATUS(SQLCOM_COMPOUND)},
+ {"create_db", STMT_STATUS(SQLCOM_CREATE_DB)},
+ {"create_event", STMT_STATUS(SQLCOM_CREATE_EVENT)},
+ {"create_function", STMT_STATUS(SQLCOM_CREATE_SPFUNCTION)},
+ {"create_index", STMT_STATUS(SQLCOM_CREATE_INDEX)},
+ {"create_procedure", STMT_STATUS(SQLCOM_CREATE_PROCEDURE)},
+ {"create_role", STMT_STATUS(SQLCOM_CREATE_ROLE)},
+ {"create_server", STMT_STATUS(SQLCOM_CREATE_SERVER)},
+ {"create_table", STMT_STATUS(SQLCOM_CREATE_TABLE)},
+ {"create_temporary_table", COM_STATUS(com_create_tmp_table)},
+ {"create_trigger", STMT_STATUS(SQLCOM_CREATE_TRIGGER)},
+ {"create_udf", STMT_STATUS(SQLCOM_CREATE_FUNCTION)},
+ {"create_user", STMT_STATUS(SQLCOM_CREATE_USER)},
+ {"create_view", STMT_STATUS(SQLCOM_CREATE_VIEW)},
+ {"dealloc_sql", STMT_STATUS(SQLCOM_DEALLOCATE_PREPARE)},
+ {"delete", STMT_STATUS(SQLCOM_DELETE)},
+ {"delete_multi", STMT_STATUS(SQLCOM_DELETE_MULTI)},
+ {"do", STMT_STATUS(SQLCOM_DO)},
+ {"drop_db", STMT_STATUS(SQLCOM_DROP_DB)},
+ {"drop_event", STMT_STATUS(SQLCOM_DROP_EVENT)},
+ {"drop_function", STMT_STATUS(SQLCOM_DROP_FUNCTION)},
+ {"drop_index", STMT_STATUS(SQLCOM_DROP_INDEX)},
+ {"drop_procedure", STMT_STATUS(SQLCOM_DROP_PROCEDURE)},
+ {"drop_role", STMT_STATUS(SQLCOM_DROP_ROLE)},
+ {"drop_server", STMT_STATUS(SQLCOM_DROP_SERVER)},
+ {"drop_table", STMT_STATUS(SQLCOM_DROP_TABLE)},
+ {"drop_temporary_table", COM_STATUS(com_drop_tmp_table)},
+ {"drop_trigger", STMT_STATUS(SQLCOM_DROP_TRIGGER)},
+ {"drop_user", STMT_STATUS(SQLCOM_DROP_USER)},
+ {"drop_view", STMT_STATUS(SQLCOM_DROP_VIEW)},
+ {"empty_query", STMT_STATUS(SQLCOM_EMPTY_QUERY)},
+ {"execute_sql", STMT_STATUS(SQLCOM_EXECUTE)},
+ {"flush", STMT_STATUS(SQLCOM_FLUSH)},
+ {"get_diagnostics", STMT_STATUS(SQLCOM_GET_DIAGNOSTICS)},
+ {"grant", STMT_STATUS(SQLCOM_GRANT)},
+ {"grant_role", STMT_STATUS(SQLCOM_GRANT_ROLE)},
+ {"ha_close", STMT_STATUS(SQLCOM_HA_CLOSE)},
+ {"ha_open", STMT_STATUS(SQLCOM_HA_OPEN)},
+ {"ha_read", STMT_STATUS(SQLCOM_HA_READ)},
+ {"help", STMT_STATUS(SQLCOM_HELP)},
+ {"insert", STMT_STATUS(SQLCOM_INSERT)},
+ {"insert_select", STMT_STATUS(SQLCOM_INSERT_SELECT)},
+ {"install_plugin", STMT_STATUS(SQLCOM_INSTALL_PLUGIN)},
+ {"kill", STMT_STATUS(SQLCOM_KILL)},
+ {"load", STMT_STATUS(SQLCOM_LOAD)},
+ {"lock_tables", STMT_STATUS(SQLCOM_LOCK_TABLES)},
+ {"optimize", STMT_STATUS(SQLCOM_OPTIMIZE)},
+ {"preload_keys", STMT_STATUS(SQLCOM_PRELOAD_KEYS)},
+ {"prepare_sql", STMT_STATUS(SQLCOM_PREPARE)},
+ {"purge", STMT_STATUS(SQLCOM_PURGE)},
+ {"purge_before_date", STMT_STATUS(SQLCOM_PURGE_BEFORE)},
+ {"release_savepoint", STMT_STATUS(SQLCOM_RELEASE_SAVEPOINT)},
+ {"rename_table", STMT_STATUS(SQLCOM_RENAME_TABLE)},
+ {"rename_user", STMT_STATUS(SQLCOM_RENAME_USER)},
+ {"repair", STMT_STATUS(SQLCOM_REPAIR)},
+ {"replace", STMT_STATUS(SQLCOM_REPLACE)},
+ {"replace_select", STMT_STATUS(SQLCOM_REPLACE_SELECT)},
+ {"reset", STMT_STATUS(SQLCOM_RESET)},
+ {"resignal", STMT_STATUS(SQLCOM_RESIGNAL)},
+ {"revoke", STMT_STATUS(SQLCOM_REVOKE)},
+ {"revoke_all", STMT_STATUS(SQLCOM_REVOKE_ALL)},
+ {"revoke_role", STMT_STATUS(SQLCOM_REVOKE_ROLE)},
+ {"rollback", STMT_STATUS(SQLCOM_ROLLBACK)},
+ {"rollback_to_savepoint",STMT_STATUS(SQLCOM_ROLLBACK_TO_SAVEPOINT)},
+ {"savepoint", STMT_STATUS(SQLCOM_SAVEPOINT)},
+ {"select", STMT_STATUS(SQLCOM_SELECT)},
+ {"set_option", STMT_STATUS(SQLCOM_SET_OPTION)},
+ {"show_authors", STMT_STATUS(SQLCOM_SHOW_AUTHORS)},
+ {"show_binlog_events", STMT_STATUS(SQLCOM_SHOW_BINLOG_EVENTS)},
+ {"show_binlogs", STMT_STATUS(SQLCOM_SHOW_BINLOGS)},
+ {"show_charsets", STMT_STATUS(SQLCOM_SHOW_CHARSETS)},
+ {"show_collations", STMT_STATUS(SQLCOM_SHOW_COLLATIONS)},
+ {"show_contributors", STMT_STATUS(SQLCOM_SHOW_CONTRIBUTORS)},
+ {"show_create_db", STMT_STATUS(SQLCOM_SHOW_CREATE_DB)},
+ {"show_create_event", STMT_STATUS(SQLCOM_SHOW_CREATE_EVENT)},
+ {"show_create_func", STMT_STATUS(SQLCOM_SHOW_CREATE_FUNC)},
+ {"show_create_proc", STMT_STATUS(SQLCOM_SHOW_CREATE_PROC)},
+ {"show_create_table", STMT_STATUS(SQLCOM_SHOW_CREATE)},
+ {"show_create_trigger", STMT_STATUS(SQLCOM_SHOW_CREATE_TRIGGER)},
+ {"show_databases", STMT_STATUS(SQLCOM_SHOW_DATABASES)},
+ {"show_engine_logs", STMT_STATUS(SQLCOM_SHOW_ENGINE_LOGS)},
+ {"show_engine_mutex", STMT_STATUS(SQLCOM_SHOW_ENGINE_MUTEX)},
+ {"show_engine_status", STMT_STATUS(SQLCOM_SHOW_ENGINE_STATUS)},
+ {"show_errors", STMT_STATUS(SQLCOM_SHOW_ERRORS)},
+ {"show_events", STMT_STATUS(SQLCOM_SHOW_EVENTS)},
+ {"show_explain", STMT_STATUS(SQLCOM_SHOW_EXPLAIN)},
+ {"show_fields", STMT_STATUS(SQLCOM_SHOW_FIELDS)},
#ifndef DBUG_OFF
- {"show_function_code", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FUNC_CODE]), SHOW_LONG_STATUS},
-#endif
- {"show_function_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS_FUNC]), SHOW_LONG_STATUS},
- {"show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS},
- {"show_index_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_INDEX_STATS]), SHOW_LONG_STATUS},
- {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
- {"show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
- {"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
- {"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
- {"show_privileges", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PRIVILEGES]), SHOW_LONG_STATUS},
+ {"show_function_code", STMT_STATUS(SQLCOM_SHOW_FUNC_CODE)},
+#endif
+ {"show_function_status", STMT_STATUS(SQLCOM_SHOW_STATUS_FUNC)},
+ {"show_generic", STMT_STATUS(SQLCOM_SHOW_GENERIC)},
+ {"show_grants", STMT_STATUS(SQLCOM_SHOW_GRANTS)},
+ {"show_keys", STMT_STATUS(SQLCOM_SHOW_KEYS)},
+ {"show_master_status", STMT_STATUS(SQLCOM_SHOW_MASTER_STAT)},
+ {"show_open_tables", STMT_STATUS(SQLCOM_SHOW_OPEN_TABLES)},
+ {"show_plugins", STMT_STATUS(SQLCOM_SHOW_PLUGINS)},
+ {"show_privileges", STMT_STATUS(SQLCOM_SHOW_PRIVILEGES)},
#ifndef DBUG_OFF
- {"show_procedure_code", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROC_CODE]), SHOW_LONG_STATUS},
-#endif
- {"show_procedure_status",(char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS_PROC]), SHOW_LONG_STATUS},
- {"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
- {"show_profile", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROFILE]), SHOW_LONG_STATUS},
- {"show_profiles", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROFILES]), SHOW_LONG_STATUS},
- {"show_relaylog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_RELAYLOG_EVENTS]), SHOW_LONG_STATUS},
- {"show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
- {"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
- {"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
- {"show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS},
- {"show_table_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATS]), SHOW_LONG_STATUS},
- {"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
- {"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
- {"show_triggers", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TRIGGERS]), SHOW_LONG_STATUS},
- {"show_user_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_USER_STATS]), SHOW_LONG_STATUS},
- {"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
- {"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
- {"shutdown", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHUTDOWN]), SHOW_LONG_STATUS},
- {"signal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SIGNAL]), SHOW_LONG_STATUS},
- {"start_all_slaves", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_ALL_START]), SHOW_LONG_STATUS},
- {"start_slave", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
- {"stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS},
- {"stmt_execute", (char*) offsetof(STATUS_VAR, com_stmt_execute), SHOW_LONG_STATUS},
- {"stmt_fetch", (char*) offsetof(STATUS_VAR, com_stmt_fetch), SHOW_LONG_STATUS},
- {"stmt_prepare", (char*) offsetof(STATUS_VAR, com_stmt_prepare), SHOW_LONG_STATUS},
- {"stmt_reprepare", (char*) offsetof(STATUS_VAR, com_stmt_reprepare), SHOW_LONG_STATUS},
- {"stmt_reset", (char*) offsetof(STATUS_VAR, com_stmt_reset), SHOW_LONG_STATUS},
- {"stmt_send_long_data", (char*) offsetof(STATUS_VAR, com_stmt_send_long_data), SHOW_LONG_STATUS},
- {"stop_all_slaves", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_ALL_STOP]), SHOW_LONG_STATUS},
- {"stop_slave", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS},
- {"truncate", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
- {"uninstall_plugin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNINSTALL_PLUGIN]), SHOW_LONG_STATUS},
- {"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
- {"update", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
- {"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
- {"xa_commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_COMMIT]),SHOW_LONG_STATUS},
- {"xa_end", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_END]),SHOW_LONG_STATUS},
- {"xa_prepare", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_PREPARE]),SHOW_LONG_STATUS},
- {"xa_recover", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_RECOVER]),SHOW_LONG_STATUS},
- {"xa_rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_ROLLBACK]),SHOW_LONG_STATUS},
- {"xa_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_START]),SHOW_LONG_STATUS},
+ {"show_procedure_code", STMT_STATUS(SQLCOM_SHOW_PROC_CODE)},
+#endif
+ {"show_procedure_status",STMT_STATUS(SQLCOM_SHOW_STATUS_PROC)},
+ {"show_processlist", STMT_STATUS(SQLCOM_SHOW_PROCESSLIST)},
+ {"show_profile", STMT_STATUS(SQLCOM_SHOW_PROFILE)},
+ {"show_profiles", STMT_STATUS(SQLCOM_SHOW_PROFILES)},
+ {"show_relaylog_events", STMT_STATUS(SQLCOM_SHOW_RELAYLOG_EVENTS)},
+ {"show_slave_hosts", STMT_STATUS(SQLCOM_SHOW_SLAVE_HOSTS)},
+ {"show_slave_status", STMT_STATUS(SQLCOM_SHOW_SLAVE_STAT)},
+ {"show_status", STMT_STATUS(SQLCOM_SHOW_STATUS)},
+ {"show_storage_engines", STMT_STATUS(SQLCOM_SHOW_STORAGE_ENGINES)},
+ {"show_table_status", STMT_STATUS(SQLCOM_SHOW_TABLE_STATUS)},
+ {"show_tables", STMT_STATUS(SQLCOM_SHOW_TABLES)},
+ {"show_triggers", STMT_STATUS(SQLCOM_SHOW_TRIGGERS)},
+ {"show_variables", STMT_STATUS(SQLCOM_SHOW_VARIABLES)},
+ {"show_warnings", STMT_STATUS(SQLCOM_SHOW_WARNS)},
+ {"shutdown", STMT_STATUS(SQLCOM_SHUTDOWN)},
+ {"signal", STMT_STATUS(SQLCOM_SIGNAL)},
+ {"start_all_slaves", STMT_STATUS(SQLCOM_SLAVE_ALL_START)},
+ {"start_slave", STMT_STATUS(SQLCOM_SLAVE_START)},
+ {"stmt_close", COM_STATUS(com_stmt_close)},
+ {"stmt_execute", COM_STATUS(com_stmt_execute)},
+ {"stmt_fetch", COM_STATUS(com_stmt_fetch)},
+ {"stmt_prepare", COM_STATUS(com_stmt_prepare)},
+ {"stmt_reprepare", COM_STATUS(com_stmt_reprepare)},
+ {"stmt_reset", COM_STATUS(com_stmt_reset)},
+ {"stmt_send_long_data", COM_STATUS(com_stmt_send_long_data)},
+ {"stop_all_slaves", STMT_STATUS(SQLCOM_SLAVE_ALL_STOP)},
+ {"stop_slave", STMT_STATUS(SQLCOM_SLAVE_STOP)},
+ {"truncate", STMT_STATUS(SQLCOM_TRUNCATE)},
+ {"uninstall_plugin", STMT_STATUS(SQLCOM_UNINSTALL_PLUGIN)},
+ {"unlock_tables", STMT_STATUS(SQLCOM_UNLOCK_TABLES)},
+ {"update", STMT_STATUS(SQLCOM_UPDATE)},
+ {"update_multi", STMT_STATUS(SQLCOM_UPDATE_MULTI)},
+ {"xa_commit", STMT_STATUS(SQLCOM_XA_COMMIT)},
+ {"xa_end", STMT_STATUS(SQLCOM_XA_END)},
+ {"xa_prepare", STMT_STATUS(SQLCOM_XA_PREPARE)},
+ {"xa_recover", STMT_STATUS(SQLCOM_XA_RECOVER)},
+ {"xa_rollback", STMT_STATUS(SQLCOM_XA_ROLLBACK)},
+ {"xa_start", STMT_STATUS(SQLCOM_XA_START)},
{NullS, NullS, SHOW_LONG}
};
@@ -3712,11 +3850,11 @@ PSI_statement_info com_statement_info[(uint) COM_END + 1];
*/
void init_sql_statement_info()
{
- 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;
+ size_t first_com= offsetof(STATUS_VAR, com_stat[0]);
+ size_t last_com= offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_END]);
+ int record_size= offsetof(STATUS_VAR, com_stat[1])
+ - offsetof(STATUS_VAR, com_stat[0]);
+ size_t ptr;
uint i;
uint com_index;
@@ -3730,8 +3868,8 @@ void init_sql_statement_info()
SHOW_VAR *var= &com_status_vars[0];
while (var->name != NULL)
{
- ptr= var->value;
- if ((first_com <= ptr) && (ptr <= last_com))
+ ptr= (size_t)(var->value);
+ if ((first_com <= ptr) && (ptr < last_com))
{
com_index= ((int)(ptr - first_com))/record_size;
DBUG_ASSERT(com_index < (uint) SQLCOM_END);
@@ -3783,32 +3921,93 @@ extern "C" my_thread_id mariadb_dbug_id()
extern "C" {
static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
{
- /* If thread specific memory */
- if (is_thread_specific)
+ THD *thd= current_thd;
+
+ if (is_thread_specific) /* If thread specific memory */
{
- THD *thd= current_thd;
- if (mysqld_server_initialized || thd)
+ /*
+ When thread specfic is set, both mysqld_server_initialized and thd
+ must be set
+ */
+ DBUG_ASSERT(mysqld_server_initialized && thd);
+
+ DBUG_PRINT("info", ("thd memory_used: %lld size: %lld",
+ (longlong) thd->status_var.local_memory_used,
+ size));
+ thd->status_var.local_memory_used+= size;
+ if (thd->status_var.local_memory_used > (int64)thd->variables.max_mem_used &&
+ !thd->killed)
{
- /*
- THD may not be set if we are called from my_net_init() before THD
- thread has started.
- However, this should never happen, so better to assert and
- fix this.
- */
- DBUG_ASSERT(thd);
- if (thd)
- {
- DBUG_PRINT("info", ("memory_used: %lld size: %lld",
- (longlong) thd->status_var.memory_used, size));
- thd->status_var.memory_used+= size;
- DBUG_ASSERT((longlong) thd->status_var.memory_used >= 0);
- }
+ char buf[1024];
+ thd->killed= KILL_QUERY;
+ my_snprintf(buf, sizeof(buf), "--max-thread-mem-used=%llu",
+ thd->variables.max_mem_used);
+ my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), buf);
}
+ DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0);
+ }
+ else if (likely(thd))
+ {
+ DBUG_PRINT("info", ("global thd memory_used: %lld size: %lld",
+ (longlong) thd->status_var.global_memory_used, size));
+ thd->status_var.global_memory_used+= size;
}
- // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1)
- int64 volatile * volatile ptr=&global_status_var.memory_used;
- my_atomic_add64(ptr, size);
+ else
+ {
+ update_global_memory_status(size);
+ }
+}
}
+
+/**
+ Create a replication file name or base for file names.
+
+ @param[in] opt Value of option, or NULL
+ @param[in] def Default value if option value is not set.
+ @param[in] ext Extension to use for the path
+
+ @returns Pointer to string containing the full file path, or NULL if
+ it was not possible to create the path.
+ */
+static inline const char *
+rpl_make_log_name(const char *opt,
+ const char *def,
+ const char *ext)
+{
+ DBUG_ENTER("rpl_make_log_name");
+ DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt, def, ext));
+ char buff[FN_REFLEN];
+ const char *base= opt ? opt : def;
+ unsigned int options=
+ MY_REPLACE_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH;
+
+ /* mysql_real_data_home_ptr may be null if no value of datadir has been
+ specified through command-line or througha cnf file. If that is the
+ case we make mysql_real_data_home_ptr point to mysql_real_data_home
+ which, in that case holds the default path for data-dir.
+ */
+ if(mysql_real_data_home_ptr == NULL)
+ mysql_real_data_home_ptr= mysql_real_data_home;
+
+ if (fn_format(buff, base, mysql_real_data_home_ptr, ext, options))
+ DBUG_RETURN(my_strdup(buff, MYF(MY_WME)));
+ else
+ DBUG_RETURN(NULL);
+}
+
+/* We have to setup my_malloc_size_cb_func early to catch all mallocs */
+
+static int init_early_variables()
+{
+ if (pthread_key_create(&THR_THD, NULL))
+ {
+ fprintf(stderr, "Fatal error: Can't create thread-keys\n");
+ return 1;
+ }
+ set_current_thd(0);
+ set_malloc_size_cb(my_malloc_size_cb_func);
+ global_status_var.global_memory_used= 0;
+ return 0;
}
@@ -3823,16 +4022,12 @@ static int init_common_variables()
connection_errors_peer_addr= 0;
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
- if (pthread_key_create(&THR_THD,NULL) ||
- pthread_key_create(&THR_MALLOC,NULL))
+ if (pthread_key_create(&THR_MALLOC,NULL))
{
sql_print_error("Can't create thread-keys");
return 1;
}
- set_current_thd(0);
- set_malloc_size_cb(my_malloc_size_cb_func);
-
init_libstrings();
tzset(); // Set tzname
@@ -3915,6 +4110,8 @@ static int init_common_variables()
return 1;
}
+ opt_log_basename= const_cast<char *>("mysql");
+
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
{
/*
@@ -3924,16 +4121,14 @@ static int init_common_variables()
strmake(glob_hostname, STRING_WITH_LEN("localhost"));
sql_print_warning("gethostname failed, using '%s' as hostname",
glob_hostname);
- opt_log_basename= const_cast<char *>("mysql");
}
- else
+ else if (is_filename_allowed(glob_hostname, strlen(glob_hostname), FALSE))
opt_log_basename= glob_hostname;
- if (!*pidfile_name)
- {
- strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);
- strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
- }
+ strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);
+ strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
+ SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name);
+ set_sys_var_value_origin(&opt_tc_log_size, sys_var::AUTO);
/*
The default-storage-engine entry in my_long_options should have a
@@ -3952,6 +4147,7 @@ static int init_common_variables()
#else
default_storage_engine= const_cast<char *>("MyISAM");
#endif
+ default_tmp_storage_engine= NULL;
/*
Add server status variables to the dynamic list of
@@ -3967,32 +4163,34 @@ static int init_common_variables()
We have few debug-only commands in com_status_vars, only visible in debug
builds. for simplicity we enable the assert only in debug builds
- There are 8 Com_ variables which don't have corresponding SQLCOM_ values:
+ There are 10 Com_ variables which don't have corresponding SQLCOM_ values:
(TODO strictly speaking they shouldn't be here, should not have Com_ prefix
that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?)
- Com_admin_commands => com_other
- Com_stmt_close => com_stmt_close
- Com_stmt_execute => com_stmt_execute
- Com_stmt_fetch => com_stmt_fetch
- Com_stmt_prepare => com_stmt_prepare
- Com_stmt_reprepare => com_stmt_reprepare
- Com_stmt_reset => com_stmt_reset
- Com_stmt_send_long_data => com_stmt_send_long_data
+ Com_admin_commands => com_other
+ Com_create_temporary_table => com_create_tmp_table
+ Com_drop_temporary_table => com_drop_tmp_table
+ Com_stmt_close => com_stmt_close
+ Com_stmt_execute => com_stmt_execute
+ Com_stmt_fetch => com_stmt_fetch
+ Com_stmt_prepare => com_stmt_prepare
+ Com_stmt_reprepare => com_stmt_reprepare
+ Com_stmt_reset => com_stmt_reset
+ Com_stmt_send_long_data => com_stmt_send_long_data
With this correction the number of Com_ variables (number of elements in
the array, excluding the last element - terminator) must match the number
of SQLCOM_ constants.
*/
compile_time_assert(sizeof(com_status_vars)/sizeof(com_status_vars[0]) - 1 ==
- SQLCOM_END + 8);
+ SQLCOM_END + 10);
#endif
if (get_options(&remaining_argc, &remaining_argv))
return 1;
set_server_version();
- if (!opt_help)
+ if (!opt_abort)
sql_print_information("%s (mysqld %s) starting as process %lu ...",
my_progname, server_version, (ulong) getpid());
@@ -4006,20 +4204,18 @@ static int init_common_variables()
#ifdef HAVE_LARGE_PAGES
/* Initialize large page size */
- if (opt_large_pages && (opt_large_page_size= my_get_large_page_size()))
+ if (opt_large_pages)
{
+ SYSVAR_AUTOSIZE(opt_large_page_size, my_get_large_page_size());
+ if (opt_large_page_size)
+ {
DBUG_PRINT("info", ("Large page set, large_page_size = %d",
opt_large_page_size));
my_use_large_pages= 1;
my_large_page_size= opt_large_page_size;
- }
- else
- {
- opt_large_pages= 0;
- /*
- Either not configured to use large pages or Linux haven't
- been compiled with large page support
- */
+ }
+ else
+ SYSVAR_AUTOSIZE(opt_large_pages, 0);
}
#endif /* HAVE_LARGE_PAGES */
#ifdef HAVE_SOLARIS_LARGE_PAGES
@@ -4073,6 +4269,32 @@ static int init_common_variables()
}
#endif /* HAVE_SOLARIS_LARGE_PAGES */
+
+#if defined(HAVE_POOL_OF_THREADS) && !defined(_WIN32)
+ if (IS_SYSVAR_AUTOSIZE(&threadpool_size))
+ SYSVAR_AUTOSIZE(threadpool_size, my_getncpus());
+#endif
+
+ /* Fix host_cache_size. */
+ if (IS_SYSVAR_AUTOSIZE(&host_cache_size))
+ {
+ if (max_connections <= 628 - 128)
+ SYSVAR_AUTOSIZE(host_cache_size, 128 + max_connections);
+ else if (max_connections <= ((ulong)(2000 - 628)) * 20 + 500)
+ SYSVAR_AUTOSIZE(host_cache_size, 628 + ((max_connections - 500) / 20));
+ else
+ SYSVAR_AUTOSIZE(host_cache_size, 2000);
+ }
+
+ /* Fix back_log (back_log == 0 added for MySQL compatibility) */
+ if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log))
+ {
+ if ((900 - 50) * 5 >= max_connections)
+ SYSVAR_AUTOSIZE(back_log, (50 + max_connections / 5));
+ else
+ SYSVAR_AUTOSIZE(back_log, 900);
+ }
+
/* connections and databases needs lots of files */
{
uint files, wanted_files, max_open_files;
@@ -4103,27 +4325,28 @@ static int init_common_variables()
If we have requested too much file handles than we bring
max_connections in supported bounds.
*/
- max_connections= (ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
+ SYSVAR_AUTOSIZE(max_connections,
+ (ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2, max_connections));
/*
Decrease tc_size according to max_connections, but
not below TABLE_OPEN_CACHE_MIN. Outer MY_MIN() ensures that we
never increase tc_size automatically (that could
happen if max_connections is decreased above).
*/
- tc_size= (ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2,
- TABLE_OPEN_CACHE_MIN), tc_size);
+ SYSVAR_AUTOSIZE(tc_size,
+ (ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2,
+ TABLE_OPEN_CACHE_MIN), tc_size));
DBUG_PRINT("warning",
("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld",
files, max_connections, tc_size));
- if (global_system_variables.log_warnings)
+ if (global_system_variables.log_warnings > 1)
sql_print_warning("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld",
files, max_connections, tc_size);
}
else if (global_system_variables.log_warnings)
sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files);
}
- open_files_limit= files;
+ SYSVAR_AUTOSIZE(open_files_limit, files);
}
unireg_init(opt_specialflag); /* Set up extern variabels */
if (!(my_default_lc_messages=
@@ -4132,9 +4355,11 @@ static int init_common_variables()
sql_print_error("Unknown locale: '%s'", lc_messages);
return 1;
}
- global_system_variables.lc_messages= my_default_lc_messages;
+
if (init_errmessage()) /* Read error messages from file */
return 1;
+ global_system_variables.lc_messages= my_default_lc_messages;
+ global_system_variables.errmsgs= my_default_lc_messages->errmsgs->errmsgs;
init_client_errs();
mysql_library_init(unused,unused,unused); /* for replication */
lex_init();
@@ -4232,7 +4457,8 @@ static int init_common_variables()
"--log option, log tables are used. "
"To enable logging to files use the --log-output option.");
- if (opt_slow_log && opt_slow_logname && *opt_slow_logname &&
+ if (global_system_variables.sql_log_slow && opt_slow_logname &&
+ *opt_slow_logname &&
!(log_output_options & (LOG_FILE | LOG_NONE)))
sql_print_warning("Although a path was specified for the "
"--log-slow-queries option, log tables are used. "
@@ -4265,35 +4491,26 @@ static int init_common_variables()
get corrupted if accesses with names of different case.
*/
DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names));
- lower_case_file_system= test_if_case_insensitive(mysql_real_data_home);
+ SYSVAR_AUTOSIZE(lower_case_file_system,
+ test_if_case_insensitive(mysql_real_data_home));
if (!lower_case_table_names && lower_case_file_system == 1)
{
if (lower_case_table_names_used)
{
-#if MYSQL_VERSION_ID < 100100
- if (global_system_variables.log_warnings)
- sql_print_warning("You have forced lower_case_table_names to 0 through "
- "a command-line option, even though your file system "
- "'%s' is case insensitive. This means that you can "
- "corrupt your tables if you access them using names "
- "with different letter case. You should consider "
- "changing lower_case_table_names to 1 or 2",
- mysql_real_data_home);
-#else
sql_print_error("The server option 'lower_case_table_names' is "
"configured to use case sensitive table names but the "
"data directory resides on a case-insensitive file system. "
"Please use a case sensitive file system for your data "
"directory or switch to a case-insensitive table name "
"mode.");
-#endif
return 1;
}
else
{
if (global_system_variables.log_warnings)
- sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home);
- lower_case_table_names= 2;
+ sql_print_warning("Setting lower_case_table_names=2 because file "
+ "system for %s is case insensitive", mysql_real_data_home);
+ SYSVAR_AUTOSIZE(lower_case_table_names, 2);
}
}
else if (lower_case_table_names == 2 &&
@@ -4304,7 +4521,7 @@ static int init_common_variables()
"the file system '%s' is case sensitive. Now setting "
"lower_case_table_names to 0 to avoid future problems.",
mysql_real_data_home);
- lower_case_table_names= 0;
+ SYSVAR_AUTOSIZE(lower_case_table_names, 0);
}
else
{
@@ -4345,6 +4562,7 @@ static int init_thread_environment()
mysql_mutex_init(key_LOCK_global_system_variables,
&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
mysql_mutex_record_order(&LOCK_active_mi, &LOCK_global_system_variables);
+ mysql_mutex_record_order(&LOCK_status, &LOCK_thread_count);
mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash,
&LOCK_system_variables_hash);
mysql_mutex_init(key_LOCK_prepared_stmt_count,
@@ -4365,11 +4583,13 @@ static int init_thread_environment()
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);
+ mysql_mutex_init(key_LOCK_after_binlog_sync, &LOCK_after_binlog_sync,
+ MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_commit_ordered, &LOCK_commit_ordered,
MY_MUTEX_INIT_SLOW);
- mysql_mutex_init(key_LOCK_slave_init, &LOCK_slave_init,
+ mysql_mutex_init(key_LOCK_slave_background, &LOCK_slave_background,
MY_MUTEX_INIT_SLOW);
- mysql_cond_init(key_COND_slave_init, &COND_slave_init, NULL);
+ mysql_cond_init(key_COND_slave_background, &COND_slave_background, NULL);
#ifdef HAVE_OPENSSL
mysql_mutex_init(key_LOCK_des_key_file,
@@ -4559,6 +4779,52 @@ static void add_file_to_crash_report(char *file)
}
#endif
+#define init_default_storage_engine(X,Y) \
+ init_default_storage_engine_impl(#X, X, &global_system_variables.Y)
+
+static int init_default_storage_engine_impl(const char *opt_name,
+ char *engine_name, plugin_ref *res)
+{
+ if (!engine_name)
+ {
+ *res= 0;
+ return 0;
+ }
+
+ LEX_STRING name= { engine_name, strlen(engine_name) };
+ plugin_ref plugin;
+ handlerton *hton;
+ if ((plugin= ha_resolve_by_name(0, &name, false)))
+ hton= plugin_hton(plugin);
+ else
+ {
+ sql_print_error("Unknown/unsupported storage engine: %s", engine_name);
+ return 1;
+ }
+ if (!ha_storage_engine_is_enabled(hton))
+ {
+ if (!opt_bootstrap)
+ {
+ sql_print_error("%s (%s) is not available", opt_name, engine_name);
+ return 1;
+ }
+ DBUG_ASSERT(*res);
+ }
+ else
+ {
+ /*
+ Need to unlock as global_system_variables.table_plugin
+ was acquired during plugin_init()
+ */
+ mysql_mutex_lock(&LOCK_global_system_variables);
+ if (*res)
+ plugin_unlock(0, *res);
+ *res= plugin;
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+ }
+ return 0;
+}
+
static int init_server_components()
{
DBUG_ENTER("init_server_components");
@@ -4567,16 +4833,33 @@ static int init_server_components()
all things are initialized so that unireg_abort() doesn't fail
*/
mdl_init();
- if (tdc_init() | hostname_cache_init())
+ tdc_init();
+ if (hostname_cache_init())
unireg_abort(1);
query_cache_set_min_res_unit(query_cache_min_res_unit);
+ query_cache_result_size_limit(query_cache_limit);
+ /* if we set size of QC non zero in config then probably we want it ON */
+ if (query_cache_size != 0 &&
+ global_system_variables.query_cache_type == 0 &&
+ !IS_SYSVAR_AUTOSIZE(&query_cache_size))
+ {
+ global_system_variables.query_cache_type= 1;
+ }
query_cache_init();
query_cache_resize(query_cache_size);
- query_cache_result_size_limit(query_cache_limit);
my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
setup_fpu();
init_thr_lock();
+
+#ifndef EMBEDDED_LIBRARY
+ if (init_thr_timer(thread_scheduler->max_threads + extra_max_connections))
+ {
+ fprintf(stderr, "Can't initialize timers\n");
+ unireg_abort(1);
+ }
+#endif
+
my_uuid_init((ulong) (my_rnd(&sql_rand))*12345,12345);
#ifdef HAVE_REPLICATION
init_slave_list();
@@ -4593,16 +4876,17 @@ static int init_server_components()
if (opt_error_log && !opt_abort)
{
if (!log_error_file_ptr[0])
+ {
fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
+ SYSVAR_AUTOSIZE(log_error_file_ptr, log_error_file);
+ }
else
+ {
fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
MY_UNPACK_FILENAME | MY_SAFE_PATH);
- /*
- _ptr may have been set to my_disabled_option or "" if no argument was
- passed, but we need to show the real name in SHOW VARIABLES:
- */
- log_error_file_ptr= log_error_file;
+ log_error_file_ptr= log_error_file;
+ }
if (!log_error_file[0])
opt_error_log= 0; // Too long file name
else
@@ -4649,11 +4933,7 @@ static int init_server_components()
my_charset_error_reporter= charset_error_reporter;
#endif
- if (xid_cache_init())
- {
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
+ xid_cache_init();
/*
initialize delegates for extension observers, errors have already
@@ -4663,7 +4943,7 @@ static int init_server_components()
unireg_abort(1);
/* need to configure logging before initializing storage engines */
- if (!opt_bin_log_used)
+ if (!opt_bin_log_used && !WSREP_ON)
{
if (opt_log_slave_updates)
sql_print_warning("You need to use --log-bin to make "
@@ -4695,8 +4975,6 @@ static int init_server_components()
}
#endif
- DBUG_ASSERT(!opt_bin_log || opt_bin_logname);
-
if (opt_bin_log)
{
/* Reports an error and aborts, if the --log-bin's path
@@ -4742,15 +5020,114 @@ static int init_server_components()
opt_log_basename, ln);
}
if (ln == buf)
- {
opt_bin_logname= my_once_strdup(buf, MYF(MY_WME));
+ }
+
+ /*
+ Since some wsrep threads (THDs) are create before plugins are
+ initialized, LOCK_plugin mutex needs to be initialized here.
+ */
+ plugin_mutex_init();
+
+ /*
+ Wsrep initialization must happen at this point, because:
+ - opt_bin_logname must be known when starting replication
+ since SST may need it
+ - SST may modify binlog index file, so it must be opened
+ after SST has happened
+
+ We also (unconditionally) initialize wsrep LOCKs and CONDs.
+ It is because they are used while accessing wsrep system
+ variables even when a wsrep provider is not loaded.
+ */
+
+ /* It's now safe to use thread specific memory */
+ mysqld_server_initialized= 1;
+
+ wsrep_thr_init();
+
+ if (WSREP_ON && !wsrep_recovery && !opt_abort) /* WSREP BEFORE SE */
+ {
+ if (opt_bootstrap) // bootsrap option given - disable wsrep functionality
+ {
+ wsrep_provider_init(WSREP_NONE);
+ if (wsrep_init())
+ unireg_abort(1);
}
- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE))
+ else // full wsrep initialization
+ {
+ // add basedir/bin to PATH to resolve wsrep script names
+ char* const tmp_path= (char*)my_alloca(strlen(mysql_home) +
+ strlen("/bin") + 1);
+ if (tmp_path)
+ {
+ strcpy(tmp_path, mysql_home);
+ strcat(tmp_path, "/bin");
+ wsrep_prepend_PATH(tmp_path);
+ }
+ else
+ {
+ WSREP_ERROR("Could not append %s/bin to PATH", mysql_home);
+ }
+ my_afree(tmp_path);
+
+ if (wsrep_before_SE())
+ {
+ set_ports(); // this is also called in network_init() later but we need
+ // to know mysqld_port now - lp:1071882
+ wsrep_init_startup(true);
+ }
+ }
+ }
+
+ if (opt_bin_log)
+ {
+ if (mysql_bin_log.open_index_file(opt_binlog_index_name, opt_bin_logname,
+ TRUE))
{
unireg_abort(1);
}
}
+ if (opt_bin_log)
+ {
+ log_bin_basename=
+ rpl_make_log_name(opt_bin_logname, pidfile_name,
+ opt_bin_logname ? "" : "-bin");
+ log_bin_index=
+ rpl_make_log_name(opt_binlog_index_name, log_bin_basename, ".index");
+ if (log_bin_basename == NULL || log_bin_index == NULL)
+ {
+ sql_print_error("Unable to create replication path names:"
+ " out of memory or path names too long"
+ " (path name exceeds " STRINGIFY_ARG(FN_REFLEN)
+ " or file name exceeds " STRINGIFY_ARG(FN_LEN) ").");
+ unireg_abort(1);
+ }
+ }
+
+#ifndef EMBEDDED_LIBRARY
+ DBUG_PRINT("debug",
+ ("opt_bin_logname: %s, opt_relay_logname: %s, pidfile_name: %s",
+ opt_bin_logname, opt_relay_logname, pidfile_name));
+ if (opt_relay_logname)
+ {
+ relay_log_basename=
+ rpl_make_log_name(opt_relay_logname, pidfile_name,
+ opt_relay_logname ? "" : "-relay-bin");
+ relay_log_index=
+ rpl_make_log_name(opt_relaylog_index_name, relay_log_basename, ".index");
+ if (relay_log_basename == NULL || relay_log_index == NULL)
+ {
+ sql_print_error("Unable to create replication path names:"
+ " out of memory or path names too long"
+ " (path name exceeds " STRINGIFY_ARG(FN_REFLEN)
+ " or file name exceeds " STRINGIFY_ARG(FN_LEN) ").");
+ unireg_abort(1);
+ }
+ }
+#endif /* !EMBEDDED_LIBRARY */
+
/* call ha_init_key_cache() on all key caches to init them */
process_key_caches(&ha_init_key_cache, 0);
@@ -4802,6 +5179,9 @@ static int init_server_components()
}
}
+ if (init_io_cache_encryption())
+ unireg_abort(1);
+
if (opt_abort)
unireg_abort(0);
@@ -4842,60 +5222,56 @@ static int init_server_components()
/* purecov: begin inspected */
sql_print_error("CSV engine is not present, falling back to the "
"log files");
- log_output_options= (log_output_options & ~LOG_TABLE) | LOG_FILE;
+ SYSVAR_AUTOSIZE(log_output_options,
+ (log_output_options & ~LOG_TABLE) | LOG_FILE);
/* purecov: end */
}
- logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE,
+ logger.set_handlers(LOG_FILE,
+ global_system_variables.sql_log_slow ?
+ log_output_options:LOG_NONE,
opt_log ? log_output_options:LOG_NONE);
}
- /*
- Set the default storage engine
- */
- LEX_STRING name= { default_storage_engine, strlen(default_storage_engine) };
- plugin_ref plugin;
- handlerton *hton;
- if ((plugin= ha_resolve_by_name(0, &name)))
- hton= plugin_hton(plugin);
- else
- {
- sql_print_error("Unknown/unsupported storage engine: %s",
- default_storage_engine);
+ if (init_default_storage_engine(default_storage_engine, table_plugin))
unireg_abort(1);
- }
- if (!ha_storage_engine_is_enabled(hton))
- {
- if (!opt_bootstrap)
- {
- sql_print_error("Default storage engine (%s) is not available",
- default_storage_engine);
- unireg_abort(1);
- }
- DBUG_ASSERT(global_system_variables.table_plugin);
- }
- else
- {
- /*
- Need to unlock as global_system_variables.table_plugin
- was acquired during plugin_init()
- */
- mysql_mutex_lock(&LOCK_global_system_variables);
- plugin_unlock(0, global_system_variables.table_plugin);
- global_system_variables.table_plugin= plugin;
- mysql_mutex_unlock(&LOCK_global_system_variables);
- }
+
+ if (default_tmp_storage_engine && !*default_tmp_storage_engine)
+ default_tmp_storage_engine= NULL;
+
+ if (enforced_storage_engine && !*enforced_storage_engine)
+ enforced_storage_engine= NULL;
+
+ if (init_default_storage_engine(default_tmp_storage_engine, tmp_table_plugin))
+ unireg_abort(1);
+
+ if (init_default_storage_engine(enforced_storage_engine, enforced_table_plugin))
+ unireg_abort(1);
+
#ifdef USE_ARIA_FOR_TMP_TABLES
if (!ha_storage_engine_is_enabled(maria_hton) && !opt_bootstrap)
{
sql_print_error("Aria engine is not enabled or did not start. The Aria engine must be enabled to continue as mysqld was configured with --with-aria-tmp-tables");
unireg_abort(1);
}
- internal_tmp_table_max_key_length= maria_max_key_length();
- internal_tmp_table_max_key_segments= maria_max_key_segments();
-#else
- internal_tmp_table_max_key_length= myisam_max_key_length();
- internal_tmp_table_max_key_segments= myisam_max_key_segments();
+#endif
+
+#ifdef WITH_WSREP
+ /*
+ Now is the right time to initialize members of wsrep startup threads
+ that rely on plugins and other related global system variables to be
+ initialized. This initialization was not possible before, as plugins
+ (and thus some global system variables) are initialized after wsrep
+ startup threads are created.
+ Note: This only needs to be done for rsync, xtrabackup based SST methods.
+ */
+ if (wsrep_before_SE())
+ wsrep_plugins_post_init();
+
+ if (WSREP_ON && !opt_bin_log)
+ {
+ wsrep_emulate_bin_log= 1;
+ }
#endif
tc_log= get_tc_log_implementation();
@@ -4916,7 +5292,7 @@ static int init_server_components()
int error;
mysql_mutex_t *log_lock= mysql_bin_log.get_log_lock();
mysql_mutex_lock(log_lock);
- error= mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
+ error= mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0, 0,
WRITE_CACHE, max_binlog_size, 0, TRUE);
mysql_mutex_unlock(log_lock);
if (error)
@@ -4936,25 +5312,33 @@ static int init_server_components()
(void) mi_log(1);
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
- if (locked_in_memory && !getuid())
+ if (locked_in_memory)
{
- if (setreuid((uid_t)-1, 0) == -1)
- { // this should never happen
- sql_perror("setreuid");
- unireg_abort(1);
+ int error;
+ if (user_info)
+ {
+ DBUG_ASSERT(!getuid());
+ if (setreuid((uid_t) -1, 0) == -1)
+ {
+ sql_perror("setreuid");
+ unireg_abort(1);
+ }
+ error= mlockall(MCL_CURRENT);
+ set_user(mysqld_user, user_info);
}
- if (mlockall(MCL_CURRENT))
+ else
+ error= mlockall(MCL_CURRENT);
+
+ if (error)
{
if (global_system_variables.log_warnings)
sql_print_warning("Failed to lock memory. Errno: %d\n",errno);
locked_in_memory= 0;
}
- if (user_info)
- set_user(mysqld_user, user_info);
}
- else
+#else
+ locked_in_memory= 0;
#endif
- locked_in_memory=0;
ft_init_stopwords();
@@ -4990,7 +5374,6 @@ static void create_shutdown_thread()
#endif /* EMBEDDED_LIBRARY */
-
#if (defined(_WIN32) || defined(HAVE_SMEM)) && !defined(EMBEDDED_LIBRARY)
static void handle_connections_methods()
{
@@ -5068,41 +5451,6 @@ 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
@@ -5155,6 +5503,9 @@ int mysqld_main(int argc, char **argv)
sf_leaking_memory= 1; // no safemalloc memory leak reports if we exit early
mysqld_server_started= mysqld_server_initialized= 0;
+ if (init_early_variables())
+ exit(1);
+
#ifdef HAVE_NPTL
ld_assume_kernel_is_set= (getenv("LD_ASSUME_KERNEL") != 0);
#endif
@@ -5181,7 +5532,6 @@ 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
@@ -5200,9 +5550,16 @@ int mysqld_main(int argc, char **argv)
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
pfs_param.m_pfs_instrument= const_cast<char*>("");
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
+ my_timer_init(&sys_timer_info);
int ho_error __attribute__((unused))= handle_early_options();
+ /* fix tdc_size */
+ if (IS_SYSVAR_AUTOSIZE(&tdc_size))
+ {
+ SYSVAR_AUTOSIZE(tdc_size, MY_MIN(400 + tdc_size / 2, 2000));
+ }
+
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
if (ho_error == 0)
{
@@ -5312,8 +5669,11 @@ int mysqld_main(int argc, char **argv)
init_signals();
- my_thread_stack_size= my_setstacksize(&connection_attrib,
- my_thread_stack_size);
+ ulonglong new_thread_stack_size;
+ new_thread_stack_size= my_setstacksize(&connection_attrib,
+ my_thread_stack_size);
+ if (new_thread_stack_size != my_thread_stack_size)
+ SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size);
(void) thr_setconcurrency(concurrency); // 10 by default
@@ -5347,9 +5707,12 @@ int mysqld_main(int argc, char **argv)
set_user(mysqld_user, user_info);
}
+ if (WSREP_ON && wsrep_check_opts())
+ global_system_variables.wsrep_on= 0;
+
if (opt_bin_log && !global_system_variables.server_id)
{
- global_system_variables.server_id= ::server_id= 1;
+ SYSVAR_AUTOSIZE(global_system_variables.server_id, ::server_id= 1);
#ifdef EXTRA_DEBUG
sql_print_warning("You have enabled the binary log, but you haven't set "
"server-id to a non-zero value: we force server id to 1; "
@@ -5388,6 +5751,19 @@ int mysqld_main(int argc, char **argv)
}
#endif
+#ifdef WITH_WSREP
+ // Recover and exit.
+ if (wsrep_recovery)
+ {
+ select_thread_in_use= 0;
+ if (WSREP_ON)
+ wsrep_recover();
+ else
+ sql_print_information("WSREP: disabled, skipping position recovery");
+ unireg_abort(0);
+ }
+#endif
+
/*
init signals & alarm
After this we can't quit by a simple unireg_abort
@@ -5421,14 +5797,6 @@ int mysqld_main(int argc, char **argv)
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
initialize_performance_schema_acl(opt_bootstrap);
- /*
- Do not check the structure of the performance schema tables
- during bootstrap:
- - the tables are not supposed to exist yet, bootstrap will create them
- - a check would print spurious error messages
- */
- if (! opt_bootstrap)
- check_performance_schema();
#endif
initialize_information_schema_acl();
@@ -5446,6 +5814,33 @@ int mysqld_main(int argc, char **argv)
if (Events::init((THD*) 0, opt_noacl || opt_bootstrap))
unireg_abort(1);
+ if (WSREP_ON)
+ {
+ if (opt_bootstrap)
+ {
+ /*! bootstrap wsrep init was taken care of above */
+ }
+ else
+ {
+ wsrep_SE_initialized();
+
+ if (wsrep_before_SE())
+ {
+ /*! in case of no SST wsrep waits in view handler callback */
+ wsrep_SE_init_grab();
+ wsrep_SE_init_done();
+ /*! in case of SST wsrep waits for wsrep->sst_received */
+ wsrep_sst_continue();
+ }
+ else
+ {
+ wsrep_init_startup (false);
+ }
+
+ wsrep_create_appliers(wsrep_slave_threads - 1);
+ }
+ }
+
if (opt_bootstrap)
{
select_thread_in_use= 0; // Allow 'kill' to work
@@ -5459,9 +5854,6 @@ int mysqld_main(int argc, char **argv)
}
}
- /* It's now safe to use thread specific memory */
- mysqld_server_initialized= 1;
-
create_shutdown_thread();
start_handle_manager();
@@ -5485,12 +5877,20 @@ int mysqld_main(int argc, char **argv)
unireg_abort(1);
}
+ disable_log_notes= 0; /* Startup done, now we can give notes again */
sql_print_information(ER_DEFAULT(ER_STARTUP),my_progname,server_version,
((mysql_socket_getfd(unix_sock) == INVALID_SOCKET) ?
(char*) "" : mysqld_unix_port),
mysqld_port,
MYSQL_COMPILATION_COMMENT);
- fclose(stdin);
+
+ // try to keep fd=0 busy
+ if (!freopen(IF_WIN("NUL","/dev/null"), "r", stdin))
+ {
+ // fall back on failure
+ fclose(stdin);
+ }
+
#if defined(_WIN32) && !defined(EMBEDDED_LIBRARY)
Service.SetRunning();
#endif
@@ -5517,6 +5917,7 @@ int mysqld_main(int argc, char **argv)
#ifdef EXTRA_DEBUG2
sql_print_error("Before Lock_thread_count");
#endif
+ WSREP_DEBUG("Before Lock_thread_count");
mysql_mutex_lock(&LOCK_thread_count);
DBUG_PRINT("quit", ("Got thread_count mutex"));
select_thread_in_use=0; // For close_connections
@@ -5782,8 +6183,11 @@ static void bootstrap(MYSQL_FILE *file)
DBUG_ENTER("bootstrap");
THD *thd= new THD;
+#ifdef WITH_WSREP
+ thd->variables.wsrep_on= 0;
+#endif
thd->bootstrap=1;
- my_net_init(&thd->net,(st_vio*) 0, MYF(0));
+ my_net_init(&thd->net,(st_vio*) 0, (void*) 0, MYF(0));
thd->max_client_packet_length= thd->net.max_packet;
thd->security_ctx->master_access= ~(ulong)0;
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
@@ -5928,7 +6332,7 @@ void create_thread_to_handle_connection(THD *thd)
thd->unlink();
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
return;
/* purecov: end */
}
@@ -5982,7 +6386,7 @@ static void create_new_thread(THD *thd)
mysql_mutex_unlock(&LOCK_connection_count);
- thread_safe_increment32(&thread_count, &thread_count_lock);
+ thread_safe_increment32(&thread_count);
/* Start a new thread to handle connection. */
mysql_mutex_lock(&LOCK_thread_count);
@@ -6069,6 +6473,9 @@ void handle_connections_sockets()
socket_flags=fcntl(mysql_socket_getfd(unix_sock), F_GETFL, 0);
#endif
+ sd_notify(0, "READY=1\n"
+ "STATUS=Taking your SQL requests now...");
+
DBUG_PRINT("general",("Waiting for connections."));
MAYBE_BROKEN_SYSCALL;
while (!abort_loop)
@@ -6183,6 +6590,9 @@ void handle_connections_sockets()
sleep(1); // Give other threads some time
continue;
}
+#ifdef FD_CLOEXEC
+ (void) fcntl(mysql_socket_getfd(new_sock), F_SETFD, FD_CLOEXEC);
+#endif
#ifdef HAVE_LIBWRAP
{
@@ -6249,7 +6659,7 @@ void handle_connections_sockets()
mysql_socket_vio_new(new_sock,
is_unix_sock ? VIO_TYPE_SOCKET : VIO_TYPE_TCPIP,
is_unix_sock ? VIO_LOCALHOST: 0)) ||
- my_net_init(&thd->net, vio_tmp, MYF(MY_THREAD_SPECIFIC)))
+ my_net_init(&thd->net, vio_tmp, thd, MYF(MY_THREAD_SPECIFIC)))
{
/*
Only delete the temporary vio if we didn't already attach it to the
@@ -6280,6 +6690,8 @@ void handle_connections_sockets()
create_new_thread(thd);
set_current_thd(0);
}
+ sd_notify(0, "STOPPING=1\n"
+ "STATUS=Shutdown in progress");
DBUG_VOID_RETURN;
}
@@ -6374,7 +6786,7 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
}
set_current_thd(thd);
if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) ||
- my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC)))
+ my_net_init(&thd->net, thd->net.vio, thd, MYF(MY_THREAD_SPECIFIC)))
{
close_connection(thd, ER_OUT_OF_RESOURCES);
delete thd;
@@ -6571,7 +6983,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
event_server_wrote,
event_server_read,
event_conn_closed)) ||
- my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC)))
+ my_net_init(&thd->net, thd->net.vio, thd, MYF(MY_THREAD_SPECIFIC)))
{
close_connection(thd, ER_OUT_OF_RESOURCES);
errmsg= 0;
@@ -6773,9 +7185,6 @@ struct my_option my_long_options[]=
0, 0, 0},
{"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
- /* default-storage-engine should have "MyISAM" as def_value. Instead
- of initializing it here it is done in init_common_variables() due
- to a compiler bug in Sun Studio compiler. */
#ifdef DBUG_OFF
{"debug", '#', "Built in DBUG debugger. Disabled in this build.",
&current_dbug_option, &current_dbug_option, 0, GET_STR, OPT_ARG,
@@ -6832,9 +7241,16 @@ struct my_option my_long_options[]=
&opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
#endif /* HAVE_REPLICATION */
+ /* default-storage-engine should have "MyISAM" as def_value. Instead
+ of initializing it here it is done in init_common_variables() due
+ to a compiler bug in Sun Studio compiler. */
{"default-storage-engine", 0, "The default storage engine for new tables",
&default_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0 },
+ {"default-tmp-storage-engine", 0,
+ "The default storage engine for user-created temporary tables",
+ &default_tmp_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0 },
{"default-time-zone", 0, "Set the default time zone.",
&default_tz_name, &default_tz_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
@@ -6856,6 +7272,9 @@ struct my_option my_long_options[]=
{"stack-trace", 0 , "Print a symbolic stack trace on failure",
&opt_stack_trace, &opt_stack_trace, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
#endif /* HAVE_STACKTRACE */
+ {"enforce-storage-engine", 0, "Force the use of a storage engine for new tables",
+ &enforced_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0 },
{"external-locking", 0, "Use system (external) locking (disabled by "
"default). With this option enabled you can run myisamchk to test "
"(not repair) tables while the MySQL server is running. Disable with "
@@ -6906,6 +7325,11 @@ struct my_option my_long_options[]=
"File that holds the names for last binary log files.",
&opt_binlog_index_name, &opt_binlog_index_name, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"relay-log-index", 0,
+ "The location and name to use for the file that keeps a list of the last "
+ "relay logs",
+ &opt_relaylog_index_name, &opt_relaylog_index_name, 0, GET_STR,
+ REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
&myisam_log_filename, &myisam_log_filename, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -6913,25 +7337,11 @@ struct my_option my_long_options[]=
"Don't log extra information to update and slow-query logs.",
&opt_short_log_format, &opt_short_log_format,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-admin-statements", 0,
- "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to "
- "the slow log if it is open.", &opt_log_slow_admin_statements,
- &opt_log_slow_admin_statements, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-slave-statements", 0,
- "Log slow statements executed by slave thread to the slow log if it is open.",
- &opt_log_slow_slave_statements, &opt_log_slow_slave_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"log-tc", 0,
"Path to transaction coordinator log (used for transactions that affect "
"more than one storage engine, when binary log is disabled).",
&opt_tc_log_file, &opt_tc_log_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#ifdef HAVE_MMAP
- {"log-tc-size", 0, "Size of transaction coordinator log.",
- &opt_tc_log_size, &opt_tc_log_size, 0, GET_ULONG,
- REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, (ulonglong) ULONG_MAX, 0,
- TC_LOG_PAGE_SIZE, 0},
-#endif
{"master-info-file", 0,
"The location and name of the file that remembers the master and where "
"the I/O replication thread is in the master's binlogs. Defaults to "
@@ -6943,7 +7353,7 @@ struct my_option my_long_options[]=
&master_retry_count, &master_retry_count, 0, GET_ULONG,
REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
#ifdef HAVE_REPLICATION
- {"init-rpl-role", 0, "Set the replication role.",
+ {"init-rpl-role", 0, "Set the replication role",
&rpl_status, &rpl_status, &rpl_role_typelib,
GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif /* HAVE_REPLICATION */
@@ -7022,8 +7432,10 @@ struct my_option my_long_options[]=
"Show user and password in SHOW SLAVE HOSTS on this master.",
&opt_show_slave_auth_info, &opt_show_slave_auth_info, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"silent-startup", OPT_SILENT, "Don't print [Note] to the error log during startup.",
+ &opt_silent_startup, &opt_silent_startup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-bdb", OPT_DEPRECATED_OPTION,
- "Deprecated option; Exist only for compatiblity with old my.cnf files",
+ "Deprecated option; Exist only for compatibility with old my.cnf files",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DISABLE_GRANT_OPTIONS
{"skip-grant-tables", 0,
@@ -7036,6 +7448,20 @@ struct my_option my_long_options[]=
{"skip-slave-start", 0,
"If set, slave is not autostarted.", &opt_skip_slave_start,
&opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_REPLICATION
+ {"slave-parallel-mode", OPT_SLAVE_PARALLEL_MODE,
+ "Controls what transactions are applied in parallel when using "
+ "--slave-parallel-threads. Possible values: \"optimistic\" tries to "
+ "apply most transactional DML in parallel, and handles any conflicts "
+ "with rollback and retry. \"conservative\" limits parallelism in an "
+ "effort to avoid any conflicts. \"aggressive\" tries to maximise the "
+ "parallelism, possibly at the cost of increased conflict rate. "
+ "\"minimal\" only parallelizes the commit steps of transactions. "
+ "\"none\" disables parallel apply completely.",
+ &opt_slave_parallel_mode, &opt_slave_parallel_mode,
+ &slave_parallel_mode_typelib, GET_ENUM | GET_ASK_ADDR, REQUIRED_ARG,
+ SLAVE_PARALLEL_CONSERVATIVE, 0, 0, 0, 0, 0},
+#endif
#if defined(_WIN32) && !defined(EMBEDDED_LIBRARY)
{"slow-start-timeout", 0,
"Maximum number of milliseconds that the service control manager should wait "
@@ -7071,8 +7497,8 @@ struct my_option my_long_options[]=
&global_system_variables.sysdate_is_now,
0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
{"tc-heuristic-recover", 0,
- "Decision to use in heuristic recover process. Possible values are COMMIT "
- "or ROLLBACK.", &tc_heuristic_recover, &tc_heuristic_recover,
+ "Decision to use in heuristic recover process",
+ &tc_heuristic_recover, &tc_heuristic_recover,
&tc_heuristic_recover_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"temp-pool", 0,
#if (ENABLE_TEMP_POOL)
@@ -7084,7 +7510,7 @@ struct my_option my_long_options[]=
&use_temp_pool, &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0},
{"transaction-isolation", 0,
- "Default transaction isolation level.",
+ "Default transaction isolation level",
&global_system_variables.tx_isolation,
&global_system_variables.tx_isolation, &tx_isolation_typelib,
GET_ENUM, REQUIRED_ARG, ISO_REPEATABLE_READ, 0, 0, 0, 0, 0},
@@ -7115,15 +7541,19 @@ struct my_option my_long_options[]=
{"table_cache", 0, "Deprecated; use --table-open-cache instead.",
&tc_size, &tc_size, 0, GET_ULONG,
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
+#ifdef WITH_WSREP
+ {"wsrep-new-cluster", 0, "Bootstrap a cluster. It works by overriding the "
+ "current value of wsrep_cluster_address. It is recommended not to add this "
+ "option to the config file as this will trigger bootstrap on every server "
+ "start.", &wsrep_new_cluster, &wsrep_new_cluster, 0, GET_BOOL, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
+#endif
/* The following options exist in 5.6 but not in 10.0 */
- MYSQL_TO_BE_IMPLEMENTED_OPTION("default-tmp-storage-engine"),
MYSQL_COMPATIBILITY_OPTION("log-raw"),
MYSQL_COMPATIBILITY_OPTION("log-bin-use-v1-row-events"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("default-authentication-plugin"),
MYSQL_COMPATIBILITY_OPTION("binlog-max-flush-queue-time"),
- MYSQL_TO_BE_IMPLEMENTED_OPTION("binlog-row-image"),
- MYSQL_TO_BE_IMPLEMENTED_OPTION("explicit-defaults-for-timestamp"),
MYSQL_COMPATIBILITY_OPTION("master-info-repository"),
MYSQL_COMPATIBILITY_OPTION("relay-log-info-repository"),
MYSQL_SUGGEST_ANALOG_OPTION("binlog-rows-query-log-events", "--binlog-annotate-row-events"),
@@ -7161,22 +7591,25 @@ struct my_option my_long_options[]=
MYSQL_TO_BE_IMPLEMENTED_OPTION("validate-user-plugins") // NO_EMBEDDED_ACCESS_CHECKS
};
-static int show_queries(THD *thd, SHOW_VAR *var, char *buff)
+static int show_queries(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONGLONG;
- var->value= (char *)&thd->query_id;
+ var->value= &thd->query_id;
return 0;
}
-static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff)
+static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_MY_BOOL;
- var->value= (char *)&thd->net.compress;
+ var->value= &thd->net.compress;
return 0;
}
-static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
+static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7185,7 +7618,8 @@ static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
}
#ifdef ENABLED_PROFILING
-static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
+static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7195,18 +7629,19 @@ static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
#endif
#ifdef HAVE_REPLICATION
-static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff)
+static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]);
return 0;
}
-static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
+static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
Master_info *mi= NULL;
- bool tmp;
- LINT_INIT(tmp);
+ bool UNINIT_VAR(tmp);
var->type= SHOW_MY_BOOL;
var->value= buff;
@@ -7256,7 +7691,8 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
}
-static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
+static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
Master_info *mi;
@@ -7275,9 +7711,10 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
}
-static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
+static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
- Master_info *mi= NULL;
+ Master_info *mi;
var->type= SHOW_CHAR;
var->value= buff;
@@ -7296,7 +7733,8 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
#endif /* HAVE_REPLICATION */
-static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
+static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7304,7 +7742,8 @@ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff)
+static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7314,7 +7753,8 @@ static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff)
+static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7323,7 +7763,8 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff)
}
-static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff)
+static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7334,7 +7775,8 @@ static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff)
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
/* Functions relying on CTX */
-static int show_ssl_ctx_sess_accept(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_accept(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7343,7 +7785,8 @@ static int show_ssl_ctx_sess_accept(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_accept_good(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_accept_good(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7352,7 +7795,8 @@ static int show_ssl_ctx_sess_accept_good(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_connect_good(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_connect_good(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7361,7 +7805,9 @@ static int show_ssl_ctx_sess_connect_good(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_accept_renegotiate(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_accept_renegotiate(THD *thd, SHOW_VAR *var,
+ char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7370,7 +7816,9 @@ static int show_ssl_ctx_sess_accept_renegotiate(THD *thd, SHOW_VAR *var, char *b
return 0;
}
-static int show_ssl_ctx_sess_connect_renegotiate(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_connect_renegotiate(THD *thd, SHOW_VAR *var,
+ char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7379,7 +7827,8 @@ static int show_ssl_ctx_sess_connect_renegotiate(THD *thd, SHOW_VAR *var, char *
return 0;
}
-static int show_ssl_ctx_sess_cb_hits(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_cb_hits(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7388,7 +7837,8 @@ static int show_ssl_ctx_sess_cb_hits(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_hits(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_hits(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7397,7 +7847,8 @@ static int show_ssl_ctx_sess_hits(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_cache_full(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_cache_full(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7406,7 +7857,8 @@ static int show_ssl_ctx_sess_cache_full(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_misses(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_misses(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7415,7 +7867,8 @@ static int show_ssl_ctx_sess_misses(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_timeouts(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_timeouts(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7424,7 +7877,8 @@ static int show_ssl_ctx_sess_timeouts(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_number(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_number(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7433,7 +7887,8 @@ static int show_ssl_ctx_sess_number(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_connect(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_connect(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7442,7 +7897,9 @@ static int show_ssl_ctx_sess_connect(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_sess_get_cache_size(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_sess_get_cache_size(THD *thd, SHOW_VAR *var,
+ char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7451,7 +7908,8 @@ static int show_ssl_ctx_sess_get_cache_size(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7460,7 +7918,8 @@ static int show_ssl_ctx_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7469,7 +7928,9 @@ static int show_ssl_ctx_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_ctx_get_session_cache_mode(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_ctx_get_session_cache_mode(THD *thd, SHOW_VAR *var,
+ char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
if (!ssl_acceptor_fd)
@@ -7502,17 +7963,20 @@ static int show_ssl_ctx_get_session_cache_mode(THD *thd, SHOW_VAR *var, char *bu
when session_status or global_status is requested from
inside an Event.
*/
-static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff)
+
+static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg )
var->value= const_cast<char*>(SSL_get_version((SSL*) thd->net.vio->ssl_arg));
else
- var->value= (char *)"";
+ var->value= const_cast<char*>("");
return 0;
}
-static int show_ssl_session_reused(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_session_reused(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7523,7 +7987,8 @@ static int show_ssl_session_reused(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7534,7 +7999,8 @@ static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7545,7 +8011,8 @@ static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->value= buff;
@@ -7556,17 +8023,19 @@ static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
-static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg )
var->value= const_cast<char*>(SSL_get_cipher((SSL*) thd->net.vio->ssl_arg));
else
- var->value= (char *)"";
+ var->value= const_cast<char*>("");
return 0;
}
-static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff)
+static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
var->value= buff;
@@ -7640,7 +8109,8 @@ end:
*/
static int
-show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff)
+show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7673,7 +8143,8 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff)
*/
static int
-show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff)
+show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7694,7 +8165,8 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff)
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
-static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff)
+static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
struct st_data {
KEY_CACHE_STATISTICS stats;
@@ -7706,14 +8178,14 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff)
v= data->var;
var->type= SHOW_ARRAY;
- var->value= (char*)v;
+ var->value= v;
get_key_cache_statistics(dflt_key_cache, 0, &data->stats);
#define set_one_keycache_var(X,Y) \
v->name= X; \
v->type= SHOW_LONGLONG; \
- v->value= (char*)&data->stats.Y; \
+ v->value= &data->stats.Y; \
v++;
set_one_keycache_var("blocks_not_flushed", blocks_changed);
@@ -7734,8 +8206,25 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
+
+static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff,
+ struct system_status_var *status_var,
+ enum enum_var_type scope)
+{
+ var->type= SHOW_LONGLONG;
+ var->value= buff;
+ if (scope == OPT_GLOBAL)
+ *(longlong*) buff= (status_var->global_memory_used +
+ status_var->local_memory_used);
+ else
+ *(longlong*) buff= status_var->local_memory_used;
+ return 0;
+}
+
+
#ifndef DBUG_OFF
-static int debug_status_func(THD *thd, SHOW_VAR *var, char *buff)
+static int debug_status_func(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
#define add_var(X,Y,Z) \
v->name= X; \
@@ -7751,11 +8240,11 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, char *buff)
if (_db_keyword_(0, "role_merge_stats", 1))
{
static SHOW_VAR roles[]= {
- {"global", (char*) &role_global_merges, SHOW_ULONG},
- {"db", (char*) &role_db_merges, SHOW_ULONG},
- {"table", (char*) &role_table_merges, SHOW_ULONG},
- {"column", (char*) &role_column_merges, SHOW_ULONG},
- {"routine", (char*) &role_routine_merges, SHOW_ULONG},
+ {"global", &role_global_merges, SHOW_ULONG},
+ {"db", &role_db_merges, SHOW_ULONG},
+ {"table", &role_table_merges, SHOW_ULONG},
+ {"column", &role_column_merges, SHOW_ULONG},
+ {"routine", &role_routine_merges, SHOW_ULONG},
{NullS, NullS, SHOW_LONG}
};
@@ -7771,7 +8260,8 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, char *buff)
#endif
#ifdef HAVE_POOL_OF_THREADS
-int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff)
+int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
+ enum enum_var_type scope)
{
var->type= SHOW_INT;
var->value= buff;
@@ -7787,6 +8277,7 @@ int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff)
SHOW_VAR status_vars[]= {
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
+ {"Acl", (char*) acl_statistics, SHOW_ARRAY},
{"Access_denied_errors", (char*) offsetof(STATUS_VAR, access_denied_errors), SHOW_LONG_STATUS},
{"Binlog_bytes_written", (char*) offsetof(STATUS_VAR, binlog_bytes_written), SHOW_LONGLONG_STATUS},
{"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG},
@@ -7857,8 +8348,12 @@ SHOW_VAR status_vars[]= {
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
{"Key", (char*) &show_default_keycache, SHOW_FUNC},
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
+ {"Max_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_STATUS},
+ {"Master_gtid_wait_count", (char*) offsetof(STATUS_VAR, master_gtid_wait_count), SHOW_LONGLONG_STATUS},
+ {"Master_gtid_wait_timeouts", (char*) offsetof(STATUS_VAR, master_gtid_wait_timeouts), SHOW_LONGLONG_STATUS},
+ {"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONGLONG_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
- {"Memory_used", (char*) offsetof(STATUS_VAR, memory_used), SHOW_LONGLONG_STATUS},
+ {"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
{"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH},
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH},
@@ -7902,6 +8397,7 @@ SHOW_VAR status_vars[]= {
{"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats, SHOW_SIMPLE_FUNC},
{"Slave_retried_transactions",(char*)&slave_retried_transactions, SHOW_LONG},
{"Slave_running", (char*) &show_slave_running, SHOW_SIMPLE_FUNC},
+ {"Slave_skipped_errors", (char*) &slave_skipped_errors, SHOW_LONGLONG},
#endif
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
@@ -7966,6 +8462,9 @@ SHOW_VAR status_vars[]= {
#ifdef ENABLED_PROFILING
{"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC},
#endif
+#ifdef WITH_WSREP
+ {"wsrep", (char*) &wsrep_show_status, SHOW_FUNC},
+#endif
{NullS, NullS, SHOW_LONG}
};
@@ -8034,9 +8533,9 @@ static void print_help()
my_print_help((my_option*) all_options.buffer);
- /* Add variables that can be shown but not changed, like version numbers */
+ /* Add variables that must be shown but not changed, like version numbers */
pop_dynamic(&all_options);
- sys_var_add_options(&all_options, sys_var::SHOW_VALUE_IN_HELP);
+ sys_var_add_options(&all_options, sys_var::GETOPT_ONLY_HELP);
sort_dynamic(&all_options, (qsort_cmp) option_cmp);
add_terminator(&all_options);
my_print_variables((my_option*) all_options.buffer);
@@ -8115,7 +8614,7 @@ static int mysql_init_variables(void)
/* We can only test for sub paths if my_symlink.c is using realpath */
mysys_test_invalid_symlink= path_starts_from_data_home_dir;
#endif
- opt_log= opt_slow_log= 0;
+ opt_log= 0;
opt_bin_log= opt_bin_log_used= 0;
opt_disable_networking= opt_skip_show_db=0;
opt_skip_name_resolve= 0;
@@ -8125,6 +8624,7 @@ static int mysql_init_variables(void)
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
opt_secure_auth= 0;
opt_bootstrap= opt_myisam_log= 0;
+ disable_log_notes= 0;
mqh_used= 0;
kill_in_progress= 0;
cleanup_done= 0;
@@ -8149,7 +8649,9 @@ static int mysql_init_variables(void)
prepared_stmt_count= 0;
mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
- bzero((char *) &global_status_var, sizeof(global_status_var));
+ /* Clear all except global_memory_used */
+ bzero((char*) &global_status_var, offsetof(STATUS_VAR,
+ last_cleared_system_status_var));
opt_large_pages= 0;
opt_super_large_pages= 0;
#if defined(ENABLED_DEBUG_SYNC)
@@ -8167,18 +8669,12 @@ static int mysql_init_variables(void)
opt_specialflag= SPECIAL_ENGLISH;
unix_sock= base_ip_sock= extra_ip_sock= MYSQL_INVALID_SOCKET;
mysql_home_ptr= mysql_home;
- pidfile_name_ptr= pidfile_name;
log_error_file_ptr= log_error_file;
protocol_version= PROTOCOL_VERSION;
what_to_log= ~ (1L << (uint) COM_TIME);
denied_connections= 0;
executed_events= 0;
global_query_id= thread_id= 1L;
- my_atomic_rwlock_init(&global_query_id_lock);
- my_atomic_rwlock_init(&thread_running_lock);
- my_atomic_rwlock_init(&thread_count_lock);
- my_atomic_rwlock_init(&statistics_lock);
- my_atomic_rwlock_init(&slave_executed_entries_lock);
strnmov(server_version, MYSQL_SERVER_VERSION, sizeof(server_version)-1);
threads.empty();
thread_cache.empty();
@@ -8203,6 +8699,8 @@ static int mysql_init_variables(void)
report_user= report_password = report_host= 0; /* TO BE DELETED */
opt_relay_logname= opt_relaylog_index_name= 0;
slave_retried_transactions= 0;
+ log_bin_basename= NULL;
+ log_bin_index= NULL;
/* Variables in libraries */
charsets_dir= 0;
@@ -8306,15 +8804,29 @@ static int mysql_init_variables(void)
if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
tmpenv = DEFAULT_MYSQL_HOME;
strmake_buf(mysql_home, tmpenv);
+ set_sys_var_value_origin(&mysql_home_ptr, sys_var::ENV);
#endif
+
+ if (wsrep_init_vars())
+ return 1;
+
return 0;
}
my_bool
-mysqld_get_one_option(int optid,
- const struct my_option *opt __attribute__((unused)),
- char *argument)
+mysqld_get_one_option(int optid, const struct my_option *opt, char *argument)
{
+ if (opt->app_type)
+ {
+ sys_var *var= (sys_var*) opt->app_type;
+ if (argument == autoset_my_option)
+ {
+ var->value_origin= sys_var::AUTO;
+ return 0;
+ }
+ var->value_origin= sys_var::CONFIG;
+ }
+
switch(optid) {
case '#':
#ifndef DBUG_OFF
@@ -8329,6 +8841,7 @@ mysqld_get_one_option(int optid,
if (argument[0] == '1' && !argument[1])
break;
DBUG_SET_INITIAL(argument);
+ current_dbug_option= argument;
opt_endinfo=1; /* unireg: memory allocation */
#else
sql_print_warning("'%s' is disabled in this build", opt->name);
@@ -8336,7 +8849,7 @@ mysqld_get_one_option(int optid,
break;
case OPT_DEPRECATED_OPTION:
sql_print_warning("'%s' is deprecated. It does nothing and exists only "
- "for compatiblity with old my.cnf files.",
+ "for compatibility with old my.cnf files.",
opt->name);
break;
case OPT_MYSQL_COMPATIBILITY:
@@ -8348,8 +8861,8 @@ mysqld_get_one_option(int optid,
"in later versions.", opt->name);
break;
case 'a':
- global_system_variables.sql_mode= MODE_ANSI;
- global_system_variables.tx_isolation= ISO_SERIALIZABLE;
+ SYSVAR_AUTOSIZE(global_system_variables.sql_mode, MODE_ANSI);
+ SYSVAR_AUTOSIZE(global_system_variables.tx_isolation, ISO_SERIALIZABLE);
break;
case 'b':
strmake_buf(mysql_home, argument);
@@ -8407,28 +8920,46 @@ mysqld_get_one_option(int optid,
case (int) OPT_LOG_BASENAME:
{
if (opt_log_basename[0] == 0 || strchr(opt_log_basename, FN_EXTCHAR) ||
- strchr(opt_log_basename,FN_LIBCHAR))
+ strchr(opt_log_basename,FN_LIBCHAR) ||
+ !is_filename_allowed(opt_log_basename, strlen(opt_log_basename), FALSE))
{
- sql_print_error("Wrong argument for --log-basename. It can't be empty or contain '.' or '" FN_DIRSEP "'");
+ sql_print_error("Wrong argument for --log-basename. It can't be empty or contain '.' or '" FN_DIRSEP "'. It must be valid filename.");
return 1;
}
if (log_error_file_ptr != disabled_my_option)
- log_error_file_ptr= opt_log_basename;
+ SYSVAR_AUTOSIZE(log_error_file_ptr, opt_log_basename);
+ /* General log file */
make_default_log_name(&opt_logname, ".log", false);
+ /* Slow query log file */
make_default_log_name(&opt_slow_logname, "-slow.log", false);
+ /* Binary log file */
make_default_log_name(&opt_bin_logname, "-bin", true);
+ /* Binary log index file */
make_default_log_name(&opt_binlog_index_name, "-bin.index", true);
+ set_sys_var_value_origin(&opt_logname, sys_var::AUTO);
+ set_sys_var_value_origin(&opt_slow_logname, sys_var::AUTO);
+ if (!opt_logname || !opt_slow_logname || !opt_bin_logname ||
+ !opt_binlog_index_name)
+ return 1;
+
+#ifdef HAVE_REPLICATION
+ /* Relay log file */
make_default_log_name(&opt_relay_logname, "-relay-bin", true);
+ /* Relay log index file */
make_default_log_name(&opt_relaylog_index_name, "-relay-bin.index", true);
+ set_sys_var_value_origin(&opt_relay_logname, sys_var::AUTO);
+ if (!opt_relay_logname || !opt_relaylog_index_name)
+ return 1;
+#endif
- pidfile_name_ptr= pidfile_name;
+ SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name);
+ /* PID file */
strmake(pidfile_name, argument, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid");
/* check for errors */
- if (!opt_bin_logname || !opt_relaylog_index_name || ! opt_logname ||
- ! opt_slow_logname || !pidfile_name_ptr)
+ if (!pidfile_name_ptr)
return 1; // out of memory error
break;
}
@@ -8474,6 +9005,13 @@ mysqld_get_one_option(int optid,
cur_rpl_filter->add_db_rewrite(key, val);
break;
}
+ case (int)OPT_SLAVE_PARALLEL_MODE:
+ {
+ /* Store latest mode for Master::Info */
+ cur_rpl_filter->set_parallel_mode
+ ((enum_slave_parallel_mode)opt_slave_parallel_mode);
+ break;
+ }
case (int)OPT_BINLOG_IGNORE_DB:
{
@@ -8524,11 +9062,11 @@ mysqld_get_one_option(int optid,
#endif /* HAVE_REPLICATION */
case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC;
- delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
- myisam_recover_options= HA_RECOVER_DEFAULT;
+ SYSVAR_AUTOSIZE(delay_key_write_options, (uint) DELAY_KEY_WRITE_NONE);
+ SYSVAR_AUTOSIZE(myisam_recover_options, HA_RECOVER_DEFAULT);
ha_open_options&= ~(HA_OPEN_DELAY_KEY_WRITE);
#ifdef HAVE_QUERY_CACHE
- query_cache_size=0;
+ SYSVAR_AUTOSIZE(query_cache_size, 0);
#endif
sql_print_warning("The syntax '--safe-mode' is deprecated and will be "
"removed in a future release.");
@@ -8596,7 +9134,6 @@ mysqld_get_one_option(int optid,
}
}
break;
-
case OPT_PLUGIN_LOAD:
free_list(opt_plugin_load_list_ptr);
/* fall through */
@@ -8607,6 +9144,7 @@ mysqld_get_one_option(int optid,
max_long_data_size_used= true;
break;
case OPT_PFS_INSTRUMENT:
+ {
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#ifndef EMBEDDED_LIBRARY
/* Parse instrument name and value from argument string */
@@ -8676,6 +9214,17 @@ mysqld_get_one_option(int optid,
#endif
break;
}
+#ifdef WITH_WSREP
+ case OPT_WSREP_CAUSAL_READS:
+ wsrep_causal_reads_update(&global_system_variables);
+ break;
+ case OPT_WSREP_SYNC_WAIT:
+ global_system_variables.wsrep_causal_reads=
+ MY_TEST(global_system_variables.wsrep_sync_wait &
+ WSREP_SYNC_WAIT_BEFORE_READ);
+ break;
+#endif /* WITH_WSREP */
+ }
return 0;
}
@@ -8720,6 +9269,7 @@ mysql_getopt_value(const char *name, uint length,
return (uchar**) &key_cache->changed_blocks_hash_size;
}
}
+#ifdef HAVE_REPLICATION
case OPT_REPLICATE_DO_DB:
case OPT_REPLICATE_DO_TABLE:
case OPT_REPLICATE_IGNORE_DB:
@@ -8727,6 +9277,7 @@ mysql_getopt_value(const char *name, uint length,
case OPT_REPLICATE_WILD_DO_TABLE:
case OPT_REPLICATE_WILD_IGNORE_TABLE:
case OPT_REPLICATE_REWRITE_DB:
+ case OPT_SLAVE_PARALLEL_MODE:
{
/* Store current filter for mysqld_get_one_option() */
if (!(cur_rpl_filter= get_or_create_rpl_filter(name, length)))
@@ -8734,8 +9285,17 @@ mysql_getopt_value(const char *name, uint length,
if (error)
*error= EXIT_OUT_OF_MEMORY;
}
+ if (option->id == OPT_SLAVE_PARALLEL_MODE)
+ {
+ /*
+ Ensure parallel_mode variable is shown in --help. The other
+ variables are not easily printable here.
+ */
+ return (char**) &opt_slave_parallel_mode;
+ }
return 0;
}
+#endif
}
return option->value;
}
@@ -8797,6 +9357,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
(*argc_ptr)++;
(*argv_ptr)--;
+ disable_log_notes= opt_silent_startup;
+
/*
Options have been parsed. Now some of them need additional special
handling, like custom value checking, checking of incompatibilites
@@ -8806,7 +9368,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
opt_log_slow_slave_statements) &&
- !opt_slow_log)
+ !global_system_variables.sql_log_slow)
sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set");
if (global_system_variables.net_buffer_length >
global_system_variables.max_allowed_packet)
@@ -8817,6 +9379,17 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
global_system_variables.max_allowed_packet);
}
+#if MYSQL_VERSION_ID > 101001
+ /*
+ TIMESTAMP columns get implicit DEFAULT values when
+ --explicit_defaults_for_timestamp is not set.
+ */
+ if (!opt_help && !opt_explicit_defaults_for_timestamp)
+ sql_print_warning("TIMESTAMP with implicit DEFAULT value is deprecated. "
+ "Please use --explicit_defaults_for_timestamp server "
+ "option (see documentation for more details).");
+#endif
+
if (log_error_file_ptr != disabled_my_option)
opt_error_log= 1;
else
@@ -8854,6 +9427,16 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
else
global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
+ if (!opt_bootstrap && WSREP_PROVIDER_EXISTS &&
+ global_system_variables.binlog_format != BINLOG_FORMAT_ROW)
+ {
+
+ WSREP_ERROR ("Only binlog_format = 'ROW' is currently supported. "
+ "Configured value: '%s'. Please adjust your configuration.",
+ binlog_format_names[global_system_variables.binlog_format]);
+ return 1;
+ }
+
// Synchronize @@global.autocommit on --autocommit
const ulonglong turn_bit_on= opt_autocommit ?
OPTION_AUTOCOMMIT : OPTION_NOT_AUTOCOMMIT;
@@ -8888,7 +9471,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
if (mysqld_chroot)
set_root(mysqld_chroot);
#else
- thread_handling = SCHEDULER_NO_THREADS;
+ SYSVAR_AUTOSIZE(thread_handling, SCHEDULER_NO_THREADS);
max_allowed_packet= global_system_variables.max_allowed_packet;
net_buffer_length= global_system_variables.net_buffer_length;
#endif
@@ -8916,7 +9499,9 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
debug_assert_if_crashed_table= 1;
global_system_variables.long_query_time= (ulonglong)
- (global_system_variables.long_query_time_double * 1e6);
+ (global_system_variables.long_query_time_double * 1e6 + 0.1);
+ global_system_variables.max_statement_time= (ulonglong)
+ (global_system_variables.max_statement_time_double * 1e6 + 0.1);
if (opt_short_log_format)
opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
@@ -8938,7 +9523,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
/* workaround: disable thread pool on XP */
if (GetProcAddress(GetModuleHandle("kernel32"),"CreateThreadpool") == 0 &&
thread_handling > SCHEDULER_NO_THREADS)
- thread_handling = SCHEDULER_ONE_THREAD_PER_CONNECTION;
+ SYSVAR_AUTOSIZE(thread_handling, SCHEDULER_ONE_THREAD_PER_CONNECTION);
#endif
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
@@ -8955,10 +9540,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
&extra_connection_count);
#endif
- global_system_variables.engine_condition_pushdown=
- MY_TEST(global_system_variables.optimizer_switch &
- OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN);
-
opt_readonly= read_only;
/*
@@ -8966,24 +9547,27 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
value of max_allowed_packet.
*/
if (!max_long_data_size_used)
- max_long_data_size= global_system_variables.max_allowed_packet;
+ SYSVAR_AUTOSIZE(max_long_data_size,
+ global_system_variables.max_allowed_packet);
/* Remember if max_user_connections was 0 at startup */
max_user_connections_checking= global_system_variables.max_user_connections != 0;
+#ifdef HAVE_REPLICATION
{
sys_var *max_relay_log_size_var, *max_binlog_size_var;
/* If max_relay_log_size is 0, then set it to max_binlog_size */
if (!global_system_variables.max_relay_log_size)
- global_system_variables.max_relay_log_size= max_binlog_size;
+ SYSVAR_AUTOSIZE(global_system_variables.max_relay_log_size,
+ max_binlog_size);
/*
Fix so that DEFAULT and limit checking works with max_relay_log_size
(Yes, this is a hack, but it's required as the definition of
max_relay_log_size allows it to be set to 0).
*/
- max_relay_log_size_var= intern_find_sys_var("max_relay_log_size", 0);
- max_binlog_size_var= intern_find_sys_var("max_binlog_size", 0);
+ max_relay_log_size_var= intern_find_sys_var(STRING_WITH_LEN("max_relay_log_size"));
+ max_binlog_size_var= intern_find_sys_var(STRING_WITH_LEN("max_binlog_size"));
if (max_binlog_size_var && max_relay_log_size_var)
{
max_relay_log_size_var->option.min_value=
@@ -8992,12 +9576,13 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
max_binlog_size_var->option.def_value;
}
}
+#endif
/* Ensure that some variables are not set higher than needed */
if (back_log > max_connections)
- back_log= max_connections;
+ SYSVAR_AUTOSIZE(back_log, max_connections);
if (thread_cache_size > max_connections)
- thread_cache_size= max_connections;
+ SYSVAR_AUTOSIZE(thread_cache_size, max_connections);
return 0;
}
@@ -9023,7 +9608,7 @@ void set_server_version(void)
if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
end= strnmov(end, "-debug", (version_end-end));
#endif
- if (opt_log || opt_slow_log || opt_bin_log)
+ if (opt_log || global_system_variables.sql_log_slow || opt_bin_log)
strnmov(end, "-log", (version_end-end)); // This may slow down system
*end= 0;
}
@@ -9165,13 +9750,18 @@ static int fix_paths(void)
/* If --character-sets-dir isn't given, use shared library dir */
if (charsets_dir)
+ {
strmake_buf(mysql_charsets_dir, charsets_dir);
+ charsets_dir= mysql_charsets_dir;
+ }
else
+ {
strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
CHARSET_DIR, NullS);
+ SYSVAR_AUTOSIZE(charsets_dir, mysql_charsets_dir);
+ }
(void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
- charsets_dir=mysql_charsets_dir;
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
DBUG_RETURN(1);
@@ -9179,7 +9769,7 @@ static int fix_paths(void)
opt_mysql_tmpdir= mysql_tmpdir;
#ifdef HAVE_REPLICATION
if (!slave_load_tmpdir)
- slave_load_tmpdir= mysql_tmpdir;
+ SYSVAR_AUTOSIZE(slave_load_tmpdir, mysql_tmpdir);
#endif /* HAVE_REPLICATION */
/*
Convert the secure-file-priv option to system format, allowing
@@ -9228,9 +9818,9 @@ static int test_if_case_insensitive(const char *dir_name)
MY_STAT stat_info;
DBUG_ENTER("test_if_case_insensitive");
- fn_format(buff, glob_hostname, dir_name, ".lower-test",
+ fn_format(buff, opt_log_basename, dir_name, ".lower-test",
MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR);
- fn_format(buff2, glob_hostname, dir_name, ".LOWER-TEST",
+ fn_format(buff2, opt_log_basename, dir_name, ".LOWER-TEST",
MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR);
mysql_file_delete(key_file_casetest, buff2, MYF(0));
if ((file= mysql_file_create(key_file_casetest,
@@ -9307,11 +9897,16 @@ void refresh_status(THD *thd)
/* Reset thread's status variables */
thd->set_status_var_init();
+ thd->status_var.global_memory_used= 0;
bzero((uchar*) &thd->org_status_var, sizeof(thd->org_status_var));
thd->start_bytes_received= 0;
/* Reset some global variables */
reset_status_vars();
+#ifdef WITH_WSREP
+ if (WSREP_ON)
+ wsrep->stats_reset(wsrep);
+#endif /* WITH_WSREP */
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters, 0);
@@ -9363,6 +9958,7 @@ static PSI_file_info all_server_files[]=
};
#endif /* HAVE_PSI_INTERFACE */
+PSI_stage_info stage_after_apply_event= { 0, "after apply log event", 0};
PSI_stage_info stage_after_create= { 0, "After create", 0};
PSI_stage_info stage_after_opening_tables= { 0, "After opening tables", 0};
PSI_stage_info stage_after_table_lock= { 0, "After table lock", 0};
@@ -9370,6 +9966,7 @@ PSI_stage_info stage_allocating_local_table= { 0, "allocating local table", 0};
PSI_stage_info stage_alter_inplace_prepare= { 0, "preparing for alter table", 0};
PSI_stage_info stage_alter_inplace= { 0, "altering table", 0};
PSI_stage_info stage_alter_inplace_commit= { 0, "committing alter table to storage engine", 0};
+PSI_stage_info stage_apply_event= { 0, "apply log event", 0};
PSI_stage_info stage_changing_master= { 0, "Changing master", 0};
PSI_stage_info stage_checking_master_version= { 0, "Checking master version", 0};
PSI_stage_info stage_checking_permissions= { 0, "checking permissions", 0};
@@ -9443,6 +10040,7 @@ PSI_stage_info stage_sql_thd_waiting_until_delay= { 0, "Waiting until MASTER_DEL
PSI_stage_info stage_storing_result_in_query_cache= { 0, "storing result in query cache", 0};
PSI_stage_info stage_storing_row_into_queue= { 0, "storing row into queue", 0};
PSI_stage_info stage_system_lock= { 0, "System lock", 0};
+PSI_stage_info stage_unlocking_tables= { 0, "Unlocking tables", 0};
PSI_stage_info stage_table_lock= { 0, "Table lock", 0};
PSI_stage_info stage_filling_schema_table= { 0, "Filling schema table", 0};
PSI_stage_info stage_update= { 0, "update", 0};
@@ -9484,11 +10082,15 @@ PSI_stage_info stage_waiting_for_rpl_thread_pool= { 0, "Waiting while replicatio
PSI_stage_info stage_master_gtid_wait_primary= { 0, "Waiting in MASTER_GTID_WAIT() (primary waiter)", 0};
PSI_stage_info stage_master_gtid_wait= { 0, "Waiting in MASTER_GTID_WAIT()", 0};
PSI_stage_info stage_gtid_wait_other_connection= { 0, "Waiting for other master connection to process GTID received on multiple master connections", 0};
+PSI_stage_info stage_slave_background_process_request= { 0, "Processing requests", 0};
+PSI_stage_info stage_slave_background_wait_request= { 0, "Waiting for requests", 0};
+PSI_stage_info stage_waiting_for_deadlock_kill= { 0, "Waiting for parallel replication deadlock handling to complete", 0};
#ifdef HAVE_PSI_INTERFACE
PSI_stage_info *all_server_stages[]=
{
+ & stage_after_apply_event,
& stage_after_create,
& stage_after_opening_tables,
& stage_after_table_lock,
@@ -9496,6 +10098,7 @@ PSI_stage_info *all_server_stages[]=
& stage_alter_inplace,
& stage_alter_inplace_commit,
& stage_alter_inplace_prepare,
+ & stage_apply_event,
& stage_binlog_processing_checkpoint_notify,
& stage_binlog_stopping_background_thread,
& stage_binlog_waiting_background_tasks,
@@ -9572,6 +10175,7 @@ PSI_stage_info *all_server_stages[]=
& stage_storing_result_in_query_cache,
& stage_storing_row_into_queue,
& stage_system_lock,
+ & stage_unlocking_tables,
& stage_table_lock,
& stage_filling_schema_table,
& stage_update,
@@ -9605,7 +10209,9 @@ PSI_stage_info *all_server_stages[]=
& stage_waiting_to_get_readlock,
& stage_master_gtid_wait_primary,
& stage_master_gtid_wait,
- & stage_gtid_wait_other_connection
+ & stage_gtid_wait_other_connection,
+ & stage_slave_background_process_request,
+ & stage_slave_background_wait_request
};
PSI_socket_key key_socket_tcpip, key_socket_unix, key_socket_client_connection;