YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifdefined(HAVE_RO_AFTER_INIT) && !defined(EMBEDDED_LIBRARY) // start and end of the ro_after_init section, to test if a variable is in it externchar ro_after_init_start[] __attribute__((weak)); externchar ro_after_init_end[] __attribute__((weak));
/** name of reference on left expression in rewritten IN subquery */ const Lex_ident_column in_left_expr_name= "<left expr>"_Lex_ident_column; /** name of additional condition */ const Lex_ident_column in_having_cond= "<IN HAVING>"_Lex_ident_column; const Lex_ident_column in_additional_cond= "<IN COND>"_Lex_ident_column;
/** Number of connection errors when selecting on the listening port */
ulong connection_errors_select= 0; /** Number of connection errors when accepting sockets in the listening port. */
ulong connection_errors_accept= 0; /** Number of connection errors from TCP wrappers. */
ulong connection_errors_tcpwrap= 0; /** Number of connection errors from internal server errors. */
ulong connection_errors_internal= 0; /** Number of connection errors from the server max_connection limit. */
ulong connection_errors_max_connection= 0; /** Number of errors when reading the peer address. */
ulong connection_errors_peer_addr= 0;
void init_net_server_extension(THD *thd)
{ /* Start with a clean state for connection events. */
thd->m_idle_psi= NULL;
thd->m_statement_psi= NULL; /* Hook up the NET_SERVER callback in the net layer. */
thd->m_net_server_extension.m_user_data= thd;
thd->m_net_server_extension.m_before_header= net_before_header_psi;
thd->m_net_server_extension.m_after_header= net_after_header_psi; /* Activate this private extension for the mysqld server. */
thd->net.extension= & thd->m_net_server_extension;
} #else void init_net_server_extension(THD *thd)
{
} #endif/* EMBEDDED_LIBRARY */
/** Alogmessagefortheerrorlog,bufferedinmemory. Logmessagesaretemporarilybufferedwhengeneratedbeforetheerrorlog isinitialized,andthenprintedoncetheerrorlogisready.
*/ class Buffered_log : public Sql_alloc
{ public:
Buffered_log(enum loglevel level, constchar *message);
/* OS specific variables */ #ifndef EMBEDDED_LIBRARY #ifdef _WIN32 /** wakeup main thread by signaling this event */
HANDLE hEventShutdown; #else /** wakeup listening(main) thread by writing to this descriptor */ staticint termination_event_fd= -1; #endif #endif
/* common callee of two shutdown phases */ staticvoid kill_thread(THD *thd)
{
mysql_mutex_lock(&thd->LOCK_thd_kill);
thd->abort_current_cond_wait(true);
mysql_mutex_unlock(&thd->LOCK_thd_kill);
}
/** Firstshutdowneverythingbutslavethreadsandbinlogdumpconnections
*/ static my_bool kill_thread_phase_1(THD *thd, void *)
{
DBUG_PRINT("quit", ("Informing thread %ld that it's time to die",
(ulong) thd->thread_id));
if (thd->slave_thread || thd->is_binlog_dump_thread()) return0;
if (DBUG_IF("only_kill_system_threads") && !thd->system_thread) return0; if (DBUG_IF("only_kill_system_threads_no_loop") && !thd->system_thread) return0;
for (int i= 0; THD_count::connection_thd_count() && i < 1000; i++)
{ if (DBUG_IF("only_kill_system_threads_no_loop")) break;
my_sleep(20000);
}
if (global_system_variables.log_warnings)
server_threads.iterate(warn_threads_active_after_phase_1);
#ifdef WITH_WSREP if (wsrep_inited == 1)
{
wsrep_deinit(true);
} #endif /* All threads has now been aborted */
DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)",
THD_count::connection_thd_count()));
while (THD_count::connection_thd_count())
{ if (DBUG_IF("only_kill_system_threads_no_loop")) break;
my_sleep(1000);
}
/* Kill phase 2 */
server_threads.iterate(kill_thread_phase_2); for (uint64 i= 0; THD_count::value() > local_connection_thread_count; i++)
{ /* Thistimethewarningsareemittedwithinthelooptoprovidea dynamicviewontheshutdownstatusthroughtheerrorlog.
*/ if (global_system_variables.log_warnings > 2 && i % 60000 == 0)
server_threads.iterate(warn_threads_active_after_phase_2);
my_sleep(1000);
} /* End of kill phase 2 */
if (opt_help)
usage(); elseif (exit_code)
sql_print_error("Aborting"); /* Don't write more notes to the log to not hide error message */
disable_log_notes= 1;
#ifdef WITH_WSREP // Note that we do not have thd here, thus can't use // WSREP(thd)
if (WSREP_ON &&
Wsrep_server_state::is_inited() &&
Wsrep_server_state::instance().state() != wsrep::server_state::s_disconnected)
{ /* Thisisanabortsituation,wecannotexpecttogracefullycloseall wsrepthreadshere,wecanonlydisconnectfromservice
*/
wsrep_close_client_connections(FALSE);
Wsrep_server_state::instance().disconnect();
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.");
}
set_ro_after_init_prot(MY_VMEM_READWRITE); // to allow cleanup
#ifdef HAVE_REPLICATION // We must call end_slave() as clean_up may have been called during startup
end_slave(); if (use_slave_mask)
my_bitmap_free(&slave_error_mask); #endif
stop_handle_manager();
ddl_log_release();
logger.cleanup_base();
injector::free_instance();
mysql_bin_log.cleanup();
Gtid_index_writer::gtid_index_cleanup(); if (opt_binlog_engine_plugin)
plugin_unlock(0, opt_binlog_engine_plugin);
#ifndef EMBEDDED_LIBRARY /** Thisismainlyneededwhenrunningwithpurify,butit'sstillniceto knowthatallchildthreadshavediedwhenmysqldexits.
*/ staticvoid wait_for_signal_thread_to_end()
{ #ifndef _WIN32
uint i, n_waits= DBUG_IF("force_sighup_processing_timeout") ? 5 : 100; int err= 0; /* Waitupto10secondsforsignalthreadtodie.Weusethismainlyto avoidgettingwarningsthatmy_thread_endhasnotbeencalled
*/ for (i= 0 ; i < n_waits && signal_thread_in_use; i++)
{
kill(getpid(), MYSQL_KILL_SIGNAL);
my_sleep(100000); // Give it time to die, .1s per iteration
}
if (err && err != ESRCH)
{
sql_print_error("Failed to send kill signal to signal handler thread, " "pthread_kill() errno: %d",
err);
}
if (i == n_waits && signal_thread_in_use)
{
sql_print_warning("Signal handler thread did not exit in a timely manner. " "Continuing to wait for it to stop..");
} if (signal_thread_needs_join)
{
pthread_join(signal_thread, NULL);
signal_thread_needs_join= false;
} #endif
} #endif/*EMBEDDED_LIBRARY*/
#ifdef EMBEDDED_LIBRARY void close_connection(THD *thd, uint sql_errno)
{
} #else staticvoid set_ports()
{ char *env; if (!mysqld_port && !opt_disable_networking)
{ // Get port if not from commandline
mysqld_port= MYSQL_PORT;
if (my_bind_addr_str && strcmp(my_bind_addr_str, "*") == 0)
real_bind_addr_str= NULL; // windows doesn't seem to support * here else
real_bind_addr_str= my_bind_addr_str;
if (stype != SOCK_STREAM)
{
sql_print_error("Unknown systemd socket activation socket %d," " not of type SOCK_STREAM - type %d", fd, stype); goto err;
}
if (MYSQL_CONNECTION_DONE_ENABLED())
{
sleep(0); /* Workaround to avoid tailcall optimisation */
}
mysql_audit_notify_connection_disconnect(thd, sql_errno);
DBUG_VOID_RETURN;
}
/** Called when mysqld is aborted with ^C */ /* ARGSUSED */ extern"C" sig_handler end_mysqld_signal(int sig __attribute__((unused)))
{
DBUG_ENTER("end_mysqld_signal"); /* Don't kill if signal thread is not running */ if (signal_thread_in_use)
break_connect_loop(); // Take down mysqld nicely
DBUG_VOID_RETURN; /* purecov: deadcode */
} #endif/* EMBEDDED_LIBRARY */
staticvoid start_signal_handler(void)
{ #ifndef EMBEDDED_LIBRARY // Save vm id of this process if (!opt_bootstrap)
create_pid_file(); #endif/* EMBEDDED_LIBRARY */
}
#ifdef HAVE_GETRLIMIT if (test_flags & TEST_CORE_ON_SIGNAL)
{ /* Change limits so that we will get a core file */
STRUCT_RLIMIT rl;
rl.rlim_cur = rl.rlim_max = (rlim_t) RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
sql_print_warning("setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals");
} #endif
(void) sigemptyset(&set);
my_sigset(SIGPIPE,SIG_IGN);
sigaddset(&set,SIGPIPE); #ifndef IGNORE_SIGHUP_SIGQUIT
sigaddset(&set,SIGQUIT);
sigaddset(&set,SIGHUP); #endif
sigaddset(&set,SIGTERM);
/* Fix signals if blocked by parents (can happen on Mac OS X) */
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = print_signal_warning;
sigaction(SIGTERM, &sa, (struct sigaction*) 0);
sa.sa_flags = 0;
sa.sa_handler = print_signal_warning;
sigaction(SIGHUP, &sa, (struct sigaction*) 0); if (test_flags & TEST_SIGINT)
{ /* Allow SIGINT to break mysqld. This is for debugging with --gdb */
my_sigset(SIGINT, end_mysqld_signal);
sigdelset(&set, SIGINT);
} else
{
sigaddset(&set,SIGINT); #ifdef SIGTSTP
sigaddset(&set,SIGTSTP); #endif
}
(void) pthread_sigmask(SIG_BLOCK,&set,NULL); for (;;)
{ int error; int origin;
if (abort_loop) break;
while ((error= my_sigwait(&set, &sig, &origin)) == EINTR) /* no-op */;
if (abort_loop) break;
switch (sig) { case SIGTERM: case SIGQUIT: #ifdef EXTRA_DEBUG
sql_print_information("Got signal %d to shutdown server",sig); #endif /* switch to the old log message processing */
logger.set_handlers(global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE,
opt_log ? LOG_FILE:LOG_NONE);
break_connect_loop();
DBUG_ASSERT(abort_loop); break; case SIGHUP: #ifdefined(SI_KERNEL) if (origin != SI_KERNEL) #elifdefined(SI_USER) if (origin <= SI_USER) #endif
{ int not_used;
mysql_print_status(); // Print some debug info
reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
REFRESH_GRANT |
REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, ¬_used); // Flush logs
/* reenable logs after the options were reloaded */
ulonglong fixed_log_output_options=
log_output_options & LOG_NONE ? LOG_TABLE : log_output_options;
global_tmp_space_used+= size_change; if (size_change > 0)
{ /* Cache to avoid reading global_tmp_space_used too many times */
ulonglong cached_space= global_tmp_space_used;
if (cached_space > global_max_tmp_space_usage && !no_error &&
global_max_tmp_space_usage)
{
global_tmp_space_used-= size_change;
error= EE_GLOBAL_TMP_SPACE_FULL;
my_errno= ENOSPC; gotoexit;
} if (thd->status_var.tmp_space_used + size_change >
thd->variables.max_tmp_space_usage && !no_error &&
thd->variables.max_tmp_space_usage)
{
global_tmp_space_used-= size_change;
error= EE_LOCAL_TMP_SPACE_FULL;
my_errno= ENOSPC; gotoexit;
}
set_if_bigger(global_status_var.max_tmp_space_used, cached_space);
}
thd->status_var.tmp_space_used+= size_change; /* Max value for the connection */
set_if_bigger(thd->status_var.max_tmp_space_used,
thd->status_var.tmp_space_used); /* Max value for the query */
set_if_bigger(thd->max_tmp_space_used,
thd->status_var.tmp_space_used);
DBUG_ASSERT((longlong) global_tmp_space_used >= 0);
DBUG_ASSERT((longlong) thd->status_var.tmp_space_used >= 0);
/* Record that we have registered the change */
track->previous_file_size= track->file_size;
exit: if (unlikely(thd->shared_thd))
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
DBUG_RETURN(error);
}
/* mysql_real_data_home_ptr may be null if no value of datadir has been specifiedthroughcommand-lineorthroughacnffile.Ifthatisthe casewemakemysql_real_data_home_ptrpointtomysql_real_data_home which,inthatcaseholdsthedefaultpathfordata-dir.
*/ if(mysql_real_data_home_ptr == NULL)
mysql_real_data_home_ptr= mysql_real_data_home;
global_rpl_filter= new Rpl_filter;
binlog_filter= new Rpl_filter; if (!global_rpl_filter || !binlog_filter)
{
sql_perror("Could not allocate replication and binlog filters"); exit(1);
}
#if LONG_SIZE == 4 /* TODO: remove this when my_time_t is 64 bit compatible */ if (!IS_TIME_T_VALID_FOR_TIMESTAMP(server_start_time))
{
sql_print_error("This server doesn't support dates later than 2038"); exit(1);
} #endif
opt_log_basename= const_cast<char *>("mysql");
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
{ /* Gethostnameofcomputer(usedby'showvariables')andasdefault basenameforthepidfileif--log-basenameisnotgiven.
*/
strmake(glob_hostname, STRING_WITH_LEN("localhost"));
sql_print_warning("gethostname failed, using '%s' as hostname",
glob_hostname);
} elseif (is_filename_allowed(glob_hostname, strlen(glob_hostname), FALSE))
opt_log_basename= glob_hostname;
/* Addserverstatusvariablestothedynamiclistof statusvariablesthatisshownbySHOWSTATUS. Later,inplugin_init,andmysql_install_plugin newentriescouldbeaddedtothatlist.
*/ if (add_status_vars(status_vars)) exit(1); // an error was already reported
int opt_err; if ((opt_err= get_options(&remaining_argc, &remaining_argv))) exit(opt_err); if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
set_server_version(server_version, sizeof(server_version));
if (calculate_server_uid(server_uid))
strmov(server_uid, "unknown");
sf_leaking_memory= 0; // no memory leaks from now on
#ifndef EMBEDDED_LIBRARY if (opt_abort && !opt_verbose)
unireg_abort(0); #endif/*!EMBEDDED_LIBRARY*/
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
server_version, SYSTEM_TYPE,MACHINE_TYPE));
/* Initialize large page size */ if (opt_large_pages)
{
DBUG_PRINT("info", ("Large page set")); if (my_init_large_pages())
{ return1;
}
}
#ifdefined(HAVE_POOL_OF_THREADS) if (IS_SYSVAR_AUTOSIZE(&threadpool_size))
SYSVAR_AUTOSIZE(threadpool_size, my_getncpus()); #endif
/* connections and databases needs lots of files */
{
uint files, wanted_files, max_open_files, min_tc_size, extra_files,
min_connections;
ulong org_max_connections, org_tc_size;
/* Number of files reserved for temporary files */
extra_files= 30;
min_connections= 10; /* MyISAM requires two file handles per table. */
wanted_files= (extra_files + max_connections + extra_max_connections +
tc_size * 2 * tc_instances); #ifdefined(HAVE_POOL_OF_THREADS) && !defined(_WIN32) // add epoll or kevent fd for each threadpool group, in case pool of threads is used
wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; #endif
if (files < max_open_files && global_system_variables.log_warnings)
sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, max_open_files);
/* If we required too much tc_instances than we reduce */
SYSVAR_AUTOSIZE_IF_CHANGED(tc_instances,
(uint32) MY_MIN(MY_MAX((files - extra_files -
max_connections)/ 2/tc_size, 1),
tc_instances),
uint32); /* Ifwehaverequestedtoomuchfilehandlesthanwebring max_connectionsinsupportedbounds.Stillleaveatleast 'min_connections'connections
*/
SYSVAR_AUTOSIZE_IF_CHANGED(max_connections,
(ulong) MY_MAX(MY_MIN(files- extra_files-
min_tc_size*2*tc_instances,
max_connections),
min_connections),
ulong);
if (character_set_collations_str[0])
{
Lex_cstring_strlen str(character_set_collations_str); if (global_system_variables.character_set_collations.
from_text(str, utf8_flag))
{
sql_print_error(ER_DEFAULT(ER_WRONG_VALUE_FOR_VAR), "character_set_collations", character_set_collations_str);
}
}
for (;;)
{ char *next_character_set_name= strchr(default_character_set_name, ','); if (next_character_set_name)
*next_character_set_name++= '\0'; if (!(default_charset_info=
get_charset_by_csname(default_character_set_name,
MY_CS_PRIMARY, MYF(utf8_flag | MY_WME))))
{ if (next_character_set_name)
{
default_character_set_name= next_character_set_name;
default_collation_name= 0; // Ignore collation
} else return1; // Eof of the list
} else
{
Sql_used used;
default_charset_info= global_system_variables.character_set_collations.
get_collation_for_charset(&used,
default_charset_info); break;
}
}
if (default_collation_name)
{
CHARSET_INFO *default_collation;
default_collation= get_charset_by_name(default_collation_name, MYF(utf8_flag)); if (!default_collation)
{ #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
buffered_logs.print();
buffered_logs.cleanup(); #endif
sql_print_error(ER_DEFAULT(ER_UNKNOWN_COLLATION), default_collation_name); return1;
} if (!my_charset_same(default_charset_info, default_collation))
{
sql_print_error(ER_DEFAULT(ER_COLLATION_CHARSET_MISMATCH),
default_collation_name,
default_charset_info->cs_name.str); return1;
}
default_charset_info= default_collation;
} /* Set collations that depend on the default collation */
global_system_variables.collation_server= default_charset_info;
global_system_variables.collation_database= default_charset_info; if (is_supported_parser_charset(default_charset_info))
{
global_system_variables.collation_connection= default_charset_info;
global_system_variables.character_set_results=
global_system_variables.character_set_client=
Lex_exact_charset_opt_extended_collate(default_charset_info, true).
find_compiled_default_collation();
} else
{
sql_print_warning("'%s' can not be used as client character set. " "'%s' will be used as default client character set.",
default_charset_info->cs_name.str,
my_charset_latin1.cs_name.str);
global_system_variables.collation_connection= &my_charset_latin1;
global_system_variables.character_set_results= &my_charset_latin1;
global_system_variables.character_set_client= &my_charset_latin1;
}
if (!(character_set_filesystem=
get_charset_by_csname(character_set_filesystem_name,
MY_CS_PRIMARY, MYF(utf8_flag | MY_WME)))) return1;
global_system_variables.character_set_filesystem= character_set_filesystem;
/* check log options and issue warnings if needed */ if (opt_log && opt_logname && *opt_logname &&
!(log_output_options & (LOG_FILE | LOG_NONE)))
sql_print_warning("Although a general log file was specified, " "log tables are used. " "To enable logging to files use the --log-output option.");
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 slow query log file was specified, " "log tables are used. " "To enable logging to files use the --log-output=file option.");
if (!opt_logname || !*opt_logname)
make_default_log_name(&opt_logname, ".log", false); if (!opt_slow_logname || !*opt_slow_logname)
make_default_log_name(&opt_slow_logname, "-slow.log", false);
String sqlpath(const_cast<constchar*>(opt_path), strlen(opt_path),
character_set_filesystem); if (global_system_variables.path.from_text(global_system_variables, &sqlpath)) return1;
#ifdefined(ENABLED_DEBUG_SYNC) /* Initialize the debug sync facility. See debug_sync.cc. */ if (debug_sync_init()) return1; /* purecov: tested */ #endif/* defined(ENABLED_DEBUG_SYNC) */
/* Ensurethatlower_case_table_namesissetonsystemwherewehavecase insensitivenames.IfthisisnotdonetheusersMyISAMtableswill getcorruptedifaccesseswithnamesofdifferentcase.
*/
DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names)); if(mysql_real_data_home_ptr == NULL || *mysql_real_data_home_ptr == 0)
mysql_real_data_home_ptr= mysql_real_data_home;
SYSVAR_AUTOSIZE(lower_case_file_system,
test_if_case_insensitive(mysql_real_data_home_ptr)); if (!lower_case_table_names && lower_case_file_system == 1)
{ if (lower_case_table_names_used)
{
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."); return1;
} 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_ptr);
SYSVAR_AUTOSIZE(lower_case_table_names, 2);
}
} elseif (lower_case_table_names == 2 &&
!(lower_case_file_system= (lower_case_file_system == 1)))
{ if (global_system_variables.log_warnings)
sql_print_warning("lower_case_table_names was set to 2, even though your " "the file system '%s' is case sensitive. Now setting " "lower_case_table_names to 0 to avoid future problems.",
mysql_real_data_home_ptr);
SYSVAR_AUTOSIZE(lower_case_table_names, 0);
} else
{
lower_case_file_system= (lower_case_file_system == 1);
}
/* Reset table_alias_charset, now that lower_case_table_names is set. */
table_alias_charset= (lower_case_table_names ?
files_charset_info :
&my_charset_bin);
if (ignore_db_dirs_process_additions())
{
sql_print_error("An error occurred while storing ignore_db_dirs to a hash."); return1;
}
if (tls_version & (VIO_TLSv1_0 + VIO_TLSv1_1))
sql_print_warning("TLSv1.0 and TLSv1.1 are insecure and should not be used for tls_version");
/* create_temporary_table... must always have the flag BINLOG_FORMAT_STMT */
global_system_variables.create_temporary_table_binlog_formats|=
(1ULL << BINLOG_FORMAT_STMT);
staticvoid openssl_lock_function(int mode, int n, constchar *file, int line)
{ if (n < 0 || n > CRYPTO_num_locks())
{ /* Lock number out of bounds. */
sql_print_error("Fatal: OpenSSL interface problem (n = %d)", n);
abort();
}
openssl_lock(mode, &openssl_stdlocks[n], file, line);
}
staticvoid openssl_lock(int mode, openssl_lock_t *lock, constchar *file, int line)
{ int err; charconst *what;
switch (mode) { case CRYPTO_LOCK|CRYPTO_READ:
what = "read lock";
err= mysql_rwlock_rdlock(&lock->lock); break; case CRYPTO_LOCK|CRYPTO_WRITE:
what = "write lock";
err= mysql_rwlock_wrlock(&lock->lock); break; case CRYPTO_UNLOCK|CRYPTO_READ: case CRYPTO_UNLOCK|CRYPTO_WRITE:
what = "unlock";
err= mysql_rwlock_unlock(&lock->lock); break; default: /* Unknown locking mode. */
sql_print_error("Fatal: OpenSSL interface problem (mode=0x%x)", mode);
abort();
} if (err)
{
sql_print_error("Fatal: can't %s OpenSSL lock", what);
abort();
}
} #endif/* HAVE_OPENSSL10 */
struct SSL_ACCEPTOR_STATS
{ long accept; long accept_good; long cache_size; long verify_mode; long verify_depth; long zero; constchar *session_cache_mode;
uchar fprint[256/8];
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();
DBUG_ASSERT(query_cache_size < ULONG_MAX);
query_cache_resize((ulong)query_cache_size);
my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
setup_fpu();
init_thr_lock();
backup_init();
/* need to configure logging before initializing storage engines */ if (!opt_bin_log_used && !WSREP_ON)
{ if (opt_log_slave_updates && (global_system_variables.log_warnings >= 4))
sql_print_information("You need to use --log-bin to make " "--log-slave-updates work."); if (binlog_format_used && (global_system_variables.log_warnings >= 4))
sql_print_information("You need to use --log-bin to make " "--binlog-format work.");
}
/* Check that we have not let the format to unspecified at this point */
DBUG_ASSERT((uint)global_system_variables.binlog_format <=
array_elements(binlog_format_names)-1);
#ifdef HAVE_REPLICATION if (opt_log_slave_updates && replicate_same_server_id)
{ if (opt_bin_log)
{
sql_print_error("using --replicate-same-server-id in conjunction with " "--log-slave-updates is impossible, it would lead to " "infinite loops in this server.");
unireg_abort(1);
} else
sql_print_warning("using --replicate-same-server-id in conjunction with " "--log-slave-updates would lead to infinite loops in " "this server. However this will be ignored as the " "--log-bin option is not defined.");
} #endif
if (opt_bin_log)
{ if (opt_binlog_storage_engine && *opt_binlog_storage_engine)
binlog_engine_used= true;
/* Reports an error and aborts, if the --log-bin's path
is a directory.*/ if (opt_bin_logname[0] &&
opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR)
{
sql_print_error("Path '%s' is a directory name, please specify " "a file name for --log-bin option, or use " "--binlog-directory", opt_bin_logname);
unireg_abort(1);
}
if (!binlog_engine_used)
{ /* Reports an error and aborts, if the --log-bin-index's path
is a directory.*/ if (opt_binlog_index_name &&
opt_binlog_index_name[strlen(opt_binlog_index_name) - 1]
== FN_LIBCHAR)
{
sql_print_error("Path '%s' is a directory name, please specify " "a file name for --log-bin-index option",
opt_binlog_index_name);
unireg_abort(1);
}
}
char buf[FN_REFLEN], buf2[FN_REFLEN]; constchar *ln;
ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf); /* Add in opt_binlog_directory, if given. */ if (opt_binlog_directory && opt_binlog_directory[0])
{ if (strlen(opt_binlog_directory) + 1 + strlen(ln) + 1 > FN_REFLEN)
{
sql_print_error("The combination of --binlog-directory path '%s' with " "filename '%s' from --log-bin results in a too long " "path", opt_binlog_directory, ln);
unireg_abort(1);
} if (create_dir_path_if_needed(opt_binlog_directory))
{
sql_print_error("Failed to create the directory '%s' specified in " "--binlog-directory, error code: %d",
opt_binlog_directory, my_errno);
unireg_abort(1);
} constchar *end= &buf2[FN_REFLEN-1]; char *p= strmake(buf2, opt_binlog_directory, FN_REFLEN - 2);
*p++= FN_LIBCHAR;
strmake(p, ln, end - p - 1);
ln= buf2;
} if (!binlog_engine_used && !opt_bin_logname[0] && !opt_binlog_index_name)
{ /* Userdidn'tgiveusinfotonamethebinlogindexfile. Picking`hostname`-bin.indexlikedidin4.x,causesreplicationto failifthehostnameischangedlater.So,wewouldliketoinstead requireaname.Butaswedon'twanttobreakmanyexistingsetups,we onlygivewarning,noterror.
*/
sql_print_warning("No argument was provided to --log-bin and " "neither --log-basename or --log-bin-index where " "used; This may cause repliction to break when this " "server acts as a master and has its hostname " "changed! Please use '--log-basename=%s' or " "'--log-bin=%s' to avoid this problem.",
opt_log_basename, ln);
} if (ln == buf)
opt_bin_logname= my_once_strdup(buf, MYF(MY_WME)); elseif (ln == buf2)
opt_bin_logname= my_once_strdup(buf2, MYF(MY_WME));
}
/* It's now safe to use thread specific memory */
mysqld_server_initialized= 1;
#ifndef EMBEDDED_LIBRARY
wsrep_thr_init(); #endif
#ifdef WITH_WSREP if (wsrep_init_server()) unireg_abort(1);
if (WSREP_ON && !wsrep_recovery && !opt_abort)
{ if (binlog_engine_used)
{
sql_print_error("Galera cannot be used with the " "--binlog-storage-engine option");
unireg_abort(1);
} if (opt_bootstrap) // bootstrap option given - disable wsrep functionality
{
wsrep_provider_init(WSREP_NONE); if (wsrep_init())
unireg_abort(1);
} else// full wsrep initialization
{ // add basedir/bin to PATH to resolve wsrep script names
size_t tmp_path_size= strlen(mysql_home) + 5; /* including "/bin" */ char* const tmp_path= (char*)my_alloca(tmp_path_size); if (tmp_path)
{
snprintf(tmp_path, tmp_path_size, "%s/bin", mysql_home);
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);
}
}
} #endif/* WITH_WSREP */
if (!opt_help && !binlog_engine_used && opt_bin_log)
{ if (mysql_bin_log.open_index_file(opt_binlog_index_name, opt_bin_logname, TRUE))
{
unireg_abort(1);
}
log_bin_basename=
rpl_make_log_name(key_memory_MYSQL_BIN_LOG_basename,
opt_bin_logname, pidfile_name,
opt_bin_logname ? "" : "-bin");
log_bin_index=
rpl_make_log_name(key_memory_MYSQL_BIN_LOG_index,
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(key_memory_MYSQL_RELAY_LOG_basename,
opt_relay_logname, pidfile_name,
opt_relay_logname ? "" : "-relay-bin");
relay_log_index=
rpl_make_log_name(key_memory_MYSQL_RELAY_LOG_index,
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);
/* PluginsmaynotbecompletedbecausesystemtableDDLsareonly runaftertheddlrecoverydone.Thereforebetweenthe plugin_init()callandtheha_signal_ddl_recovery_done()call belowonlythingsrelatedtopreparationforrecoveryshouldbe doneandnothingelse,anddefinitelynotanythingassumingthat allpluginshavebeeninitialised.
*/ if (plugin_init(&remaining_argc, remaining_argv,
(opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
(opt_abort ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
{
sql_print_error("Failed to initialize plugins.");
unireg_abort(1);
}
plugins_are_initialized= TRUE; /* Don't separate from init function */
#ifdef HAVE_REPLICATION /* Semisyncisnotrequiredbyothercomponents,whichjustifiesits initializationatthispointwhenthreadspecificmemoryisalsoavailable.
*/ if (repl_semisync_master.init_object() ||
repl_semisync_slave.init_object())
{
sql_print_error("Could not initialize semisync.");
unireg_abort(1);
} #endif
#ifndef EMBEDDED_LIBRARY if (session_tracker_init()) return1; #endif//EMBEDDED_LIBRARY
/* we do want to exit if there are any other unknown options */ if (remaining_argc > 1)
{ int ho_error; struct my_option removed_opts[]=
{ /* The following options exist in 5.6 but not in 10.0 */
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_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"),
MYSQL_COMPATIBILITY_OPTION("binlog-order-commits"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("log-throttle-queries-not-using-indexes"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("end-markers-in-json"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-features"), // OPTIMIZER_TRACE
MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-offset"), // OPTIMIZER_TRACE
MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-limit"), // OPTIMIZER_TRACE
MYSQL_COMPATIBILITY_OPTION("server-id-bits"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-rows-search-algorithms"), // HAVE_REPLICATION
MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-allow-batching"), // HAVE_REPLICATION
MYSQL_COMPATIBILITY_OPTION("slave-checkpoint-period"), // HAVE_REPLICATION
MYSQL_COMPATIBILITY_OPTION("slave-checkpoint-group"), // HAVE_REPLICATION
MYSQL_SUGGEST_ANALOG_OPTION("slave-pending-jobs-size-max", "--slave-parallel-max-queued"), // HAVE_REPLICATION
MYSQL_TO_BE_IMPLEMENTED_OPTION("sha256-password-private-key-path"), // HAVE_OPENSSL
MYSQL_TO_BE_IMPLEMENTED_OPTION("sha256-password-public-key-path"), // HAVE_OPENSSL
/* The following options exist in 5.5 and 5.6 but not in 10.0 */
MYSQL_SUGGEST_ANALOG_OPTION("abort-slave-event-count", "--debug-abort-slave-event-count"),
MYSQL_SUGGEST_ANALOG_OPTION("disconnect-slave-event-count", "--debug-disconnect-slave-event-count"),
MYSQL_SUGGEST_ANALOG_OPTION("exit-info", "--debug-exit-info"),
MYSQL_SUGGEST_ANALOG_OPTION("max-binlog-dump-events", "--debug-max-binlog-dump-events"),
MYSQL_SUGGEST_ANALOG_OPTION("sporadic-binlog-dump-fail", "--debug-sporadic-binlog-dump-fail"),
MYSQL_COMPATIBILITY_OPTION("new"),
MYSQL_COMPATIBILITY_OPTION("show_compatibility_56"),
/* The following options were removed in 10.6 */
MARIADB_REMOVED_OPTION("innodb-force-load-corrupted"),
/* The following options were removed in 10.5 */ #ifdefined(__linux__)
MARIADB_REMOVED_OPTION("super-large-pages"), #endif
MARIADB_REMOVED_OPTION("innodb-defragment"),
MARIADB_REMOVED_OPTION("innodb-defragment-n-pages"),
MARIADB_REMOVED_OPTION("innodb-defragment-stats-accuracy"),
MARIADB_REMOVED_OPTION("innodb-defragment-fill-factor"),
MARIADB_REMOVED_OPTION("innodb-defragment-fill-factor-n-recs"),
MARIADB_REMOVED_OPTION("innodb-defragment-frequency"),
MARIADB_REMOVED_OPTION("innodb-idle-flush-pct"),
MARIADB_REMOVED_OPTION("innodb-locks-unsafe-for-binlog"),
MARIADB_REMOVED_OPTION("innodb-rollback-segments"),
MARIADB_REMOVED_OPTION("innodb-stats-sample-pages"),
MARIADB_REMOVED_OPTION("max-long-data-size"),
MARIADB_REMOVED_OPTION("multi-range-count"),
MARIADB_REMOVED_OPTION("skip-bdb"),
MARIADB_REMOVED_OPTION("thread-concurrency"),
MARIADB_REMOVED_OPTION("timed-mutexes"),
/* The following options were added after 5.6.10 */
MYSQL_TO_BE_IMPLEMENTED_OPTION("rpl-stop-slave-timeout"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("validate-user-plugins"), // NO_EMBEDDED_ACCESS_CHECKS
/* The following options were deprecated in 10.5 or earlier */
MARIADB_REMOVED_OPTION("innodb-adaptive-max-sleep-delay"),
MARIADB_REMOVED_OPTION("innodb-background-scrub-data-check-interval"),
MARIADB_REMOVED_OPTION("innodb-background-scrub-data-compressed"),
MARIADB_REMOVED_OPTION("innodb-background-scrub-data-interval"),
MARIADB_REMOVED_OPTION("innodb-background-scrub-data-uncompressed"),
MARIADB_REMOVED_OPTION("innodb-buffer-pool-instances"),
MARIADB_REMOVED_OPTION("innodb-commit-concurrency"),
MARIADB_REMOVED_OPTION("innodb-concurrency-tickets"),
MARIADB_REMOVED_OPTION("innodb-file-format"),
MARIADB_REMOVED_OPTION("innodb-large-prefix"),
MARIADB_REMOVED_OPTION("innodb-lock-schedule-algorithm"),
MARIADB_REMOVED_OPTION("innodb-log-checksums"),
MARIADB_REMOVED_OPTION("innodb-log-compressed-pages"),
MARIADB_REMOVED_OPTION("innodb-log-files-in-group"),
MARIADB_REMOVED_OPTION("innodb-log-optimize-ddl"),
MARIADB_REMOVED_OPTION("innodb-lru-flush-size"),
MARIADB_REMOVED_OPTION("innodb-page-cleaners"),
MARIADB_REMOVED_OPTION("innodb-purge-rseg-truncate-frequency"),
MARIADB_REMOVED_OPTION("innodb-replication-delay"),
MARIADB_REMOVED_OPTION("innodb-scrub-log"),
MARIADB_REMOVED_OPTION("innodb-scrub-log-speed"),
MARIADB_REMOVED_OPTION("innodb-sync-array-size"),
MARIADB_REMOVED_OPTION("innodb-thread-concurrency"),
MARIADB_REMOVED_OPTION("innodb-thread-sleep-delay"),
MARIADB_REMOVED_OPTION("innodb-undo-logs"),
/* The following options were deprecated in 10.9 */
MARIADB_REMOVED_OPTION("innodb-change-buffering"),
/* removed in 11.3 */
MARIADB_REMOVED_OPTION("date-format"),
MARIADB_REMOVED_OPTION("datetime-format"),
MARIADB_REMOVED_OPTION("time-format"),
MARIADB_REMOVED_OPTION("wsrep-causal-reads"),
/* removed in 11.5 */
MARIADB_REMOVED_OPTION("wsrep-load-data-splitting"),
/* removed in 12.0 */
MARIADB_REMOVED_OPTION("big-tables"),
MARIADB_REMOVED_OPTION("large-page-size"),
MARIADB_REMOVED_OPTION("storage-engine"),
/* Add back the program name handle_options removes */
remaining_argc++;
remaining_argv--;
my_getopt_skip_unknown= TRUE;
#ifdef WITH_WSREP if (!wsrep_recovery)
{ #endif if (remaining_argc > 1)
{
fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n",
my_progname, remaining_argv[1]);
unireg_abort(1);
} #ifdef WITH_WSREP
} #endif
}
if (opt_abort)
unireg_abort(0);
if (init_io_cache_encryption())
unireg_abort(1);
/* if the errmsg.sys is not loaded, terminate to maintain behaviour */ if (!DEFAULT_ERRMSGS[0][0])
unireg_abort(1);
/* We have to initialize the storage engines before CSV logging */ if (ha_init())
{
sql_print_error("Can't init databases");
unireg_abort(1);
}
if (opt_bootstrap)
log_output_options= LOG_FILE; else
logger.init_log_tables();
if (log_output_options & LOG_NONE)
{ /* Issueawarningiftherewerespecifiedadditionaloptionstothe log-outputalongwithNONE.Probablythiswasn'twhatuserwanted.
*/ if ((log_output_options & LOG_NONE) && (log_output_options & ~LOG_NONE))
sql_print_warning("There were other values specified to " "log-output besides NONE. Disabling slow " "and general logs anyway.");
logger.set_handlers(LOG_NONE, LOG_NONE);
} else
{ /* fall back to the log files if tables are not present */
LEX_CSTRING csv_name={STRING_WITH_LEN("csv")}; if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN))
{ /* purecov: begin inspected */
sql_print_error("CSV engine is not present, falling back to the " "log files");
SYSVAR_AUTOSIZE(log_output_options,
(log_output_options & ~LOG_TABLE) | LOG_FILE); /* purecov: end */
}
if (init_default_storage_engine(default_storage_engine, table_plugin))
unireg_abort(1);
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);
if (init_gtid_pos_auto_engines())
unireg_abort(1);
if (opt_binlog_directory && opt_binlog_directory[0] &&
opt_bin_log_path)
{
sql_print_error("Cannot specify a directory path for the binlog in " "--log-bin when --binlog-directory-path is also used");
unireg_abort(1);
}
if (binlog_engine_used)
{
LEX_CSTRING name= { opt_binlog_storage_engine, strlen(opt_binlog_storage_engine) };
opt_binlog_engine_plugin= ha_resolve_by_name(0, &name, false); if (!opt_binlog_engine_plugin ||
!ha_storage_engine_is_enabled(opt_binlog_engine_hton=
plugin_hton(opt_binlog_engine_plugin)))
{ if (!opt_binlog_engine_plugin)
sql_print_error("Unknown/unsupported storage engine: %s",
opt_binlog_storage_engine); else
sql_print_error("Engine %s is not available for " "--binlog-storage-engine",
opt_binlog_storage_engine);
unireg_abort(1);
} if (!opt_binlog_engine_hton->binlog_write_direct ||
!opt_binlog_engine_hton->get_binlog_reader)
{
sql_print_error("Engine %s does not support --binlog-storage-engine",
opt_binlog_storage_engine);
unireg_abort(1);
}
if (opt_bin_log_nonempty)
{
sql_print_error("Binlog name can not be set with --log-bin=NAME when " "--binlog-storage-engine is used. Use --log-bin " "(without argument) to enable the binlog, and use " "--binlog-directory to specify a separate directory " "for binlogs");
unireg_abort(1);
} #ifdef HAVE_REPLICATION if (rpl_semi_sync_master_enabled)
{
sql_print_error("Semi-synchronous replication is not yet supported " "with --binlog-storage-engine");
unireg_abort(1);
} if (rpl_status != RPL_AUTH_MASTER)
{
sql_print_error("The --init-rpl-role option is not available with " "--binlog-storage-engine");
unireg_abort(1);
} if (encrypt_binlog)
{
sql_print_error("Binlog encryption is not available with " "--binlog-storage-engine. Using full-disk encryption on " "the operating system level is recommended instead");
unireg_abort(1);
} #endif
}
#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 server was configured with --with-aria-tmp-tables");
unireg_abort(1);
} #endif
copy_tmptable_optimizer_costs();
if (opt_bin_log)
{ if (!opt_binlog_engine_hton)
{ if (binlog_space_limit)
mysql_bin_log.count_binlog_space_with_mutex();
mysql_bin_log.purge(1);
}
} else
{ if ((binlog_expire_logs_seconds || binlog_space_limit) &&
(global_system_variables.log_warnings >= 4))
sql_print_information("You need to use --log-bin to make " "--expire-logs-days, " "--binlog-expire-logs-seconds or " "--max-binlog-total-size " "work.");
} #endif
int mysqld_main(int argc, char **argv)
{ #ifndef _WIN32 /* We can't close stdin until we know we're not in bootstrap mode. */ bool please_close_stdin= fcntl(STDIN_FILENO, F_GETFD) >= 0; #endif
/* Performbasicthreadlibraryandmallocinitialization, tobeabletoreaddefaultsfilesandparseoptions.
*/
my_progname= argv[0];
sf_leaking_memory= 1; // no safemalloc memory leak reports if we exit early
mysqld_server_started= mysqld_server_initialized= 0;
/* Must be initialized early for comparison of options name */
system_charset_info= &my_charset_utf8mb3_general1400_as_ci;
system_charset_info_for_i_s= &my_charset_utf8mb3_general_ci;
/* Atomic write initialization must be done as root */
my_init_atomic_write();
if ((user_info= check_user(mysqld_user)))
{ #ifdefined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory) // getuid() == 0 here
set_effective_user(user_info); else #endif
set_user(mysqld_user, user_info);
}
#ifdef WITH_WSREP
wsrep_set_wsrep_on(nullptr); if (WSREP_ON && wsrep_check_opts()) unireg_abort(1);
if (!opt_bootstrap && WSREP_PROVIDER_EXISTS && WSREP_ON)
{ if (global_system_variables.binlog_format != BINLOG_FORMAT_ROW)
{
sql_print_information("Binlog_format changed to \"ROW\" because of " "Galera");
SYSVAR_AUTOSIZE(global_system_variables.binlog_format, BINLOG_FORMAT_ROW);
}
binlog_format_used= 1; if (IS_SYSVAR_AUTOSIZE(&internal_slave_connections_needed_for_purge))
{
slave_connections_needed_for_purge=
internal_slave_connections_needed_for_purge= 0;
SYSVAR_AUTOSIZE(internal_slave_connections_needed_for_purge, 0);
sql_print_information( "slave_connections_needed_for_purge changed to 0 because " "of Galera. Change it to 1 or higher if this Galera node " "is also Master in a normal replication setup");
}
} #endif/* WITH_WSREP */
#ifndef _WIN32 // try to keep fd=0 busy if (please_close_stdin && !freopen("/dev/null", "r", stdin))
{ // fall back on failure
fclose(stdin);
} #endif
/* Signal threads waiting for server to be started */
mysql_mutex_lock(&LOCK_server_started);
mysqld_server_started= 1;
mysql_cond_broadcast(&COND_server_started);
mysql_mutex_unlock(&LOCK_server_started);
(void)MYSQL_SET_STAGE(0 ,__FILE__, __LINE__);
/* Memory used when everything is setup */
start_memory_used= (global_status_var.global_memory_used +
my_malloc_init_memory_allocated);
run_main_loop();
/* Shutdown requested */
{ char *user= shutdown_user.load(std::memory_order_relaxed);
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
user ? user : "unknown");
}
#ifdef WITH_WSREP
wsrep_shutdown(); /* Release threads if they are waiting in WSREP_SYNC_WAIT_UPTO_GTID */
wsrep_gtid_server.signal_waiters(0, true); #endif
sd_notify(0, "READY=1\n" "STATUS=Taking your SQL requests now...\n");
DBUG_PRINT("general",("Waiting for connections.")); while (!abort_loop)
{
retval= poll(fds.get_pos(0), fds.size(), -1);
if (retval < 0)
{ if (socket_errno != SOCKET_EINTR)
{ /* select(2)/poll(2)failedonthelisteningport. Thereisnotmuchdetailstoreportabouttheclient, incrementtheserverglobalstatusvariable.
*/
statistic_increment(connection_errors_accept, &LOCK_status); if (!select_errors++ && !abort_loop) /* purecov: inspected */
sql_print_error("Server: Got error %d from select",socket_errno); /* purecov: inspected */
} continue;
}
if (abort_loop) break;
/* Is this a new connection request ? */ for (size_t i= 0; i < fds.size(); ++i)
{ if (fds.at(i).revents & POLLIN)
{
sock= listen_sockets.at(i); break;
}
}
ho_error= handle_options(&remaining_argc, &remaining_argv,
(my_option*)(all_early_options.buffer),
mysqld_get_one_option); if (ho_error == 0)
{ /* Add back the program name handle_options removes */
remaining_argc++;
remaining_argv--;
}
struct my_option my_long_options[]=
{
{"help", '?', "Display this help and exit",
&opt_help, &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ansi", 'a', "Use ANSI SQL syntax instead of MariaDB syntax. This mode " "will also set transaction isolation level 'serializable'", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, /* BecauseSys_var_bitdoesnotsupportcommand-lineoptions,weneedto explicitlyaddonefor--autocommit
*/
{"autocommit", 0, "Set default value for autocommit (0 or 1)",
&opt_autocommit, &opt_autocommit, 0,
GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, NULL},
{"binlog-do-db", OPT_BINLOG_DO_DB, "Tells the master it should log updates for the specified database, " "and exclude all others not explicitly mentioned", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, "Tells the master that updates to the given database should not be logged to the binary log", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS
{"bootstrap", OPT_BOOTSTRAP, "Used by MariaDB installation scripts", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif
{"character-set-client-handshake", 0, "Don't ignore client side character set value sent during handshake",
&opt_character_set_client_handshake,
&opt_character_set_client_handshake, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"character-set-filesystem", 0, "Set the filesystem character set",
&character_set_filesystem_name,
&character_set_filesystem_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"character-set-server", 'C', "Set the default character set",
&default_character_set_name, &default_character_set_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"chroot", 'r', "Chroot mariadbd process during startup",
&mysqld_chroot, &mysqld_chroot, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"collation-server", 0, "Set the default collation",
&default_collation_name, &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"character-set-collations", 0, "Overrides for character set default collations",
&character_set_collations_str, &character_set_collations_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"console", OPT_CONSOLE, "Write error output on screen; don't remove the console window on Windows",
&opt_console, &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF
{"debug", '#', "Built in DBUG debugger. Disabled in this build",
¤t_dbug_option, ¤t_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_REPLICATION
{"debug-abort-slave-event-count", 0, "Option used by mysql-test for debugging and testing of replication",
&abort_slave_event_count, &abort_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif/* HAVE_REPLICATION */ #ifndef DBUG_OFF
{"debug-assert", 0, "Allow DBUG_ASSERT() to invoke assert()",
&my_assert, &my_assert, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
{"debug-assert-on-error", 0, "Do an assert in various functions if we get a fatal error",
&my_assert_on_error, &my_assert_on_error, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-assert-if-crashed-table", 0, "Do an assert in handler::print_error() if we get a crashed table",
&debug_assert_if_crashed_table, &debug_assert_if_crashed_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_REPLICATION
{"debug-disconnect-slave-event-count", 0, "Option used by mysql-test for debugging and testing of replication",
&disconnect_slave_event_count, &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif/* HAVE_REPLICATION */
{"debug-exit-info", 'T', "Used for debugging. Use at your own risk", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug-gdb", 0, "Set up signals usable for debugging",
&opt_debugging, &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION
{"debug-max-binlog-dump-events", 0, "Option used by mysql-test for debugging and testing of replication",
&max_binlog_dump_events, &max_binlog_dump_events, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif/* HAVE_REPLICATION */
{"debug-no-sync", 0, "Disables system sync calls. Only for running tests or debugging",
&my_disable_sync, &my_disable_sync, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION
{"debug-sporadic-binlog-dump-fail", 0, "Option used by mysql-test for debugging and testing of replication",
&opt_sporadic_binlog_dump_fail,
&opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif/* HAVE_REPLICATION */ #ifndef DBUG_OFF
{"debug-assert-on-not-freed-memory", 0, "Assert if we found problems with memory allocation",
&debug_assert_on_not_freed_memory,
&debug_assert_on_not_freed_memory, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, #endif/* DBUG_OFF */
{"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 }, #ifdefined(ENABLED_DEBUG_SYNC)
{"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT, "Enable the debug sync facility " "and optionally specify a default wait timeout in seconds. " "A zero value keeps the facility disabled",
&opt_debug_sync_timeout, 0, 0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0}, #endif/* defined(ENABLED_DEBUG_SYNC) */ #ifdef HAVE_STACKTRACE
{"stack-trace", 0, "Print a symbolic stack trace on failure",
&opt_stack_trace, &opt_stack_trace, 0, GET_BOOL, NO_ARG, #ifdefined(MY_ADDR_RESOLVE_FORK) && \
(defined(__SANITIZE_ADDRESS__) || __has_feature(memory_sanitizer)) 0 #else 1 #endif
, 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 MariaDB server is running. Disable with " "--skip-external-locking", &opt_external_locking, &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, /* We must always support the next option to make scripts like mysqltest
easier to do */
{"flashback", 0, "Setup the server to use flashback. This enables binary log in row mode and will enable extra logging for DDL's needed by flashback feature",
&opt_support_flashback, &opt_support_flashback, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"gdb", 0, "Set up signals usable for debugging",
&opt_debugging, &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, "debug_gdb", 0, 0},
{"gtid-pos-auto-engines", 0, "List of engines for which to automatically create a " "mysql.gtid_slave_pos_ENGINE table, if a transaction using that engine " "is replicated. This can be used to avoid introducing cross-engine " "transactions, if engines are used different from that used by table " "mysql.gtid_slave_pos",
>id_pos_auto_engines, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #ifdef HAVE_SOLARIS_LARGE_PAGES
{"super-large-pages", 0, "Enable support for super large pages",
&opt_super_large_pages, &opt_super_large_pages, 0,
GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0}, #endif
{"language", 'L', "Client error messages in given language. May be given as a full path", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, "lc_messages_dir", 0, 0},
{"lc-messages", 0, "Set the language used for the error messages",
&lc_messages, &lc_messages, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"lc-time-names", 0, "Set the language used for the month names and the days of the week",
&lc_time_names_name, &lc_time_names_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"log-basename", OPT_LOG_BASENAME, "Basename for all log files and the .pid file. This sets all log file " "names at once (in 'datadir') and is normally the only option you need " "for specifying log files. Sets names for --log-bin, --log-bin-index, " "--relay-log, --relay-log-index, --general-log-file, " "--log-slow-query-file, --log-error-file, and --pid-file. " "If log-basename includes a path, the path will apply for all above " "variables except pid-file that will use it without the path",
&opt_log_basename, &opt_log_basename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-bin", OPT_BIN_LOG, "Log update queries in binary format. Optional argument should be name for " "binary log. If not given " "'datadir'/'log-basename'-bin or 'datadir'/mysql-bin will be used (the later if " "--log-basename is not specified). We strongly recommend to use either " "--log-basename or specify a filename to ensure that replication doesn't " "stop if the real hostname of the computer changes",
&opt_bin_logname, &opt_bin_logname, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-bin-index", 0, "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-ddl-recovery", 0, "Path to file used for recovery of DDL statements after a crash",
&opt_ddl_recovery_file, &opt_ddl_recovery_file, 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},
{"log-short-format", 0, "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-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_REPLICATION
{"master-connect-retry", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_CONNECT_RETRY, " "the interval in integer seconds between each try to connect to the master",
&master_connect_retry, nullptr, nullptr, GET_UINT,
REQUIRED_ARG, master_connect_retry, 0, 0, nullptr, 0, nullptr},
{"master-heartbeat-period", OPT_MASTER_HEARTBEAT_PERIOD, "The DEFAULT value for the CHANGE MASTER option MASTER_HEARTBEAT_PERIOD, " "the interval in DECIMAL(10, 3) seconds between replication heartbeats; " "the autoset value is @@slave_net_timeout/2 calculated on use", /*TODO Likethefilters,itiseasiertoparsefromastringthantoimplement newoptiontypes.Compromiseswouldnotbenecessaryiftheoptions parserisn'tstuckwiththelackofheterogenoustypesbackinyourday, letalonethe(in)accessiblitytoC++'s@std::optional.
*/
&master_heartbeat_period_str, nullptr, nullptr, GET_STR|GET_AUTO,
REQUIRED_ARG, reinterpret_cast<longlong>(master_heartbeat_period_str), /* ignored for @ref GET_STR */ 0, 0, nullptr, 0, nullptr},
{"master-use-gtid", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_USE_GTID, which " "specifies which GTID record (or neither) to start replicating from; the " "autoset value is Slave_Pos, or No if that master does not support GTIDs",
&master_use_gtid, nullptr,
&master_use_gtid_typelib, GET_ENUM|GET_AUTO, REQUIRED_ARG, static_cast<longlong>(master_use_gtid), 0, 0, nullptr, 0, nullptr},
{"master-retry-count", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_RETRY_COUNT, " "the number of tries to connect to the master before giving up",
&master_retry_count, nullptr, 0, GET_ULL, REQUIRED_ARG, static_cast<longlong>(master_retry_count), 0, 0, nullptr, 0, nullptr},
{"master-ssl", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL, " "which is whether to use TLS to connect to the master",
&master_ssl, nullptr, nullptr, GET_BOOL, NO_ARG,
master_ssl, 0, 0, nullptr, 0, nullptr},
{"master-ssl-ca", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CA, " "an optional path to a Certificate Authorities' " "certificates file for TLS replication",
&master_ssl_ca, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_ca), 0, 0, nullptr, 0, nullptr},
{"master-ssl-capath", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CAPATH, " "an optional path to a directory of Certificate Authority's " "certificate files for TLS replication, ",
&master_ssl_capath, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_capath), 0, 0, nullptr, 0, nullptr},
{"master-ssl-cert", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CERT, " "an optional path to the master's certificate for TLS replication",
&master_ssl_cert, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_cert), 0, 0, nullptr, 0, nullptr},
{"master-ssl-cipher", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CIPHER, " "a list of permitted ciphers for TLS replication",
&master_ssl_cipher, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_cipher), 0, 0, nullptr, 0, nullptr},
{"master-ssl-crl", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CRL, " "an optional path to a revoked certificates file for TLS replication",
&master_ssl_crl, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_crl), 0, 0, nullptr, 0, nullptr},
{"master-ssl-crlpath", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_CRLPATH, " "an optional path to a directory of revoked " "certificate files for TLS replication",
&master_ssl_crlpath, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_crlpath), 0, 0, nullptr, 0, nullptr},
{"master-ssl-key", 0, "The DEFAULT value for the CHANGE MASTER option MASTER_SSL_KEY, " "an optional path to the master's private key for TLS replication",
&master_ssl_key, nullptr, nullptr, GET_STR, REQUIRED_ARG, reinterpret_cast<longlong>(master_ssl_key), 0, 0, nullptr, 0, nullptr},
{"master-ssl-verify-server-cert", 0, "The DEFAULT value for the CHANGE MASTER " "option MASTER_SSL_VERIFY_SERVER_CERT, " "which is whether to validate the master's certificate in TLS replication",
&master_ssl_verify_server_cert, nullptr, nullptr, GET_BOOL, NO_ARG,
master_ssl_verify_server_cert, 0, 0, nullptr, 0, nullptr}, #endif/* HAVE_REPLICATION */
{"memlock", 0, "Lock mariadbd process in memory", &locked_in_memory,
&locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"old-style-user-limits", 0, "Enable old-style user limits (before 5.0.3, user resources were counted " "per each user+host vs. per account)",
&opt_old_style_user_limits, &opt_old_style_user_limits, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"port-open-timeout", 0, "Maximum time in seconds to wait for the port to become free. " "(Default: No wait)", &mysqld_port_timeout, &mysqld_port_timeout, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-do-db", OPT_REPLICATE_DO_DB, "Tells the slave thread to restrict replication to the specified database. " "To specify more than one database, use the directive multiple times, " "once for each database. Note that this will only work if you do not use " "cross-database queries such as UPDATE some_db.some_table SET foo='bar' " "while having selected a different or no database. If you need cross " "database updates to work, make sure you have 3.23.28 or later, and use " "replicate-wild-do-table=db_name.%", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-do-table", OPT_REPLICATE_DO_TABLE, "Tells the slave thread to restrict replication to the specified table. " "To specify more than one table, use the directive multiple times, once " "for each table. This will work for cross-database updates, in contrast " "to replicate-do-db", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB, "Tells the slave thread to not replicate to the specified database. To " "specify more than one database to ignore, use the directive multiple " "times, once for each database. This option will not work if you use " "cross database updates. If you need cross database updates to work, " "make sure you have 3.23.28 or later, and use replicate-wild-ignore-" "table=db_name.%. ", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE, "Tells the slave thread to not replicate to the specified table. To specify " "more than one table to ignore, use the directive multiple times, once for " "each table. This will work for cross-database updates, in contrast to " "replicate-ignore-db", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB, "Updates to a database with a different name than the original. Example: " "replicate-rewrite-db=master_db_name->slave_db_name", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, "Tells the slave thread to restrict replication to the tables that match " "the specified wildcard pattern. To specify more than one table, use the " "directive multiple times, once for each table. This will work for cross-" "database updates. Example: replicate-wild-do-table=foo%.bar% will " "replicate only updates to tables in all databases that start with foo " "and whose table names start with bar", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE, "Tells the slave thread to not replicate to the tables that match the " "given wildcard pattern. To specify more than one table to ignore, use " "the directive multiple times, once for each table. This will work for " "cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% " "will not do updates to tables in databases that start with foo and whose " "table names start with bar", 0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, "", 0, 0},
{"safe-user-create", 0, "Don't allow new user creation by the user who has no write privileges to the mysql.user table",
&opt_safe_user_create, &opt_safe_user_create, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent-startup", OPT_SILENT, "Don't print [Note] or failed plugin_loads " "to the error log during startup",
&opt_silent_startup, &opt_silent_startup, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"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 #ifdefined(_WIN32) && !defined(EMBEDDED_LIBRARY)
{"slow-start-timeout", 0, "Maximum number of milliseconds that the service control manager should wait " "before trying to kill the windows service during startup",
&slow_start_timeout, &slow_start_timeout, 0,
GET_ULONG, REQUIRED_ARG, 15000, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_OPENSSL
{"ssl", 0, "Enable SSL for connection (automatically enabled if an ssl option is used)",
&opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, #endif #ifdef _WIN32
{"standalone", 0, "Dummy option to start as a standalone program (NT)", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, #endif
{"symbolic-links", 's', "Enable symbolic link support",
&my_use_symdir, &my_use_symdir, 0, GET_BOOL, NO_ARG, /* Thesystemcallrealpath()produceswarningsundervalgrindand purify.Thesearenotsuppressed:insteadwedisablesymlinks optionifcompiledwithvalgrindsupport. AlsodisablebydefaultonWindows,duetohighoverheadforchecking.sym files.
*/
IF_WIN(0,1), 0, 0, 0, 0, 0},
{"sysdate-is-now", 0, "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. " "Since 5.0, SYSDATE() returns a `dynamic' value different for different " "invocations, even within the same statement",
&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",
&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) "Using this option will cause most temporary files created to use a small " "set of names, rather than a unique name for each new file", #else "This option is ignored on this OS", #endif
&use_temp_pool, &use_temp_pool, 0, GET_BOOL, NO_ARG, 0, 0, 0, "", 0, 0},
{"transaction-isolation", 0, "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},
{"transaction-read-only", 0, "Default transaction access mode. " "True if transactions are read-only",
&global_system_variables.tx_read_only,
&global_system_variables.tx_read_only, 0,
GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User to run mariadbd process as", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Used with --help option for detailed help",
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit", 0, 0, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-load", OPT_PLUGIN_LOAD, "Semicolon-separated list of plugins to load, where each plugin is " "specified as either a plugin_name=library_file pair or only a library_file. " "If the latter case, all plugins from a given library_file will be loaded", 0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-load-add", OPT_PLUGIN_LOAD_ADD, "Optional semicolon-separated list of plugins to load. This option adds " "to the list specified by --plugin-load in an incremental way. " "It can be specified many times, adding more plugins every time", 0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"table_cache", 0, "Sets table_open_cache",
&tc_size, &tc_size, 0, GET_ULONG,
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, "table_open_cache", 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
{"path", 0, "Comma-separated list of schema names that defines the search " "order for stored routines", &opt_path, &opt_path, 0,
GET_STR, REQUIRED_ARG, (longlong)(intptr)"CURRENT_SCHEMA", 0, 0, 0, 0, 0 },
};
staticint show_flushstatustime(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *status_var,
enum_var_type type)
{ if (type == SHOW_OPT_GLOBAL)
{ /* For global status, global_status_var.flush_status_time is up to date */
status_var= &global_status_var;
}
/* Add variables that must be shown but not changed, like version numbers */
pop_dynamic(&all_options);
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);
free_root(&mem_root, MYF(0));
}
staticvoid usage(void)
{
DBUG_ENTER("usage"); if (!default_collation_name)
{
myf utf8_flag= global_system_variables.old_behavior &
OLD_MODE_UTF8_IS_UTF8MB3 ? MY_UTF8_IS_UTF8MB3 : 0;
default_charset_info= get_charset_by_csname(default_character_set_name,
MY_CS_PRIMARY, MYF(utf8_flag | MY_WME)); if (default_charset_info)
default_collation_name= (char*) default_charset_info->coll_name.str;
}
print_version();
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
puts("Starts the MariaDB database server.\n");
printf("Usage: %s [OPTIONS]\n", my_progname); if (!opt_verbose)
puts("\nFor more help options (several pages), use mariadbd --verbose --help."); else
{ #ifdef _WIN32
puts("NT and Win32 specific options:\n" " --install Install the default service (NT).\n" " --install-manual Install the default service started manually (NT).\n" " --install service_name Install an optional service (NT).\n" " --install-manual service_name Install an optional service started manually (NT).\n" " --remove Remove the default service from the service list (NT).\n" " --remove service_name Remove the service_name from the service list (NT).\n" " --enable-named-pipe Only to be used for the default server (NT).\n" " --standalone Dummy option to start as a standalone server (NT).");
puts(""); #endif
print_defaults(MYSQL_CONFIG_NAME,load_default_groups);
puts("");
set_ports();
/* Print out all the options including plugin supplied options */
print_help();
if (! plugins_are_initialized)
{
puts("\nPlugins have parameters that are not reflected in this list" "\nbecause execution stopped before plugins were initialized.");
}
puts("\nTo see what variables a running server is using, type" "\n'SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES' instead " "of 'mariadbd --verbose --help'.");
}
DBUG_VOID_RETURN;
} #endif/*!EMBEDDED_LIBRARY*/
#ifdefined(_WIN32) /* Allow Win32 users to move MySQL anywhere */
{ char prg_dev[LIBLEN]; char executing_path_name[LIBLEN]; if (!test_if_hard_path(my_progname))
{ // we don't want to use GetModuleFileName inside of my_path since // my_path is a generic path dereferencing function and here we care // only about the executing binary.
GetModuleFileName(NULL, executing_path_name, sizeof(executing_path_name));
my_path(prg_dev, executing_path_name, NULL);
} else
my_path(prg_dev, my_progname, "mysql/bin"); // Remove 'bin' to get base dir
safe_strcat(prg_dev, sizeof(prg_dev), "/../");
cleanup_dirname(mysql_home,prg_dev);
} #else constchar *tmpenv; 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()) return1;
return0;
}
my_bool
mysqld_get_one_option(conststruct my_option *opt, constchar *argument, constchar *filename)
{ if (opt->app_type)
{
sys_var *var= (sys_var*) opt->app_type; if (argument == autoset_my_option)
{
var->value_origin= sys_var::AUTO; return0;
} if (*filename)
{
var->origin_filename= filename;
var->value_origin= sys_var::CONFIG;
} else
var->value_origin= sys_var::COMMAND_LINE;
} // Handle `GET_AUTO` for `--master-heartbeat-period` and `--master-use-gtid` if (argument == autoset_my_option)
my_getopt_init_one_value(opt, opt->value, opt->def_value);
switch(opt->id) { case'#': #ifndef DBUG_OFF if (!argument)
argument= (char*) default_dbug_option; if (argument[0] == '0' && !argument[1])
{
DEBUGGER_OFF; break;
}
DEBUGGER_ON; 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); #endif break; case OPT_REMOVED_OPTION:
sql_print_warning("'%s' was removed. It does nothing now and exists only " "for compatibility with old my.cnf files.", opt->name); /* Restore default value (to show that the option cannot be used) */
my_getopt_init_one_value(opt, opt->value, opt->def_value); break; case OPT_MYSQL_COMPATIBILITY:
sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. Not used or " "needed in MariaDB.", opt->name); break; case OPT_MYSQL_TO_BE_IMPLEMENTED:
sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. To be " "implemented in later versions.", opt->name); break; case'a':
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); break; case'C': if (default_collation_name == compiled_default_collation_name)
default_collation_name= 0; break; case'h':
strmake_buf(mysql_real_data_home, argument); /* Correct pointer set by my_getopt (for embedded library) */
mysql_real_data_home_ptr= mysql_real_data_home; break; case'u': if (!mysqld_user || !strcmp(mysqld_user, argument))
mysqld_user= argument; else
sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user); break; case'L':
strmake_buf(lc_messages_dir, argument); break; case OPT_BINLOG_FORMAT:
binlog_format_used= true; break; #include <sslopt-case.h> case'V': if (argument)
{
strmake(server_version, argument, sizeof(server_version) - 1);
set_sys_var_value_origin(&server_version_ptr,
*filename ? sys_var::CONFIG : sys_var::COMMAND_LINE, filename);
} #ifndef EMBEDDED_LIBRARY else
{
print_version();
opt_abort= 1; // Abort after parsing all options
} #endif/*EMBEDDED_LIBRARY*/ break; case'W': if (!argument)
global_system_variables.log_warnings++; elseif (argument == disabled_my_option)
global_system_variables.log_warnings= 0L; else
global_system_variables.log_warnings= atoi(argument); break; case'T':
test_flags= argument ? ((uint) atoi(argument) & ~TEST_BLOCKING) : 0;
opt_endinfo=1; break; case (int) OPT_ISAM_LOG:
opt_myisam_log=1; break; case (int) OPT_BIN_LOG:
opt_bin_log= MY_TEST(argument != disabled_my_option);
opt_bin_log_used= 1;
opt_bin_log_nonempty= (argument && argument[0]);
opt_bin_log_path= argument &&
(strchr(argument, FN_LIBCHAR) || strchr(argument, FN_LIBCHAR2)); break; case (int) OPT_LOG_BASENAME:
{ if (opt_log_basename[0] == 0 || strchr(opt_log_basename, FN_EXTCHAR) ||
!my_basename(opt_log_basename)[0] ||
!is_filename_allowed(opt_log_basename, strlen(opt_log_basename), FALSE))
{
sql_print_error("Wrong argument for --log-basename. It can't be empty, " "contain '.' or be a directory name'. " "It must be valid filename."); return1;
} if (log_error_file_ptr != disabled_my_option)
SYSVAR_AUTOSIZE(log_error_file_ptr, opt_log_basename);
#ifdef HAVE_REPLICATION case (int)OPT_REPLICATE_IGNORE_DB:
{
cur_rpl_filter->add_ignore_db(argument); break;
} case (int)OPT_REPLICATE_DO_DB:
{
cur_rpl_filter->add_do_db(argument); break;
} case (int)OPT_REPLICATE_REWRITE_DB:
{ /* See also OPT_REWRITE_DB handling in client/mysqlbinlog.cc */ if (cur_rpl_filter->add_rewrite_db(argument))
{
sql_print_error("Bad syntax in replicate-rewrite-db.Expected syntax is FROM->TO."); return1;
} 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:
{
binlog_filter->add_ignore_db(argument); break;
} case (int)OPT_BINLOG_DO_DB:
{
binlog_filter->add_do_db(argument); break;
} case (int)OPT_REPLICATE_DO_TABLE:
{ if (cur_rpl_filter->add_do_table(argument))
{
sql_print_error("Could not add do table rule '%s'", argument); return1;
} break;
} case (int)OPT_REPLICATE_WILD_DO_TABLE:
{ if (cur_rpl_filter->add_wild_do_table(argument))
{
sql_print_error("Could not add do table rule '%s'", argument); return1;
} break;
} case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
{ if (cur_rpl_filter->add_wild_ignore_table(argument))
{
sql_print_error("Could not add ignore table rule '%s'", argument); return1;
} break;
} case (int)OPT_REPLICATE_IGNORE_TABLE:
{ if (cur_rpl_filter->add_ignore_table(argument))
{
sql_print_error("Could not add ignore table rule '%s'", argument); return1;
} break;
} case OPT_MASTER_HEARTBEAT_PERIOD: if (master_heartbeat_period_str == autoset_my_option)
master_heartbeat_period.reset(); else
{ bool overprecise; if (Master_info_file::Heartbeat_period_value::from_chars(
master_heartbeat_period, master_heartbeat_period_str,
strchr(master_heartbeat_period_str, '\0'), overprecise, '\0')
)
{
sql_print_error( "Bad value for master-heartbeat-period; " "should be between 0 and %s seconds inclusive.",
Master_info_file::Heartbeat_period_value::MAX
); returntrue;
} if (unlikely(!*master_heartbeat_period && overprecise))
sql_print_warning( "master-heartbeat-period rounded to 0, " "meaning that heartbeating will effectively be disabled."
);
} break; #endif/* HAVE_REPLICATION */ case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC;
SYSVAR_AUTOSIZE(delay_key_write_options, (uint) DELAY_KEY_WRITE_NONE);
myisam_recover_options= HA_RECOVER_DEFAULT;
ha_open_options&= ~(HA_OPEN_DELAY_KEY_WRITE);
SYSVAR_AUTOSIZE(query_cache_size, 0); break; case (int) OPT_SKIP_HOST_CACHE:
opt_specialflag|= SPECIAL_NO_HOST_CACHE; break; case OPT_CONSOLE: if (opt_console)
opt_error_log= 0; // Force logs to stdout break; case OPT_BOOTSTRAP:
opt_noacl=opt_bootstrap=1;
opt_use_ssl= 0; #ifdef _WIN32
{ /* Checkifsecuritydescriptorispassedfrom mysql_install_db.exe. UsedbyWindowsinstallertocorrectlysetup privilegesonthenewdirectories.
*/ char* dir_sddl = getenv("MARIADB_NEW_DIRECTORY_SDDL"); if (dir_sddl)
{
ConvertStringSecurityDescriptorToSecurityDescriptor(
dir_sddl, SDDL_REVISION_1, &my_dir_security_attributes.lpSecurityDescriptor, NULL);
DBUG_ASSERT(my_dir_security_attributes.lpSecurityDescriptor);
}
} #endif break; case OPT_SERVER_ID:
::server_id= global_system_variables.server_id; break; case OPT_SEQURE_FILE_PRIV: if (argument == disabled_my_option)
{
my_free(opt_secure_file_priv);
opt_secure_file_priv= 0;
} break; case OPT_LOWER_CASE_TABLE_NAMES:
lower_case_table_names_used= 1; break; #ifdefined(ENABLED_DEBUG_SYNC) case OPT_DEBUG_SYNC_TIMEOUT: /* DebugSyncFacility.Seedebug_sync.cc. DefaulttimeoutforWAIT_FORaction. Defaultvalueiszero(facilitydisabled). Ifoptionisgivenwithoutanargument,supplyanon-zerovalue.
*/ if (!argument)
{ /* purecov: begin tested */
opt_debug_sync_timeout= DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT; /* purecov: end */
} break; #endif/* defined(ENABLED_DEBUG_SYNC) */ case OPT_LOG_ERROR: /* "No--log-error"=="writeerrorstostderr", "--log-errorwithoutargument"=="writeerrorstoafile".
*/ if (argument == NULL) /* no argument */
log_error_file_ptr= const_cast<char*>(""); break; case OPT_LOG_SLOW_FILTER: if (argument == NULL || *argument == 0)
{ /* By default log_slow_filter_has all values except QPLAN_NOT_USING_INDEX */
global_system_variables.log_slow_filter= opt->def_value | QPLAN_NOT_USING_INDEX;
sql_print_warning("log_slow_filter=\"\" changed to log_slow_filter=ALL");
} break; case OPT_IGNORE_DB_DIRECTORY: if (*argument == 0)
ignore_db_dirs_reset(); else
{ if (push_ignored_db_dir(argument))
{
sql_print_error("Can't start server: " "cannot process --ignore-db-dir=%.*s",
FN_REFLEN, argument); return1;
}
} break; case OPT_PLUGIN_LOAD:
free_list(opt_plugin_load_list_ptr); if (argument == disabled_my_option) break; // Resets plugin list /* fall through */ case OPT_PLUGIN_LOAD_ADD:
opt_plugin_load_list_ptr->push_back(new i_string(argument)); break; case OPT_PFS_INSTRUMENT:
{ #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #ifndef EMBEDDED_LIBRARY /* Parse instrument name and value from argument string */ constchar *name= argument, *ptr, *val;
/* Trim leading spaces from instrument name */ while (*name && my_isspace(mysqld_charset, *name))
name++;
/* Assignment required */ if (!(ptr= strchr(name, '=')))
{
my_getopt_error_reporter(WARNING_LEVEL, "Missing value for performance_schema_instrument " "'%s'", argument); return0;
}
/* Option value */
val= ptr + 1;
/* Trim trailing spaces and slashes from instrument name */ while (ptr > name && (my_isspace(mysqld_charset, ptr[-1]) ||
ptr[-1] == '/'))
ptr--; if (ptr == name)
{
my_getopt_error_reporter(WARNING_LEVEL, "Invalid instrument name for " "performance_schema_instrument '%s'", name); return0;
}
name= strmake_root(&startup_root, name, (size_t) (ptr - name));
/* Trim leading spaces from option value */ while (*val && my_isspace(mysqld_charset, *val))
val++;
/* Find end of value */ for (ptr= val; *ptr && !my_isspace(mysqld_charset, *ptr) ; ptr++)
{} if (ptr == val)
{
my_getopt_error_reporter(WARNING_LEVEL, "No value for performance_schema_instrument " "'%s'", name); return0;
}
val= strmake_root(&startup_root, val, (size_t) (ptr - val));
/* Add instrument name and value to array of configuration options */ if (add_pfs_instr_to_array(Lex_cstring_strlen(name),
Lex_cstring_strlen(val)))
{
my_getopt_error_reporter(WARNING_LEVEL, "Invalid value for performance_schema_instrument " "'%s'", name); return0;
} #endif/* EMBEDDED_LIBRARY */ #endif break;
}
}
staticvoid *
mysql_getopt_value(constchar *name, uint length, conststruct my_option *option, int *error)
{ if (error)
*error= 0; switch (option->id) { case OPT_KEY_BUFFER_SIZE: case OPT_KEY_CACHE_BLOCK_SIZE: case OPT_KEY_CACHE_DIVISION_LIMIT: case OPT_KEY_CACHE_AGE_THRESHOLD: case OPT_KEY_CACHE_PARTITIONS: case OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE:
{
KEY_CACHE *key_cache; if (unlikely(!(key_cache= get_or_create_key_cache(name, length))))
{ if (error)
*error= EXIT_OUT_OF_MEMORY; return0;
} switch (option->id) { case OPT_KEY_BUFFER_SIZE: return &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: return &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: return &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: return &key_cache->param_age_threshold; case OPT_KEY_CACHE_PARTITIONS: return (uchar**) &key_cache->param_partitions; case OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE: return (uchar**) &key_cache->changed_blocks_hash_size;
}
} /* We return in all cases above. Let us silence -Wimplicit-fallthrough */
DBUG_ASSERT(0); break; #ifdef HAVE_REPLICATION /* fall through */ case OPT_REPLICATE_DO_DB: case OPT_REPLICATE_DO_TABLE: case OPT_REPLICATE_IGNORE_DB: case OPT_REPLICATE_IGNORE_TABLE: 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)))
{ if (error)
*error= EXIT_OUT_OF_MEMORY;
} if (option->id == OPT_SLAVE_PARALLEL_MODE)
{ /* Ensureparallel_modevariableisshownin--help.Theother variablesarenoteasilyprintablehere.
*/ return (char**) &opt_slave_parallel_mode;
} return0;
} break; #endif case OPT_COSTS_DISK_READ_COST: case OPT_COSTS_INDEX_BLOCK_COPY_COST: case OPT_COSTS_KEY_CMP_COST: case OPT_COSTS_KEY_COPY_COST: case OPT_COSTS_KEY_LOOKUP_COST: case OPT_COSTS_KEY_NEXT_FIND_COST: case OPT_COSTS_DISK_READ_RATIO: case OPT_COSTS_ROW_COPY_COST: case OPT_COSTS_ROW_LOOKUP_COST: case OPT_COSTS_ROW_NEXT_FIND_COST: case OPT_COSTS_ROWID_CMP_COST: case OPT_COSTS_ROWID_COPY_COST:
{
OPTIMIZER_COSTS *costs; if (unlikely(!(costs= get_or_create_optimizer_costs(name, length))))
{ if (error)
*error= EXIT_OUT_OF_MEMORY; return0;
} switch (option->id) { case OPT_COSTS_DISK_READ_COST: return &costs->disk_read_cost; case OPT_COSTS_INDEX_BLOCK_COPY_COST: return &costs->index_block_copy_cost; case OPT_COSTS_KEY_CMP_COST: return &costs->key_cmp_cost; case OPT_COSTS_KEY_COPY_COST: return &costs->key_copy_cost; case OPT_COSTS_KEY_LOOKUP_COST: return &costs->key_lookup_cost; case OPT_COSTS_KEY_NEXT_FIND_COST: return &costs->key_next_find_cost; case OPT_COSTS_DISK_READ_RATIO: return &costs->disk_read_ratio; case OPT_COSTS_ROW_COPY_COST: return &costs->row_copy_cost; case OPT_COSTS_ROW_LOOKUP_COST: return &costs->row_lookup_cost; case OPT_COSTS_ROW_NEXT_FIND_COST: return &costs->row_next_find_cost; case OPT_COSTS_ROWID_CMP_COST: return &costs->rowid_cmp_cost; case OPT_COSTS_ROWID_COPY_COST: return &costs->rowid_copy_cost; default:
DBUG_ASSERT(0);
}
}
} return option->value;
}
if (global_system_variables.net_buffer_length >
global_system_variables.max_allowed_packet)
{
sql_print_warning("net_buffer_length (%lu) is set to be larger " "than max_allowed_packet (%lu). Please rectify.",
global_system_variables.net_buffer_length,
global_system_variables.max_allowed_packet);
}
if (log_error_file_ptr != disabled_my_option)
opt_error_log= 1; else
log_error_file_ptr= const_cast<char*>("");
if (opt_disable_networking)
mysqld_port= mysqld_extra_port= 0;
if (opt_skip_show_db)
opt_specialflag|= SPECIAL_SKIP_SHOW_DB;
if (myisam_flush)
flush_time= 0;
#ifdef HAVE_REPLICATION
rpl_status= init_rpl_role_val; if (init_slave_skip_errors(opt_slave_skip_errors)) return1; if (init_slave_transaction_retry_errors(opt_slave_transaction_retry_errors)) return1; #endif
if (global_system_variables.max_join_size == HA_POS_ERROR)
global_system_variables.option_bits|= OPTION_BIG_SELECTS; else
global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
if (opt_support_flashback)
{ /* Force binary logging */ if (!opt_bin_logname)
opt_bin_logname= (char*) ""; // Use default name
opt_bin_log= opt_bin_log_used= 1;
/* Force format to row */ if (global_system_variables.binlog_format != BINLOG_FORMAT_ROW)
{
sql_print_information("Binlog_format changed to \"ROW\" because of " "flashback");
SYSVAR_AUTOSIZE(global_system_variables.binlog_format,
BINLOG_FORMAT_ROW);
}
binlog_format_used= 1;
}
/* Logmysyserrorswhenwedon'thaveathdorthd->log_all_errorsisset (recovery)tothelog.Thisismainlyusefulfordebuggingstrangesystem errors.
*/ if (global_system_variables.log_warnings >= 10)
my_global_flags= MY_WME | ME_NOTE; /* Log all errors not handled by thd->handle_error() to my_message_sql() */ if (global_system_variables.log_warnings >= 11)
my_global_flags|= ME_ERROR_LOG; if (my_assert_on_error)
debug_assert_if_crashed_table= 1;
/* 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)
SYSVAR_AUTOSIZE(global_system_variables.max_relay_log_size,
max_binlog_size);
/* Ensure that some variables are not set higher than needed */ if (thread_cache_size > max_connections)
SYSVAR_AUTOSIZE(thread_cache_size, max_connections);
if (opt_secure_file_priv)
cmp= opt_secure_file_priv; else #ifdef _WIN32 returnTRUE; // All paths are secure if opt_secure_file_priv is unset #else
cmp= "/proc/"; // Check that it doesn't start with this prefix #endif
if (strlen(path) >= FN_REFLEN) returnFALSE;
if (my_realpath(buf1, path, 0))
{ /* The supplied file path might have been a file and not a directory. */
size_t length= dirname_length(path); // Guaranteed to be < FN_REFLEN
memcpy(buf2, path, length);
buf2[length]= '\0'; if (length == 0 || my_realpath(buf1, buf2, 0)) returnFALSE;
}
convert_dirname(buf2, buf1, NullS);
/** Clear session (connection) status variables */
void refresh_session_status(THD *thd)
{ /* Add thread's status variables to global status */
mysql_mutex_lock(&LOCK_status);
add_to_status(&global_status_var, &thd->status_var);
mysql_mutex_unlock(&LOCK_status);
/* Reset some global variables */ #ifdef WITH_WSREP if (WSREP_ON)
{
Wsrep_server_state::instance().provider().reset_status();
} #endif/* WITH_WSREP */
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters, 0);
global_status_var.flush_status_time= my_time(0);
mysql_mutex_unlock(&LOCK_status);
if (max_gap < 2)
{ /* Can't find free id. This is not really possible,
we'd need 2^32 connections for this to happen.*/
sql_print_error("Cannot find free connection id.");
abort();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.