diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 980 |
1 files changed, 600 insertions, 380 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1fb39e56840..8f0440ecc04 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -21,15 +21,13 @@ #include "sql_acl.h" #include "slave.h" #include "sql_repl.h" +#include "repl_failsafe.h" #include "stacktrace.h" #ifdef HAVE_BERKELEY_DB #include "ha_berkeley.h" #endif #ifdef HAVE_INNOBASE_DB -#include "ha_innobase.h" -#endif -#ifdef HAVE_GEMINI_DB -#include "ha_gemini.h" +#include "ha_innodb.h" #endif #include "ha_myisam.h" #include <nisam.h> @@ -40,10 +38,16 @@ #define ONE_THREAD #endif +/* do 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" +char pstack_file_name[80]; +#endif /* __linux__ */ + #if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) #define HAVE_CLOSE_SERVER_SOCK 1 -void close_server_sock(); -#endif +#endif extern "C" { // Because of SCO 3.2V4.2 #include <errno.h> @@ -77,9 +81,7 @@ extern "C" { // Because of SCO 3.2V4.2 #include <sys/select.h> #endif #include <sys/utsname.h> -#else -#include <windows.h> -#endif // __WIN__ +#endif /* __WIN__ */ #ifdef HAVE_LIBWRAP #include <tcpd.h> @@ -112,8 +114,13 @@ typedef fp_except fp_except_t; inline void reset_floating_point_exceptions() { /* Don't fall for overflow, underflow,divide-by-zero or loss of precision */ - fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | - FP_X_DZ | FP_X_IMP)); +#if defined(__i386__) + fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ | + FP_X_IMP)); +#else + fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | + FP_X_IMP)); +#endif } #else #define reset_floating_point_exceptions() @@ -182,17 +189,12 @@ SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_YES; #else SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_NO; #endif -#ifdef HAVE_GEMINI_DB -SHOW_COMP_OPTION have_gemini=SHOW_OPTION_YES; -#else -SHOW_COMP_OPTION have_gemini=SHOW_OPTION_NO; -#endif #ifdef HAVE_INNOBASE_DB SHOW_COMP_OPTION have_innodb=SHOW_OPTION_YES; #else SHOW_COMP_OPTION have_innodb=SHOW_OPTION_NO; #endif -#ifndef NO_ISAM +#ifdef HAVE_ISAM SHOW_COMP_OPTION have_isam=SHOW_OPTION_YES; #else SHOW_COMP_OPTION have_isam=SHOW_OPTION_NO; @@ -203,16 +205,19 @@ SHOW_COMP_OPTION have_raid=SHOW_OPTION_YES; SHOW_COMP_OPTION have_raid=SHOW_OPTION_NO; #endif #ifdef HAVE_OPENSSL -SHOW_COMP_OPTION have_ssl=SHOW_OPTION_YES; +SHOW_COMP_OPTION have_openssl=SHOW_OPTION_YES; #else -SHOW_COMP_OPTION have_ssl=SHOW_OPTION_NO; +SHOW_COMP_OPTION have_openssl=SHOW_OPTION_NO; #endif +SHOW_COMP_OPTION have_symlink=SHOW_OPTION_YES; -static bool opt_skip_slave_start = 0; // if set, slave is not autostarted +bool opt_skip_slave_start = 0; // If set, slave is not autostarted +static bool opt_do_pstack = 0; static ulong opt_specialflag=SPECIAL_ENGLISH; -static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET; static ulong back_log,connect_timeout,concurrency; +static ulong opt_myisam_block_size; +static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET; static my_string opt_logname=0,opt_update_logname=0, opt_binlog_index_name = 0,opt_slow_logname=0; static char mysql_home[FN_REFLEN],pidfile_name[FN_REFLEN]; @@ -222,32 +227,30 @@ static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl, opt_myisam_log=0, opt_large_files=sizeof(my_off_t) > 4; bool opt_sql_bin_update = 0, opt_log_slave_updates = 0, opt_safe_show_db=0, - opt_safe_user_create=0; + opt_show_slave_auth_info = 0, opt_old_rpl_compat = 0, + opt_safe_user_create = 0, opt_no_mix_types = 0; +volatile bool mqh_used = 0; FILE *bootstrap_file=0; int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice -extern MASTER_INFO glob_mi; -extern int init_master_info(MASTER_INFO* mi); -// if sql_bin_update is true, SQL_LOG_UPDATE and SQL_LOG_BIN are kept in sync, -// and are treated as aliases for each other +/* + If sql_bin_update is true, SQL_LOG_UPDATE and SQL_LOG_BIN are kept in sync, + and are treated as aliases for each other +*/ static bool kill_in_progress=FALSE; static struct rand_struct sql_rand; static int cleanup_done; static char **defaults_argv,time_zone[30]; static const char *default_table_type_name; -static char glob_hostname[FN_REFLEN]; +char glob_hostname[FN_REFLEN]; +#include "sslopt-vars.h" #ifdef HAVE_OPENSSL -static bool opt_use_ssl = FALSE; -static char *opt_ssl_key = 0; -static char *opt_ssl_cert = 0; -static char *opt_ssl_ca = 0; -static char *opt_ssl_capath = 0; -static VioSSLAcceptorFd* ssl_acceptor_fd = 0; +char *des_key_file = 0; +struct st_VioSSLAcceptorFd * ssl_acceptor_fd = 0; #endif /* HAVE_OPENSSL */ - I_List <i_string_pair> replicate_rewrite_db; I_List<i_string> replicate_do_db, replicate_ignore_db; // allow the user to tell us which db to replicate and which to ignore @@ -258,9 +261,9 @@ uint32 server_id = 0; bool server_id_supplied = 0; uint mysql_port; -uint test_flags, select_errors=0, dropping_tables=0,ha_open_options=0; +uint test_flags = 0, select_errors=0, dropping_tables=0,ha_open_options=0; uint volatile thread_count=0, thread_running=0, kill_cached_threads=0, - wake_thread=0, global_read_lock=0; + wake_thread=0; ulong thd_startup_options=(OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL | OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE ); uint protocol_version=PROTOCOL_VERSION; @@ -274,14 +277,21 @@ 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; volatile ulong cached_thread_count=0; // replication parameters, if master_host is not NULL, we are a slave my_string master_user = (char*) "test", master_password = 0, master_host=0, - master_info_file = (char*) "master.info"; + master_info_file = (char*) "master.info", + relay_log_info_file = (char*) "relay-log.info", + master_ssl_key=0, master_ssl_cert=0; +my_string report_user = 0, report_password = 0, report_host=0; + const char *localhost=LOCAL_HOST; const char *delayed_user="DELAYED"; uint master_port = MYSQL_PORT, master_connect_retry = 60; +uint report_port = MYSQL_PORT; +bool master_ssl = 0; ulong max_tmp_tables,max_heap_table_size,master_retry_count=0; ulong bytes_sent = 0L, bytes_received = 0L; @@ -309,11 +319,20 @@ ulong slow_launch_threads = 0; ulong myisam_max_sort_file_size, myisam_max_extra_sort_file_size; char mysql_real_data_home[FN_REFLEN], - mysql_data_home[2],language[LIBLEN],reg_ext[FN_EXTLEN], + language[LIBLEN],reg_ext[FN_EXTLEN], default_charset[LIBLEN],mysql_charsets_dir[FN_REFLEN], *charsets_list, blob_newline,f_fyllchar,max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file; +#ifndef EMBEDDED_LIBRARY +char mysql_data_home_buff[2], *mysql_data_home=mysql_data_home_buff; +bool mysql_embedded=0; +#else +char *mysql_data_home=mysql_real_data_home; +bool mysql_embedded=1; +#endif + char *opt_bin_logname = 0; // this one needs to be seen in sql_parse.cc +char *opt_relay_logname = 0, *opt_relaylog_index_name=0; char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION; const char *first_keyword="first"; const char **errmesg; /* Error messages */ @@ -322,10 +341,9 @@ const char *sql_mode_str="OFF"; const char *default_tx_isolation_name; enum_tx_isolation default_tx_isolation=ISO_READ_COMMITTED; -#ifdef HAVE_GEMINI_DB -const char *gemini_recovery_options_str="FULL"; -#endif -my_string mysql_unix_port=NULL,mysql_tmpdir=NULL; +uint rpl_recovery_rank=0; + +my_string mysql_unix_port=NULL, mysql_tmpdir=NULL, allocated_mysql_tmpdir=NULL; ulong my_bind_addr; /* the address we bind to */ DATE_FORMAT dayord; double log_10[32]; /* 10 potences */ @@ -335,8 +353,8 @@ time_t start_time; ulong opt_sql_mode = 0L; const char *sql_mode_names[] = { "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", - "SERIALIZE","ONLY_FULL_GROUP_BY", NullS }; -TYPELIB sql_mode_typelib= {array_elements(sql_mode_names),"", + "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS }; +TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"", sql_mode_names}; MY_BITMAP temp_pool; @@ -350,8 +368,10 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_error_log, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, - LOCK_binlog_update, LOCK_slave, LOCK_server_id, - LOCK_user_conn; + 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; @@ -363,10 +383,12 @@ enum db_type default_table_type=DB_TYPE_MYISAM; #ifdef __WIN__ #undef getpid #include <process.h> +#if !defined(EMBEDDED_LIBRARY) HANDLE hEventShutdown; #include "nt_servc.h" static NTService Service; // Service object for WinNT #endif +#endif #ifdef OS2 pthread_cond_t eventShutdown; @@ -381,6 +403,7 @@ static void fix_paths(void); static pthread_handler_decl(handle_connections_sockets,arg); static pthread_handler_decl(kill_server_thread,arg); static int bootstrap(FILE *file); +static void close_server_sock(); static bool read_init_file(char *file_name); #ifdef __NT__ static pthread_handler_decl(handle_connections_namedpipes,arg); @@ -430,15 +453,7 @@ static void close_connections(void) if (pthread_kill(select_thread,THR_CLIENT_ALARM)) break; // allready dead #endif -#ifdef HAVE_TIMESPEC_TS_SEC - abstime.ts_sec=time(NULL)+2; // Bsd 2.1 - abstime.ts_nsec=0; -#else - struct timeval tv; - gettimeofday(&tv,0); - abstime.tv_sec=tv.tv_sec+2; - abstime.tv_nsec=tv.tv_usec*1000; -#endif + set_timespec(abstime, 2); for (uint tmp=0 ; tmp < 10 ; tmp++) { error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count, @@ -450,9 +465,7 @@ static void close_connections(void) if (error != 0 && !count++) sql_print_error("Got error %d from pthread_cond_timedwait",error); #endif -#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) close_server_sock(); -#endif } (void) pthread_mutex_unlock(&LOCK_thread_count); #endif /* __WIN__ */ @@ -470,28 +483,28 @@ static void close_connections(void) } } #ifdef __NT__ -if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) -{ - HANDLE temp; - DBUG_PRINT( "quit", ("Closing named pipes") ); - - /* 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) + if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) { - WaitNamedPipe(szPipeName, 1000); - DWORD dwMode = PIPE_READMODE_BYTE | PIPE_WAIT; - SetNamedPipeHandleState(temp, &dwMode, NULL, NULL); - CancelIo(temp); - DisconnectNamedPipe(temp); - CloseHandle(temp); + HANDLE temp; + DBUG_PRINT( "quit", ("Closing named pipes") ); + + /* 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 if (unix_sock != INVALID_SOCKET) @@ -538,7 +551,7 @@ if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) /* Force remaining threads to die by closing the connection to the client */ - (void) my_net_init(&net, (Vio*) 0); + (void) my_net_init(&net, (st_vio*) 0); for (;;) { DBUG_PRINT("quit",("Locking LOCK_thread_count")); @@ -579,59 +592,68 @@ if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) DBUG_VOID_RETURN; } -#ifdef HAVE_CLOSE_SERVER_SOCK -void close_server_sock() +static void close_server_sock() { +#ifdef HAVE_CLOSE_SERVER_SOCK DBUG_ENTER("close_server_sock"); - if (ip_sock != INVALID_SOCKET) + my_socket tmp_sock; + tmp_sock=ip_sock; + if (tmp_sock != INVALID_SOCKET) { - DBUG_PRINT("info",("closing TCP/IP socket")); - VOID(shutdown(ip_sock,2)); - VOID(closesocket(ip_sock)); ip_sock=INVALID_SOCKET; + DBUG_PRINT("info",("closing TCP/IP socket")); + VOID(shutdown(tmp_sock,2)); + VOID(closesocket(tmp_sock)); } - if (unix_sock != INVALID_SOCKET) + tmp_sock=unix_sock; + if (tmp_sock != INVALID_SOCKET) { + unix_sock=INVALID_SOCKET; DBUG_PRINT("info",("closing Unix socket")); - VOID(shutdown(unix_sock,2)); - VOID(closesocket(unix_sock)); + VOID(shutdown(tmp_sock,2)); + VOID(closesocket(tmp_sock)); VOID(unlink(mysql_unix_port)); - unix_sock=INVALID_SOCKET; } DBUG_VOID_RETURN; -} #endif +} void kill_mysql(void) { DBUG_ENTER("kill_mysql"); + #ifdef SIGNALS_DONT_BREAK_READ close_server_sock(); /* force accept to wake up */ -#endif +#endif + #if defined(__WIN__) +#if !defined(EMBEDDED_LIBRARY) { if (!SetEvent(hEventShutdown)) { DBUG_PRINT("error",("Got error: %ld from SetEvent",GetLastError())); } - // or: - // HANDLE hEvent=OpenEvent(0, FALSE, "MySqlShutdown"); - // SetEvent(hEventShutdown); - // CloseHandle(hEvent); + /* + or: + HANDLE hEvent=OpenEvent(0, FALSE, "MySqlShutdown"); + SetEvent(hEventShutdown); + CloseHandle(hEvent); + */ } +#endif #elif defined(OS2) pthread_cond_signal( &eventShutdown); // post semaphore #elif defined(HAVE_PTHREAD_KILL) - if (pthread_kill(signal_thread,MYSQL_KILL_SIGNAL))// End everything nicely + if (pthread_kill(signal_thread,SIGTERM)) /* End everything nicely */ { DBUG_PRINT("error",("Got error %d from pthread_kill",errno)); /* purecov: inspected */ } #elif !defined(SIGNALS_DONT_BREAK_READ) - kill(current_pid,MYSQL_KILL_SIGNAL); + kill(current_pid,SIGTERM); #endif DBUG_PRINT("quit",("After pthread_kill")); shutdown_in_progress=1; // Safety if kill didn't work -#ifdef SIGNALS_DONT_BREAK_READ +#ifdef SIGNALS_DONT_BREAK_READ if (!abort_loop) { pthread_t tmp; @@ -661,8 +683,7 @@ static void __cdecl kill_server(int sig_ptr) int sig=(int) (long) sig_ptr; // This is passed a int DBUG_ENTER("kill_server"); - // if there is a signal during the kill in progress, we do not need - // another one + // if there is a signal during the kill in progress, ignore the other if (kill_in_progress) // Safety RETURN_FROM_KILL_SERVER; kill_in_progress=TRUE; @@ -687,7 +708,7 @@ static void __cdecl kill_server(int sig_ptr) #ifdef USE_ONE_SIGNAL_HAND -pthread_handler_decl(kill_server_thread,arg __attribute__((unused))) +static pthread_handler_decl(kill_server_thread,arg __attribute__((unused))) { my_thread_init(); // Initialize new thread kill_server(0); @@ -696,6 +717,11 @@ pthread_handler_decl(kill_server_thread,arg __attribute__((unused))) } #endif +#if defined(__amiga__) +#undef sigset +#define sigset signal +#endif + static sig_handler print_signal_warning(int sig) { if (opt_warnings) @@ -714,15 +740,19 @@ static sig_handler print_signal_warning(int sig) void unireg_end(int signal_number __attribute__((unused))) { clean_up(); + my_thread_end(); pthread_exit(0); // Exit is in main thread } void unireg_abort(int exit_code) { + DBUG_ENTER("unireg_abort"); if (exit_code) sql_print_error("Aborting\n"); clean_up(); /* purecov: inspected */ + DBUG_PRINT("quit",("done with cleanup in unireg_abort")); + my_thread_end(); exit(exit_code); /* purecov: inspected */ } @@ -736,7 +766,7 @@ void clean_up(bool print_message) bitmap_free(&slave_error_mask); acl_free(1); grant_free(); - sql_cache_free(); + query_cache.destroy(); table_cache_free(); hostname_cache_free(); item_user_lock_free(); @@ -750,27 +780,42 @@ void clean_up(bool print_message) #ifdef USE_RAID end_raid(); #endif +#ifdef HAVE_OPENSSL + my_free(opt_ssl_key,MYF(MY_ALLOW_ZERO_PTR)); + my_free(opt_ssl_cert,MYF(MY_ALLOW_ZERO_PTR)); + 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(mysql_tmpdir,MYF(0)); + my_free(allocated_mysql_tmpdir,MYF(MY_ALLOW_ZERO_PTR)); + my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR)); x_free(opt_bin_logname); + x_free(opt_relay_logname); bitmap_free(&temp_pool); free_max_user_conn(); -#ifndef __WIN__ + end_slave_list(); + +#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist #endif - if (print_message) + if (print_message && errmesg) sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname); x_free((gptr) my_errmsg[ERRMAPP]); /* Free messages */ - my_thread_end(); - + DBUG_PRINT("quit", ("Error messages freed")); /* Tell main we are ready */ (void) pthread_mutex_lock(&LOCK_thread_count); + DBUG_PRINT("quit", ("got thread count lock")); ready_to_exit=1; /* do the broadcast inside the lock to ensure that my_end() is not called */ (void) pthread_cond_broadcast(&COND_thread_count); (void) pthread_mutex_unlock(&LOCK_thread_count); + DBUG_PRINT("quit", ("done with cleanup")); } /* clean_up */ @@ -830,20 +875,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); @@ -913,14 +971,16 @@ 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 */ @@ -1023,7 +1083,7 @@ void yyerror(const char *s) void close_connection(NET *net,uint errcode,bool lock) { - Vio* vio; + st_vio* vio; DBUG_ENTER("close_connection"); DBUG_PRINT("enter",("fd: %s error: '%s'", net->vio? vio_description(net->vio):"(not connected)", @@ -1088,6 +1148,8 @@ void end_thread(THD *thd, bool put_in_cache) DBUG_PRINT("info", ("sending a broadcast")) /* Tell main we are ready */ + // TODO: explain why we broadcast outside of the lock or + // fix the bug - Sasha (void) pthread_mutex_unlock(&LOCK_thread_count); (void) pthread_cond_broadcast(&COND_thread_count); DBUG_PRINT("info", ("unlocked thread_count mutex")) @@ -1101,20 +1163,6 @@ void end_thread(THD *thd, bool put_in_cache) DBUG_VOID_RETURN; } -#ifdef SIGNALS_DONT_BREAK_READ -inline void kill_broken_server() -{ - /* hack to get around signals ignored in syscalls for problem OS's */ - if (unix_sock == INVALID_SOCKET || ip_sock ==INVALID_SOCKET) - { - select_thread_in_use = 0; - kill_server((void*)MYSQL_KILL_SIGNAL); /* never returns */ - } -} -#define MAYBE_BROKEN_SYSCALL kill_broken_server(); -#else -#define MAYBE_BROKEN_SYSCALL -#endif /* Start a cached thread. LOCK_thread_count is locked on entry */ @@ -1182,19 +1230,6 @@ static void start_signal_handler(void) } #elif defined(__EMX__) -static void init_signals(void) -{ - signal(SIGQUIT, sig_kill); - signal(SIGKILL, sig_kill); - signal(SIGTERM, sig_kill); - signal(SIGINT, sig_kill); - signal(SIGHUP, sig_reload); // Flush everything - signal(SIGALRM, SIG_IGN); - signal(SIGBREAK,SIG_IGN); - signal_thread = pthread_self(); -} - - static void sig_reload(int signo) { reload_acl_and_cache((THD*) 0,REFRESH_LOG, (TABLE_LIST*) 0); // Flush everything @@ -1211,10 +1246,22 @@ static void sig_kill(int signo) signal(signo, SIG_ACK); } +static void init_signals(void) +{ + signal(SIGQUIT, sig_kill); + signal(SIGKILL, sig_kill); + signal(SIGTERM, sig_kill); + signal(SIGINT, sig_kill); + signal(SIGHUP, sig_reload); // Flush everything + signal(SIGALRM, SIG_IGN); + signal(SIGBREAK,SIG_IGN); + signal_thread = pthread_self(); +} static void start_signal_handler(void) { } + #else /* if ! __WIN__ && ! __EMX__ */ #ifdef HAVE_LINUXTHREADS @@ -1225,10 +1272,10 @@ static sig_handler handle_segfault(int sig) { THD *thd=current_thd; /* - Strictly speaking, we should need a mutex here + Strictly speaking, one needs a mutex here but since we have got SIGSEGV already, things are a mess so not having the mutex is not as bad as possibly using a buggy - mutex - so we keep things simple. + mutex - so we keep things simple */ if (segfaulted) { @@ -1240,13 +1287,13 @@ static sig_handler handle_segfault(int sig) fprintf(stderr,"\ mysqld got signal %d;\n\ This could be because you hit a bug. It is also possible that this binary\n\ -or one of the libraries it was linked agaist is corrupt, improperly built,\n\ +or one of the libraries it was linked against is corrupt, improperly built,\n\ or misconfigured. This error can also be caused by malfunctioning hardware.\n", sig); fprintf(stderr, "\ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ -and this may fail\n\n"); +and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%ld\n", keybuff_size); fprintf(stderr, "record_buffer=%ld\n", my_default_record_cache_size); fprintf(stderr, "sort_buffer=%ld\n", sortbuff_size); @@ -1257,15 +1304,15 @@ and this may fail\n\n"); key_buffer_size + (record_buffer + sort_buffer)*max_connections = %ld K\n\ bytes of memory\n", (keybuff_size + (my_default_record_cache_size + sortbuff_size) * max_connections)/ 1024); - fprintf(stderr, "Hope that's ok, if not, decrease some variables in the equation\n\n"); + fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); #if defined(HAVE_LINUXTHREADS) if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS) { fprintf(stderr, "\ You seem to be running 32-bit Linux and have %d concurrent connections.\n\ -If you have not changed STACK_SIZE in LinuxThreads and build the binary \n\ -yourself, LinuxThreads is quite likely to steal a part of global heap for\n\ +If you have not changed STACK_SIZE in LinuxThreads and built the binary \n\ +yourself, LinuxThreads is quite likely to steal a part of the global heap for\n\ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n", thread_count); } @@ -1274,9 +1321,7 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n", #ifdef HAVE_STACKTRACE if(!(test_flags & TEST_NO_STACKTRACE)) { -#ifdef HAVE_GEMINI_DB - utrace(); -#endif + fprintf(stderr,"thd=%p\n",thd); print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0, thread_stack); } @@ -1289,12 +1334,12 @@ Some pointers may be invalid and cause the dump to abort...\n"); fprintf(stderr, "\n\ Successfully dumped variables, if you ran with --log, take a look at the\n\ details of what thread %ld did to cause the crash. In some cases of really\n\ -bad corruption, the values shown above may be invalid\n\n", +bad corruption, the values shown above may be invalid.\n\n", thd->thread_id); } fprintf(stderr, "\ The manual page at http://www.mysql.com/doc/C/r/Crashing.html contains\n\ -information that should help you find out what is causing the crash\n"); +information that should help you find out what is causing the crash.\n"); fflush(stderr); #endif /* HAVE_STACKTRACE */ @@ -1326,7 +1371,11 @@ static void init_signals(void) sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); init_stacktrace(); +#if defined(__amiga__) + sa.sa_handler=(void(*)())handle_segfault; +#else sa.sa_handler=handle_segfault; +#endif sigaction(SIGSEGV, &sa, NULL); #ifdef SIGBUS sigaction(SIGBUS, &sa, NULL); @@ -1345,8 +1394,8 @@ static void init_signals(void) sigaddset(&set,SIGQUIT); sigaddset(&set,SIGTERM); sigaddset(&set,SIGHUP); - sigset(SIGTERM,print_signal_warning); // If it's blocked by parent - signal(SIGHUP,print_signal_warning); // If it's blocked by parent + signal(SIGTERM,SIG_DFL); // If it's blocked by parent + signal(SIGHUP,SIG_DFL); // If it's blocked by parent #ifdef SIGTSTP sigaddset(&set,SIGTSTP); #endif @@ -1430,6 +1479,13 @@ static void *signal_hand(void *arg __attribute__((unused))) (void) my_close(pidFile,MYF(0)); } } +#ifdef HAVE_STACK_TRACE_ON_SEGV + if (opt_do_pstack) + { + sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (ulong)getpid()); + pstack_install_segv_action(pstack_file_name); + } +#endif /* HAVE_STACK_TRACE_ON_SEGV */ // signal to start_signal_handler that we are ready (void) pthread_mutex_lock(&LOCK_thread_count); @@ -1441,7 +1497,7 @@ static void *signal_hand(void *arg __attribute__((unused))) int error; // Used when debugging if (shutdown_in_progress && !abort_loop) { - sig= MYSQL_KILL_SIGNAL; + sig=SIGTERM; error=0; } else @@ -1464,15 +1520,18 @@ static void *signal_hand(void *arg __attribute__((unused))) if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR); if (pthread_create(&tmp,&connection_attrib, kill_server_thread, - (void*) 0)) + (void*) sig)) sql_print_error("Error: Can't create thread to kill server"); #else - kill_server((void*) sig); // MIT THREAD has a alarm thread + kill_server((void*) sig); // MIT THREAD has a alarm thread #endif } break; case SIGHUP: - reload_acl_and_cache((THD*) 0,REFRESH_LOG, + reload_acl_and_cache((THD*) 0, + (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | + REFRESH_STATUS | REFRESH_GRANT | REFRESH_THREADS | + REFRESH_HOSTS), (TABLE_LIST*) 0); // Flush logs mysql_print_status((THD*) 0); // Send debug some info break; @@ -1542,8 +1601,9 @@ pthread_handler_decl(handle_shutdown,arg) /* this call should create the message queue for this thread */ PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE); - +#if !defined(EMBEDDED_LIBRARY) if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0) +#endif kill_server(MYSQL_KILL_SIGNAL); return 0; } @@ -1571,8 +1631,10 @@ pthread_handler_decl(handle_shutdown,arg) // close semaphore and kill server pthread_cond_destroy( &eventShutdown); - // exit main loop on main thread, so kill will be done from - // main thread (this is thread 2) + /* + Exit main loop on main thread, so kill will be done from + main thread (this is thread 2) + */ abort_loop = 1; // unblock select() @@ -1589,15 +1651,17 @@ const char *load_default_groups[]= { "mysqld","server",0 }; char *libwrapName=NULL; #endif -static void open_log(MYSQL_LOG *log, const char *hostname, +void open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, - enum_log_type type) + enum_log_type type, bool read_append, + bool no_auto_events) { char tmp[FN_REFLEN]; if (!opt_name || !opt_name[0]) { - /* 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. + /* + 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,hostname,FN_REFLEN-5); strmov(strcend(tmp,'.'),extension); @@ -1614,7 +1678,8 @@ static void open_log(MYSQL_LOG *log, const char *hostname, opt_name=tmp; } } - log->open(opt_name,type); + log->open(opt_name,type,0,(read_append) ? SEQ_READ_APPEND : WRITE_CACHE, + no_auto_events); } @@ -1710,33 +1775,35 @@ int main(int argc, char **argv) (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST); - (void) pthread_mutex_init(&LOCK_binlog_update, MY_MUTEX_INIT_FAST); // QQ NOT USED - (void) pthread_mutex_init(&LOCK_slave, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_server_id, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST); + (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); + (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL); (void) pthread_cond_init(&COND_flush_thread_cache,NULL); (void) pthread_cond_init(&COND_manager,NULL); - (void) pthread_cond_init(&COND_binlog_update, NULL); - (void) pthread_cond_init(&COND_slave_stopped, NULL); - (void) pthread_cond_init(&COND_slave_start, NULL); + (void) pthread_cond_init(&COND_rpl_status, NULL); init_signals(); if (set_default_charset_by_name(default_charset, MYF(MY_WME))) - unireg_abort(1); + exit( 1 ); charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS)); #ifdef HAVE_OPENSSL if (opt_use_ssl) { - ssl_acceptor_fd = VioSSLAcceptorFd_new(opt_ssl_key, opt_ssl_cert, - opt_ssl_ca, opt_ssl_capath); + ssl_acceptor_fd = new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert, + 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; - /* having ssl_acceptor_fd!=0 signals the use of SSL */ + opt_use_ssl = 0; + /* having ssl_acceptor_fd != 0 signals the use of SSL */ } + if (des_key_file) + load_des_key_file(des_key_file); #endif /* HAVE_OPENSSL */ #ifdef HAVE_LIBWRAP @@ -1757,7 +1824,7 @@ int main(int argc, char **argv) pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); #if defined( SET_RLIMIT_NOFILE) || defined( OS2) - /* connections and databases neads lots of files */ + /* connections and databases needs lots of files */ { uint wanted_files=10+(uint) max(max_connections*5, max_connections+table_cache_size*2); @@ -1801,14 +1868,12 @@ int main(int argc, char **argv) server_init(); table_cache_init(); hostname_cache_init(); - sql_cache_init(); + 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(); - - /* Fix varibles that are base 1024*1024 */ - myisam_max_temp_length= (my_off_t) min(((ulonglong) myisam_max_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); - myisam_max_extra_temp_length= (my_off_t) min(((ulonglong) myisam_max_extra_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); + init_slave_list(); /* Setup log files */ if (opt_log) @@ -1819,19 +1884,9 @@ int main(int argc, char **argv) LOG_NEW); using_update_log=1; } - - //make sure slave thread gets started - // if server_id is set, valid master.info is present, and master_host has - // not been specified - if(server_id && !master_host) - { - char fname[FN_REFLEN+128]; - MY_STAT stat_area; - fn_format(fname, master_info_file, mysql_data_home, "", 4+16+32); - if(my_stat(fname, &stat_area, MYF(0)) && !init_master_info(&glob_mi)) - master_host = glob_mi.host; - } - + + init_slave(); + if (opt_bin_log && !server_id) { server_id= !master_host ? 1 : 2; @@ -1868,7 +1923,7 @@ The server will not act as a slave."); LOG_BIN); using_update_log=1; } - + if (opt_slow_log) open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log", LOG_NORMAL); @@ -1898,15 +1953,15 @@ The server will not act as a slave."); } #else locked_in_memory=0; -#endif +#endif if (opt_myisam_log) (void) mi_log( 1 ); - ft_init_stopwords(ft_precompiled_stopwords); /* SerG */ + ft_init_stopwords(ft_precompiled_stopwords); #ifdef __WIN__ if (!opt_console) - FreeConsole(); // Remove window + FreeConsole(); // Remove window #endif /* @@ -1927,14 +1982,13 @@ The server will not act as a slave."); (void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL); #ifndef __WIN__ if (!opt_bootstrap) - (void) my_delete(pidfile_name,MYF(MY_WME)); // Not neaded anymore + (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore #endif exit(1); } if (!opt_noacl) (void) grant_init(); - if (max_user_connections) - init_max_user_conn(); + init_max_user_conn(); #ifdef HAVE_DLOPEN if (!opt_noacl) @@ -1956,7 +2010,7 @@ The server will not act as a slave."); } } (void) thr_setconcurrency(concurrency); // 10 by default -#ifdef __WIN__ //IRENA +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA { hEventShutdown=CreateEvent(0, FALSE, FALSE, "MySqlShutdown"); pthread_t hThread; @@ -1987,17 +2041,6 @@ The server will not act as a slave."); sql_print_error("Warning: Can't create thread to manage maintenance"); } - // slave thread - if (master_host) - { - pthread_t hThread; - if (!opt_skip_slave_start && - pthread_create(&hThread, &connection_attrib, handle_slave, 0)) - sql_print_error("Warning: Can't create thread to handle slave"); - else if(opt_skip_slave_start) - init_master_info(&glob_mi); - } - printf(ER(ER_READY),my_progname,server_version,""); fflush(stdout); @@ -2044,7 +2087,7 @@ The server will not act as a slave."); } #else handle_connections_sockets(0); -#ifdef EXTRA_DEBUG +#ifdef EXTRA_DEBUG2 sql_print_error("Exiting main thread"); #endif #endif /* __NT__ */ @@ -2054,17 +2097,18 @@ The server will not act as a slave."); DBUG_PRINT("quit",("Exiting main thread")); #ifndef __WIN__ -#ifdef EXTRA_DEBUG +#ifdef EXTRA_DEBUG2 sql_print_error("Before Lock_thread_count"); #endif (void) pthread_mutex_lock(&LOCK_thread_count); + DBUG_PRINT("quit", ("Got thread_count mutex")); select_thread_in_use=0; // For close_connections (void) pthread_cond_broadcast(&COND_thread_count); (void) pthread_mutex_unlock(&LOCK_thread_count); -#ifdef EXTRA_DEBUG +#ifdef EXTRA_DEBUG2 sql_print_error("After lock_thread_count"); #endif -#endif +#endif /* __WIN__ */ /* Wait until cleanup is done */ (void) pthread_mutex_lock(&LOCK_thread_count); @@ -2073,22 +2117,16 @@ The server will not act as a slave."); pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); } (void) pthread_mutex_unlock(&LOCK_thread_count); -#ifdef __WIN__ - if (Service.IsNT()) - { - if(start_mode) - Service.Stop(); - else - { - Service.SetShutdownEvent(0); - if(hEventShutdown) CloseHandle(hEventShutdown); - } - } - else - { + +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) + if (Service.IsNT() && start_mode) + Service.Stop(); + else + { Service.SetShutdownEvent(0); - if(hEventShutdown) CloseHandle(hEventShutdown); - } + if (hEventShutdown) + CloseHandle(hEventShutdown); + } #endif my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); exit(0); @@ -2096,7 +2134,7 @@ The server will not act as a slave."); } -#ifdef __WIN__ +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) /* ------------------------------------------------------------------------ main and thread entry function for Win32 (all this is needed only to run mysqld as a service on WinNT) @@ -2143,9 +2181,11 @@ int main(int argc, char **argv) } } - // This is a WIN95 machine or a start of mysqld as a standalone program - // we have to pass the arguments, in case of NT-service this will be done - // by ServiceMain() + /* + This is a WIN95 machine or a start of mysqld as a standalone program + we have to pass the arguments, in case of NT-service this will be done + by ServiceMain() + */ Service.my_argc=argc; Service.my_argv=argv; @@ -2162,7 +2202,7 @@ static int bootstrap(FILE *file) int error; thd->bootstrap=1; thd->client_capabilities=0; - my_net_init(&thd->net,(Vio*) 0); + my_net_init(&thd->net,(st_vio*) 0); thd->max_packet_length=thd->net.max_packet; thd->master_access= ~0; thd->thread_id=thread_id++; @@ -2280,7 +2320,7 @@ static void create_new_thread(THD *thd) (void) pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; } - + (void) pthread_mutex_unlock(&LOCK_thread_count); } } @@ -2288,6 +2328,20 @@ static void create_new_thread(THD *thd) DBUG_VOID_RETURN; } +#ifdef SIGNALS_DONT_BREAK_READ +inline void kill_broken_server() +{ + /* hack to get around signals ignored in syscalls for problem OS's */ + if (unix_sock == INVALID_SOCKET || ip_sock ==INVALID_SOCKET) + { + select_thread_in_use = 0; + kill_server((void*)MYSQL_KILL_SIGNAL); /* never returns */ + } +} +#define MAYBE_BROKEN_SYSCALL kill_broken_server(); +#else +#define MAYBE_BROKEN_SYSCALL +#endif /* Handle new connections and spawn new process to handle them */ @@ -2300,7 +2354,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) THD *thd; struct sockaddr_in cAddr; int ip_flags=0,socket_flags=0,flags; - Vio *vio_tmp; + st_vio *vio_tmp; DBUG_ENTER("handle_connections_sockets"); LINT_INIT(new_sock); @@ -2338,13 +2392,15 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) if (!select_errors++ && !abort_loop) /* purecov: inspected */ sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */ } - MAYBE_BROKEN_SYSCALL; + MAYBE_BROKEN_SYSCALL continue; } #endif /* HPUX */ if (abort_loop) + { + MAYBE_BROKEN_SYSCALL; break; - + } /* ** Is this a new connection request */ @@ -2410,21 +2466,31 @@ 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)) { - // This may be stupid but refuse() includes an exit(0) - // which we surely don't want... - // clean_exit() - same stupid thing ... + /* + This may be stupid but refuse() includes an exit(0) + which we surely don't want... + 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); - // C++ sucks (the gibberish in front just translates the supplied - // sink function pointer in the req structure from a void (*sink)(); - // to a void(*sink)(int) if you omit the cast, the C++ compiler - // will cry... - + /* + C++ sucks (the gibberish in front just translates the supplied + sink function pointer in the req structure from a void (*sink)(); + to a void(*sink)(int) if you omit the cast, the C++ compiler + will cry... + */ (void) shutdown(new_sock,2); // This looks fine to me... (void) closesocket(new_sock); continue; @@ -2452,7 +2518,8 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) if (!(thd= new THD)) { - (void) shutdown(new_sock,2); VOID(closesocket(new_sock)); + (void) shutdown(new_sock,2); + VOID(closesocket(new_sock)); continue; } if (!(vio_tmp=vio_new(new_sock, @@ -2604,6 +2671,8 @@ enum options { OPT_MASTER_PASSWORD, OPT_MASTER_PORT, OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY, OPT_MASTER_RETRY_COUNT, + OPT_MASTER_SSL, OPT_MASTER_SSL_KEY, + OPT_MASTER_SSL_CERT, OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB, OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES, OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB, @@ -2622,18 +2691,22 @@ enum options { OPT_INNODB_LOG_ARCH_DIR, OPT_INNODB_LOG_ARCHIVE, OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, + OPT_INNODB_FLUSH_METHOD, OPT_INNODB_FAST_SHUTDOWN, - OPT_INNODB_UNIX_FILE_FLUSH_METHOD, OPT_SAFE_SHOW_DB, - OPT_GEMINI_SKIP, OPT_INNODB_SKIP, + OPT_INNODB_SKIP, OPT_SKIP_SAFEMALLOC, OPT_TEMP_POOL, OPT_TX_ISOLATION, - OPT_GEMINI_FLUSH_LOG, OPT_GEMINI_RECOVER, - OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC, 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_SLAVE_SKIP_ERRORS, OPT_LOCAL_INFILE + 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_LOCAL_INFILE }; static struct option long_options[] = { @@ -2661,19 +2734,17 @@ static struct option long_options[] = { {"character-sets-dir", required_argument, 0, (int) OPT_CHARSETS_DIR}, {"datadir", required_argument, 0, 'h'}, {"debug", optional_argument, 0, '#'}, + {"des-key-file", required_argument, 0, (int) OPT_DES_KEY_FILE}, {"default-character-set", required_argument, 0, 'C'}, {"default-table-type", required_argument, 0, (int) OPT_TABLE_TYPE}, {"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}, -#ifdef HAVE_GEMINI_DB - {"gemini-flush-log-at-commit",no_argument, 0, (int) OPT_GEMINI_FLUSH_LOG}, - {"gemini-recovery", required_argument, 0, (int) OPT_GEMINI_RECOVER}, - {"gemini-unbuffered-io", no_argument, 0, (int) OPT_GEMINI_UNBUFFERED_IO}, -#endif + {"init-rpl-role", required_argument, 0, (int) OPT_INIT_RPL_ROLE}, /* We must always support this option to make scripts like mysqltest easier to do */ {"innodb_data_file_path", required_argument, 0, @@ -2692,7 +2763,7 @@ static struct option long_options[] = { {"innodb_fast_shutdown", optional_argument, 0, OPT_INNODB_FAST_SHUTDOWN}, {"innodb_flush_method", required_argument, 0, - OPT_INNODB_UNIX_FILE_FLUSH_METHOD}, + OPT_INNODB_FLUSH_METHOD}, #endif {"help", no_argument, 0, '?'}, {"init-file", required_argument, 0, (int) OPT_INIT_FILE}, @@ -2714,10 +2785,15 @@ static struct option long_options[] = { {"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY}, {"master-retry-count", required_argument, 0, (int) OPT_MASTER_RETRY_COUNT}, {"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE}, + {"master-ssl", optional_argument, 0, (int) OPT_MASTER_SSL}, + {"master-ssl-key", optional_argument, 0, (int) OPT_MASTER_SSL_KEY}, + {"master-ssl-cert", optional_argument, 0, (int) OPT_MASTER_SSL_CERT}, {"myisam-recover", optional_argument, 0, (int) OPT_MYISAM_RECOVER}, {"memlock", no_argument, 0, (int) OPT_MEMLOCK}, - // needs to be available for the test case to pass in non-debugging mode - // is a no-op + /* + Option needs to be available for the test case to pass in non-debugging + mode. is a no-op. + */ {"disconnect-slave-event-count", required_argument, 0, (int) OPT_DISCONNECT_SLAVE_EVENT_COUNT}, {"abort-slave-event-count", required_argument, 0, @@ -2729,7 +2805,11 @@ static struct option long_options[] = { {"safemalloc-mem-limit", required_argument, 0, (int) OPT_SAFEMALLOC_MEM_LIMIT}, {"new", no_argument, 0, 'n'}, - {"old-protocol", no_argument, 0, 'o'}, +#ifdef NOT_YET + {"no-mix-table-types", no_argument, 0, (int) OPT_NO_MIX_TYPE}, +#endif + {"old-protocol", no_argument, 0, 'o'}, + {"old-rpl-compat", no_argument, 0, (int) OPT_OLD_RPL_COMPAT}, #ifdef ONE_THREAD {"one-thread", no_argument, 0, (int) OPT_ONE_THREAD}, #endif @@ -2738,24 +2818,33 @@ static struct option long_options[] = { {"replicate-do-db", required_argument, 0, (int) OPT_REPLICATE_DO_DB}, {"replicate-do-table", required_argument, 0, (int) OPT_REPLICATE_DO_TABLE}, - {"replicate-wild-do-table", required_argument, 0, + {"replicate-wild-do-table", required_argument, 0, (int) OPT_REPLICATE_WILD_DO_TABLE}, - {"replicate-ignore-db", required_argument, 0, + {"replicate-ignore-db", required_argument, 0, (int) OPT_REPLICATE_IGNORE_DB}, {"replicate-ignore-table", required_argument, 0, (int) OPT_REPLICATE_IGNORE_TABLE}, {"replicate-wild-ignore-table", required_argument, 0, (int) OPT_REPLICATE_WILD_IGNORE_TABLE}, - {"replicate-rewrite-db", required_argument, 0, + {"replicate-rewrite-db", required_argument, 0, (int) OPT_REPLICATE_REWRITE_DB}, + // In replication, we may need to tell the other servers how to connect + {"report-host", required_argument, 0, (int) OPT_REPORT_HOST}, + {"report-user", required_argument, 0, (int) OPT_REPORT_USER}, + {"report-password", required_argument, 0, (int) OPT_REPORT_PASSWORD}, + {"report-port", required_argument, 0, (int) OPT_REPORT_PORT}, + {"rpl-recovery-rank", required_argument, 0, (int) OPT_RPL_RECOVERY_RANK}, + {"relay-log", required_argument, 0, (int) OPT_RELAY_LOG}, + {"relay-log-index", required_argument, 0, (int) OPT_RELAY_LOG_INDEX}, {"safe-mode", no_argument, 0, (int) OPT_SAFE}, {"safe-show-database", no_argument, 0, (int) OPT_SAFE_SHOW_DB}, {"safe-user-create", no_argument, 0, (int) OPT_SAFE_USER_CREATE}, {"server-id", required_argument, 0, (int) OPT_SERVER_ID}, {"set-variable", required_argument, 0, 'O'}, + {"show-slave-auth-info", no_argument, 0, + (int) OPT_SHOW_SLAVE_AUTH_INFO}, {"skip-bdb", no_argument, 0, (int) OPT_BDB_SKIP}, {"skip-innodb", no_argument, 0, (int) OPT_INNODB_SKIP}, - {"skip-gemini", no_argument, 0, (int) OPT_GEMINI_SKIP}, {"skip-concurrent-insert", no_argument, 0, (int) OPT_SKIP_CONCURRENT_INSERT}, {"skip-delay-key-write", no_argument, 0, (int) OPT_SKIP_DELAY_KEY_WRITE}, {"skip-grant-tables", no_argument, 0, (int) OPT_SKIP_GRANT}, @@ -2770,7 +2859,10 @@ static struct option long_options[] = { {"skip-stack-trace", no_argument, 0, (int) OPT_SKIP_STACK_TRACE}, {"skip-symlink", no_argument, 0, (int) OPT_SKIP_SYMLINKS}, {"skip-thread-priority", no_argument, 0, (int) OPT_SKIP_PRIOR}, - {"slave-skip-errors", required_argument,0, + {"relay-log-info-file", required_argument, 0, + (int) OPT_RELAY_LOG_INFO_FILE}, + {"slave-load-tmpdir", required_argument, 0, (int) OPT_SLAVE_LOAD_TMPDIR}, + {"slave-skip-errors", required_argument, 0, (int) OPT_SLAVE_SKIP_ERRORS}, {"socket", required_argument, 0, (int) OPT_SOCKET}, {"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME}, @@ -2820,22 +2912,12 @@ CHANGEABLE_VAR changeable_vars[] = { DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1 }, { "flush_time", (long*) &flush_time, FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1 }, -#ifdef HAVE_GEMINI_DB - { "gemini_buffer_cache", (long*) &gemini_buffer_cache, - 128 * 8192, 16, LONG_MAX, 0, 1 }, - { "gemini_connection_limit", (long*) &gemini_connection_limit, - 100, 10, LONG_MAX, 0, 1 }, - { "gemini_io_threads", (long*) &gemini_io_threads, - 2, 0, 256, 0, 1 }, - { "gemini_log_cluster_size", (long*) &gemini_log_cluster_size, - 256 * 1024, 16 * 1024, LONG_MAX, 0, 1 }, - { "gemini_lock_table_size", (long*) &gemini_locktablesize, - 4096, 1024, LONG_MAX, 0, 1 }, - { "gemini_lock_wait_timeout",(long*) &gemini_lock_wait_timeout, - 10, 1, LONG_MAX, 0, 1 }, - { "gemini_spin_retries", (long*) &gemini_spin_retries, - 1, 0, LONG_MAX, 0, 1 }, -#endif + { "ft_min_word_len", (long*) &ft_min_word_len, + 4, 1, HA_FT_MAXLEN, 0, 1 }, + { "ft_max_word_len", (long*) &ft_max_word_len, + HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1 }, + { "ft_max_word_len_for_sort",(long*) &ft_max_word_len_for_sort, + 20, 4, HA_FT_MAXLEN, 0, 1 }, #ifdef HAVE_INNOBASE_DB {"innodb_mirrored_log_groups", (long*) &innobase_mirrored_log_groups, 1, 1, 10, 0, 1}, @@ -2897,6 +2979,11 @@ CHANGEABLE_VAR changeable_vars[] = { 0, 1, ~0L, 0, 1 }, { "max_write_lock_count", (long*) &max_write_lock_count, ~0L, 1, ~0L, 0, 1 }, + { "myisam_bulk_insert_tree_size", (long*) &myisam_bulk_insert_tree_size, + 8192*1024, 0, ~0L, 0, 1 }, + { "myisam_block_size", (long*) &opt_myisam_block_size, + MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, + 0, MI_MIN_KEY_BLOCK_LENGTH }, { "myisam_max_extra_sort_file_size", (long*) &myisam_max_extra_sort_file_size, (long) (MI_MAX_TEMP_LENGTH/(1024L*1024L)), 0, ~0L, 0, 1 }, @@ -2916,6 +3003,12 @@ 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 }, + { "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}, { "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, @@ -2967,22 +3060,16 @@ struct show_var_st init_vars[]= { {"delayed_queue_size", (char*) &delayed_queue_size, SHOW_LONG}, {"flush", (char*) &myisam_flush, SHOW_MY_BOOL}, {"flush_time", (char*) &flush_time, SHOW_LONG}, -#ifdef HAVE_GEMINI_DB - {"gemini_buffer_cache", (char*) &gemini_buffer_cache, SHOW_LONG}, - {"gemini_connection_limit", (char*) &gemini_connection_limit, SHOW_LONG}, - {"gemini_io_threads", (char*) &gemini_io_threads, SHOW_LONG}, - {"gemini_log_cluster_size", (char*) &gemini_log_cluster_size, SHOW_LONG}, - {"gemini_lock_table_size", (char*) &gemini_locktablesize, SHOW_LONG}, - {"gemini_lock_wait_timeout",(char*) &gemini_lock_wait_timeout, SHOW_LONG}, - {"gemini_recovery_options", (char*) &gemini_recovery_options_str, SHOW_CHAR_PTR}, - {"gemini_spin_retries", (char*) &gemini_spin_retries, SHOW_LONG}, -#endif + {"ft_min_word_len", (char*) &ft_min_word_len, SHOW_LONG}, + {"ft_max_word_len", (char*) &ft_max_word_len, SHOW_LONG}, + {"ft_max_word_len_for_sort",(char*) &ft_max_word_len_for_sort, SHOW_LONG}, + {"ft_boolean_syntax", (char*) ft_boolean_syntax, SHOW_CHAR}, {"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE}, - {"have_gemini", (char*) &have_gemini, SHOW_HAVE}, {"have_innodb", (char*) &have_innodb, SHOW_HAVE}, {"have_isam", (char*) &have_isam, SHOW_HAVE}, {"have_raid", (char*) &have_raid, SHOW_HAVE}, - {"have_openssl", (char*) &have_ssl, SHOW_HAVE}, + {"have_symlink", (char*) &have_symlink, SHOW_HAVE}, + {"have_openssl", (char*) &have_openssl, 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 }, @@ -3016,7 +3103,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}, @@ -3032,10 +3119,11 @@ struct show_var_st init_vars[]= { {"max_user_connections", (char*) &max_user_connections, SHOW_LONG}, {"max_tmp_tables", (char*) &max_tmp_tables, SHOW_LONG}, {"max_write_lock_count", (char*) &max_write_lock_count, SHOW_LONG}, + {"myisam_bulk_insert_tree_size", (char*) &myisam_bulk_insert_tree_size, SHOW_INT}, {"myisam_max_extra_sort_file_size", (char*) &myisam_max_extra_sort_file_size, SHOW_LONG}, {"myisam_max_sort_file_size",(char*) &myisam_max_sort_file_size, SHOW_LONG}, - {"myisam_recover_options", (char*) &myisam_recover_options, 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}, @@ -3050,7 +3138,11 @@ struct show_var_st init_vars[]= { {"protocol_version", (char*) &protocol_version, SHOW_INT}, {"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG}, {"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}, + {"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}, {"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}, @@ -3098,16 +3190,21 @@ struct show_var_st status_vars[]= { {"Com_create_index", (char*) (com_stat+(uint) SQLCOM_CREATE_INDEX),SHOW_LONG}, {"Com_create_table", (char*) (com_stat+(uint) SQLCOM_CREATE_TABLE),SHOW_LONG}, {"Com_delete", (char*) (com_stat+(uint) SQLCOM_DELETE),SHOW_LONG}, + {"Com_delete_multi", (char*) (com_stat+(uint) SQLCOM_DELETE_MULTI),SHOW_LONG}, {"Com_drop_db", (char*) (com_stat+(uint) SQLCOM_DROP_DB),SHOW_LONG}, {"Com_drop_function", (char*) (com_stat+(uint) SQLCOM_DROP_FUNCTION),SHOW_LONG}, {"Com_drop_index", (char*) (com_stat+(uint) SQLCOM_DROP_INDEX),SHOW_LONG}, {"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG}, {"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG}, {"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG}, + {"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG}, + {"Com_ha_open", (char*) (com_stat+(uint) SQLCOM_HA_OPEN),SHOW_LONG}, + {"Com_ha_read", (char*) (com_stat+(uint) SQLCOM_HA_READ),SHOW_LONG}, {"Com_insert", (char*) (com_stat+(uint) SQLCOM_INSERT),SHOW_LONG}, {"Com_insert_select", (char*) (com_stat+(uint) SQLCOM_INSERT_SELECT),SHOW_LONG}, {"Com_kill", (char*) (com_stat+(uint) SQLCOM_KILL),SHOW_LONG}, {"Com_load", (char*) (com_stat+(uint) SQLCOM_LOAD),SHOW_LONG}, + {"Com_load_master_data", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_DATA),SHOW_LONG}, {"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG}, {"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG}, {"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG}, @@ -3122,6 +3219,7 @@ struct show_var_st status_vars[]= { {"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG}, {"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG}, {"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG}, + {"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG}, {"Com_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG}, {"Com_show_create", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG}, {"Com_show_databases", (char*) (com_stat+(uint) SQLCOM_SHOW_DATABASES),SHOW_LONG}, @@ -3130,8 +3228,10 @@ struct show_var_st status_vars[]= { {"Com_show_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG}, {"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG}, {"Com_show_master_stat", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG}, + {"Com_show_new_master", (char*) (com_stat+(uint) SQLCOM_SHOW_NEW_MASTER),SHOW_LONG}, {"Com_show_open_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_OPEN_TABLES),SHOW_LONG}, {"Com_show_processlist", (char*) (com_stat+(uint) SQLCOM_SHOW_PROCESSLIST),SHOW_LONG}, + {"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG}, {"Com_show_slave_stat", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG}, {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG}, {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG}, @@ -3149,6 +3249,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}, @@ -3156,6 +3257,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}, @@ -3171,19 +3273,55 @@ 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}, + {"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}, + {"Qcache_not_cached", (char*) &query_cache.refused, SHOW_LONG}, + {"Qcache_free_memory", (char*) &query_cache.free_memory, + SHOW_LONG_CONST}, + {"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, + SHOW_LONG_CONST}, + {"Qcache_total_blocks", (char*) &query_cache.total_blocks, + SHOW_LONG_CONST}, + {"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}, {"Select_range", (char*) &select_range_count, SHOW_LONG}, {"Select_range_check", (char*) &select_range_check_count, SHOW_LONG}, {"Select_scan", (char*) &select_scan_count, SHOW_LONG}, - {"Slave_running", (char*) &slave_running, SHOW_BOOL}, {"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG}, + {"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING}, {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG}, {"Slow_queries", (char*) &long_query_count, SHOW_LONG}, {"Sort_merge_passes", (char*) &filesort_merge_passes, SHOW_LONG}, {"Sort_range", (char*) &filesort_range_count, SHOW_LONG}, {"Sort_rows", (char*) &filesort_rows, SHOW_LONG}, {"Sort_scan", (char*) &filesort_scan_count, SHOW_LONG}, +#ifdef HAVE_OPENSSL + {"ssl_accepts", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT}, + {"ssl_finished_accepts", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT_GOOD}, + {"ssl_finished_connects", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT_GOOD}, + {"ssl_accept_renegotiates", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE}, + {"ssl_connect_renegotiates", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE}, + {"ssl_callback_cache_hits", (char*) 0, SHOW_SSL_CTX_SESS_CB_HITS}, + {"ssl_session_cache_hits", (char*) 0, SHOW_SSL_CTX_SESS_HITS}, + {"ssl_session_cache_misses", (char*) 0, SHOW_SSL_CTX_SESS_MISSES}, + {"ssl_session_cache_timeouts", (char*) 0, SHOW_SSL_CTX_SESS_TIMEOUTS}, + {"ssl_used_session_cache_entries",(char*) 0, SHOW_SSL_CTX_SESS_NUMBER}, + {"ssl_client_connects", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT}, + {"ssl_session_cache_overflows", (char*) 0, SHOW_SSL_CTX_SESS_CACHE_FULL}, + {"ssl_session_cache_size", (char*) 0, SHOW_SSL_CTX_SESS_GET_CACHE_SIZE}, + {"ssl_session_cache_mode", (char*) 0, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE}, + {"ssl_sessions_reused", (char*) 0, SHOW_SSL_SESSION_REUSED}, + {"ssl_ctx_verify_mode", (char*) 0, SHOW_SSL_CTX_GET_VERIFY_MODE}, + {"ssl_ctx_verify_depth", (char*) 0, SHOW_SSL_CTX_GET_VERIFY_DEPTH}, + {"ssl_verify_mode", (char*) 0, SHOW_SSL_GET_VERIFY_MODE}, + {"ssl_verify_depth", (char*) 0, SHOW_SSL_GET_VERIFY_DEPTH}, + {"ssl_version", (char*) 0, SHOW_SSL_GET_VERSION}, + {"ssl_cipher", (char*) 0, SHOW_SSL_GET_CIPHER}, + {"ssl_cipher_list", (char*) 0, SHOW_SSL_GET_CIPHER_LIST}, + {"ssl_default_timeout", (char*) 0, SHOW_SSL_GET_DEFAULT_TIMEOUT}, +#endif /* HAVE_OPENSSL */ {"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG}, {"Table_locks_waited", (char*) &locks_waited, SHOW_LONG}, {"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_CONST}, @@ -3204,7 +3342,7 @@ static void use_help(void) { print_version(); printf("Use '--help' or '--no-defaults --help' for a list of available options\n"); -} +} static void usage(void) { @@ -3244,8 +3382,15 @@ Starts the MySQL server\n"); Set the default table type for tables\n\ --delay-key-write-for-all-tables\n\ Don't flush key buffers between writes for any MyISAM\n\ - table\n\ + table\n"); +#ifdef HAVE_OPENSSL + puts("\ + --des-key-file Load keys for des_encrypt() and des_encrypt\n\ + from given file"); +#endif /* HAVE_OPENSSL */ + puts("\ --enable-locking Enable system locking\n\ + --enable-pstack Print a symbolic stack trace on failure\n\ -T, --exit-info Used for debugging; Use at your own risk!\n\ --flush Flush tables to disk between SQL commands\n\ -?, --help Display this help and exit\n\ @@ -3278,18 +3423,17 @@ Starts the MySQL server\n"); puts("\ -O, --set-variable var=option\n\ Give a variable an value. --help lists variables\n\ - -Sg, --skip-grant-tables\n\ - Start without grant tables. This gives all users\n\ - FULL ACCESS to all tables!\n\ --safe-mode Skip some optimize stages (for testing)\n\ --safe-show-database Don't show databases for which the user has no\n\ privileges\n\ - --safe-user-create Don't new users cretaion without privileges to the\n\ - mysql.user table\n\ + --safe-user-create Don't allow new user creation by the user who has\n\ + no write privileges to the mysql.user table\n\ --skip-concurrent-insert\n\ Don't use concurrent insert with MyISAM\n\ --skip-delay-key-write\n\ Ignore the delay_key_write option for all tables\n\ + --skip-grant-tables Start without grant tables. This gives all users\n\ + FULL ACCESS to all tables!\n\ --skip-host-cache Don't cache host names\n\ --skip-locking Don't use system locking. To use isamchk one has\n\ to shut down the server.\n\ @@ -3300,6 +3444,7 @@ Starts the MySQL server\n"); /* We have to break the string here because of VC++ limits */ puts("\ --skip-stack-trace Don't print a stack trace on failure\n\ + --skip-symlink Don't allow symlinking of tables\n\ --skip-show-database Don't allow 'SHOW DATABASE' commands\n\ --skip-thread-priority\n\ Don't give threads different priorities.\n\ @@ -3307,7 +3452,8 @@ Starts the MySQL server\n"); -t, --tmpdir=path Path for temporary files\n\ --sql-mode=option[,option[,option...]] where option can be one of:\n\ REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES,\n\ - IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY.\n\ + IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY,\n\ + NO_UNSIGNED_SUBTRACTION.\n\ --transaction-isolation\n\ Default transaction isolation level\n\ --temp-pool Use a pool of temporary files\n\ @@ -3341,16 +3487,6 @@ Starts the MySQL server\n"); --skip-bdb Don't use berkeley db (will save memory)\n\ "); #endif /* HAVE_BERKELEY_DB */ -#ifdef HAVE_GEMINI_DB - puts("\ - --gemini-recovery=mode Set Crash Recovery operating mode\n\ - (FULL, NONE, FORCE - default FULL)\n\ - --gemini-flush-log-at-commit\n\ - Every commit forces a write to the reovery log\n\ - --gemini-unbuffered-io Use unbuffered i/o\n\ - --skip-gemini Don't use gemini (will save memory)\n\ -"); -#endif #ifdef HAVE_INNOBASE_DB puts("\ --innodb_data_home_dir=dir The common part for Innodb table spaces\n\ @@ -3438,7 +3574,7 @@ static void set_options(void) #endif #if defined( HAVE_mit_thread ) || defined( __WIN__ ) || defined( HAVE_LINUXTHREADS ) - my_disable_locking = 1; + my_disable_locking=myisam_single_user= 1; #endif my_bind_addr = htonl( INADDR_ANY ); } @@ -3450,6 +3586,16 @@ static void get_options(int argc,char **argv) int c,option_index=0; myisam_delay_key_write=1; // Allow use of this +#ifndef HAVE_purify + my_use_symdir=1; // Use internal symbolic links +#else + /* Symlinks gives too many warnings with purify */ + my_disable_symlinks=1; + my_use_symdir=0; + have_symlink=SHOW_OPTION_DISABLED; +#endif + + optind = 0; // setup in case getopt() was called previously while ((c=getopt_long(argc,argv,"ab:C:h:#::T::?l::L:O:P:sS::t:u:noVvWI?", long_options, &option_index)) != EOF) { @@ -3509,6 +3655,18 @@ static void get_options(int argc,char **argv) safemalloc_mem_limit = atoi(optarg); #endif break; + case OPT_RPL_RECOVERY_RANK: + rpl_recovery_rank=atoi(optarg); + break; + case OPT_SLAVE_LOAD_TMPDIR: + slave_load_tmpdir = my_strdup(optarg, MYF(MY_FAE)); + break; + case OPT_OLD_RPL_COMPAT: + opt_old_rpl_compat = 1; + break; + case OPT_SHOW_SLAVE_AUTH_INFO: + opt_show_slave_auth_info = 1; + break; case OPT_SOCKET: mysql_unix_port= optarg; break; @@ -3541,20 +3699,6 @@ static void get_options(int argc,char **argv) test_flags= optarg ? (uint) atoi(optarg) : 0; opt_endinfo=1; break; - case 'S': - if (!optarg) - opt_specialflag|= SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE; - else if (!strcmp(optarg,"l")) - my_disable_locking=1; - else if (!strcmp(optarg,"g")) - opt_noacl=1; - else - { - fprintf(stderr,"%s: Unrecognized option: %s\n",my_progname,optarg); - use_help(); - exit(1); - } - break; case (int) OPT_BIG_TABLES: thd_startup_options|=OPTION_BIG_TABLES; break; @@ -3567,6 +3711,14 @@ static void get_options(int argc,char **argv) opt_update_log=1; opt_update_logname=optarg; // Use hostname.# if null break; + case (int) OPT_RELAY_LOG_INDEX: + opt_relaylog_index_name = optarg; + break; + case (int) OPT_RELAY_LOG: + x_free(opt_relay_logname); + if (optarg && optarg[0]) + opt_relay_logname=my_strdup(optarg,MYF(0)); + break; case (int) OPT_BIN_LOG_INDEX: opt_binlog_index_name = optarg; break; @@ -3602,6 +3754,17 @@ static void get_options(int argc,char **argv) opt_log_slave_updates = 1; break; + case (int) OPT_INIT_RPL_ROLE: + { + int role; + if ((role=find_type(optarg, &rpl_role_typelib, 2)) <= 0) + { + fprintf(stderr, "Unknown replication role: %s\n", optarg); + exit(1); + } + rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE; + break; + } case (int)OPT_REPLICATE_IGNORE_DB: { i_string *db = new i_string(optarg); @@ -3721,12 +3884,14 @@ static void get_options(int argc,char **argv) break; case (int) OPT_SKIP_NEW: opt_specialflag|= SPECIAL_NO_NEW_FUNC; - default_table_type=DB_TYPE_ISAM; myisam_delay_key_write=0; myisam_concurrent_insert=0; myisam_recover_options= HA_RECOVER_NONE; my_disable_symlinks=1; + my_use_symdir=0; + have_symlink=SHOW_OPTION_DISABLED; ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED; + query_cache_size=0; break; case (int) OPT_SAFE: opt_specialflag|= SPECIAL_SAFE_MODE; @@ -3744,13 +3909,13 @@ static void get_options(int argc,char **argv) opt_noacl=1; break; case (int) OPT_SKIP_LOCK: - my_disable_locking=1; + my_disable_locking=myisam_single_user= 1; break; case (int) OPT_SKIP_HOST_CACHE: opt_specialflag|= SPECIAL_NO_HOST_CACHE; break; case (int) OPT_ENABLE_LOCK: - my_disable_locking=0; + my_disable_locking=myisam_single_user=0; break; case (int) OPT_USE_LOCKING: my_disable_locking=0; @@ -3761,6 +3926,9 @@ static void get_options(int argc,char **argv) case (int) OPT_LONG_FORMAT: opt_specialflag|=SPECIAL_LONG_LOG_FORMAT; break; + case (int) OPT_NO_MIX_TYPE: + opt_no_mix_types = 1; + break; case (int) OPT_SKIP_NETWORKING: opt_disable_networking=1; mysql_port=0; @@ -3784,6 +3952,8 @@ static void get_options(int argc,char **argv) break; case (int) OPT_SKIP_SYMLINKS: my_disable_symlinks=1; + my_use_symdir=0; + have_symlink=SHOW_OPTION_DISABLED; break; case (int) OPT_BIND_ADDRESS: if (optarg && isdigit(optarg[0])) @@ -3832,7 +4002,10 @@ static void get_options(int argc,char **argv) break; #endif case (int) OPT_FLUSH: - nisam_flush=myisam_flush=1; +#ifdef HAVE_ISAM + nisam_flush=1; +#endif + myisam_flush=1; flush_time=0; // No auto flush break; case OPT_LOW_PRIORITY_UPDATES: @@ -3873,6 +4046,11 @@ static void get_options(int argc,char **argv) charsets_dir = mysql_charsets_dir; break; #include "sslopt-case.h" + case OPT_DES_KEY_FILE: +#ifdef HAVE_OPENSSL + des_key_file=optarg; +#endif + break; case OPT_TX_ISOLATION: { int type; @@ -3928,27 +4106,6 @@ static void get_options(int argc,char **argv) have_berkeley_db=SHOW_OPTION_DISABLED; #endif break; - case OPT_GEMINI_SKIP: -#ifdef HAVE_GEMINI_DB - gemini_skip=1; - have_gemini=SHOW_OPTION_DISABLED; - break; - case OPT_GEMINI_RECOVER: - gemini_recovery_options_str=optarg; - if ((gemini_recovery_options= - find_bit_type(optarg, &gemini_recovery_typelib)) == ~(ulong) 0) - { - fprintf(stderr, "Unknown option to gemini-recovery: %s\n",optarg); - exit(1); - } - break; - case OPT_GEMINI_FLUSH_LOG: - gemini_options |= GEMOPT_FLUSH_LOG; - break; - case OPT_GEMINI_UNBUFFERED_IO: - gemini_options |= GEMOPT_UNBUFFERED_IO; -#endif - break; case OPT_INNODB_SKIP: #ifdef HAVE_INNOBASE_DB innodb_skip=1; @@ -3979,13 +4136,16 @@ static void get_options(int argc,char **argv) case OPT_INNODB_FAST_SHUTDOWN: innobase_fast_shutdown= optarg ? test(atoi(optarg)) : 1; break; - case OPT_INNODB_UNIX_FILE_FLUSH_METHOD: + case OPT_INNODB_FLUSH_METHOD: innobase_unix_file_flush_method=optarg; break; #endif /* HAVE_INNOBASE_DB */ + case OPT_DO_PSTACK: + opt_do_pstack = 1; + break; case OPT_MYISAM_RECOVER: { - if (!optarg) + if (!optarg || !optarg[0]) { myisam_recover_options= HA_RECOVER_DEFAULT; myisam_recover_options_str= myisam_recover_typelib.type_names[0]; @@ -4029,9 +4189,33 @@ static void get_options(int argc,char **argv) case OPT_MASTER_INFO_FILE: master_info_file=optarg; break; + case OPT_RELAY_LOG_INFO_FILE: + relay_log_info_file=optarg; + break; case OPT_MASTER_PORT: master_port= atoi(optarg); break; + case OPT_MASTER_SSL: + master_ssl=atoi(optarg); + break; + case OPT_MASTER_SSL_KEY: + master_ssl_key=optarg; + break; + case OPT_MASTER_SSL_CERT: + master_ssl_cert=optarg; + break; + case OPT_REPORT_HOST: + report_host=optarg; + break; + case OPT_REPORT_USER: + report_user=optarg; + break; + case OPT_REPORT_PASSWORD: + report_password=optarg; + break; + case OPT_REPORT_PORT: + report_port= atoi(optarg); + break; case OPT_MASTER_CONNECT_RETRY: master_connect_retry= atoi(optarg); break; @@ -4055,7 +4239,7 @@ static void get_options(int argc,char **argv) exit(1); } } - // Skipp empty arguments (from shell) + // Skip empty arguments (from shell) while (argc != optind && !argv[optind][0]) optind++; if (argc != optind) @@ -4064,12 +4248,19 @@ static void get_options(int argc,char **argv) use_help(); exit(1); } + optind = 0; // setup so that getopt_long() can be called again fix_paths(); default_table_type_name=ha_table_typelib.type_names[default_table_type-1]; default_tx_isolation_name=tx_isolation_typelib.type_names[default_tx_isolation]; /* To be deleted in MySQL 4.0 */ if (!record_rnd_cache_size) record_rnd_cache_size=my_default_record_cache_size; + + /* Fix variables that are base 1024*1024 */ + myisam_max_temp_length= (my_off_t) min(((ulonglong) myisam_max_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); + myisam_max_extra_temp_length= (my_off_t) min(((ulonglong) myisam_max_extra_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); + + myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size); } @@ -4087,12 +4278,34 @@ static char *get_relative_path(const char *path) } +/* + Fix filename and replace extension where 'dir' is relative to + mysql_real_data_home. + Return 1 if len(path) > FN_REFLEN +*/ + +bool +fn_format_relative_to_data_home(my_string to, const char *name, + const char *dir, const char *extension) +{ + char tmp_path[FN_REFLEN]; + if (!test_if_hard_path(dir)) + { + strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home, + dir, NullS); + dir=tmp_path; + } + return !fn_format(to, name, dir, extension, + MY_REPLACE_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH); +} + + static void fix_paths(void) { (void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks - convert_dirname(mysql_home); - convert_dirname(mysql_real_data_home); - convert_dirname(language); + convert_dirname(mysql_home,mysql_home,NullS); + convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS); + convert_dirname(language,language,NullS); (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home); (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home); @@ -4102,7 +4315,7 @@ static void fix_paths(void) strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */ else strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS); - convert_dirname(buff); + convert_dirname(buff,buff,NullS); (void) my_load_path(language,language,buff); /* If --character-sets-dir isn't given, use shared library dir */ @@ -4117,11 +4330,16 @@ static void fix_paths(void) char *tmp= (char*) my_malloc(FN_REFLEN,MYF(MY_FAE)); if (tmp) { - strmake(tmp, mysql_tmpdir, FN_REFLEN-1); - mysql_tmpdir=tmp; - convert_dirname(mysql_tmpdir); - mysql_tmpdir=(char*) my_realloc(mysql_tmpdir,(uint) strlen(mysql_tmpdir)+1, + char *end=convert_dirname(tmp, mysql_tmpdir, NullS); + + mysql_tmpdir=(char*) my_realloc(tmp,(uint) (end-tmp)+1, MYF(MY_HOLD_ON_ERROR)); + allocated_mysql_tmpdir=mysql_tmpdir; + } + if (!slave_load_tmpdir) + { + // no need to check return value, if we fail, my_malloc() never returns + slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE)); } } @@ -4140,16 +4358,17 @@ static uint set_maximum_open_files(uint max_file_limit) rlimit.rlim_cur=rlimit.rlim_max=max_file_limit; if (setrlimit(RLIMIT_NOFILE,&rlimit)) { - sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %ld", - old_cur); /* purecov: inspected */ + sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)", + old_cur, max_file_limit); /* purecov: inspected */ max_file_limit=old_cur; } else { (void) getrlimit(RLIMIT_NOFILE,&rlimit); if ((uint) rlimit.rlim_cur != max_file_limit) - sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld", - (ulong) rlimit.rlim_cur); /* purecov: inspected */ + sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)", + (ulong) rlimit.rlim_cur, + max_file_limit); /* purecov: inspected */ max_file_limit=rlimit.rlim_cur; } } @@ -4197,6 +4416,7 @@ static ulong find_bit_type(const char *x, TYPELIB *bit_lib) DBUG_PRINT("enter",("x: '%s'",x)); found=0; + found_end= 0; pos=(my_string) x; while (*pos == ' ') pos++; found_end= *pos == 0; @@ -4205,7 +4425,7 @@ static ulong find_bit_type(const char *x, TYPELIB *bit_lib) if (!*(end=strcend(pos,','))) /* Let end point at fieldend */ { while (end > pos && end[-1] == ' ') - end--; /* Skipp end-space */ + end--; /* Skip end-space */ found_end=1; } found_int=0; found_count=0; |