summaryrefslogtreecommitdiff
path: root/sql/mysqld.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r--sql/mysqld.cc358
1 files changed, 225 insertions, 133 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d5c3e6f1c6f..f787181174a 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -38,7 +38,17 @@
#define ONE_THREAD
#endif
-/* do stack traces are only supported on linux intel */
+#ifdef SAFEMALLOC
+#define SHUTDOWN_THD shutdown_th=pthread_self();
+#define MAIN_THD main_th=pthread_self();
+#define SIGNAL_THD signal_th=pthread_self();
+#else
+#define SHUTDOWN_THD
+#define MAIN_THD
+#define SIGNAL_THD
+#endif
+
+/* stack traces are only supported on linux intel */
#if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK)
#define HAVE_STACK_TRACE_ON_SEGV
#include "../pstack/pstack.h"
@@ -162,6 +172,7 @@ static SECURITY_DESCRIPTOR sdPipeDescriptor;
static HANDLE hPipe = INVALID_HANDLE_VALUE;
static pthread_cond_t COND_handler_count;
static uint handler_count;
+static bool opt_enable_named_pipe = 0;
#endif
#ifdef __WIN__
static bool opt_console=0,start_mode=0;
@@ -209,7 +220,11 @@ SHOW_COMP_OPTION have_openssl=SHOW_OPTION_YES;
SHOW_COMP_OPTION have_openssl=SHOW_OPTION_NO;
#endif
SHOW_COMP_OPTION have_symlink=SHOW_OPTION_YES;
-
+#ifdef HAVE_QUERY_CACHE
+SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_YES;
+#else
+SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_NO;
+#endif
bool opt_skip_slave_start = 0; // If set, slave is not autostarted
static bool opt_do_pstack = 0;
@@ -276,7 +291,11 @@ ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
ulong com_stat[(uint) SQLCOM_END], com_other;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
-ulong query_cache_size=0, query_cache_limit=0, query_cache_startup_type=1;
+#ifdef HAVE_QUERY_CACHE
+ulong query_cache_size=0, query_cache_limit=0, query_cache_startup_type=1;
+Query_cache query_cache;
+#endif
+
volatile ulong cached_thread_count=0;
// replication parameters, if master_host is not NULL, we are a slave
@@ -297,6 +316,7 @@ ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory;
bool opt_using_transactions, using_update_log, opt_warnings=0;
+bool opt_local_infile=1;
bool volatile abort_loop,select_thread_in_use,grant_option;
bool volatile ready_to_exit,shutdown_in_progress;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
@@ -369,8 +389,6 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
LOCK_server_id,
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-Query_cache query_cache;
-
pthread_cond_t COND_refresh,COND_thread_count,COND_binlog_update,
COND_slave_stopped, COND_slave_start;
pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
@@ -481,13 +499,27 @@ static void close_connections(void)
}
}
#ifdef __NT__
- if ( hPipe != INVALID_HANDLE_VALUE )
+ if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
{
- HANDLE hTempPipe = &hPipe;
+ HANDLE temp;
DBUG_PRINT( "quit", ("Closing named pipes") );
- hPipe = INVALID_HANDLE_VALUE;
- DisconnectNamedPipe( hTempPipe );
- CloseHandle( hTempPipe );
+
+ /* Create connection to the handle named pipe handler to break the loop */
+ if ((temp = CreateFile(szPipeName,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL )) != INVALID_HANDLE_VALUE)
+ {
+ WaitNamedPipe(szPipeName, 1000);
+ DWORD dwMode = PIPE_READMODE_BYTE | PIPE_WAIT;
+ SetNamedPipeHandleState(temp, &dwMode, NULL, NULL);
+ CancelIo(temp);
+ DisconnectNamedPipe(temp);
+ CloseHandle(temp);
+ }
}
#endif
#ifdef HAVE_SYS_UN_H
@@ -679,6 +711,7 @@ static void __cdecl kill_server(int sig_ptr)
sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)
+ SHUTDOWN_THD;
my_thread_init(); // If this is a new thread
#endif
close_connections();
@@ -694,6 +727,7 @@ static void __cdecl kill_server(int sig_ptr)
#ifdef USE_ONE_SIGNAL_HAND
static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
+ SHUTDOWN_THD;
my_thread_init(); // Initialize new thread
kill_server(0);
my_thread_end(); // Normally never reached
@@ -708,8 +742,9 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
static sig_handler print_signal_warning(int sig)
{
- sql_print_error("Warning: Got signal %d from thread %d",
- sig,my_thread_id());
+ if (opt_warnings)
+ sql_print_error("Warning: Got signal %d from thread %d",
+ sig,my_thread_id());
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
@@ -749,7 +784,7 @@ void clean_up(bool print_message)
bitmap_free(&slave_error_mask);
acl_free(1);
grant_free();
- query_cache.destroy();
+ query_cache_destroy();
table_cache_free();
hostname_cache_free();
item_user_lock_free();
@@ -769,8 +804,10 @@ void clean_up(bool print_message)
my_free(opt_ssl_ca,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_capath,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_cipher,MYF(MY_ALLOW_ZERO_PTR));
+ my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_key=opt_ssl_cert=opt_ssl_ca=opt_ssl_capath=0;
#endif /* HAVE_OPENSSL */
+
free_defaults(defaults_argv);
my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR));
my_free(allocated_mysql_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
@@ -856,20 +893,33 @@ static void set_user(const char *user)
if (!strcmp(user,"root"))
return; // Avoid problem with dynamic libraries
+ uid_t uid;
if (!(ent = getpwnam(user)))
{
- fprintf(stderr,"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
- unireg_abort(1);
+ // allow a numeric uid to be used
+ const char *pos;
+ for (pos=user; isdigit(*pos); pos++) ;
+ if (*pos) // Not numeric id
+ {
+ fprintf(stderr,"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
+ unireg_abort(1);
+ }
+ uid=atoi(user); // Use numberic uid
}
+ else
+ {
#ifdef HAVE_INITGROUPS
- initgroups((char*) user,ent->pw_gid);
+ initgroups((char*) user,ent->pw_gid);
#endif
- if (setgid(ent->pw_gid) == -1)
- {
- sql_perror("setgid");
- unireg_abort(1);
+ if (setgid(ent->pw_gid) == -1)
+ {
+ sql_perror("setgid");
+ unireg_abort(1);
+ }
+ uid=ent->pw_uid;
}
- if (setuid(ent->pw_uid) == -1)
+
+ if (setuid(uid) == -1)
{
sql_perror("setuid");
unireg_abort(1);
@@ -939,18 +989,21 @@ static void server_init(void)
unireg_abort(1);
}
if (listen(ip_sock,(int) back_log) < 0)
- sql_print_error("Warning: listen() on TCP/IP failed with error %d",
+ {
+ sql_print_error("Error: listen() on TCP/IP failed with error %d",
socket_errno);
+ unireg_abort(1);
+ }
}
if (mysqld_chroot)
set_root(mysqld_chroot);
-
- set_user(mysqld_user); // set_user now takes care of mysqld_user==NULL
+ set_user(mysqld_user); // Works also with mysqld_user==NULL
#ifdef __NT__
/* create named pipe */
- if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap)
+ if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap &&
+ opt_enable_named_pipe)
{
sprintf( szPipeName, "\\\\.\\pipe\\%s", mysql_unix_port );
ZeroMemory( &saPipeSecurity, sizeof(saPipeSecurity) );
@@ -1221,6 +1274,7 @@ static void init_signals(void)
signal(SIGALRM, SIG_IGN);
signal(SIGBREAK,SIG_IGN);
signal_thread = pthread_self();
+ SIGNAL_THD;
}
static void start_signal_handler(void)
@@ -1346,6 +1400,7 @@ static void init_signals(void)
sigaction(SIGBUS, &sa, NULL);
#endif
sigaction(SIGILL, &sa, NULL);
+ sigaction(SIGFPE, &sa, NULL);
}
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
@@ -1413,7 +1468,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
int sig;
my_thread_init(); // Init new thread
DBUG_ENTER("signal_hand");
-
+ SIGNAL_THD;
/* Setup alarm handler */
init_thr_alarm(max_connections+max_insert_delayed_threads);
#if SIGINT != THR_KILL_SIGNAL
@@ -1468,7 +1523,10 @@ static void *signal_hand(void *arg __attribute__((unused)))
else
while ((error=my_sigwait(&set,&sig)) == EINTR) ;
if (cleanup_done)
+ {
+ my_thread_end();
pthread_exit(0); // Safety
+ }
switch (sig) {
case SIGTERM:
case SIGQUIT:
@@ -1562,6 +1620,7 @@ int uname(struct utsname *a)
pthread_handler_decl(handle_shutdown,arg)
{
MSG msg;
+ SHUTDOWN_THD;
my_thread_init();
/* this call should create the message queue for this thread */
@@ -1588,6 +1647,7 @@ int __stdcall handle_kill(ulong ctrl_type)
#ifdef OS2
pthread_handler_decl(handle_shutdown,arg)
{
+ SHUTDOWN_THD;
my_thread_init();
// wait semaphore
@@ -1659,6 +1719,7 @@ int main(int argc, char **argv)
my_umask=0660; // Default umask for new files
my_umask_dir=0700; // Default umask for new directories
+ MAIN_THD;
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
@@ -1689,7 +1750,7 @@ int main(int argc, char **argv)
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
- strmov(pidfile_name,glob_hostname);
+ strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(strcend(pidfile_name,'.'),".pid"); // Add extension
#ifndef DBUG_OFF
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
@@ -1760,7 +1821,8 @@ int main(int argc, char **argv)
if (opt_use_ssl)
{
ssl_acceptor_fd = new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert,
- opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher);
+ opt_ssl_ca, opt_ssl_capath,
+ opt_ssl_cipher);
DBUG_PRINT("info",("ssl_acceptor_fd: %p",ssl_acceptor_fd));
if (!ssl_acceptor_fd)
opt_use_ssl = 0;
@@ -1832,8 +1894,8 @@ int main(int argc, char **argv)
server_init();
table_cache_init();
hostname_cache_init();
- query_cache.result_size_limit(query_cache_limit);
- query_cache.resize(query_cache_size);
+ query_cache_result_size_limit(query_cache_limit);
+ query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions();
init_thr_lock();
@@ -1849,48 +1911,17 @@ int main(int argc, char **argv)
using_update_log=1;
}
- init_slave();
-
- if (opt_bin_log && !server_id)
- {
- server_id= !master_host ? 1 : 2;
- switch (server_id) {
-#ifdef EXTRA_DEBUG
- case 1:
- sql_print_error("\
-Warning: You have enabled the binary log, but you haven't set server-id:\n\
-Updates will be logged to the binary log, but connections to slaves will\n\
-not be accepted.");
- break;
-#endif
- case 2:
- sql_print_error("\
-Warning: You should set server-id to a non-0 value if master_host is set.\n\
-The server will not act as a slave.");
- break;
- }
- }
- if (opt_bin_log)
- {
- if (!opt_bin_logname)
- {
- char tmp[FN_REFLEN];
- /* TODO: The following should be using fn_format(); We just need to
- first change fn_format() to cut the file name if it's too long.
- */
- strmake(tmp,glob_hostname,FN_REFLEN-5);
- strmov(strcend(tmp,'.'),"-bin");
- opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
- }
- mysql_bin_log.set_index_file_name(opt_binlog_index_name);
- open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
- LOG_BIN);
- using_update_log=1;
- }
-
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL);
+#ifdef __WIN__
+#define MYSQL_ERR_FILE "mysql.err"
+ if (!opt_console)
+ {
+ freopen(MYSQL_ERR_FILE,"a+",stdout);
+ freopen(MYSQL_ERR_FILE,"a+",stderr);
+ }
+#endif
if (ha_init())
{
sql_print_error("Can't init databases");
@@ -1916,13 +1947,8 @@ The server will not act as a slave.");
ft_init_stopwords(ft_precompiled_stopwords);
#ifdef __WIN__
-#define MYSQL_ERR_FILE "mysql.err"
if (!opt_console)
- {
- freopen(MYSQL_ERR_FILE,"a+",stdout);
- freopen(MYSQL_ERR_FILE,"a+",stderr);
FreeConsole(); // Remove window
- }
#endif
/*
@@ -1955,6 +1981,46 @@ The server will not act as a slave.");
if (!opt_noacl)
udf_init();
#endif
+ /* init_slave() must be called after the thread keys are created */
+ init_slave();
+
+ if (opt_bin_log && !server_id)
+ {
+ server_id= !master_host ? 1 : 2;
+ switch (server_id) {
+#ifdef EXTRA_DEBUG
+ case 1:
+ sql_print_error("\
+Warning: You have enabled the binary log, but you haven't set server-id:\n\
+Updates will be logged to the binary log, but connections to slaves will\n\
+not be accepted.");
+ break;
+#endif
+ case 2:
+ sql_print_error("\
+Warning: You should set server-id to a non-0 value if master_host is set.\n\
+The server will not act as a slave.");
+ break;
+ }
+ }
+ if (opt_bin_log)
+ {
+ if (!opt_bin_logname)
+ {
+ char tmp[FN_REFLEN];
+ /* TODO: The following should be using fn_format(); We just need to
+ first change fn_format() to cut the file name if it's too long.
+ */
+ strmake(tmp,glob_hostname,FN_REFLEN-5);
+ strmov(strcend(tmp,'.'),"-bin");
+ opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
+ }
+ mysql_bin_log.set_index_file_name(opt_binlog_index_name);
+ open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
+ LOG_BIN);
+ using_update_log=1;
+ }
+
if (opt_bootstrap)
{
@@ -2006,9 +2072,11 @@ The server will not act as a slave.");
fflush(stdout);
#ifdef __NT__
- if (hPipe == INVALID_HANDLE_VALUE && !have_tcpip)
+ if (hPipe == INVALID_HANDLE_VALUE &&
+ (!have_tcpip || opt_disable_networking))
{
- sql_print_error("TCP/IP must be installed on Win98 platforms");
+ sql_print_error("TCP/IP or --enable-named-pipe should be configured on NT OS");
+ unireg_abort(1);
}
else
{
@@ -2017,7 +2085,7 @@ The server will not act as a slave.");
{
pthread_t hThread;
handler_count=0;
- if ( hPipe != INVALID_HANDLE_VALUE )
+ if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
@@ -2067,42 +2135,26 @@ The server will not act as a slave.");
#ifdef EXTRA_DEBUG2
sql_print_error("After lock_thread_count");
#endif
-#else
-#if !defined(EMBEDDED_LIBRARY)
- if (Service.IsNT())
- {
- if(start_mode)
- {
- if (WaitForSingleObject(hEventShutdown,1000)==WAIT_TIMEOUT)
- Service.Stop();
- }
- else
- {
- Service.SetShutdownEvent(0);
- if(hEventShutdown) CloseHandle(hEventShutdown);
- }
- }
- else
- {
- Service.SetShutdownEvent(0);
- if(hEventShutdown) CloseHandle(hEventShutdown);
- }
-#endif
-#endif
-#ifdef HAVE_OPENSSL
- my_free((gptr)ssl_acceptor_fd,MYF(MY_ALLOW_ZERO_PTR));
-#endif /* HAVE_OPENSSL */
+#endif /* __WIN__ */
+
/* Wait until cleanup is done */
(void) pthread_mutex_lock(&LOCK_thread_count);
- DBUG_PRINT("quit", ("Got thread_count mutex for clean up wait"));
-
while (!ready_to_exit)
{
- DBUG_PRINT("quit", ("not yet ready to exit"));
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
}
- DBUG_PRINT("quit", ("ready to exit"));
(void) pthread_mutex_unlock(&LOCK_thread_count);
+
+#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
+ if (Service.IsNT() && start_mode)
+ Service.Stop();
+ else
+ {
+ Service.SetShutdownEvent(0);
+ if (hEventShutdown)
+ CloseHandle(hEventShutdown);
+ }
+#endif
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(0);
return(0); /* purecov: deadcode */
@@ -2441,6 +2493,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
struct request_info req;
signal(SIGCHLD, SIG_DFL);
request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, new_sock, NULL);
+#ifndef __linux__
fromhost(&req);
if (!hosts_access(&req))
{
@@ -2450,6 +2503,12 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
clean_exit() - same stupid thing ...
*/
syslog(deny_severity, "refused connect from %s", eval_client(&req));
+#else
+ fromhost();
+ if (!hosts_access())
+ {
+ syslog(deny_severity, "refused connect from %s", eval_client());
+#endif
if (req.sink)
((void (*)(int))req.sink)(req.fd);
@@ -2543,9 +2602,9 @@ pthread_handler_decl(handle_connections_namedpipes,arg)
fConnected = ConnectNamedPipe( hPipe, NULL );
if (abort_loop)
break;
- if ( !fConnected )
+ if (!fConnected)
fConnected = GetLastError() == ERROR_PIPE_CONNECTED;
- if ( !fConnected )
+ if (!fConnected)
{
CloseHandle( hPipe );
if ((hPipe = CreateNamedPipe(szPipeName,
@@ -2583,7 +2642,7 @@ pthread_handler_decl(handle_connections_namedpipes,arg)
continue; // We have to try again
}
- if ( !(thd = new THD))
+ if (!(thd = new THD))
{
DisconnectNamedPipe( hConnectedPipe );
CloseHandle( hConnectedPipe );
@@ -2667,13 +2726,14 @@ enum options {
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
OPT_SAFE_USER_CREATE, OPT_SQL_MODE,
+ OPT_HAVE_NAMED_PIPE,
OPT_DO_PSTACK, OPT_REPORT_HOST,
OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT,
OPT_SHOW_SLAVE_AUTH_INFO, OPT_OLD_RPL_COMPAT,
OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE,
OPT_RPL_RECOVERY_RANK,OPT_INIT_RPL_ROLE,
OPT_RELAY_LOG, OPT_RELAY_LOG_INDEX, OPT_RELAY_LOG_INFO_FILE,
- OPT_SLAVE_SKIP_ERRORS, OPT_DES_KEY_FILE
+ OPT_SLAVE_SKIP_ERRORS, OPT_DES_KEY_FILE, OPT_LOCAL_INFILE
};
static struct option long_options[] = {
@@ -2707,6 +2767,7 @@ static struct option long_options[] = {
{"delay-key-write-for-all-tables",
no_argument, 0, (int) OPT_DELAY_KEY_WRITE},
{"enable-locking", no_argument, 0, (int) OPT_ENABLE_LOCK},
+ {"enable-named-pipe", no_argument, 0, (int) OPT_HAVE_NAMED_PIPE},
{"enable-pstack", no_argument, 0, (int) OPT_DO_PSTACK},
{"exit-info", optional_argument, 0, 'T'},
{"flush", no_argument, 0, (int) OPT_FLUSH},
@@ -2735,6 +2796,7 @@ static struct option long_options[] = {
{"init-file", required_argument, 0, (int) OPT_INIT_FILE},
{"log", optional_argument, 0, 'l'},
{"language", required_argument, 0, 'L'},
+ {"local-infile", optional_argument, 0, (int) OPT_LOCAL_INFILE},
{"log-bin", optional_argument, 0, (int) OPT_BIN_LOG},
{"log-bin-index", required_argument, 0, (int) OPT_BIN_LOG_INDEX},
{"log-isam", optional_argument, 0, (int) OPT_ISAM_LOG},
@@ -2970,16 +3032,20 @@ CHANGEABLE_VAR changeable_vars[] = {
0, 0, 65535, 0, 1},
{ "query_buffer_size", (long*) &query_buff_size,
0, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE },
+#ifdef HAVE_QUERY_CACHE
{ "query_cache_limit", (long*) &query_cache_limit,
1024*1024L, 0, ULONG_MAX, 0, 1},
{ "query_cache_size", (long*) &query_cache_size,
0, 0, ULONG_MAX, 0, 1},
{ "query_cache_startup_type",(long*) &query_cache_startup_type,
1, 0, 2, 0, 1},
+#endif /*HAVE_QUERY_CACHE*/
{ "record_buffer", (long*) &my_default_record_cache_size,
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE },
{ "record_rnd_buffer", (long*) &record_rnd_cache_size,
0, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE },
+ { "relay_log_space_limit", (long*) &relay_log_space_limit, 0L, 0L,ULONG_MAX,
+ 0, 1},
{ "slave_net_timeout", (long*) &slave_net_timeout,
SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1 },
{ "slow_launch_time", (long*) &slow_launch_time,
@@ -3037,6 +3103,7 @@ struct show_var_st init_vars[]= {
{"have_raid", (char*) &have_raid, SHOW_HAVE},
{"have_symlink", (char*) &have_symlink, SHOW_HAVE},
{"have_openssl", (char*) &have_openssl, SHOW_HAVE},
+ {"have_query_cache", (char*) &have_query_cache, SHOW_HAVE},
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
#ifdef HAVE_INNOBASE_DB
{"innodb_additional_mem_pool_size", (char*) &innobase_additional_mem_pool_size, SHOW_LONG },
@@ -3070,7 +3137,7 @@ struct show_var_st init_vars[]= {
{"log_update", (char*) &opt_update_log, SHOW_BOOL},
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_BOOL},
- {"log_long_queries", (char*) &opt_slow_log, SHOW_BOOL},
+ {"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL},
{"long_query_time", (char*) &long_query_time, SHOW_LONG},
{"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL},
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG},
@@ -3092,6 +3159,9 @@ struct show_var_st init_vars[]= {
{"myisam_max_sort_file_size",(char*) &myisam_max_sort_file_size, SHOW_LONG},
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
{"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG},
+#ifdef __NT__
+ {"named_pipe", (char*) &opt_enable_named_pipe, SHOW_BOOL},
+#endif
{"net_buffer_length", (char*) &net_buffer_length, SHOW_LONG},
{"net_read_timeout", (char*) &net_read_timeout, SHOW_LONG},
{"net_retry_count", (char*) &mysqld_net_retry_count, SHOW_LONG},
@@ -3104,9 +3174,11 @@ struct show_var_st init_vars[]= {
{"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG},
{"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG},
{"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
+#ifdef HAVE_QUERY_CACHE
{"query_cache_limit", (char*) &query_cache.query_cache_limit, SHOW_LONG},
{"query_cache_size", (char*) &query_cache.query_cache_size, SHOW_LONG},
{"query_cache_startup_type",(char*) &query_cache_startup_type, SHOW_LONG},
+#endif /*HAVE_QUERY_CACHE*/
{"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL},
{"server_id", (char*) &server_id, SHOW_LONG},
{"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG},
@@ -3213,6 +3285,7 @@ struct show_var_st status_vars[]= {
{"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
{"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
+ {"Handler_commit", (char*) &ha_commit_count, SHOW_LONG},
{"Handler_delete", (char*) &ha_delete_count, SHOW_LONG},
{"Handler_read_first", (char*) &ha_read_first_count, SHOW_LONG},
{"Handler_read_key", (char*) &ha_read_key_count, SHOW_LONG},
@@ -3220,6 +3293,7 @@ struct show_var_st status_vars[]= {
{"Handler_read_prev", (char*) &ha_read_prev_count, SHOW_LONG},
{"Handler_read_rnd", (char*) &ha_read_rnd_count, SHOW_LONG},
{"Handler_read_rnd_next", (char*) &ha_read_rnd_next_count, SHOW_LONG},
+ {"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG},
{"Handler_update", (char*) &ha_update_count, SHOW_LONG},
{"Handler_write", (char*) &ha_write_count, SHOW_LONG},
{"Key_blocks_used", (char*) &_my_blocks_used, SHOW_LONG_CONST},
@@ -3235,6 +3309,7 @@ struct show_var_st status_vars[]= {
{"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST},
{"Opened_tables", (char*) &opened_tables, SHOW_LONG},
{"Questions", (char*) 0, SHOW_QUESTION},
+#ifdef HAVE_QUERY_CACHE
{"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_CONST},
{"Qcache_inserts", (char*) &query_cache.inserts, SHOW_LONG},
{"Qcache_hits", (char*) &query_cache.hits, SHOW_LONG},
@@ -3245,6 +3320,7 @@ struct show_var_st status_vars[]= {
SHOW_LONG_CONST},
{"Qcache_total_blocks", (char*) &query_cache.total_blocks,
SHOW_LONG_CONST},
+#endif /*HAVE_QUERY_CACHE*/
{"Rpl_status", (char*) 0, SHOW_RPL_STATUS},
{"Select_full_join", (char*) &select_full_join_count, SHOW_LONG},
{"Select_full_range_join", (char*) &select_full_range_join_count, SHOW_LONG},
@@ -3309,10 +3385,11 @@ static void use_help(void)
static void usage(void)
{
print_version();
- puts("Copyright (C) 2000 MySQL AB & MySQL Finland AB, by Monty and others");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
- puts("and you are welcome to modify and redistribute it under the GPL license\n");
- puts("Starts the MySQL server\n");
+ puts("\
+Copyright (C) 2000 MySQL AB, by Monty and others\n\
+This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
+and you are welcome to modify and redistribute it under the GPL license\n\
+Starts the MySQL server\n");
printf("Usage: %s [OPTIONS]\n", my_progname);
puts("\n\
@@ -3358,6 +3435,7 @@ static void usage(void)
--init-file=file Read SQL commands from this file at startup\n\
-L, --language=... Client error messages in given language. May be\n\
given as a full path\n\
+ --local-infile=[1|0] Enable/disable LOAD DATA LOCAL INFILE\n\
-l, --log[=file] Log connections and queries to file\n\
--log-bin[=file] Log queries in new binary format (for replication)\n\
--log-bin-index=file File that holds the names for last binary log files\n\
@@ -3422,10 +3500,12 @@ static void usage(void)
-W, --warnings Log some not critical warnings to the log file\n");
#ifdef __WIN__
puts("NT and Win32 specific options:\n\
- --console Don't remove the console window\n\
- --install Install mysqld as a service (NT)\n\
- --remove Remove mysqld from the service list (NT)\n\
- --standalone Dummy option to start as a standalone program (NT)\
+ --console Don't remove the console window\n\
+ --install Install the default service (NT)\n\
+ --install-manual Install the default service started manually (NT)\n\
+ --remove Remove the default service from the service list (NT)\n\
+ --enable-named-pipe Enable the named pipe (NT)\n\
+ --standalone Dummy option to start as a standalone program (NT)\
");
#ifdef USE_SYMDIR
puts("--use-symbolic-links Enable symbolic link support");
@@ -3512,9 +3592,10 @@ static void set_options(void)
opt_specialflag |= SPECIAL_NO_PRIOR;
#endif
- (void) strmov( default_charset, MYSQL_CHARSET);
- (void) strmov( language, LANGUAGE);
- (void) strmov( mysql_real_data_home, get_relative_path(DATADIR));
+ (void) strmake(default_charset, MYSQL_CHARSET, sizeof(default_charset)-1);
+ (void) strmake(language, LANGUAGE, sizeof(language)-1);
+ (void) strmake(mysql_real_data_home, get_relative_path(DATADIR),
+ sizeof(mysql_real_data_home-1));
#ifdef __WIN__
/* Allow Win32 users to move MySQL anywhere */
{
@@ -3525,9 +3606,9 @@ static void set_options(void)
}
#else
const char *tmpenv;
- if ( !(tmpenv = getenv("MY_BASEDIR_VERSION")))
+ if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
tmpenv = DEFAULT_MYSQL_HOME;
- (void) strmov( mysql_home, tmpenv );
+ (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
#endif
#if defined( HAVE_mit_thread ) || defined( __WIN__ ) || defined( HAVE_LINUXTHREADS )
@@ -3573,17 +3654,17 @@ static void get_options(int argc,char **argv)
default_tx_isolation= ISO_SERIALIZABLE;
break;
case 'b':
- strmov(mysql_home,optarg);
+ strmake(mysql_home,optarg,sizeof(mysql_home)-1);
break;
case 'l':
opt_log=1;
opt_logname=optarg; // Use hostname.log if null
break;
case 'h':
- strmov(mysql_real_data_home,optarg);
+ strmake(mysql_real_data_home,optarg, sizeof(mysql_real_data_home)-1);
break;
case 'L':
- strmov(language,optarg);
+ strmake(language, optarg, sizeof(language)-1);
break;
case 'n':
opt_specialflag|= SPECIAL_NEW_FUNC;
@@ -3601,6 +3682,9 @@ static void get_options(int argc,char **argv)
case 'P':
mysql_port= (unsigned int) atoi(optarg);
break;
+ case OPT_LOCAL_INFILE:
+ opt_local_infile= test(!optarg || atoi(optarg) != 0);
+ break;
case OPT_SLAVE_SKIP_ERRORS:
init_slave_skip_errors(optarg);
break;
@@ -3845,7 +3929,9 @@ static void get_options(int argc,char **argv)
my_use_symdir=0;
have_symlink=SHOW_OPTION_DISABLED;
ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED;
+#ifdef HAVE_QUERY_CACHE
query_cache_size=0;
+#endif
break;
case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE;
@@ -3938,11 +4024,16 @@ static void get_options(int argc,char **argv)
}
break;
case (int) OPT_PID_FILE:
- strmov(pidfile_name,optarg);
+ strmake(pidfile_name, optarg, sizeof(pidfile_name)-1);
break;
case (int) OPT_INIT_FILE:
opt_init_file=optarg;
break;
+ case (int) OPT_HAVE_NAMED_PIPE:
+#if __NT__
+ opt_enable_named_pipe=1;
+#endif
+ break;
#ifdef __WIN__
case (int) OPT_STANDALONE: /* Dummy option for NT */
break;
@@ -3988,10 +4079,10 @@ static void get_options(int argc,char **argv)
myisam_delay_key_write=0;
break;
case 'C':
- strmov(default_charset,optarg);
+ strmake(default_charset, optarg, sizeof(default_charset)-1);
break;
case OPT_CHARSETS_DIR:
- strmov(mysql_charsets_dir, optarg);
+ strmake(mysql_charsets_dir, optarg, sizeof(mysql_charsets_dir)-1);
charsets_dir = mysql_charsets_dir;
break;
#ifdef TO_BE_DONE
@@ -4263,16 +4354,17 @@ static void fix_paths(void)
char buff[FN_REFLEN],*sharedir=get_relative_path(SHAREDIR);
if (test_if_hard_path(sharedir))
- strmov(buff,sharedir); /* purecov: tested */
+ strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
else
- strxmov(buff,mysql_home,sharedir,NullS);
+ strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
convert_dirname(buff,buff,NullS);
(void) my_load_path(language,language,buff);
/* If --character-sets-dir isn't given, use shared library dir */
if (charsets_dir != mysql_charsets_dir)
{
- strmov(strmov(mysql_charsets_dir,buff),CHARSET_DIR);
+ strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
+ CHARSET_DIR, NullS);
charsets_dir=mysql_charsets_dir;
}