00001 /* Copyright (C) 2000-2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #include "mysql_priv.h" 00018 #include <m_ctype.h> 00019 #include <my_dir.h> 00020 #include "slave.h" 00021 #include "sql_repl.h" 00022 #include "rpl_filter.h" 00023 #include "repl_failsafe.h" 00024 #include "stacktrace.h" 00025 #include "mysqld_suffix.h" 00026 #include "mysys_err.h" 00027 #include "events.h" 00028 00029 #include "ha_myisam.h" 00030 00031 #ifdef HAVE_ROW_BASED_REPLICATION 00032 #include "rpl_injector.h" 00033 #endif 00034 00035 #ifdef WITH_INNOBASE_STORAGE_ENGINE 00036 #define OPT_INNODB_DEFAULT 1 00037 #else 00038 #define OPT_INNODB_DEFAULT 0 00039 #endif 00040 #define OPT_BDB_DEFAULT 0 00041 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 00042 #define OPT_NDBCLUSTER_DEFAULT 0 00043 #if defined(NOT_ENOUGH_TESTED) \ 00044 && defined(NDB_SHM_TRANSPORTER) && MYSQL_VERSION_ID >= 50000 00045 #define OPT_NDB_SHM_DEFAULT 1 00046 #else 00047 #define OPT_NDB_SHM_DEFAULT 0 00048 #endif 00049 #else 00050 #define OPT_NDBCLUSTER_DEFAULT 0 00051 #endif 00052 00053 #include <thr_alarm.h> 00054 #include <ft_global.h> 00055 #include <errmsg.h> 00056 #include "sp_rcontext.h" 00057 #include "sp_cache.h" 00058 00059 #define mysqld_charset &my_charset_latin1 00060 00061 #ifndef DBUG_OFF 00062 #define ONE_THREAD 00063 #endif 00064 00065 #ifdef HAVE_purify 00066 #define IF_PURIFY(A,B) (A) 00067 #else 00068 #define IF_PURIFY(A,B) (B) 00069 #endif 00070 00071 /* stack traces are only supported on linux intel */ 00072 #if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK) 00073 #define HAVE_STACK_TRACE_ON_SEGV 00074 #include "../pstack/pstack.h" 00075 char pstack_file_name[80]; 00076 #endif /* __linux__ */ 00077 00078 /* We have HAVE_purify below as this speeds up the shutdown of MySQL */ 00079 00080 #if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_purify) && defined(__linux__) 00081 #define HAVE_CLOSE_SERVER_SOCK 1 00082 #endif 00083 00084 extern "C" { // Because of SCO 3.2V4.2 00085 #include <errno.h> 00086 #include <sys/stat.h> 00087 #ifndef __GNU_LIBRARY__ 00088 #define __GNU_LIBRARY__ // Skip warnings in getopt.h 00089 #endif 00090 #include <my_getopt.h> 00091 #ifdef HAVE_SYSENT_H 00092 #include <sysent.h> 00093 #endif 00094 #ifdef HAVE_PWD_H 00095 #include <pwd.h> // For getpwent 00096 #endif 00097 #ifdef HAVE_GRP_H 00098 #include <grp.h> 00099 #endif 00100 #include <my_net.h> 00101 00102 #if !defined(__WIN__) 00103 # ifndef __NETWARE__ 00104 #include <sys/resource.h> 00105 # endif /* __NETWARE__ */ 00106 #ifdef HAVE_SYS_UN_H 00107 # include <sys/un.h> 00108 #endif 00109 #include <netdb.h> 00110 #ifdef HAVE_SELECT_H 00111 # include <select.h> 00112 #endif 00113 #ifdef HAVE_SYS_SELECT_H 00114 #include <sys/select.h> 00115 #endif 00116 #include <sys/utsname.h> 00117 #endif /* __WIN__ */ 00118 00119 #include <my_libwrap.h> 00120 00121 #ifdef HAVE_SYS_MMAN_H 00122 #include <sys/mman.h> 00123 #endif 00124 00125 #ifdef __NETWARE__ 00126 #define zVOLSTATE_ACTIVE 6 00127 #define zVOLSTATE_DEACTIVE 2 00128 #define zVOLSTATE_MAINTENANCE 3 00129 00130 #undef __event_h__ 00131 #include <../include/event.h> 00132 /* 00133 This #undef exists here because both libc of NetWare and MySQL have 00134 files named event.h which causes compilation errors. 00135 */ 00136 00137 #include <nks/netware.h> 00138 #include <nks/vm.h> 00139 #include <library.h> 00140 #include <monitor.h> 00141 #include <zOmni.h> //For NEB 00142 #include <neb.h> //For NEB 00143 #include <nebpub.h> //For NEB 00144 #include <zEvent.h> //For NSS event structures 00145 #include <zPublics.h> 00146 00147 static void *neb_consumer_id= NULL; //For storing NEB consumer id 00148 static char datavolname[256]= {0}; 00149 static VolumeID_t datavolid; 00150 static event_handle_t eh; 00151 static Report_t ref; 00152 static void *refneb= NULL; 00153 my_bool event_flag= FALSE; 00154 static int volumeid= -1; 00155 00156 /* NEB event callback */ 00157 unsigned long neb_event_callback(struct EventBlock *eblock); 00158 static void registerwithneb(); 00159 static void getvolumename(); 00160 static void getvolumeID(BYTE *volumeName); 00161 #endif /* __NETWARE__ */ 00162 00163 00164 #ifdef _AIX41 00165 int initgroups(const char *,unsigned int); 00166 #endif 00167 00168 #if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) 00169 #include <ieeefp.h> 00170 #ifdef HAVE_FP_EXCEPT // Fix type conflict 00171 typedef fp_except fp_except_t; 00172 #endif 00173 00174 /* We can't handle floating point exceptions with threads, so disable 00175 this on freebsd 00176 */ 00177 00178 inline void reset_floating_point_exceptions() 00179 { 00180 /* Don't fall for overflow, underflow,divide-by-zero or loss of precision */ 00181 #if defined(__i386__) 00182 fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ | 00183 FP_X_IMP)); 00184 #else 00185 fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | 00186 FP_X_IMP)); 00187 #endif 00188 } 00189 #else 00190 #define reset_floating_point_exceptions() 00191 #endif /* __FreeBSD__ && HAVE_IEEEFP_H */ 00192 00193 } /* cplusplus */ 00194 00195 00196 #if defined(HAVE_LINUXTHREADS) 00197 #define THR_KILL_SIGNAL SIGINT 00198 #else 00199 #define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads 00200 #endif 00201 #define MYSQL_KILL_SIGNAL SIGTERM 00202 00203 #ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R 00204 #include <sys/types.h> 00205 #else 00206 #include <my_pthread.h> // For thr_setconcurency() 00207 #endif 00208 00209 #ifdef SOLARIS 00210 extern "C" int gethostname(char *name, int namelen); 00211 #endif 00212 00213 00214 /* Constants */ 00215 00216 const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"}; 00217 static const char *sql_mode_names[]= 00218 { 00219 "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", 00220 "?", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION", 00221 "NO_DIR_IN_CREATE", 00222 "POSTGRESQL", "ORACLE", "MSSQL", "DB2", "MAXDB", "NO_KEY_OPTIONS", 00223 "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40", "ANSI", 00224 "NO_AUTO_VALUE_ON_ZERO", "NO_BACKSLASH_ESCAPES", "STRICT_TRANS_TABLES", 00225 "STRICT_ALL_TABLES", 00226 "NO_ZERO_IN_DATE", "NO_ZERO_DATE", "ALLOW_INVALID_DATES", 00227 "ERROR_FOR_DIVISION_BY_ZERO", 00228 "TRADITIONAL", "NO_AUTO_CREATE_USER", "HIGH_NOT_PRECEDENCE", 00229 "NO_ENGINE_SUBSTITUTION", 00230 NullS 00231 }; 00232 static const unsigned int sql_mode_names_len[]= 00233 { 00234 /*REAL_AS_FLOAT*/ 13, 00235 /*PIPES_AS_CONCAT*/ 15, 00236 /*ANSI_QUOTES*/ 11, 00237 /*IGNORE_SPACE*/ 12, 00238 /*?*/ 1, 00239 /*ONLY_FULL_GROUP_BY*/ 18, 00240 /*NO_UNSIGNED_SUBTRACTION*/ 23, 00241 /*NO_DIR_IN_CREATE*/ 16, 00242 /*POSTGRESQL*/ 10, 00243 /*ORACLE*/ 6, 00244 /*MSSQL*/ 5, 00245 /*DB2*/ 3, 00246 /*MAXDB*/ 5, 00247 /*NO_KEY_OPTIONS*/ 14, 00248 /*NO_TABLE_OPTIONS*/ 16, 00249 /*NO_FIELD_OPTIONS*/ 16, 00250 /*MYSQL323*/ 8, 00251 /*MYSQL40*/ 7, 00252 /*ANSI*/ 4, 00253 /*NO_AUTO_VALUE_ON_ZERO*/ 21, 00254 /*NO_BACKSLASH_ESCAPES*/ 20, 00255 /*STRICT_TRANS_TABLES*/ 19, 00256 /*STRICT_ALL_TABLES*/ 17, 00257 /*NO_ZERO_IN_DATE*/ 15, 00258 /*NO_ZERO_DATE*/ 12, 00259 /*ALLOW_INVALID_DATES*/ 19, 00260 /*ERROR_FOR_DIVISION_BY_ZERO*/ 26, 00261 /*TRADITIONAL*/ 11, 00262 /*NO_AUTO_CREATE_USER*/ 19, 00263 /*HIGH_NOT_PRECEDENCE*/ 19, 00264 /*NO_ENGINE_SUBSTITUTION*/ 22 00265 }; 00266 TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"", 00267 sql_mode_names, 00268 (unsigned int *)sql_mode_names_len }; 00269 static const char *tc_heuristic_recover_names[]= 00270 { 00271 "COMMIT", "ROLLBACK", NullS 00272 }; 00273 static TYPELIB tc_heuristic_recover_typelib= 00274 { 00275 array_elements(tc_heuristic_recover_names)-1,"", 00276 tc_heuristic_recover_names, NULL 00277 }; 00278 const char *first_keyword= "first", *binary_keyword= "BINARY"; 00279 const char *my_localhost= "localhost", *delayed_user= "DELAYED"; 00280 #if SIZEOF_OFF_T > 4 && defined(BIG_TABLES) 00281 #define GET_HA_ROWS GET_ULL 00282 #else 00283 #define GET_HA_ROWS GET_ULONG 00284 #endif 00285 00286 bool opt_large_files= sizeof(my_off_t) > 4; 00287 00288 /* 00289 Used with --help for detailed option 00290 */ 00291 static my_bool opt_help= 0, opt_verbose= 0; 00292 00293 arg_cmp_func Arg_comparator::comparator_matrix[5][2] = 00294 {{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string}, 00295 {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real}, 00296 {&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int}, 00297 {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}, 00298 {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}}; 00299 00300 const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS}; 00301 static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 }; 00302 TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"", 00303 log_output_names, 00304 (unsigned int *) log_output_names_len}; 00305 00306 /* static variables */ 00307 00308 /* the default log output is log tables */ 00309 static bool lower_case_table_names_used= 0; 00310 static bool volatile select_thread_in_use, signal_thread_in_use; 00311 static bool volatile ready_to_exit; 00312 static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0; 00313 static my_bool opt_isam, opt_ndbcluster, opt_merge; 00314 static my_bool opt_short_log_format= 0; 00315 static uint kill_cached_threads, wake_thread; 00316 static ulong killed_threads, thread_created; 00317 static ulong max_used_connections; 00318 static ulong my_bind_addr; /* the address we bind to */ 00319 static volatile ulong cached_thread_count= 0; 00320 static const char *sql_mode_str= "OFF"; 00321 static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; 00322 static char *opt_init_slave, *language_ptr, *opt_init_connect; 00323 static char *default_character_set_name; 00324 static char *character_set_filesystem_name; 00325 static char *my_bind_addr_str; 00326 static char *default_collation_name; 00327 static char *default_storage_engine_str; 00328 static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; 00329 static char mysql_data_home_buff[2]; 00330 static struct passwd *user_info; 00331 static I_List<THD> thread_cache; 00332 00333 static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; 00334 00335 /* Global variables */ 00336 00337 bool opt_update_log, opt_bin_log; 00338 my_bool opt_log, opt_slow_log; 00339 ulong log_output_options; 00340 my_bool opt_log_queries_not_using_indexes= 0; 00341 bool opt_error_log= IF_WIN(1,0); 00342 bool opt_disable_networking=0, opt_skip_show_db=0; 00343 my_bool opt_character_set_client_handshake= 1; 00344 bool server_id_supplied = 0; 00345 bool opt_endinfo,using_udf_functions; 00346 my_bool locked_in_memory; 00347 bool opt_using_transactions, using_update_log; 00348 bool volatile abort_loop; 00349 bool volatile shutdown_in_progress, grant_option; 00350 00351 my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted 00352 my_bool opt_reckless_slave = 0; 00353 my_bool opt_enable_named_pipe= 0; 00354 my_bool opt_local_infile, opt_slave_compressed_protocol; 00355 my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; 00356 my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; 00357 my_bool opt_log_slave_updates= 0; 00358 my_bool opt_innodb; 00359 #ifdef WITH_INNOBASE_STORAGE_ENGINE 00360 extern SHOW_VAR innodb_status_variables[]; 00361 extern uint innobase_init_flags, innobase_lock_type; 00362 extern uint innobase_flush_log_at_trx_commit; 00363 extern ulong innobase_cache_size, innobase_fast_shutdown; 00364 extern ulong innobase_large_page_size; 00365 extern char *innobase_home, *innobase_tmpdir, *innobase_logdir; 00366 extern long innobase_lock_scan_time; 00367 extern long innobase_mirrored_log_groups, innobase_log_files_in_group; 00368 extern longlong innobase_log_file_size; 00369 extern long innobase_log_buffer_size; 00370 extern longlong innobase_buffer_pool_size; 00371 extern long innobase_additional_mem_pool_size; 00372 extern long innobase_buffer_pool_awe_mem_mb; 00373 extern long innobase_file_io_threads, innobase_lock_wait_timeout; 00374 extern long innobase_force_recovery; 00375 extern long innobase_open_files; 00376 extern char *innobase_data_home_dir, *innobase_data_file_path; 00377 extern char *innobase_log_group_home_dir, *innobase_log_arch_dir; 00378 extern char *innobase_unix_file_flush_method; 00379 /* The following variables have to be my_bool for SHOW VARIABLES to work */ 00380 extern my_bool innobase_log_archive, 00381 innobase_use_doublewrite, 00382 innobase_use_checksums, 00383 innobase_use_large_pages, 00384 innobase_use_native_aio, 00385 innobase_file_per_table, innobase_locks_unsafe_for_binlog, 00386 innobase_create_status_file; 00387 extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before 00388 calling innobase_end() if you want 00389 InnoDB to shut down without 00390 flushing the buffer pool: this 00391 is equivalent to a 'crash' */ 00392 extern "C" { 00393 extern ulong srv_max_buf_pool_modified_pct; 00394 extern ulong srv_max_purge_lag; 00395 extern ulong srv_auto_extend_increment; 00396 extern ulong srv_n_spin_wait_rounds; 00397 extern ulong srv_n_free_tickets_to_enter; 00398 extern ulong srv_thread_sleep_delay; 00399 extern ulong srv_thread_concurrency; 00400 extern ulong srv_commit_concurrency; 00401 extern ulong srv_flush_log_at_trx_commit; 00402 } 00403 #endif 00404 00405 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 00406 const char *opt_ndbcluster_connectstring= 0; 00407 const char *opt_ndb_connectstring= 0; 00408 char opt_ndb_constrbuf[1024]; 00409 unsigned opt_ndb_constrbuf_len= 0; 00410 my_bool opt_ndb_shm, opt_ndb_optimized_node_selection; 00411 ulong opt_ndb_cache_check_time; 00412 const char *opt_ndb_mgmd; 00413 ulong opt_ndb_nodeid; 00414 ulong ndb_extra_logging; 00415 #ifdef HAVE_NDB_BINLOG 00416 ulong ndb_report_thresh_binlog_epoch_slip; 00417 ulong ndb_report_thresh_binlog_mem_usage; 00418 #endif 00419 00420 extern SHOW_VAR ndb_status_variables[]; 00421 extern const char *ndb_distribution_names[]; 00422 extern TYPELIB ndb_distribution_typelib; 00423 extern const char *opt_ndb_distribution; 00424 extern enum ndb_distribution opt_ndb_distribution_id; 00425 #endif 00426 my_bool opt_readonly, use_temp_pool, relay_log_purge; 00427 my_bool opt_sync_frm, opt_allow_suspicious_udfs; 00428 my_bool opt_secure_auth= 0; 00429 my_bool opt_log_slow_admin_statements= 0; 00430 my_bool lower_case_file_system= 0; 00431 my_bool opt_large_pages= 0; 00432 my_bool opt_myisam_use_mmap= 0; 00433 uint opt_large_page_size= 0; 00434 my_bool opt_old_style_user_limits= 0, trust_function_creators= 0; 00435 /* 00436 True if there is at least one per-hour limit for some user, so we should 00437 check them before each query (and possibly reset counters when hour is 00438 changed). False otherwise. 00439 */ 00440 volatile bool mqh_used = 0; 00441 my_bool opt_noacl; 00442 my_bool sp_automatic_privileges= 1; 00443 00444 #ifdef HAVE_ROW_BASED_REPLICATION 00445 ulong opt_binlog_rows_event_max_size; 00446 const char *binlog_format_names[]= {"STATEMENT", "ROW", "MIXED", NullS}; 00447 #else 00448 const char *binlog_format_names[]= {"STATEMENT", NullS}; 00449 #endif 00450 TYPELIB binlog_format_typelib= 00451 { array_elements(binlog_format_names)-1,"", 00452 binlog_format_names, NULL }; 00453 00454 #ifdef HAVE_INITGROUPS 00455 static bool calling_initgroups= FALSE; /* Used in SIGSEGV handler. */ 00456 #endif 00457 uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options; 00458 uint mysqld_port_timeout; 00459 uint delay_key_write_options, protocol_version; 00460 uint lower_case_table_names; 00461 uint tc_heuristic_recover= 0; 00462 uint volatile thread_count, thread_running; 00463 ulonglong thd_startup_options; 00464 ulong back_log, connect_timeout, concurrency, server_id; 00465 ulong table_cache_size, table_def_size; 00466 ulong thread_stack, what_to_log; 00467 ulong query_buff_size, slow_launch_time, slave_open_temp_tables; 00468 ulong open_files_limit, max_binlog_size, max_relay_log_size; 00469 ulong slave_net_timeout, slave_trans_retries; 00470 ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; 00471 ulong query_cache_size=0; 00472 ulong refresh_version, flush_version; /* Increments on each reload */ 00473 query_id_t query_id; 00474 ulong aborted_threads, aborted_connects; 00475 ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size; 00476 ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use; 00477 ulong delayed_insert_errors,flush_time; 00478 ulong specialflag=0; 00479 ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; 00480 ulong max_connections, max_connect_errors; 00481 uint max_user_connections= 0; 00482 /* 00483 Limit of the total number of prepared statements in the server. 00484 Is necessary to protect the server against out-of-memory attacks. 00485 */ 00486 ulong max_prepared_stmt_count; 00487 /* 00488 Current total number of prepared statements in the server. This number 00489 is exact, and therefore may not be equal to the difference between 00490 `com_stmt_prepare' and `com_stmt_close' (global status variables), as 00491 the latter ones account for all registered attempts to prepare 00492 a statement (including unsuccessful ones). Prepared statements are 00493 currently connection-local: if the same SQL query text is prepared in 00494 two different connections, this counts as two distinct prepared 00495 statements. 00496 */ 00497 ulong prepared_stmt_count=0; 00498 ulong thread_id=1L,current_pid; 00499 ulong slow_launch_threads = 0, sync_binlog_period; 00500 ulong expire_logs_days = 0; 00501 ulong rpl_recovery_rank=0; 00502 const char *log_output_str= "TABLE"; 00503 00504 double log_10[32]; /* 10 potences */ 00505 time_t start_time; 00506 00507 char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30]; 00508 char *default_tz_name; 00509 char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN]; 00510 char mysql_real_data_home[FN_REFLEN], 00511 language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN], 00512 *opt_init_file, *opt_tc_log_file, 00513 def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; 00514 uint reg_ext_length; 00515 const key_map key_map_empty(0); 00516 key_map key_map_full(0); // Will be initialized later 00517 00518 const char *opt_date_time_formats[3]; 00519 00520 char *mysql_data_home= mysql_real_data_home; 00521 char server_version[SERVER_VERSION_LENGTH]; 00522 char *mysqld_unix_port, *opt_mysql_tmpdir; 00523 const char **errmesg; /* Error messages */ 00524 const char *myisam_recover_options_str="OFF"; 00525 const char *myisam_stats_method_str="nulls_unequal"; 00526 /* name of reference on left espression in rewritten IN subquery */ 00527 const char *in_left_expr_name= "<left expr>"; 00528 /* name of additional condition */ 00529 const char *in_additional_cond= "<IN COND>"; 00530 my_decimal decimal_zero; 00531 /* classes for comparation parsing/processing */ 00532 Eq_creator eq_creator; 00533 Ne_creator ne_creator; 00534 Gt_creator gt_creator; 00535 Lt_creator lt_creator; 00536 Ge_creator ge_creator; 00537 Le_creator le_creator; 00538 00539 00540 FILE *bootstrap_file; 00541 int bootstrap_error; 00542 FILE *stderror_file=0; 00543 00544 I_List<THD> threads; 00545 I_List<NAMED_LIST> key_caches; 00546 Rpl_filter* rpl_filter; 00547 Rpl_filter* binlog_filter; 00548 00549 struct system_variables global_system_variables; 00550 struct system_variables max_system_variables; 00551 struct system_status_var global_status_var; 00552 00553 MY_TMPDIR mysql_tmpdir_list; 00554 MY_BITMAP temp_pool; 00555 00556 CHARSET_INFO *system_charset_info, *files_charset_info ; 00557 CHARSET_INFO *national_charset_info, *table_alias_charset; 00558 CHARSET_INFO *character_set_filesystem; 00559 00560 SHOW_COMP_OPTION have_row_based_replication; 00561 SHOW_COMP_OPTION have_openssl, have_symlink, have_dlopen, have_query_cache; 00562 SHOW_COMP_OPTION have_geometry, have_rtree_keys; 00563 SHOW_COMP_OPTION have_crypt, have_compress; 00564 00565 /* Thread specific variables */ 00566 00567 pthread_key(MEM_ROOT**,THR_MALLOC); 00568 pthread_key(THD*, THR_THD); 00569 pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, 00570 LOCK_mapped_file, LOCK_status, LOCK_global_read_lock, 00571 LOCK_error_log, LOCK_uuid_generator, 00572 LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, 00573 LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, 00574 LOCK_global_system_variables, 00575 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; 00576 /* 00577 The below lock protects access to two global server variables: 00578 max_prepared_stmt_count and prepared_stmt_count. These variables 00579 set the limit and hold the current total number of prepared statements 00580 in the server, respectively. As PREPARE/DEALLOCATE rate in a loaded 00581 server may be fairly high, we need a dedicated lock. 00582 */ 00583 pthread_mutex_t LOCK_prepared_stmt_count; 00584 #ifdef HAVE_OPENSSL 00585 pthread_mutex_t LOCK_des_key_file; 00586 #endif 00587 rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; 00588 pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock; 00589 pthread_t signal_thread; 00590 pthread_attr_t connection_attrib; 00591 pthread_mutex_t LOCK_server_started; 00592 pthread_cond_t COND_server_started; 00593 00594 int mysqld_server_started= 0; 00595 00596 File_parser_dummy_hook file_parser_dummy_hook; 00597 00598 /* replication parameters, if master_host is not NULL, we are a slave */ 00599 uint master_port= MYSQL_PORT, master_connect_retry = 60; 00600 uint report_port= MYSQL_PORT; 00601 ulong master_retry_count=0; 00602 char *master_user, *master_password, *master_host, *master_info_file; 00603 char *relay_log_info_file, *report_user, *report_password, *report_host; 00604 char *opt_relay_logname = 0, *opt_relaylog_index_name=0; 00605 my_bool master_ssl; 00606 char *master_ssl_key, *master_ssl_cert; 00607 char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher; 00608 char *opt_logname, *opt_slow_logname; 00609 00610 /* Static variables */ 00611 00612 static bool kill_in_progress, segfaulted; 00613 static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log; 00614 static int cleanup_done; 00615 static ulong opt_specialflag, opt_myisam_block_size; 00616 static char *opt_update_logname, *opt_binlog_index_name; 00617 static char *opt_tc_heuristic_recover; 00618 static char *mysql_home_ptr, *pidfile_name_ptr; 00619 static char **defaults_argv; 00620 static char *opt_bin_logname; 00621 00622 static my_socket unix_sock,ip_sock; 00623 static pthread_t select_thread; 00624 struct rand_struct sql_rand; // used by sql_class.cc:THD::THD() 00625 00626 /* OS specific variables */ 00627 00628 #ifdef __WIN__ 00629 #undef getpid 00630 #include <process.h> 00631 00632 static pthread_cond_t COND_handler_count; 00633 static uint handler_count; 00634 static bool start_mode=0, use_opt_args; 00635 static int opt_argc; 00636 static char **opt_argv; 00637 00638 #if !defined(EMBEDDED_LIBRARY) 00639 static HANDLE hEventShutdown; 00640 static char shutdown_event_name[40]; 00641 #include "nt_servc.h" 00642 static NTService Service; // Service object for WinNT 00643 #endif /* EMBEDDED_LIBRARY */ 00644 #endif /* __WIN__ */ 00645 00646 #ifdef __NT__ 00647 static char pipe_name[512]; 00648 static SECURITY_ATTRIBUTES saPipeSecurity; 00649 static SECURITY_DESCRIPTOR sdPipeDescriptor; 00650 static HANDLE hPipe = INVALID_HANDLE_VALUE; 00651 #endif 00652 00653 #ifndef EMBEDDED_LIBRARY 00654 bool mysqld_embedded=0; 00655 #else 00656 bool mysqld_embedded=1; 00657 #endif 00658 00659 #ifndef DBUG_OFF 00660 static const char* default_dbug_option; 00661 #endif 00662 #ifdef HAVE_LIBWRAP 00663 const char *libwrapName= NULL; 00664 int allow_severity = LOG_INFO; 00665 int deny_severity = LOG_WARNING; 00666 #endif 00667 #ifdef HAVE_QUERY_CACHE 00668 static ulong query_cache_limit= 0; 00669 ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE; 00670 Query_cache query_cache; 00671 #endif 00672 #ifdef HAVE_SMEM 00673 char *shared_memory_base_name= default_shared_memory_base_name; 00674 my_bool opt_enable_shared_memory; 00675 HANDLE smem_event_connect_request= 0; 00676 #endif 00677 00678 #define SSL_VARS_NOT_STATIC 00679 #include "sslopt-vars.h" 00680 #ifdef HAVE_OPENSSL 00681 #include <openssl/crypto.h> 00682 #ifndef HAVE_YASSL 00683 typedef struct CRYPTO_dynlock_value 00684 { 00685 rw_lock_t lock; 00686 } openssl_lock_t; 00687 00688 static openssl_lock_t *openssl_stdlocks; 00689 static openssl_lock_t *openssl_dynlock_create(const char *, int); 00690 static void openssl_dynlock_destroy(openssl_lock_t *, const char *, int); 00691 static void openssl_lock_function(int, int, const char *, int); 00692 static void openssl_lock(int, openssl_lock_t *, const char *, int); 00693 static unsigned long openssl_id_function(); 00694 #endif 00695 char *des_key_file; 00696 struct st_VioSSLFd *ssl_acceptor_fd; 00697 #endif /* HAVE_OPENSSL */ 00698 00699 00700 /* Function declarations */ 00701 00702 static void start_signal_handler(void); 00703 pthread_handler_t signal_hand(void *arg); 00704 static void mysql_init_variables(void); 00705 static void get_options(int argc,char **argv); 00706 static void set_server_version(void); 00707 static int init_thread_environment(); 00708 static char *get_relative_path(const char *path); 00709 static void fix_paths(void); 00710 pthread_handler_t handle_connections_sockets(void *arg); 00711 pthread_handler_t kill_server_thread(void *arg); 00712 static void bootstrap(FILE *file); 00713 static void close_server_sock(); 00714 static bool read_init_file(char *file_name); 00715 #ifdef __NT__ 00716 pthread_handler_t handle_connections_namedpipes(void *arg); 00717 #endif 00718 #ifdef HAVE_SMEM 00719 pthread_handler_t handle_connections_shared_memory(void *arg); 00720 #endif 00721 pthread_handler_t handle_slave(void *arg); 00722 static ulong find_bit_type(const char *x, TYPELIB *bit_lib); 00723 static void clean_up(bool print_message); 00724 static void clean_up_mutexes(void); 00725 static void wait_for_signal_thread_to_end(void); 00726 static int test_if_case_insensitive(const char *dir_name); 00727 static void create_pid_file(); 00728 static void end_ssl(); 00729 00730 #ifndef EMBEDDED_LIBRARY 00731 /**************************************************************************** 00732 ** Code to end mysqld 00733 ****************************************************************************/ 00734 00735 static void close_connections(void) 00736 { 00737 #ifdef EXTRA_DEBUG 00738 int count=0; 00739 #endif 00740 DBUG_ENTER("close_connections"); 00741 00742 /* Clear thread cache */ 00743 kill_cached_threads++; 00744 flush_thread_cache(); 00745 00746 /* kill flush thread */ 00747 (void) pthread_mutex_lock(&LOCK_manager); 00748 if (manager_thread_in_use) 00749 { 00750 DBUG_PRINT("quit",("killing manager thread: 0x%lx",manager_thread)); 00751 (void) pthread_cond_signal(&COND_manager); 00752 } 00753 (void) pthread_mutex_unlock(&LOCK_manager); 00754 00755 /* kill connection thread */ 00756 #if !defined(__WIN__) && !defined(__NETWARE__) 00757 DBUG_PRINT("quit",("waiting for select thread: 0x%lx",select_thread)); 00758 (void) pthread_mutex_lock(&LOCK_thread_count); 00759 00760 while (select_thread_in_use) 00761 { 00762 struct timespec abstime; 00763 int error; 00764 LINT_INIT(error); 00765 DBUG_PRINT("info",("Waiting for select thread")); 00766 00767 #ifndef DONT_USE_THR_ALARM 00768 if (pthread_kill(select_thread,THR_CLIENT_ALARM)) 00769 break; // allready dead 00770 #endif 00771 set_timespec(abstime, 2); 00772 for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++) 00773 { 00774 error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count, 00775 &abstime); 00776 if (error != EINTR) 00777 break; 00778 } 00779 #ifdef EXTRA_DEBUG 00780 if (error != 0 && !count++) 00781 sql_print_error("Got error %d from pthread_cond_timedwait",error); 00782 #endif 00783 close_server_sock(); 00784 } 00785 (void) pthread_mutex_unlock(&LOCK_thread_count); 00786 #endif /* __WIN__ */ 00787 00788 00789 /* Abort listening to new connections */ 00790 DBUG_PRINT("quit",("Closing sockets")); 00791 if (!opt_disable_networking ) 00792 { 00793 if (ip_sock != INVALID_SOCKET) 00794 { 00795 (void) shutdown(ip_sock,2); 00796 (void) closesocket(ip_sock); 00797 ip_sock= INVALID_SOCKET; 00798 } 00799 } 00800 #ifdef __NT__ 00801 if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) 00802 { 00803 HANDLE temp; 00804 DBUG_PRINT("quit", ("Closing named pipes") ); 00805 00806 /* Create connection to the handle named pipe handler to break the loop */ 00807 if ((temp = CreateFile(pipe_name, 00808 GENERIC_READ | GENERIC_WRITE, 00809 0, 00810 NULL, 00811 OPEN_EXISTING, 00812 0, 00813 NULL )) != INVALID_HANDLE_VALUE) 00814 { 00815 WaitNamedPipe(pipe_name, 1000); 00816 DWORD dwMode = PIPE_READMODE_BYTE | PIPE_WAIT; 00817 SetNamedPipeHandleState(temp, &dwMode, NULL, NULL); 00818 CancelIo(temp); 00819 DisconnectNamedPipe(temp); 00820 CloseHandle(temp); 00821 } 00822 } 00823 #endif 00824 #ifdef HAVE_SYS_UN_H 00825 if (unix_sock != INVALID_SOCKET) 00826 { 00827 (void) shutdown(unix_sock,2); 00828 (void) closesocket(unix_sock); 00829 (void) unlink(mysqld_unix_port); 00830 unix_sock= INVALID_SOCKET; 00831 } 00832 #endif 00833 end_thr_alarm(0); // Abort old alarms. 00834 00835 /* 00836 First signal all threads that it's time to die 00837 This will give the threads some time to gracefully abort their 00838 statements and inform their clients that the server is about to die. 00839 */ 00840 00841 THD *tmp; 00842 (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list 00843 00844 I_List_iterator<THD> it(threads); 00845 while ((tmp=it++)) 00846 { 00847 DBUG_PRINT("quit",("Informing thread %ld that it's time to die", 00848 tmp->thread_id)); 00849 /* We skip slave threads & scheduler on this first loop through. */ 00850 if (tmp->slave_thread || tmp->system_thread == SYSTEM_THREAD_EVENT_SCHEDULER) 00851 continue; 00852 00853 tmp->killed= THD::KILL_CONNECTION; 00854 if (tmp->mysys_var) 00855 { 00856 tmp->mysys_var->abort=1; 00857 pthread_mutex_lock(&tmp->mysys_var->mutex); 00858 if (tmp->mysys_var->current_cond) 00859 { 00860 pthread_mutex_lock(tmp->mysys_var->current_mutex); 00861 pthread_cond_broadcast(tmp->mysys_var->current_cond); 00862 pthread_mutex_unlock(tmp->mysys_var->current_mutex); 00863 } 00864 pthread_mutex_unlock(&tmp->mysys_var->mutex); 00865 } 00866 } 00867 (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list 00868 00869 Events::shutdown(); 00870 end_slave(); 00871 00872 if (thread_count) 00873 sleep(2); // Give threads time to die 00874 00875 /* 00876 Force remaining threads to die by closing the connection to the client 00877 This will ensure that threads that are waiting for a command from the 00878 client on a blocking read call are aborted. 00879 */ 00880 00881 for (;;) 00882 { 00883 DBUG_PRINT("quit",("Locking LOCK_thread_count")); 00884 (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list 00885 if (!(tmp=threads.get())) 00886 { 00887 DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); 00888 (void) pthread_mutex_unlock(&LOCK_thread_count); 00889 break; 00890 } 00891 #ifndef __bsdi__ // Bug in BSDI kernel 00892 if (tmp->vio_ok()) 00893 { 00894 if (global_system_variables.log_warnings) 00895 sql_print_warning(ER(ER_FORCING_CLOSE),my_progname, 00896 tmp->thread_id, 00897 (tmp->main_security_ctx.user ? 00898 tmp->main_security_ctx.user : "")); 00899 close_connection(tmp,0,0); 00900 } 00901 #endif 00902 DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); 00903 (void) pthread_mutex_unlock(&LOCK_thread_count); 00904 } 00905 /* All threads has now been aborted */ 00906 DBUG_PRINT("quit",("Waiting for threads to die (count=%u)",thread_count)); 00907 (void) pthread_mutex_lock(&LOCK_thread_count); 00908 while (thread_count) 00909 { 00910 (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); 00911 DBUG_PRINT("quit",("One thread died (count=%u)",thread_count)); 00912 } 00913 (void) pthread_mutex_unlock(&LOCK_thread_count); 00914 00915 DBUG_PRINT("quit",("close_connections thread")); 00916 DBUG_VOID_RETURN; 00917 } 00918 #endif /*EMBEDDED_LIBRARY*/ 00919 00920 00921 static void close_server_sock() 00922 { 00923 #ifdef HAVE_CLOSE_SERVER_SOCK 00924 DBUG_ENTER("close_server_sock"); 00925 my_socket tmp_sock; 00926 tmp_sock=ip_sock; 00927 if (tmp_sock != INVALID_SOCKET) 00928 { 00929 ip_sock=INVALID_SOCKET; 00930 DBUG_PRINT("info",("calling shutdown on TCP/IP socket")); 00931 VOID(shutdown(tmp_sock,2)); 00932 #if defined(__NETWARE__) 00933 /* 00934 The following code is disabled for normal systems as it causes MySQL 00935 to hang on AIX 4.3 during shutdown 00936 */ 00937 DBUG_PRINT("info",("calling closesocket on TCP/IP socket")); 00938 VOID(closesocket(tmp_sock)); 00939 #endif 00940 } 00941 tmp_sock=unix_sock; 00942 if (tmp_sock != INVALID_SOCKET) 00943 { 00944 unix_sock=INVALID_SOCKET; 00945 DBUG_PRINT("info",("calling shutdown on unix socket")); 00946 VOID(shutdown(tmp_sock,2)); 00947 #if defined(__NETWARE__) 00948 /* 00949 The following code is disabled for normal systems as it may cause MySQL 00950 to hang on AIX 4.3 during shutdown 00951 */ 00952 DBUG_PRINT("info",("calling closesocket on unix/IP socket")); 00953 VOID(closesocket(tmp_sock)); 00954 #endif 00955 VOID(unlink(mysqld_unix_port)); 00956 } 00957 DBUG_VOID_RETURN; 00958 #endif 00959 } 00960 00961 00962 void kill_mysql(void) 00963 { 00964 DBUG_ENTER("kill_mysql"); 00965 00966 #ifdef SIGNALS_DONT_BREAK_READ 00967 abort_loop=1; // Break connection loops 00968 close_server_sock(); // Force accept to wake up 00969 #endif 00970 00971 #if defined(__WIN__) 00972 #if !defined(EMBEDDED_LIBRARY) 00973 { 00974 if (!SetEvent(hEventShutdown)) 00975 { 00976 DBUG_PRINT("error",("Got error: %ld from SetEvent",GetLastError())); 00977 } 00978 /* 00979 or: 00980 HANDLE hEvent=OpenEvent(0, FALSE, "MySqlShutdown"); 00981 SetEvent(hEventShutdown); 00982 CloseHandle(hEvent); 00983 */ 00984 } 00985 #endif 00986 #elif defined(HAVE_PTHREAD_KILL) 00987 if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL)) 00988 { 00989 DBUG_PRINT("error",("Got error %d from pthread_kill",errno)); /* purecov: inspected */ 00990 } 00991 #elif !defined(SIGNALS_DONT_BREAK_READ) 00992 kill(current_pid, MYSQL_KILL_SIGNAL); 00993 #endif 00994 DBUG_PRINT("quit",("After pthread_kill")); 00995 shutdown_in_progress=1; // Safety if kill didn't work 00996 #ifdef SIGNALS_DONT_BREAK_READ 00997 if (!kill_in_progress) 00998 { 00999 pthread_t tmp; 01000 abort_loop=1; 01001 if (pthread_create(&tmp,&connection_attrib, kill_server_thread, 01002 (void*) 0)) 01003 sql_print_error("Can't create thread to kill server"); 01004 } 01005 #endif 01006 DBUG_VOID_RETURN; 01007 } 01008 01009 /* 01010 Force server down. Kill all connections and threads and exit 01011 01012 SYNOPSIS 01013 kill_server 01014 01015 sig_ptr Signal number that caused kill_server to be called. 01016 01017 NOTE! 01018 A signal number of 0 mean that the function was not called 01019 from a signal handler and there is thus no signal to block 01020 or stop, we just want to kill the server. 01021 01022 */ 01023 01024 #if defined(__NETWARE__) 01025 extern "C" void kill_server(int sig_ptr) 01026 #define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN 01027 #elif !defined(__WIN__) 01028 static void *kill_server(void *sig_ptr) 01029 #define RETURN_FROM_KILL_SERVER DBUG_RETURN(0) 01030 #else 01031 static void __cdecl kill_server(int sig_ptr) 01032 #define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN 01033 #endif 01034 { 01035 DBUG_ENTER("kill_server"); 01036 #ifndef EMBEDDED_LIBRARY 01037 int sig=(int) (long) sig_ptr; // This is passed a int 01038 // if there is a signal during the kill in progress, ignore the other 01039 if (kill_in_progress) // Safety 01040 RETURN_FROM_KILL_SERVER; 01041 kill_in_progress=TRUE; 01042 abort_loop=1; // This should be set 01043 if (sig != 0) // 0 is not a valid signal number 01044 my_sigset(sig,SIG_IGN); 01045 if (sig == MYSQL_KILL_SIGNAL || sig == 0) 01046 sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname); 01047 else 01048 sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */ 01049 01050 #if defined(HAVE_SMEM) && defined(__WIN__) 01051 /* 01052 Send event to smem_event_connect_request for aborting 01053 */ 01054 if (!SetEvent(smem_event_connect_request)) 01055 { 01056 DBUG_PRINT("error", 01057 ("Got error: %ld from SetEvent of smem_event_connect_request", 01058 GetLastError())); 01059 } 01060 #endif 01061 01062 #if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__)) 01063 my_thread_init(); // If this is a new thread 01064 #endif 01065 close_connections(); 01066 if (sig != MYSQL_KILL_SIGNAL && 01067 #ifdef __WIN__ 01068 sig != SIGINT && /* Bug#18235 */ 01069 #endif 01070 sig != 0) 01071 unireg_abort(1); /* purecov: inspected */ 01072 else 01073 unireg_end(); 01074 01075 #ifdef __NETWARE__ 01076 if (!event_flag) 01077 pthread_join(select_thread, NULL); // wait for main thread 01078 #endif /* __NETWARE__ */ 01079 01080 #if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)) 01081 my_thread_end(); 01082 #endif 01083 01084 pthread_exit(0); /* purecov: deadcode */ 01085 01086 #endif /* EMBEDDED_LIBRARY */ 01087 RETURN_FROM_KILL_SERVER; 01088 } 01089 01090 01091 #if defined(USE_ONE_SIGNAL_HAND) || (defined(__NETWARE__) && defined(SIGNALS_DONT_BREAK_READ)) 01092 pthread_handler_t kill_server_thread(void *arg __attribute__((unused))) 01093 { 01094 my_thread_init(); // Initialize new thread 01095 kill_server(0); 01096 my_thread_end(); // Normally never reached 01097 return 0; 01098 } 01099 #endif 01100 01101 extern "C" sig_handler print_signal_warning(int sig) 01102 { 01103 if (global_system_variables.log_warnings) 01104 sql_print_warning("Got signal %d from thread %d", sig,my_thread_id()); 01105 #ifdef DONT_REMEMBER_SIGNAL 01106 my_sigset(sig,print_signal_warning); /* int. thread system calls */ 01107 #endif 01108 #if !defined(__WIN__) && !defined(__NETWARE__) 01109 if (sig == SIGALRM) 01110 alarm(2); /* reschedule alarm */ 01111 #endif 01112 } 01113 01114 /* 01115 cleanup all memory and end program nicely 01116 01117 SYNOPSIS 01118 unireg_end() 01119 01120 NOTES 01121 This function never returns. 01122 01123 If SIGNALS_DONT_BREAK_READ is defined, this function is called 01124 by the main thread. To get MySQL to shut down nicely in this case 01125 (Mac OS X) we have to call exit() instead if pthread_exit(). 01126 */ 01127 01128 #ifndef EMBEDDED_LIBRARY 01129 void unireg_end(void) 01130 { 01131 clean_up(1); 01132 my_thread_end(); 01133 #if defined(SIGNALS_DONT_BREAK_READ) && !defined(__NETWARE__) 01134 exit(0); 01135 #else 01136 pthread_exit(0); // Exit is in main thread 01137 #endif 01138 } 01139 01140 extern "C" void unireg_abort(int exit_code) 01141 { 01142 DBUG_ENTER("unireg_abort"); 01143 if (exit_code) 01144 sql_print_error("Aborting\n"); 01145 clean_up(exit_code || !opt_bootstrap); /* purecov: inspected */ 01146 DBUG_PRINT("quit",("done with cleanup in unireg_abort")); 01147 wait_for_signal_thread_to_end(); 01148 clean_up_mutexes(); 01149 my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); 01150 exit(exit_code); /* purecov: inspected */ 01151 } 01152 #endif 01153 01154 01155 void clean_up(bool print_message) 01156 { 01157 DBUG_PRINT("exit",("clean_up")); 01158 if (cleanup_done++) 01159 return; /* purecov: inspected */ 01160 01161 logger.cleanup_base(); 01162 01163 /* 01164 make sure that handlers finish up 01165 what they have that is dependent on the binlog 01166 */ 01167 ha_binlog_end(current_thd); 01168 #ifdef HAVE_ROW_BASED_REPLICATION 01169 injector::free_instance(); 01170 #endif 01171 mysql_bin_log.cleanup(); 01172 01173 #ifdef HAVE_REPLICATION 01174 if (use_slave_mask) 01175 bitmap_free(&slave_error_mask); 01176 #endif 01177 my_tz_free(); 01178 my_database_names_free(); 01179 #ifndef NO_EMBEDDED_ACCESS_CHECKS 01180 acl_free(1); 01181 grant_free(); 01182 #endif 01183 query_cache_destroy(); 01184 table_cache_free(); 01185 table_def_free(); 01186 hostname_cache_free(); 01187 item_user_lock_free(); 01188 lex_free(); /* Free some memory */ 01189 set_var_free(); 01190 free_charsets(); 01191 (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ 01192 if (!opt_noacl) 01193 { 01194 #ifdef HAVE_DLOPEN 01195 udf_free(); 01196 #endif 01197 } 01198 plugin_free(); 01199 if (tc_log) 01200 tc_log->close(); 01201 xid_cache_free(); 01202 delete_elements(&key_caches, (void (*)(const char*, gptr)) free_key_cache); 01203 multi_keycache_free(); 01204 free_status_vars(); 01205 end_thr_alarm(1); /* Free allocated memory */ 01206 my_free_open_file_info(); 01207 my_free((char*) global_system_variables.date_format, 01208 MYF(MY_ALLOW_ZERO_PTR)); 01209 my_free((char*) global_system_variables.time_format, 01210 MYF(MY_ALLOW_ZERO_PTR)); 01211 my_free((char*) global_system_variables.datetime_format, 01212 MYF(MY_ALLOW_ZERO_PTR)); 01213 if (defaults_argv) 01214 free_defaults(defaults_argv); 01215 my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR)); 01216 my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR)); 01217 my_free(sys_var_general_log_path.value, MYF(MY_ALLOW_ZERO_PTR)); 01218 my_free(sys_var_slow_log_path.value, MYF(MY_ALLOW_ZERO_PTR)); 01219 free_tmpdir(&mysql_tmpdir_list); 01220 #ifdef HAVE_REPLICATION 01221 my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR)); 01222 #endif 01223 x_free(opt_bin_logname); 01224 x_free(opt_relay_logname); 01225 bitmap_free(&temp_pool); 01226 free_max_user_conn(); 01227 #ifdef HAVE_REPLICATION 01228 end_slave_list(); 01229 #endif 01230 delete binlog_filter; 01231 delete rpl_filter; 01232 end_ssl(); 01233 vio_end(); 01234 #ifdef USE_REGEX 01235 my_regex_end(); 01236 #endif 01237 01238 if (print_message && errmesg) 01239 sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); 01240 #if !defined(EMBEDDED_LIBRARY) 01241 if (!opt_bootstrap) 01242 (void) my_delete(pidfile_name,MYF(0)); // This may not always exist 01243 #endif 01244 finish_client_errs(); 01245 my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST), 01246 MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); 01247 DBUG_PRINT("quit", ("Error messages freed")); 01248 /* Tell main we are ready */ 01249 logger.cleanup_end(); 01250 (void) pthread_mutex_lock(&LOCK_thread_count); 01251 DBUG_PRINT("quit", ("got thread count lock")); 01252 ready_to_exit=1; 01253 /* do the broadcast inside the lock to ensure that my_end() is not called */ 01254 (void) pthread_cond_broadcast(&COND_thread_count); 01255 (void) pthread_mutex_unlock(&LOCK_thread_count); 01256 01257 /* 01258 The following lines may never be executed as the main thread may have 01259 killed us 01260 */ 01261 DBUG_PRINT("quit", ("done with cleanup")); 01262 } /* clean_up */ 01263 01264 01265 /* 01266 This is mainly needed when running with purify, but it's still nice to 01267 know that all child threads have died when mysqld exits 01268 */ 01269 01270 static void wait_for_signal_thread_to_end() 01271 { 01272 #ifndef __NETWARE__ 01273 uint i; 01274 /* 01275 Wait up to 10 seconds for signal thread to die. We use this mainly to 01276 avoid getting warnings that my_thread_end has not been called 01277 */ 01278 for (i= 0 ; i < 100 && signal_thread_in_use; i++) 01279 { 01280 if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL)) 01281 break; 01282 my_sleep(100); // Give it time to die 01283 } 01284 #endif 01285 } 01286 01287 01288 static void clean_up_mutexes() 01289 { 01290 (void) pthread_mutex_destroy(&LOCK_mysql_create_db); 01291 (void) pthread_mutex_destroy(&LOCK_lock_db); 01292 (void) pthread_mutex_destroy(&LOCK_Acl); 01293 (void) rwlock_destroy(&LOCK_grant); 01294 (void) pthread_mutex_destroy(&LOCK_open); 01295 (void) pthread_mutex_destroy(&LOCK_thread_count); 01296 (void) pthread_mutex_destroy(&LOCK_mapped_file); 01297 (void) pthread_mutex_destroy(&LOCK_status); 01298 (void) pthread_mutex_destroy(&LOCK_error_log); 01299 (void) pthread_mutex_destroy(&LOCK_delayed_insert); 01300 (void) pthread_mutex_destroy(&LOCK_delayed_status); 01301 (void) pthread_mutex_destroy(&LOCK_delayed_create); 01302 (void) pthread_mutex_destroy(&LOCK_manager); 01303 (void) pthread_mutex_destroy(&LOCK_crypt); 01304 (void) pthread_mutex_destroy(&LOCK_bytes_sent); 01305 (void) pthread_mutex_destroy(&LOCK_bytes_received); 01306 (void) pthread_mutex_destroy(&LOCK_user_conn); 01307 Events::destroy_mutexes(); 01308 #ifdef HAVE_OPENSSL 01309 (void) pthread_mutex_destroy(&LOCK_des_key_file); 01310 #ifndef HAVE_YASSL 01311 for (int i= 0; i < CRYPTO_num_locks(); ++i) 01312 (void) rwlock_destroy(&openssl_stdlocks[i].lock); 01313 OPENSSL_free(openssl_stdlocks); 01314 #endif 01315 #endif 01316 #ifdef HAVE_REPLICATION 01317 (void) pthread_mutex_destroy(&LOCK_rpl_status); 01318 (void) pthread_cond_destroy(&COND_rpl_status); 01319 #endif 01320 (void) pthread_mutex_destroy(&LOCK_active_mi); 01321 (void) rwlock_destroy(&LOCK_sys_init_connect); 01322 (void) rwlock_destroy(&LOCK_sys_init_slave); 01323 (void) pthread_mutex_destroy(&LOCK_global_system_variables); 01324 (void) pthread_mutex_destroy(&LOCK_global_read_lock); 01325 (void) pthread_mutex_destroy(&LOCK_uuid_generator); 01326 (void) pthread_mutex_destroy(&LOCK_prepared_stmt_count); 01327 (void) pthread_cond_destroy(&COND_thread_count); 01328 (void) pthread_cond_destroy(&COND_refresh); 01329 (void) pthread_cond_destroy(&COND_global_read_lock); 01330 (void) pthread_cond_destroy(&COND_thread_cache); 01331 (void) pthread_cond_destroy(&COND_flush_thread_cache); 01332 (void) pthread_cond_destroy(&COND_manager); 01333 } 01334 01335 /**************************************************************************** 01336 ** Init IP and UNIX socket 01337 ****************************************************************************/ 01338 01339 static void set_ports() 01340 { 01341 char *env; 01342 if (!mysqld_port && !opt_disable_networking) 01343 { // Get port if not from commandline 01344 struct servent *serv_ptr; 01345 mysqld_port= MYSQL_PORT; 01346 if ((serv_ptr= getservbyname("mysql", "tcp"))) 01347 mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ 01348 if ((env = getenv("MYSQL_TCP_PORT"))) 01349 mysqld_port= (uint) atoi(env); /* purecov: inspected */ 01350 } 01351 if (!mysqld_unix_port) 01352 { 01353 #ifdef __WIN__ 01354 mysqld_unix_port= (char*) MYSQL_NAMEDPIPE; 01355 #else 01356 mysqld_unix_port= (char*) MYSQL_UNIX_ADDR; 01357 #endif 01358 if ((env = getenv("MYSQL_UNIX_PORT"))) 01359 mysqld_unix_port= env; /* purecov: inspected */ 01360 } 01361 } 01362 01363 #ifndef EMBEDDED_LIBRARY 01364 /* Change to run as another user if started with --user */ 01365 01366 static struct passwd *check_user(const char *user) 01367 { 01368 #if !defined(__WIN__) && !defined(__NETWARE__) 01369 struct passwd *user_info; 01370 uid_t user_id= geteuid(); 01371 01372 // Don't bother if we aren't superuser 01373 if (user_id) 01374 { 01375 if (user) 01376 { 01377 // Don't give a warning, if real user is same as given with --user 01378 user_info= getpwnam(user); 01379 if ((!user_info || user_id != user_info->pw_uid) && 01380 global_system_variables.log_warnings) 01381 sql_print_warning( 01382 "One can only use the --user switch if running as root\n"); 01383 } 01384 return NULL; 01385 } 01386 if (!user) 01387 { 01388 if (!opt_bootstrap) 01389 { 01390 sql_print_error("Fatal error: Please read \"Security\" section of the manual to find out how to run mysqld as root!\n"); 01391 unireg_abort(1); 01392 } 01393 return NULL; 01394 } 01395 if (!strcmp(user,"root")) 01396 return NULL; // Avoid problem with dynamic libraries 01397 01398 if (!(user_info= getpwnam(user))) 01399 { 01400 // Allow a numeric uid to be used 01401 const char *pos; 01402 for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ; 01403 if (*pos) // Not numeric id 01404 goto err; 01405 if (!(user_info= getpwuid(atoi(user)))) 01406 goto err; 01407 else 01408 return user_info; 01409 } 01410 else 01411 return user_info; 01412 01413 err: 01414 sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); 01415 unireg_abort(1); 01416 #endif 01417 return NULL; 01418 } 01419 01420 static void set_user(const char *user, struct passwd *user_info) 01421 { 01422 #if !defined(__WIN__) && !defined(__NETWARE__) 01423 DBUG_ASSERT(user_info != 0); 01424 #ifdef HAVE_INITGROUPS 01425 /* 01426 We can get a SIGSEGV when calling initgroups() on some systems when NSS 01427 is configured to use LDAP and the server is statically linked. We set 01428 calling_initgroups as a flag to the SIGSEGV handler that is then used to 01429 output a specific message to help the user resolve this problem. 01430 */ 01431 calling_initgroups= TRUE; 01432 initgroups((char*) user, user_info->pw_gid); 01433 calling_initgroups= FALSE; 01434 #endif 01435 if (setgid(user_info->pw_gid) == -1) 01436 { 01437 sql_perror("setgid"); 01438 unireg_abort(1); 01439 } 01440 if (setuid(user_info->pw_uid) == -1) 01441 { 01442 sql_perror("setuid"); 01443 unireg_abort(1); 01444 } 01445 #endif 01446 } 01447 01448 01449 static void set_effective_user(struct passwd *user_info) 01450 { 01451 #if !defined(__WIN__) && !defined(__NETWARE__) 01452 DBUG_ASSERT(user_info != 0); 01453 if (setregid((gid_t)-1, user_info->pw_gid) == -1) 01454 { 01455 sql_perror("setregid"); 01456 unireg_abort(1); 01457 } 01458 if (setreuid((uid_t)-1, user_info->pw_uid) == -1) 01459 { 01460 sql_perror("setreuid"); 01461 unireg_abort(1); 01462 } 01463 #endif 01464 } 01465 01466 01467 /* Change root user if started with --chroot */ 01468 01469 static void set_root(const char *path) 01470 { 01471 #if !defined(__WIN__) && !defined(__NETWARE__) 01472 if (chroot(path) == -1) 01473 { 01474 sql_perror("chroot"); 01475 unireg_abort(1); 01476 } 01477 my_setwd("/", MYF(0)); 01478 #endif 01479 } 01480 01481 static void network_init(void) 01482 { 01483 struct sockaddr_in IPaddr; 01484 #ifdef HAVE_SYS_UN_H 01485 struct sockaddr_un UNIXaddr; 01486 #endif 01487 int arg=1; 01488 int ret; 01489 uint waited; 01490 uint this_wait; 01491 uint retry; 01492 DBUG_ENTER("network_init"); 01493 LINT_INIT(ret); 01494 01495 set_ports(); 01496 01497 if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap) 01498 { 01499 DBUG_PRINT("general",("IP Socket is %d",mysqld_port)); 01500 ip_sock = socket(AF_INET, SOCK_STREAM, 0); 01501 if (ip_sock == INVALID_SOCKET) 01502 { 01503 DBUG_PRINT("error",("Got error: %d from socket()",socket_errno)); 01504 sql_perror(ER(ER_IPSOCK_ERROR)); /* purecov: tested */ 01505 unireg_abort(1); /* purecov: tested */ 01506 } 01507 bzero((char*) &IPaddr, sizeof(IPaddr)); 01508 IPaddr.sin_family = AF_INET; 01509 IPaddr.sin_addr.s_addr = my_bind_addr; 01510 IPaddr.sin_port = (unsigned short) htons((unsigned short) mysqld_port); 01511 01512 #ifndef __WIN__ 01513 /* 01514 We should not use SO_REUSEADDR on windows as this would enable a 01515 user to open two mysqld servers with the same TCP/IP port. 01516 */ 01517 (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg)); 01518 #endif /* __WIN__ */ 01519 /* 01520 Sometimes the port is not released fast enough when stopping and 01521 restarting the server. This happens quite often with the test suite 01522 on busy Linux systems. Retry to bind the address at these intervals: 01523 Sleep intervals: 1, 2, 4, 6, 9, 13, 17, 22, ... 01524 Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ... 01525 Limit the sequence by mysqld_port_timeout (set --port-open-timeout=#). 01526 */ 01527 for (waited= 0, retry= 1; ; retry++, waited+= this_wait) 01528 { 01529 if (((ret= bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), 01530 sizeof(IPaddr))) >= 0) || 01531 (socket_errno != SOCKET_EADDRINUSE) || 01532 (waited >= mysqld_port_timeout)) 01533 break; 01534 sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port); 01535 this_wait= retry * retry / 3 + 1; 01536 sleep(this_wait); 01537 } 01538 if (ret < 0) 01539 { 01540 DBUG_PRINT("error",("Got error: %d from bind",socket_errno)); 01541 sql_perror("Can't start server: Bind on TCP/IP port"); 01542 sql_print_error("Do you already have another mysqld server running on port: %d ?",mysqld_port); 01543 unireg_abort(1); 01544 } 01545 if (listen(ip_sock,(int) back_log) < 0) 01546 { 01547 sql_perror("Can't start server: listen() on TCP/IP port"); 01548 sql_print_error("listen() on TCP/IP failed with error %d", 01549 socket_errno); 01550 unireg_abort(1); 01551 } 01552 } 01553 01554 #ifdef __NT__ 01555 /* create named pipe */ 01556 if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap && 01557 opt_enable_named_pipe) 01558 { 01559 01560 pipe_name[sizeof(pipe_name)-1]= 0; /* Safety if too long string */ 01561 strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\", 01562 mysqld_unix_port, NullS); 01563 bzero((char*) &saPipeSecurity, sizeof(saPipeSecurity)); 01564 bzero((char*) &sdPipeDescriptor, sizeof(sdPipeDescriptor)); 01565 if (!InitializeSecurityDescriptor(&sdPipeDescriptor, 01566 SECURITY_DESCRIPTOR_REVISION)) 01567 { 01568 sql_perror("Can't start server : Initialize security descriptor"); 01569 unireg_abort(1); 01570 } 01571 if (!SetSecurityDescriptorDacl(&sdPipeDescriptor, TRUE, NULL, FALSE)) 01572 { 01573 sql_perror("Can't start server : Set security descriptor"); 01574 unireg_abort(1); 01575 } 01576 saPipeSecurity.nLength = sizeof(SECURITY_ATTRIBUTES); 01577 saPipeSecurity.lpSecurityDescriptor = &sdPipeDescriptor; 01578 saPipeSecurity.bInheritHandle = FALSE; 01579 if ((hPipe= CreateNamedPipe(pipe_name, 01580 PIPE_ACCESS_DUPLEX, 01581 PIPE_TYPE_BYTE | 01582 PIPE_READMODE_BYTE | 01583 PIPE_WAIT, 01584 PIPE_UNLIMITED_INSTANCES, 01585 (int) global_system_variables.net_buffer_length, 01586 (int) global_system_variables.net_buffer_length, 01587 NMPWAIT_USE_DEFAULT_WAIT, 01588 &saPipeSecurity)) == INVALID_HANDLE_VALUE) 01589 { 01590 LPVOID lpMsgBuf; 01591 int error=GetLastError(); 01592 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 01593 FORMAT_MESSAGE_FROM_SYSTEM, 01594 NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 01595 (LPTSTR) &lpMsgBuf, 0, NULL ); 01596 MessageBox(NULL, (LPTSTR) lpMsgBuf, "Error from CreateNamedPipe", 01597 MB_OK|MB_ICONINFORMATION); 01598 LocalFree(lpMsgBuf); 01599 unireg_abort(1); 01600 } 01601 } 01602 #endif 01603 01604 #if defined(HAVE_SYS_UN_H) 01605 /* 01606 ** Create the UNIX socket 01607 */ 01608 if (mysqld_unix_port[0] && !opt_bootstrap) 01609 { 01610 DBUG_PRINT("general",("UNIX Socket is %s",mysqld_unix_port)); 01611 01612 if (strlen(mysqld_unix_port) > (sizeof(UNIXaddr.sun_path) - 1)) 01613 { 01614 sql_print_error("The socket file path is too long (> %d): %s", 01615 sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); 01616 unireg_abort(1); 01617 } 01618 if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) 01619 { 01620 sql_perror("Can't start server : UNIX Socket "); /* purecov: inspected */ 01621 unireg_abort(1); /* purecov: inspected */ 01622 } 01623 bzero((char*) &UNIXaddr, sizeof(UNIXaddr)); 01624 UNIXaddr.sun_family = AF_UNIX; 01625 strmov(UNIXaddr.sun_path, mysqld_unix_port); 01626 (void) unlink(mysqld_unix_port); 01627 (void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg, 01628 sizeof(arg)); 01629 umask(0); 01630 if (bind(unix_sock, my_reinterpret_cast(struct sockaddr *) (&UNIXaddr), 01631 sizeof(UNIXaddr)) < 0) 01632 { 01633 sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */ 01634 sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysqld_unix_port); 01635 unireg_abort(1); /* purecov: tested */ 01636 } 01637 umask(((~my_umask) & 0666)); 01638 #if defined(S_IFSOCK) && defined(SECURE_SOCKETS) 01639 (void) chmod(mysqld_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */ 01640 #endif 01641 if (listen(unix_sock,(int) back_log) < 0) 01642 sql_print_warning("listen() on Unix socket failed with error %d", 01643 socket_errno); 01644 } 01645 #endif 01646 DBUG_PRINT("info",("server started")); 01647 DBUG_VOID_RETURN; 01648 } 01649 01650 #endif 01652 void MYSQLerror(const char *s) 01653 { 01654 THD *thd=current_thd; 01655 char *yytext= (char*) thd->lex->tok_start; 01656 /* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */ 01657 if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0) 01658 s=ER(ER_SYNTAX_ERROR); 01659 my_printf_error(ER_PARSE_ERROR, ER(ER_PARSE_ERROR), MYF(0), s, 01660 (yytext ? (char*) yytext : ""), 01661 thd->lex->yylineno); 01662 } 01663 01664 01665 #ifndef EMBEDDED_LIBRARY 01666 /* 01667 Close a connection 01668 01669 SYNOPSIS 01670 close_connection() 01671 thd Thread handle 01672 errcode Error code to print to console 01673 lock 1 if we have have to lock LOCK_thread_count 01674 01675 NOTES 01676 For the connection that is doing shutdown, this is called twice 01677 */ 01678 01679 void close_connection(THD *thd, uint errcode, bool lock) 01680 { 01681 st_vio *vio; 01682 DBUG_ENTER("close_connection"); 01683 DBUG_PRINT("enter",("fd: %s error: '%s'", 01684 thd->net.vio ? vio_description(thd->net.vio) : 01685 "(not connected)", 01686 errcode ? ER(errcode) : "")); 01687 if (lock) 01688 (void) pthread_mutex_lock(&LOCK_thread_count); 01689 thd->killed= THD::KILL_CONNECTION; 01690 if ((vio= thd->net.vio) != 0) 01691 { 01692 if (errcode) 01693 net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */ 01694 vio_close(vio); /* vio is freed in delete thd */ 01695 } 01696 if (lock) 01697 (void) pthread_mutex_unlock(&LOCK_thread_count); 01698 DBUG_VOID_RETURN; 01699 } 01700 #endif /* EMBEDDED_LIBRARY */ 01701 01702 01703 /* Called when a thread is aborted */ 01704 /* ARGSUSED */ 01705 01706 extern "C" sig_handler end_thread_signal(int sig __attribute__((unused))) 01707 { 01708 THD *thd=current_thd; 01709 DBUG_ENTER("end_thread_signal"); 01710 if (thd && ! thd->bootstrap) 01711 { 01712 statistic_increment(killed_threads, &LOCK_status); 01713 end_thread(thd,0); 01714 } 01715 DBUG_VOID_RETURN; /* purecov: deadcode */ 01716 } 01717 01718 01719 void end_thread(THD *thd, bool put_in_cache) 01720 { 01721 DBUG_ENTER("end_thread"); 01722 thd->cleanup(); 01723 (void) pthread_mutex_lock(&LOCK_thread_count); 01724 thread_count--; 01725 delete thd; 01726 01727 if (put_in_cache && cached_thread_count < thread_cache_size && 01728 ! abort_loop && !kill_cached_threads) 01729 { 01730 /* Don't kill the thread, just put it in cache for reuse */ 01731 DBUG_PRINT("info", ("Adding thread to cache")); 01732 cached_thread_count++; 01733 while (!abort_loop && ! wake_thread && ! kill_cached_threads) 01734 (void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count); 01735 cached_thread_count--; 01736 if (kill_cached_threads) 01737 pthread_cond_signal(&COND_flush_thread_cache); 01738 if (wake_thread) 01739 { 01740 wake_thread--; 01741 thd=thread_cache.get(); 01742 thd->real_id=pthread_self(); 01743 thd->thread_stack= (char*) &thd; // For store_globals 01744 (void) thd->store_globals(); 01745 thd->thr_create_time= time(NULL); 01746 threads.append(thd); 01747 pthread_mutex_unlock(&LOCK_thread_count); 01748 DBUG_VOID_RETURN; 01749 } 01750 } 01751 01752 /* Tell main we are ready */ 01753 (void) pthread_mutex_unlock(&LOCK_thread_count); 01754 /* It's safe to broadcast outside a lock (COND... is not deleted here) */ 01755 DBUG_PRINT("signal", ("Broadcasting COND_thread_count")); 01756 (void) pthread_cond_broadcast(&COND_thread_count); 01757 #ifdef ONE_THREAD 01758 if (!(test_flags & TEST_NO_THREADS)) // For debugging under Linux 01759 #endif 01760 { 01761 my_thread_end(); 01762 pthread_exit(0); 01763 } 01764 DBUG_VOID_RETURN; 01765 } 01766 01767 01768 void flush_thread_cache() 01769 { 01770 (void) pthread_mutex_lock(&LOCK_thread_count); 01771 kill_cached_threads++; 01772 while (cached_thread_count) 01773 { 01774 pthread_cond_broadcast(&COND_thread_cache); 01775 pthread_cond_wait(&COND_flush_thread_cache,&LOCK_thread_count); 01776 } 01777 kill_cached_threads--; 01778 (void) pthread_mutex_unlock(&LOCK_thread_count); 01779 } 01780 01781 01782 /* 01783 Aborts a thread nicely. Commes here on SIGPIPE 01784 TODO: One should have to fix that thr_alarm know about this 01785 thread too. 01786 */ 01787 01788 #ifdef THREAD_SPECIFIC_SIGPIPE 01789 extern "C" sig_handler abort_thread(int sig __attribute__((unused))) 01790 { 01791 THD *thd=current_thd; 01792 DBUG_ENTER("abort_thread"); 01793 if (thd) 01794 thd->killed= THD::KILL_CONNECTION; 01795 DBUG_VOID_RETURN; 01796 } 01797 #endif 01798 01799 /****************************************************************************** 01800 Setup a signal thread with handles all signals. 01801 Because Linux doesn't support schemas use a mutex to check that 01802 the signal thread is ready before continuing 01803 ******************************************************************************/ 01804 01805 #if defined(__WIN__) 01806 static void init_signals(void) 01807 { 01808 int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT } ; 01809 for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++) 01810 signal(signals[i], kill_server) ; 01811 #if defined(__WIN__) 01812 signal(SIGBREAK,SIG_IGN); //ignore SIGBREAK for NT 01813 #else 01814 signal(SIGBREAK, kill_server); 01815 #endif 01816 } 01817 01818 static void start_signal_handler(void) 01819 { 01820 // Save vm id of this process 01821 if (!opt_bootstrap) 01822 create_pid_file(); 01823 } 01824 01825 static void check_data_home(const char *path) 01826 {} 01827 01828 01829 #elif defined(__NETWARE__) 01830 01831 // down server event callback 01832 void mysql_down_server_cb(void *, void *) 01833 { 01834 event_flag= TRUE; 01835 kill_server(0); 01836 } 01837 01838 01839 // destroy callback resources 01840 void mysql_cb_destroy(void *) 01841 { 01842 UnRegisterEventNotification(eh); // cleanup down event notification 01843 NX_UNWRAP_INTERFACE(ref); 01844 /* Deregister NSS volume deactivation event */ 01845 NX_UNWRAP_INTERFACE(refneb); 01846 if (neb_consumer_id) 01847 UnRegisterConsumer(neb_consumer_id, NULL); 01848 } 01849 01850 01851 // initialize callbacks 01852 void mysql_cb_init() 01853 { 01854 // register for down server event 01855 void *handle = getnlmhandle(); 01856 rtag_t rt= AllocateResourceTag(handle, "MySQL Down Server Callback", 01857 EventSignature); 01858 NX_WRAP_INTERFACE((void *)mysql_down_server_cb, 2, (void **)&ref); 01859 eh= RegisterForEventNotification(rt, EVENT_PRE_DOWN_SERVER, 01860 EVENT_PRIORITY_APPLICATION, 01861 NULL, ref, NULL); 01862 01863 /* 01864 Register for volume deactivation event 01865 Wrap the callback function, as it is called by non-LibC thread 01866 */ 01867 (void *) NX_WRAP_INTERFACE(neb_event_callback, 1, &refneb); 01868 registerwithneb(); 01869 01870 NXVmRegisterExitHandler(mysql_cb_destroy, NULL); // clean-up 01871 } 01872 01873 01874 /* To get the name of the NetWare volume having MySQL data folder */ 01875 01876 static void getvolumename() 01877 { 01878 char *p; 01879 /* 01880 We assume that data path is already set. 01881 If not it won't come here. Terminate after volume name 01882 */ 01883 if ((p= strchr(mysql_real_data_home, ':'))) 01884 strmake(datavolname, mysql_real_data_home, 01885 (uint) (p - mysql_real_data_home)); 01886 } 01887 01888 01889 /* 01890 Registering with NEB for NSS Volume Deactivation event 01891 */ 01892 01893 static void registerwithneb() 01894 { 01895 01896 ConsumerRegistrationInfo reg_info; 01897 01898 /* Clear NEB registration structure */ 01899 bzero((char*) ®_info, sizeof(struct ConsumerRegistrationInfo)); 01900 01901 /* Fill the NEB consumer information structure */ 01902 reg_info.CRIVersion= 1; // NEB version 01903 /* NEB Consumer name */ 01904 reg_info.CRIConsumerName= (BYTE *) "MySQL Database Server"; 01905 /* Event of interest */ 01906 reg_info.CRIEventName= (BYTE *) "NSS.ChangeVolState.Enter"; 01907 reg_info.CRIUserParameter= NULL; // Consumer Info 01908 reg_info.CRIEventFlags= 0; // Event flags 01909 /* Consumer NLM handle */ 01910 reg_info.CRIOwnerID= (LoadDefinitionStructure *)getnlmhandle(); 01911 reg_info.CRIConsumerESR= NULL; // No consumer ESR required 01912 reg_info.CRISecurityToken= 0; // No security token for the event 01913 reg_info.CRIConsumerFlags= 0; // SMP_ENABLED_BIT; 01914 reg_info.CRIFilterName= 0; // No event filtering 01915 reg_info.CRIFilterDataLength= 0; // No filtering data 01916 reg_info.CRIFilterData= 0; // No filtering data 01917 /* Callback function for the event */ 01918 (void *)reg_info.CRIConsumerCallback= (void *) refneb; 01919 reg_info.CRIOrder= 0; // Event callback order 01920 reg_info.CRIConsumerType= CHECK_CONSUMER; // Consumer type 01921 01922 /* Register for the event with NEB */ 01923 if (RegisterConsumer(®_info)) 01924 { 01925 consoleprintf("Failed to register for NSS Volume Deactivation event \n"); 01926 return; 01927 } 01928 /* This ID is required for deregistration */ 01929 neb_consumer_id= reg_info.CRIConsumerID; 01930 01931 /* Get MySQL data volume name, stored in global variable datavolname */ 01932 getvolumename(); 01933 01934 /* 01935 Get the NSS volume ID of the MySQL Data volume. 01936 Volume ID is stored in a global variable 01937 */ 01938 getvolumeID((BYTE*) datavolname); 01939 } 01940 01941 01942 /* 01943 Callback for NSS Volume Deactivation event 01944 */ 01945 01946 ulong neb_event_callback(struct EventBlock *eblock) 01947 { 01948 EventChangeVolStateEnter_s *voldata; 01949 extern bool nw_panic; 01950 01951 voldata= (EventChangeVolStateEnter_s *)eblock->EBEventData; 01952 01953 /* Deactivation of a volume */ 01954 if ((voldata->oldState == zVOLSTATE_ACTIVE && 01955 voldata->newState == zVOLSTATE_DEACTIVE || 01956 voldata->newState == zVOLSTATE_MAINTENANCE)) 01957 { 01958 /* 01959 Ensure that we bring down MySQL server only for MySQL data 01960 volume deactivation 01961 */ 01962 if (!memcmp(&voldata->volID, &datavolid, sizeof(VolumeID_t))) 01963 { 01964 consoleprintf("MySQL data volume is deactivated, shutting down MySQL Server \n"); 01965 event_flag= TRUE; 01966 nw_panic = TRUE; 01967 event_flag= TRUE; 01968 kill_server(0); 01969 } 01970 } 01971 return 0; 01972 } 01973 01974 01975 /* 01976 Function to get NSS volume ID of the MySQL data 01977 */ 01978 01979 #define ADMIN_VOL_PATH "_ADMIN:/Volumes/" 01980 01981 static void getvolumeID(BYTE *volumeName) 01982 { 01983 char path[zMAX_FULL_NAME]; 01984 Key_t rootKey= 0, fileKey= 0; 01985 QUAD getInfoMask; 01986 zInfo_s info; 01987 STATUS status; 01988 01989 /* Get the root key */ 01990 if ((status= zRootKey(0, &rootKey)) != zOK) 01991 { 01992 consoleprintf("\nGetNSSVolumeProperties - Failed to get root key, status: %d\n.", (int) status); 01993 goto exit; 01994 } 01995 01996 /* 01997 Get the file key. This is the key to the volume object in the 01998 NSS admin volumes directory. 01999 */ 02000 02001 strxmov(path, (const char *) ADMIN_VOL_PATH, (const char *) volumeName, 02002 NullS); 02003 if ((status= zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, 02004 (BYTE *) path, zRR_READ_ACCESS, &fileKey)) != zOK) 02005 { 02006 consoleprintf("\nGetNSSVolumeProperties - Failed to get file, status: %d\n.", (int) status); 02007 goto exit; 02008 } 02009 02010 getInfoMask= zGET_IDS | zGET_VOLUME_INFO ; 02011 if ((status= zGetInfo(fileKey, getInfoMask, sizeof(info), 02012 zINFO_VERSION_A, &info)) != zOK) 02013 { 02014 consoleprintf("\nGetNSSVolumeProperties - Failed in zGetInfo, status: %d\n.", (int) status); 02015 goto exit; 02016 } 02017 02018 /* Copy the data to global variable */ 02019 datavolid.timeLow= info.vol.volumeID.timeLow; 02020 datavolid.timeMid= info.vol.volumeID.timeMid; 02021 datavolid.timeHighAndVersion= info.vol.volumeID.timeHighAndVersion; 02022 datavolid.clockSeqHighAndReserved= info.vol.volumeID.clockSeqHighAndReserved; 02023 datavolid.clockSeqLow= info.vol.volumeID.clockSeqLow; 02024 /* This is guranteed to be 6-byte length (but sizeof() would be better) */ 02025 memcpy(datavolid.node, info.vol.volumeID.node, (unsigned int) 6); 02026 02027 exit: 02028 if (rootKey) 02029 zClose(rootKey); 02030 if (fileKey) 02031 zClose(fileKey); 02032 } 02033 02034 02035 static void init_signals(void) 02036 { 02037 int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT}; 02038 02039 for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++) 02040 signal(signals[i], kill_server); 02041 mysql_cb_init(); // initialize callbacks 02042 02043 } 02044 02045 static void start_signal_handler(void) 02046 { 02047 // Save vm id of this process 02048 if (!opt_bootstrap) 02049 create_pid_file(); 02050 // no signal handler 02051 } 02052 02053 02054 /* 02055 Warn if the data is on a Traditional volume 02056 02057 NOTE 02058 Already done by mysqld_safe 02059 */ 02060 02061 static void check_data_home(const char *path) 02062 { 02063 } 02064 02065 #else /* if ! __WIN__ */ 02066 02067 #ifdef HAVE_LINUXTHREADS 02068 #define UNSAFE_DEFAULT_LINUX_THREADS 200 02069 #endif 02070 02071 extern "C" sig_handler handle_segfault(int sig) 02072 { 02073 THD *thd=current_thd; 02074 /* 02075 Strictly speaking, one needs a mutex here 02076 but since we have got SIGSEGV already, things are a mess 02077 so not having the mutex is not as bad as possibly using a buggy 02078 mutex - so we keep things simple 02079 */ 02080 if (segfaulted) 02081 { 02082 fprintf(stderr, "Fatal signal %d while backtracing\n", sig); 02083 exit(1); 02084 } 02085 02086 segfaulted = 1; 02087 fprintf(stderr,"\ 02088 mysqld got signal %d;\n\ 02089 This could be because you hit a bug. It is also possible that this binary\n\ 02090 or one of the libraries it was linked against is corrupt, improperly built,\n\ 02091 or misconfigured. This error can also be caused by malfunctioning hardware.\n", 02092 sig); 02093 fprintf(stderr, "\ 02094 We will try our best to scrape up some info that will hopefully help diagnose\n\ 02095 the problem, but since we have already crashed, something is definitely wrong\n\ 02096 and this may fail.\n\n"); 02097 fprintf(stderr, "key_buffer_size=%lu\n", 02098 (ulong) dflt_key_cache->key_cache_mem_size); 02099 fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); 02100 fprintf(stderr, "max_used_connections=%lu\n", max_used_connections); 02101 fprintf(stderr, "max_connections=%lu\n", max_connections); 02102 fprintf(stderr, "threads_connected=%u\n", thread_count); 02103 fprintf(stderr, "It is possible that mysqld could use up to \n\ 02104 key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %lu K\n\ 02105 bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + 02106 (global_system_variables.read_buff_size + 02107 global_system_variables.sortbuff_size) * 02108 max_connections)/ 1024); 02109 fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); 02110 02111 #if defined(HAVE_LINUXTHREADS) 02112 if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS) 02113 { 02114 fprintf(stderr, "\ 02115 You seem to be running 32-bit Linux and have %d concurrent connections.\n\ 02116 If you have not changed STACK_SIZE in LinuxThreads and built the binary \n\ 02117 yourself, LinuxThreads is quite likely to steal a part of the global heap for\n\ 02118 the thread stack. Please read http://www.mysql.com/doc/en/Linux.html\n\n", 02119 thread_count); 02120 } 02121 #endif /* HAVE_LINUXTHREADS */ 02122 02123 #ifdef HAVE_STACKTRACE 02124 if (!(test_flags & TEST_NO_STACKTRACE)) 02125 { 02126 fprintf(stderr,"thd=%p\n",thd); 02127 print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0, 02128 thread_stack); 02129 } 02130 if (thd) 02131 { 02132 fprintf(stderr, "Trying to get some variables.\n\ 02133 Some pointers may be invalid and cause the dump to abort...\n"); 02134 safe_print_str("thd->query", thd->query, 1024); 02135 fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id); 02136 } 02137 fprintf(stderr, "\ 02138 The manual page at http://www.mysql.com/doc/en/Crashing.html contains\n\ 02139 information that should help you find out what is causing the crash.\n"); 02140 fflush(stderr); 02141 #endif /* HAVE_STACKTRACE */ 02142 02143 #ifdef HAVE_INITGROUPS 02144 if (calling_initgroups) 02145 fprintf(stderr, "\n\ 02146 This crash occured while the server was calling initgroups(). This is\n\ 02147 often due to the use of a mysqld that is statically linked against glibc\n\ 02148 and configured to use LDAP in /etc/nsswitch.conf. You will need to either\n\ 02149 upgrade to a version of glibc that does not have this problem (2.3.4 or\n\ 02150 later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\ 02151 mysqld that is not statically linked.\n"); 02152 #endif 02153 02154 if (test_flags & TEST_CORE_ON_SIGNAL) 02155 { 02156 fprintf(stderr, "Writing a core file\n"); 02157 fflush(stderr); 02158 write_core(sig); 02159 } 02160 exit(1); 02161 } 02162 02163 #ifndef SA_RESETHAND 02164 #define SA_RESETHAND 0 02165 #endif 02166 #ifndef SA_NODEFER 02167 #define SA_NODEFER 0 02168 #endif 02169 02170 static void init_signals(void) 02171 { 02172 sigset_t set; 02173 struct sigaction sa; 02174 DBUG_ENTER("init_signals"); 02175 02176 if (test_flags & TEST_SIGINT) 02177 my_sigset(THR_KILL_SIGNAL,end_thread_signal); 02178 my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! 02179 02180 if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) 02181 { 02182 sa.sa_flags = SA_RESETHAND | SA_NODEFER; 02183 sigemptyset(&sa.sa_mask); 02184 sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); 02185 02186 init_stacktrace(); 02187 #if defined(__amiga__) 02188 sa.sa_handler=(void(*)())handle_segfault; 02189 #else 02190 sa.sa_handler=handle_segfault; 02191 #endif 02192 sigaction(SIGSEGV, &sa, NULL); 02193 sigaction(SIGABRT, &sa, NULL); 02194 #ifdef SIGBUS 02195 sigaction(SIGBUS, &sa, NULL); 02196 #endif 02197 sigaction(SIGILL, &sa, NULL); 02198 sigaction(SIGFPE, &sa, NULL); 02199 } 02200 02201 #ifdef HAVE_GETRLIMIT 02202 if (test_flags & TEST_CORE_ON_SIGNAL) 02203 { 02204 /* Change limits so that we will get a core file */ 02205 STRUCT_RLIMIT rl; 02206 rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; 02207 if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings) 02208 sql_print_warning("setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals"); 02209 } 02210 #endif 02211 (void) sigemptyset(&set); 02212 my_sigset(SIGPIPE,SIG_IGN); 02213 sigaddset(&set,SIGPIPE); 02214 sigaddset(&set,SIGINT); 02215 #ifndef IGNORE_SIGHUP_SIGQUIT 02216 sigaddset(&set,SIGQUIT); 02217 sigaddset(&set,SIGHUP); 02218 #endif 02219 sigaddset(&set,SIGTERM); 02220 02221 /* Fix signals if blocked by parents (can happen on Mac OS X) */ 02222 sigemptyset(&sa.sa_mask); 02223 sa.sa_flags = 0; 02224 sa.sa_handler = print_signal_warning; 02225 sigaction(SIGTERM, &sa, (struct sigaction*) 0); 02226 sa.sa_flags = 0; 02227 sa.sa_handler = print_signal_warning; 02228 sigaction(SIGHUP, &sa, (struct sigaction*) 0); 02229 #ifdef SIGTSTP 02230 sigaddset(&set,SIGTSTP); 02231 #endif 02232 sigaddset(&set,THR_SERVER_ALARM); 02233 if (test_flags & TEST_SIGINT) 02234 sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT 02235 sigdelset(&set,THR_CLIENT_ALARM); // For alarms 02236 sigprocmask(SIG_SETMASK,&set,NULL); 02237 pthread_sigmask(SIG_SETMASK,&set,NULL); 02238 DBUG_VOID_RETURN; 02239 } 02240 02241 02242 #ifndef EMBEDDED_LIBRARY 02243 static void start_signal_handler(void) 02244 { 02245 int error; 02246 pthread_attr_t thr_attr; 02247 DBUG_ENTER("start_signal_handler"); 02248 02249 (void) pthread_attr_init(&thr_attr); 02250 #if !defined(HAVE_DEC_3_2_THREADS) 02251 pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM); 02252 (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); 02253 if (!(opt_specialflag & SPECIAL_NO_PRIOR)) 02254 my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR); 02255 #if defined(__ia64__) || defined(__ia64) 02256 /* 02257 Peculiar things with ia64 platforms - it seems we only have half the 02258 stack size in reality, so we have to double it here 02259 */ 02260 pthread_attr_setstacksize(&thr_attr,thread_stack*2); 02261 #else 02262 pthread_attr_setstacksize(&thr_attr,thread_stack); 02263 #endif 02264 #endif 02265 02266 (void) pthread_mutex_lock(&LOCK_thread_count); 02267 if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0))) 02268 { 02269 sql_print_error("Can't create interrupt-thread (error %d, errno: %d)", 02270 error,errno); 02271 exit(1); 02272 } 02273 (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); 02274 pthread_mutex_unlock(&LOCK_thread_count); 02275 02276 (void) pthread_attr_destroy(&thr_attr); 02277 DBUG_VOID_RETURN; 02278 } 02279 02280 02281 /* This threads handles all signals and alarms */ 02282 02283 /* ARGSUSED */ 02284 pthread_handler_t signal_hand(void *arg __attribute__((unused))) 02285 { 02286 sigset_t set; 02287 int sig; 02288 my_thread_init(); // Init new thread 02289 DBUG_ENTER("signal_hand"); 02290 signal_thread_in_use= 1; 02291 02292 /* 02293 Setup alarm handler 02294 This should actually be '+ max_number_of_slaves' instead of +10, 02295 but the +10 should be quite safe. 02296 */ 02297 init_thr_alarm(max_connections + 02298 global_system_variables.max_insert_delayed_threads + 10); 02299 #if SIGINT != THR_KILL_SIGNAL 02300 if (test_flags & TEST_SIGINT) 02301 { 02302 (void) sigemptyset(&set); // Setup up SIGINT for debug 02303 (void) sigaddset(&set,SIGINT); // For debugging 02304 (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL); 02305 } 02306 #endif 02307 (void) sigemptyset(&set); // Setup up SIGINT for debug 02308 #ifdef USE_ONE_SIGNAL_HAND 02309 (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms 02310 #endif 02311 #ifndef IGNORE_SIGHUP_SIGQUIT 02312 (void) sigaddset(&set,SIGQUIT); 02313 #if THR_CLIENT_ALARM != SIGHUP 02314 (void) sigaddset(&set,SIGHUP); 02315 #endif 02316 #endif 02317 (void) sigaddset(&set,SIGTERM); 02318 (void) sigaddset(&set,SIGTSTP); 02319 02320 /* Save pid to this process (or thread on Linux) */ 02321 if (!opt_bootstrap) 02322 create_pid_file(); 02323 02324 #ifdef HAVE_STACK_TRACE_ON_SEGV 02325 if (opt_do_pstack) 02326 { 02327 sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (ulong)getpid()); 02328 pstack_install_segv_action(pstack_file_name); 02329 } 02330 #endif /* HAVE_STACK_TRACE_ON_SEGV */ 02331 02332 /* 02333 signal to start_signal_handler that we are ready 02334 This works by waiting for start_signal_handler to free mutex, 02335 after which we signal it that we are ready. 02336 At this pointer there is no other threads running, so there 02337 should not be any other pthread_cond_signal() calls. 02338 */ 02339 (void) pthread_mutex_lock(&LOCK_thread_count); 02340 (void) pthread_mutex_unlock(&LOCK_thread_count); 02341 (void) pthread_cond_broadcast(&COND_thread_count); 02342 02343 (void) pthread_sigmask(SIG_BLOCK,&set,NULL); 02344 for (;;) 02345 { 02346 int error; // Used when debugging 02347 if (shutdown_in_progress && !abort_loop) 02348 { 02349 sig= SIGTERM; 02350 error=0; 02351 } 02352 else 02353 while ((error=my_sigwait(&set,&sig)) == EINTR) ; 02354 if (cleanup_done) 02355 { 02356 DBUG_PRINT("quit",("signal_handler: calling my_thread_end()")); 02357 my_thread_end(); 02358 signal_thread_in_use= 0; 02359 pthread_exit(0); // Safety 02360 } 02361 switch (sig) { 02362 case SIGTERM: 02363 case SIGQUIT: 02364 case SIGKILL: 02365 #ifdef EXTRA_DEBUG 02366 sql_print_information("Got signal %d to shutdown mysqld",sig); 02367 #endif 02368 /* switch to the old log message processing */ 02369 logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, 02370 opt_log ? LOG_FILE:LOG_NONE); 02371 DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop)); 02372 if (!abort_loop) 02373 { 02374 abort_loop=1; // mark abort for threads 02375 #ifdef USE_ONE_SIGNAL_HAND 02376 pthread_t tmp; 02377 if (!(opt_specialflag & SPECIAL_NO_PRIOR)) 02378 my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR); 02379 if (pthread_create(&tmp,&connection_attrib, kill_server_thread, 02380 (void*) &sig)) 02381 sql_print_error("Can't create thread to kill server"); 02382 #else 02383 kill_server((void*) sig); // MIT THREAD has a alarm thread 02384 #endif 02385 } 02386 break; 02387 case SIGHUP: 02388 if (!abort_loop) 02389 { 02390 bool not_used; 02391 mysql_print_status(); // Print some debug info 02392 reload_acl_and_cache((THD*) 0, 02393 (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | 02394 REFRESH_GRANT | 02395 REFRESH_THREADS | REFRESH_HOSTS), 02396 (TABLE_LIST*) 0, ¬_used); // Flush logs 02397 } 02398 /* reenable logs after the options were reloaded */ 02399 logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_TABLE:LOG_NONE, 02400 opt_log ? LOG_TABLE:LOG_NONE); 02401 break; 02402 #ifdef USE_ONE_SIGNAL_HAND 02403 case THR_SERVER_ALARM: 02404 process_alarm(sig); // Trigger alarms. 02405 break; 02406 #endif 02407 default: 02408 #ifdef EXTRA_DEBUG 02409 sql_print_warning("Got signal: %d error: %d",sig,error); /* purecov: tested */ 02410 #endif 02411 break; /* purecov: tested */ 02412 } 02413 } 02414 return(0); /* purecov: deadcode */ 02415 } 02416 #endif 02418 static void check_data_home(const char *path) 02419 {} 02420 02421 #endif /* __WIN__*/ 02422 02423 02424 /* 02425 All global error messages are sent here where the first one is stored 02426 for the client 02427 */ 02428 02429 02430 /* ARGSUSED */ 02431 static int my_message_sql(uint error, const char *str, myf MyFlags) 02432 { 02433 THD *thd; 02434 DBUG_ENTER("my_message_sql"); 02435 DBUG_PRINT("error", ("error: %u message: '%s'", error, str)); 02436 /* 02437 Put here following assertion when situation with EE_* error codes 02438 will be fixed 02439 DBUG_ASSERT(error != 0); 02440 */ 02441 if ((thd= current_thd)) 02442 { 02443 if (thd->spcont && 02444 thd->spcont->find_handler(error, MYSQL_ERROR::WARN_LEVEL_ERROR)) 02445 { 02446 if (! thd->spcont->found_handler_here()) 02447 thd->net.report_error= 1; /* Make "select" abort correctly */ 02448 DBUG_RETURN(0); 02449 } 02450 02451 thd->query_error= 1; // needed to catch query errors during replication 02452 02453 if (!thd->no_warnings_for_error) 02454 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); 02455 /* 02456 thd->lex->current_select == 0 if lex structure is not inited 02457 (not query command (COM_QUERY)) 02458 */ 02459 if (thd->lex->current_select && 02460 thd->lex->current_select->no_error && !thd->is_fatal_error) 02461 { 02462 DBUG_PRINT("error", 02463 ("Error converted to warning: current_select: no_error %d " 02464 "fatal_error: %d", 02465 (thd->lex->current_select ? 02466 thd->lex->current_select->no_error : 0), 02467 (int) thd->is_fatal_error)); 02468 } 02469 else 02470 { 02471 NET *net= &thd->net; 02472 net->report_error= 1; 02473 query_cache_abort(net); 02474 if (!net->last_error[0]) // Return only first message 02475 { 02476 strmake(net->last_error, str, sizeof(net->last_error)-1); 02477 net->last_errno= error ? error : ER_UNKNOWN_ERROR; 02478 } 02479 } 02480 } 02481 if (!thd || MyFlags & ME_NOREFRESH) 02482 sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */ 02483 DBUG_RETURN(0); 02484 } 02485 02486 02487 static void *my_str_malloc_mysqld(size_t size) 02488 { 02489 return my_malloc(size, MYF(MY_FAE)); 02490 } 02491 02492 02493 static void my_str_free_mysqld(void *ptr) 02494 { 02495 my_free((gptr)ptr, MYF(MY_FAE)); 02496 } 02497 02498 02499 #ifdef __WIN__ 02500 02501 struct utsname 02502 { 02503 char nodename[FN_REFLEN]; 02504 }; 02505 02506 02507 int uname(struct utsname *a) 02508 { 02509 return -1; 02510 } 02511 02512 02513 pthread_handler_t handle_shutdown(void *arg) 02514 { 02515 MSG msg; 02516 my_thread_init(); 02517 02518 /* this call should create the message queue for this thread */ 02519 PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE); 02520 #if !defined(EMBEDDED_LIBRARY) 02521 if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0) 02522 #endif /* EMBEDDED_LIBRARY */ 02523 kill_server(MYSQL_KILL_SIGNAL); 02524 return 0; 02525 } 02526 02527 02528 int STDCALL handle_kill(ulong ctrl_type) 02529 { 02530 if (ctrl_type == CTRL_CLOSE_EVENT || 02531 ctrl_type == CTRL_SHUTDOWN_EVENT) 02532 { 02533 kill_server(MYSQL_KILL_SIGNAL); 02534 return TRUE; 02535 } 02536 return FALSE; 02537 } 02538 #endif 02539 02540 static const char *load_default_groups[]= { 02541 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 02542 "mysql_cluster", 02543 #endif 02544 "mysqld","server", MYSQL_BASE_VERSION, 0, 0}; 02545 02546 #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) 02547 static const int load_default_groups_sz= 02548 sizeof(load_default_groups)/sizeof(load_default_groups[0]); 02549 #endif 02550 02551 02552 /* 02553 Initialize one of the global date/time format variables 02554 02555 SYNOPSIS 02556 init_global_datetime_format() 02557 format_type What kind of format should be supported 02558 var_ptr Pointer to variable that should be updated 02559 02560 NOTES 02561 The default value is taken from either opt_date_time_formats[] or 02562 the ISO format (ANSI SQL) 02563 02564 RETURN 02565 0 ok 02566 1 error 02567 */ 02568 02569 static bool init_global_datetime_format(timestamp_type format_type, 02570 DATE_TIME_FORMAT **var_ptr) 02571 { 02572 /* Get command line option */ 02573 const char *str= opt_date_time_formats[format_type]; 02574 02575 if (!str) // No specified format 02576 { 02577 str= get_date_time_format_str(&known_date_time_formats[ISO_FORMAT], 02578 format_type); 02579 /* 02580 Set the "command line" option to point to the generated string so 02581 that we can set global formats back to default 02582 */ 02583 opt_date_time_formats[format_type]= str; 02584 } 02585 if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str)))) 02586 { 02587 fprintf(stderr, "Wrong date/time format specifier: %s\n", str); 02588 return 1; 02589 } 02590 return 0; 02591 } 02592 02593 02594 static int init_common_variables(const char *conf_file_name, int argc, 02595 char **argv, const char **groups) 02596 { 02597 char buff[FN_REFLEN]; 02598 umask(((~my_umask) & 0666)); 02599 my_decimal_set_zero(&decimal_zero); // set decimal_zero constant; 02600 tzset(); // Set tzname 02601 02602 max_system_variables.pseudo_thread_id= (ulong)~0; 02603 start_time=time((time_t*) 0); 02604 if (init_thread_environment()) 02605 return 1; 02606 mysql_init_variables(); 02607 02608 #ifdef HAVE_TZNAME 02609 { 02610 struct tm tm_tmp; 02611 localtime_r(&start_time,&tm_tmp); 02612 strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0], 02613 sizeof(system_time_zone)-1); 02614 02615 } 02616 #endif 02617 /* 02618 We set SYSTEM time zone as reasonable default and 02619 also for failure of my_tz_init() and bootstrap mode. 02620 If user explicitly set time zone with --default-time-zone 02621 option we will change this value in my_tz_init(). 02622 */ 02623 global_system_variables.time_zone= my_tz_SYSTEM; 02624 02625 /* 02626 Init mutexes for the global MYSQL_BIN_LOG objects. 02627 As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of 02628 global MYSQL_BIN_LOGs in their constructors, because then they would be 02629 inited before MY_INIT(). So we do it here. 02630 */ 02631 mysql_bin_log.init_pthread_objects(); 02632 02633 if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0) 02634 strmov(glob_hostname,"mysql"); 02635 strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5); 02636 strmov(fn_ext(pidfile_name),".pid"); // Add proper extension 02637 02638 /* 02639 Add server status variables to the dynamic list of 02640 status variables that is shown by SHOW STATUS. 02641 Later, in plugin_init, plugin_load, and mysql_install_plugin 02642 new entries could be added to that list. 02643 */ 02644 if (add_status_vars(status_vars)) 02645 return 1; // an error was already reported 02646 02647 load_defaults(conf_file_name, groups, &argc, &argv); 02648 defaults_argv=argv; 02649 get_options(argc,argv); 02650 set_server_version(); 02651 02652 DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, 02653 server_version, SYSTEM_TYPE,MACHINE_TYPE)); 02654 02655 #ifdef HAVE_LARGE_PAGES 02656 /* Initialize large page size */ 02657 if (opt_large_pages && (opt_large_page_size= my_get_large_page_size())) 02658 { 02659 my_use_large_pages= 1; 02660 my_large_page_size= opt_large_page_size; 02661 #ifdef WITH_INNOBASE_STORAGE_ENGINE 02662 innobase_use_large_pages= 1; 02663 innobase_large_page_size= opt_large_page_size; 02664 #endif 02665 } 02666 #endif /* HAVE_LARGE_PAGES */ 02667 02668 /* connections and databases needs lots of files */ 02669 { 02670 uint files, wanted_files; 02671 02672 wanted_files= 10+(uint) max(max_connections*5, 02673 max_connections+table_cache_size*2); 02674 set_if_bigger(wanted_files, open_files_limit); 02675 files= my_set_max_open_files(wanted_files); 02676 02677 if (files < wanted_files) 02678 { 02679 if (!open_files_limit) 02680 { 02681 max_connections= (ulong) min((files-10),max_connections); 02682 table_cache_size= (ulong) max((files-10-max_connections)/2,64); 02683 DBUG_PRINT("warning", 02684 ("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", 02685 files, max_connections, table_cache_size)); 02686 if (global_system_variables.log_warnings) 02687 sql_print_warning("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", 02688 files, max_connections, table_cache_size); 02689 } 02690 else if (global_system_variables.log_warnings) 02691 sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); 02692 } 02693 open_files_limit= files; 02694 } 02695 unireg_init(opt_specialflag); /* Set up extern variabels */ 02696 if (init_errmessage()) /* Read error messages from file */ 02697 return 1; 02698 init_client_errs(); 02699 lex_init(); 02700 item_init(); 02701 set_var_init(); 02702 mysys_uses_curses=0; 02703 #ifdef USE_REGEX 02704 my_regex_init(&my_charset_latin1); 02705 #endif 02706 if (!(default_charset_info= get_charset_by_csname(default_character_set_name, 02707 MY_CS_PRIMARY, 02708 MYF(MY_WME)))) 02709 return 1; 02710 if (default_collation_name) 02711 { 02712 CHARSET_INFO *default_collation; 02713 default_collation= get_charset_by_name(default_collation_name, MYF(0)); 02714 if (!default_collation) 02715 { 02716 sql_print_error(ER(ER_UNKNOWN_COLLATION), default_collation_name); 02717 return 1; 02718 } 02719 if (!my_charset_same(default_charset_info, default_collation)) 02720 { 02721 sql_print_error(ER(ER_COLLATION_CHARSET_MISMATCH), 02722 default_collation_name, 02723 default_charset_info->csname); 02724 return 1; 02725 } 02726 default_charset_info= default_collation; 02727 } 02728 /* Set collactions that depends on the default collation */ 02729 global_system_variables.collation_server= default_charset_info; 02730 global_system_variables.collation_database= default_charset_info; 02731 global_system_variables.collation_connection= default_charset_info; 02732 global_system_variables.character_set_results= default_charset_info; 02733 global_system_variables.character_set_client= default_charset_info; 02734 global_system_variables.collation_connection= default_charset_info; 02735 02736 if (!(character_set_filesystem= 02737 get_charset_by_csname(character_set_filesystem_name, 02738 MY_CS_PRIMARY, MYF(MY_WME)))) 02739 return 1; 02740 global_system_variables.character_set_filesystem= character_set_filesystem; 02741 02742 sys_init_connect.value_length= 0; 02743 if ((sys_init_connect.value= opt_init_connect)) 02744 sys_init_connect.value_length= strlen(opt_init_connect); 02745 else 02746 sys_init_connect.value=my_strdup("",MYF(0)); 02747 02748 sys_init_slave.value_length= 0; 02749 if ((sys_init_slave.value= opt_init_slave)) 02750 sys_init_slave.value_length= strlen(opt_init_slave); 02751 else 02752 sys_init_slave.value=my_strdup("",MYF(0)); 02753 02754 /* check log options and issue warnings if needed */ 02755 if (opt_log && opt_logname && !(log_output_options & LOG_FILE) && 02756 !(log_output_options & LOG_NONE)) 02757 sql_print_warning("Although a path was specified for the " 02758 "--log option, log tables are used. " 02759 "To enable logging to file use the --log-output option."); 02760 02761 if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE) 02762 && !(log_output_options & LOG_NONE)) 02763 sql_print_warning("Although a path was specified for the " 02764 "--log-slow-queries option, log tables are used. " 02765 "To enable logging to file use the --log-output option."); 02766 02767 if (!opt_logname) 02768 opt_logname= make_default_log_name(buff, ".log"); 02769 sys_var_general_log_path.value= my_strdup(opt_logname, MYF(0)); 02770 sys_var_general_log_path.value_length= strlen(opt_logname); 02771 02772 if (!opt_slow_logname) 02773 opt_slow_logname= make_default_log_name(buff, "-slow.log"); 02774 sys_var_slow_log_path.value= my_strdup(opt_slow_logname, MYF(0)); 02775 sys_var_slow_log_path.value_length= strlen(opt_slow_logname); 02776 02777 if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1)) 02778 return 1; 02779 if (my_database_names_init()) 02780 return 1; 02781 02782 /* 02783 Ensure that lower_case_table_names is set on system where we have case 02784 insensitive names. If this is not done the users MyISAM tables will 02785 get corrupted if accesses with names of different case. 02786 */ 02787 DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names)); 02788 lower_case_file_system= test_if_case_insensitive(mysql_real_data_home); 02789 if (!lower_case_table_names && lower_case_file_system == 1) 02790 { 02791 if (lower_case_table_names_used) 02792 { 02793 if (global_system_variables.log_warnings) 02794 sql_print_warning("\ 02795 You have forced lower_case_table_names to 0 through a command-line \ 02796 option, even though your file system '%s' is case insensitive. This means \ 02797 that you can corrupt a MyISAM table by accessing it with different cases. \ 02798 You should consider changing lower_case_table_names to 1 or 2", 02799 mysql_real_data_home); 02800 } 02801 else 02802 { 02803 if (global_system_variables.log_warnings) 02804 sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); 02805 lower_case_table_names= 2; 02806 } 02807 } 02808 else if (lower_case_table_names == 2 && 02809 !(lower_case_file_system= 02810 (test_if_case_insensitive(mysql_real_data_home) == 1))) 02811 { 02812 if (global_system_variables.log_warnings) 02813 sql_print_warning("lower_case_table_names was set to 2, even though your " 02814 "the file system '%s' is case sensitive. Now setting " 02815 "lower_case_table_names to 0 to avoid future problems.", 02816 mysql_real_data_home); 02817 lower_case_table_names= 0; 02818 } 02819 else 02820 { 02821 lower_case_file_system= 02822 (test_if_case_insensitive(mysql_real_data_home) == 1); 02823 } 02824 02825 /* Reset table_alias_charset, now that lower_case_table_names is set. */ 02826 table_alias_charset= (lower_case_table_names ? 02827 files_charset_info : 02828 &my_charset_bin); 02829 02830 return 0; 02831 } 02832 02833 02834 static int init_thread_environment() 02835 { 02836 (void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW); 02837 (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW); 02838 (void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW); 02839 (void) pthread_mutex_init(&LOCK_open, NULL); 02840 (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST); 02841 (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW); 02842 (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST); 02843 (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST); 02844 (void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST); 02845 (void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST); 02846 (void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW); 02847 (void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST); 02848 (void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST); 02849 (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST); 02850 (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST); 02851 (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST); 02852 (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); 02853 (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST); 02854 (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST); 02855 (void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST); 02856 (void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST); 02857 #ifdef HAVE_OPENSSL 02858 (void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST); 02859 #ifndef HAVE_YASSL 02860 openssl_stdlocks= (openssl_lock_t*) OPENSSL_malloc(CRYPTO_num_locks() * 02861 sizeof(openssl_lock_t)); 02862 for (int i= 0; i < CRYPTO_num_locks(); ++i) 02863 (void) my_rwlock_init(&openssl_stdlocks[i].lock, NULL); 02864 CRYPTO_set_dynlock_create_callback(openssl_dynlock_create); 02865 CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy); 02866 CRYPTO_set_dynlock_lock_callback(openssl_lock); 02867 CRYPTO_set_locking_callback(openssl_lock_function); 02868 CRYPTO_set_id_callback(openssl_id_function); 02869 #endif 02870 #endif 02871 (void) my_rwlock_init(&LOCK_sys_init_connect, NULL); 02872 (void) my_rwlock_init(&LOCK_sys_init_slave, NULL); 02873 (void) my_rwlock_init(&LOCK_grant, NULL); 02874 (void) pthread_cond_init(&COND_thread_count,NULL); 02875 (void) pthread_cond_init(&COND_refresh,NULL); 02876 (void) pthread_cond_init(&COND_global_read_lock,NULL); 02877 (void) pthread_cond_init(&COND_thread_cache,NULL); 02878 (void) pthread_cond_init(&COND_flush_thread_cache,NULL); 02879 (void) pthread_cond_init(&COND_manager,NULL); 02880 #ifdef HAVE_REPLICATION 02881 (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); 02882 (void) pthread_cond_init(&COND_rpl_status, NULL); 02883 #endif 02884 (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST); 02885 (void) pthread_cond_init(&COND_server_started,NULL); 02886 sp_cache_init(); 02887 Events::init_mutexes(); 02888 /* Parameter for threads created for connections */ 02889 (void) pthread_attr_init(&connection_attrib); 02890 (void) pthread_attr_setdetachstate(&connection_attrib, 02891 PTHREAD_CREATE_DETACHED); 02892 pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); 02893 if (!(opt_specialflag & SPECIAL_NO_PRIOR)) 02894 my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR); 02895 02896 if (pthread_key_create(&THR_THD,NULL) || 02897 pthread_key_create(&THR_MALLOC,NULL)) 02898 { 02899 sql_print_error("Can't create thread-keys"); 02900 return 1; 02901 } 02902 return 0; 02903 } 02904 02905 02906 #if defined(HAVE_OPENSSL) && !defined(HAVE_YASSL) 02907 static unsigned long openssl_id_function() 02908 { 02909 return (unsigned long) pthread_self(); 02910 } 02911 02912 02913 static openssl_lock_t *openssl_dynlock_create(const char *file, int line) 02914 { 02915 openssl_lock_t *lock= new openssl_lock_t; 02916 my_rwlock_init(&lock->lock, NULL); 02917 return lock; 02918 } 02919 02920 02921 static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file, 02922 int line) 02923 { 02924 rwlock_destroy(&lock->lock); 02925 delete lock; 02926 } 02927 02928 02929 static void openssl_lock_function(int mode, int n, const char *file, int line) 02930 { 02931 if (n < 0 || n > CRYPTO_num_locks()) 02932 { 02933 /* Lock number out of bounds. */ 02934 sql_print_error("Fatal: OpenSSL interface problem (n = %d)", n); 02935 abort(); 02936 } 02937 openssl_lock(mode, &openssl_stdlocks[n], file, line); 02938 } 02939 02940 02941 static void openssl_lock(int mode, openssl_lock_t *lock, const char *file, 02942 int line) 02943 { 02944 int err; 02945 char const *what; 02946 02947 switch (mode) { 02948 case CRYPTO_LOCK|CRYPTO_READ: 02949 what = "read lock"; 02950 err = rw_rdlock(&lock->lock); 02951 break; 02952 case CRYPTO_LOCK|CRYPTO_WRITE: 02953 what = "write lock"; 02954 err = rw_wrlock(&lock->lock); 02955 break; 02956 case CRYPTO_UNLOCK|CRYPTO_READ: 02957 case CRYPTO_UNLOCK|CRYPTO_WRITE: 02958 what = "unlock"; 02959 err = rw_unlock(&lock->lock); 02960 break; 02961 default: 02962 /* Unknown locking mode. */ 02963 sql_print_error("Fatal: OpenSSL interface problem (mode=0x%x)", mode); 02964 abort(); 02965 } 02966 if (err) 02967 { 02968 sql_print_error("Fatal: can't %s OpenSSL %s lock", what); 02969 abort(); 02970 } 02971 } 02972 #endif /* HAVE_OPENSSL */ 02973 02974 02975 static void init_ssl() 02976 { 02977 #ifdef HAVE_OPENSSL 02978 if (opt_use_ssl) 02979 { 02980 /* having ssl_acceptor_fd != 0 signals the use of SSL */ 02981 ssl_acceptor_fd= new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert, 02982 opt_ssl_ca, opt_ssl_capath, 02983 opt_ssl_cipher); 02984 DBUG_PRINT("info",("ssl_acceptor_fd: 0x%lx", (long) ssl_acceptor_fd)); 02985 if (!ssl_acceptor_fd) 02986 { 02987 opt_use_ssl = 0; 02988 have_openssl= SHOW_OPTION_DISABLED; 02989 } 02990 } 02991 else 02992 { 02993 have_openssl= SHOW_OPTION_DISABLED; 02994 } 02995 if (des_key_file) 02996 load_des_key_file(des_key_file); 02997 #endif /* HAVE_OPENSSL */ 02998 } 02999 03000 03001 static void end_ssl() 03002 { 03003 #ifdef HAVE_OPENSSL 03004 if (ssl_acceptor_fd) 03005 { 03006 free_vio_ssl_acceptor_fd(ssl_acceptor_fd); 03007 ssl_acceptor_fd= 0; 03008 } 03009 #endif /* HAVE_OPENSSL */ 03010 } 03011 03012 03013 static int init_server_components() 03014 { 03015 DBUG_ENTER("init_server_components"); 03016 /* 03017 We need to call each of these following functions to ensure that 03018 all things are initialized so that unireg_abort() doesn't fail 03019 */ 03020 if (table_cache_init() | table_def_init() | hostname_cache_init()) 03021 unireg_abort(1); 03022 03023 query_cache_result_size_limit(query_cache_limit); 03024 query_cache_set_min_res_unit(query_cache_min_res_unit); 03025 query_cache_init(); 03026 query_cache_resize(query_cache_size); 03027 randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); 03028 reset_floating_point_exceptions(); 03029 init_thr_lock(); 03030 #ifdef HAVE_REPLICATION 03031 init_slave_list(); 03032 #endif 03033 03034 /* Setup logs */ 03035 03036 /* enable old-fashioned error log */ 03037 if (opt_error_log) 03038 { 03039 if (!log_error_file_ptr[0]) 03040 fn_format(log_error_file, glob_hostname, mysql_data_home, ".err", 03041 MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */ 03042 else 03043 fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err", 03044 MY_UNPACK_FILENAME | MY_SAFE_PATH); 03045 if (!log_error_file[0]) 03046 opt_error_log= 1; // Too long file name 03047 else 03048 { 03049 #ifndef EMBEDDED_LIBRARY 03050 if (freopen(log_error_file, "a+", stdout)) 03051 #endif 03052 freopen(log_error_file, "a+", stderr); 03053 } 03054 } 03055 03056 if (xid_cache_init()) 03057 { 03058 sql_print_error("Out of memory"); 03059 unireg_abort(1); 03060 } 03061 03062 /* need to configure logging before initializing storage engines */ 03063 if (opt_update_log) 03064 { 03065 /* 03066 Update log is removed since 5.0. But we still accept the option. 03067 The idea is if the user already uses the binlog and the update log, 03068 we completely ignore any option/variable related to the update log, like 03069 if the update log did not exist. But if the user uses only the update 03070 log, then we translate everything into binlog for him (with warnings). 03071 Implementation of the above : 03072 - If mysqld is started with --log-update and --log-bin, 03073 ignore --log-update (print a warning), push a warning when SQL_LOG_UPDATE 03074 is used, and turn off --sql-bin-update-same. 03075 This will completely ignore SQL_LOG_UPDATE 03076 - If mysqld is started with --log-update only, 03077 change it to --log-bin (with the filename passed to log-update, 03078 plus '-bin') (print a warning), push a warning when SQL_LOG_UPDATE is 03079 used, and turn on --sql-bin-update-same. 03080 This will translate SQL_LOG_UPDATE to SQL_LOG_BIN. 03081 03082 Note that we tell the user that --sql-bin-update-same is deprecated and 03083 does nothing, and we don't take into account if he used this option or 03084 not; but internally we give this variable a value to have the behaviour 03085 we want (i.e. have SQL_LOG_UPDATE influence SQL_LOG_BIN or not). 03086 As sql-bin-update-same, log-update and log-bin cannot be changed by the 03087 user after starting the server (they are not variables), the user will 03088 not later interfere with the settings we do here. 03089 */ 03090 if (opt_bin_log) 03091 { 03092 opt_sql_bin_update= 0; 03093 sql_print_error("The update log is no longer supported by MySQL in \ 03094 version 5.0 and above. It is replaced by the binary log."); 03095 } 03096 else 03097 { 03098 opt_sql_bin_update= 1; 03099 opt_bin_log= 1; 03100 if (opt_update_logname) 03101 { 03102 /* as opt_bin_log==0, no need to free opt_bin_logname */ 03103 if (!(opt_bin_logname= my_strdup(opt_update_logname, MYF(MY_WME)))) 03104 exit(EXIT_OUT_OF_MEMORY); 03105 sql_print_error("The update log is no longer supported by MySQL in \ 03106 version 5.0 and above. It is replaced by the binary log. Now starting MySQL \ 03107 with --log-bin='%s' instead.",opt_bin_logname); 03108 } 03109 else 03110 sql_print_error("The update log is no longer supported by MySQL in \ 03111 version 5.0 and above. It is replaced by the binary log. Now starting MySQL \ 03112 with --log-bin instead."); 03113 } 03114 } 03115 if (opt_log_slave_updates && !opt_bin_log) 03116 { 03117 sql_print_warning("You need to use --log-bin to make " 03118 "--log-slave-updates work."); 03119 unireg_abort(1); 03120 } 03121 03122 if (!opt_bin_log && (global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC)) 03123 { 03124 sql_print_warning("You need to use --log-bin to make " 03125 "--binlog-format work."); 03126 unireg_abort(1); 03127 } 03128 if (global_system_variables.binlog_format == BINLOG_FORMAT_UNSPEC) 03129 { 03130 #if defined(HAVE_NDB_BINLOG) && defined(HAVE_ROW_BASED_REPLICATION) 03131 if (opt_bin_log && have_ndbcluster == SHOW_OPTION_YES) 03132 global_system_variables.binlog_format= BINLOG_FORMAT_ROW; 03133 else 03134 #endif 03135 global_system_variables.binlog_format= BINLOG_FORMAT_STMT; 03136 } 03137 03138 /* Check that we have not let the format to unspecified at this point */ 03139 DBUG_ASSERT((uint)global_system_variables.binlog_format <= 03140 array_elements(binlog_format_names)-1); 03141 03142 #ifdef HAVE_REPLICATION 03143 if (opt_log_slave_updates && replicate_same_server_id) 03144 { 03145 sql_print_error("\ 03146 using --replicate-same-server-id in conjunction with \ 03147 --log-slave-updates is impossible, it would lead to infinite loops in this \ 03148 server."); 03149 unireg_abort(1); 03150 } 03151 #endif 03152 03153 if (opt_bin_log) 03154 { 03155 char buf[FN_REFLEN]; 03156 const char *ln; 03157 ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf); 03158 if (!opt_bin_logname && !opt_binlog_index_name) 03159 { 03160 /* 03161 User didn't give us info to name the binlog index file. 03162 Picking `hostname`-bin.index like did in 4.x, causes replication to 03163 fail if the hostname is changed later. So, we would like to instead 03164 require a name. But as we don't want to break many existing setups, we 03165 only give warning, not error. 03166 */ 03167 sql_print_warning("No argument was provided to --log-bin, and " 03168 "--log-bin-index was not used; so replication " 03169 "may break when this MySQL server acts as a " 03170 "master and has his hostname changed!! Please " 03171 "use '--log-bin=%s' to avoid this problem.", ln); 03172 } 03173 if (ln == buf) 03174 { 03175 my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR)); 03176 opt_bin_logname=my_strdup(buf, MYF(0)); 03177 } 03178 if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln)) 03179 { 03180 unireg_abort(1); 03181 } 03182 03183 /* 03184 Used to specify which type of lock we need to use for queries of type 03185 INSERT ... SELECT. This will change when we have row level logging. 03186 */ 03187 using_update_log=1; 03188 } 03189 03190 if (plugin_init()) 03191 { 03192 sql_print_error("Failed to init plugins."); 03193 return 1; 03194 } 03195 03196 /* We have to initialize the storage engines before CSV logging */ 03197 if (ha_init()) 03198 { 03199 sql_print_error("Can't init databases"); 03200 unireg_abort(1); 03201 } 03202 03203 #ifdef WITH_CSV_STORAGE_ENGINE 03204 if (opt_bootstrap) 03205 log_output_options= LOG_FILE; 03206 else 03207 logger.init_log_tables(); 03208 03209 if (log_output_options & LOG_NONE) 03210 { 03211 /* 03212 Issue a warining if there were specified additional options to the 03213 log-output along with NONE. Probably this wasn't what user wanted. 03214 */ 03215 if ((log_output_options & LOG_NONE) && (log_output_options & ~LOG_NONE)) 03216 sql_print_warning("There were other values specified to " 03217 "log-output besides NONE. Disabling slow " 03218 "and general logs anyway."); 03219 logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE); 03220 } 03221 else 03222 { 03223 /* fall back to the log files if tables are not present */ 03224 if (have_csv_db == SHOW_OPTION_NO) 03225 { 03226 /* purecov: begin inspected */ 03227 sql_print_error("CSV engine is not present, falling back to the " 03228 "log files"); 03229 log_output_options= (log_output_options & ~LOG_TABLE) | LOG_FILE; 03230 /* purecov: end */ 03231 } 03232 03233 logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE, 03234 opt_log ? log_output_options:LOG_NONE); 03235 } 03236 #else 03237 logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, 03238 opt_log ? LOG_FILE:LOG_NONE); 03239 #endif 03240 03241 /* 03242 Check that the default storage engine is actually available. 03243 */ 03244 { 03245 LEX_STRING name= { default_storage_engine_str, 03246 strlen(default_storage_engine_str) }; 03247 handlerton *hton= ha_resolve_by_name(0, &name); 03248 if (hton == NULL) 03249 { 03250 sql_print_error("Unknown/unsupported table type: %s", 03251 default_storage_engine_str); 03252 unireg_abort(1); 03253 } 03254 if (!ha_storage_engine_is_enabled(hton)) 03255 { 03256 if (!opt_bootstrap) 03257 { 03258 sql_print_error("Default storage engine (%s) is not available", 03259 default_storage_engine_str); 03260 unireg_abort(1); 03261 } 03262 hton= &myisam_hton; 03263 } 03264 global_system_variables.table_type= hton; 03265 } 03266 03267 tc_log= (total_ha_2pc > 1 ? (opt_bin_log ? 03268 (TC_LOG *) &mysql_bin_log : 03269 (TC_LOG *) &tc_log_mmap) : 03270 (TC_LOG *) &tc_log_dummy); 03271 03272 if (tc_log->open(opt_bin_logname)) 03273 { 03274 sql_print_error("Can't init tc log"); 03275 unireg_abort(1); 03276 } 03277 03278 if (ha_recover(0)) 03279 { 03280 unireg_abort(1); 03281 } 03282 03283 if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0, 03284 WRITE_CACHE, 0, max_binlog_size, 0)) 03285 unireg_abort(1); 03286 03287 #ifdef HAVE_REPLICATION 03288 if (opt_bin_log && expire_logs_days) 03289 { 03290 long purge_time= time(0) - expire_logs_days*24*60*60; 03291 if (purge_time >= 0) 03292 mysql_bin_log.purge_logs_before_date(purge_time); 03293 } 03294 #endif 03295 #ifdef __NETWARE__ 03296 /* Increasing stacksize of threads on NetWare */ 03297 pthread_attr_setstacksize(&connection_attrib, NW_THD_STACKSIZE); 03298 #endif 03299 03300 if (opt_myisam_log) 03301 (void) mi_log(1); 03302 03303 /* call ha_init_key_cache() on all key caches to init them */ 03304 process_key_caches(&ha_init_key_cache); 03305 03306 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY) 03307 if (locked_in_memory && !getuid()) 03308 { 03309 if (setreuid((uid_t)-1, 0) == -1) 03310 { // this should never happen 03311 sql_perror("setreuid"); 03312 unireg_abort(1); 03313 } 03314 if (mlockall(MCL_CURRENT)) 03315 { 03316 if (global_system_variables.log_warnings) 03317 sql_print_warning("Failed to lock memory. Errno: %d\n",errno); 03318 locked_in_memory= 0; 03319 } 03320 if (user_info) 03321 set_user(mysqld_user, user_info); 03322 } 03323 else 03324 #endif 03325 locked_in_memory=0; 03326 03327 ft_init_stopwords(); 03328 03329 init_max_user_conn(); 03330 init_update_queries(); 03331 DBUG_RETURN(0); 03332 } 03333 03334 03335 static void create_maintenance_thread() 03336 { 03337 if (flush_time && flush_time != ~(ulong) 0L) 03338 { 03339 pthread_t hThread; 03340 if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) 03341 sql_print_warning("Can't create thread to manage maintenance"); 03342 } 03343 } 03344 03345 03346 static void create_shutdown_thread() 03347 { 03348 #if !defined(EMBEDDED_LIBRARY) 03349 #ifdef __WIN__ 03350 hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name); 03351 pthread_t hThread; 03352 if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) 03353 sql_print_warning("Can't create thread to handle shutdown requests"); 03354 03355 // On "Stop Service" we have to do regular shutdown 03356 Service.SetShutdownEvent(hEventShutdown); 03357 #endif 03358 #endif // EMBEDDED_LIBRARY 03359 } 03360 03361 03362 #if (defined(__NT__) || defined(HAVE_SMEM)) && !defined(EMBEDDED_LIBRARY) 03363 static void handle_connections_methods() 03364 { 03365 pthread_t hThread; 03366 DBUG_ENTER("handle_connections_methods"); 03367 #ifdef __NT__ 03368 if (hPipe == INVALID_HANDLE_VALUE && 03369 (!have_tcpip || opt_disable_networking) && 03370 !opt_enable_shared_memory) 03371 { 03372 sql_print_error("TCP/IP, --shared-memory, or --named-pipe should be configured on NT OS"); 03373 unireg_abort(1); // Will not return 03374 } 03375 #endif 03376 03377 pthread_mutex_lock(&LOCK_thread_count); 03378 (void) pthread_cond_init(&COND_handler_count,NULL); 03379 handler_count=0; 03380 #ifdef __NT__ 03381 if (hPipe != INVALID_HANDLE_VALUE) 03382 { 03383 handler_count++; 03384 if (pthread_create(&hThread,&connection_attrib, 03385 handle_connections_namedpipes, 0)) 03386 { 03387 sql_print_warning("Can't create thread to handle named pipes"); 03388 handler_count--; 03389 } 03390 } 03391 #endif /* __NT__ */ 03392 if (have_tcpip && !opt_disable_networking) 03393 { 03394 handler_count++; 03395 if (pthread_create(&hThread,&connection_attrib, 03396 handle_connections_sockets, 0)) 03397 { 03398 sql_print_warning("Can't create thread to handle TCP/IP"); 03399 handler_count--; 03400 } 03401 } 03402 #ifdef HAVE_SMEM 03403 if (opt_enable_shared_memory) 03404 { 03405 handler_count++; 03406 if (pthread_create(&hThread,&connection_attrib, 03407 handle_connections_shared_memory, 0)) 03408 { 03409 sql_print_warning("Can't create thread to handle shared memory"); 03410 handler_count--; 03411 } 03412 } 03413 #endif 03414 03415 while (handler_count > 0) 03416 pthread_cond_wait(&COND_handler_count,&LOCK_thread_count); 03417 pthread_mutex_unlock(&LOCK_thread_count); 03418 DBUG_VOID_RETURN; 03419 } 03420 03421 void decrement_handler_count() 03422 { 03423 pthread_mutex_lock(&LOCK_thread_count); 03424 handler_count--; 03425 pthread_mutex_unlock(&LOCK_thread_count); 03426 pthread_cond_signal(&COND_handler_count); 03427 } 03428 #else 03429 #define decrement_handler_count() 03430 #endif /* defined(__NT__) || defined(HAVE_SMEM) */ 03431 03432 03433 #ifndef EMBEDDED_LIBRARY 03434 #ifdef __WIN__ 03435 int win_main(int argc, char **argv) 03436 #else 03437 int main(int argc, char **argv) 03438 #endif 03439 { 03440 rpl_filter= new Rpl_filter; 03441 binlog_filter= new Rpl_filter; 03442 if (!rpl_filter || !binlog_filter) 03443 { 03444 sql_perror("Could not allocate replication and binlog filters"); 03445 exit(1); 03446 } 03447 03448 MY_INIT(argv[0]); // init my_sys library & pthreads 03449 03450 /* 03451 Perform basic logger initialization logger. Should be called after 03452 MY_INIT, as it initializes mutexes. Log tables are inited later. 03453 */ 03454 logger.init_base(); 03455 03456 #ifdef _CUSTOMSTARTUPCONFIG_ 03457 if (_cust_check_startup()) 03458 { 03459 / * _cust_check_startup will report startup failure error * / 03460 exit(1); 03461 } 03462 #endif 03463 03464 #ifdef __WIN__ 03465 /* 03466 Before performing any socket operation (like retrieving hostname 03467 in init_common_variables we have to call WSAStartup 03468 */ 03469 { 03470 WSADATA WsaData; 03471 if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) 03472 { 03473 /* errors are not read yet, so we use english text here */ 03474 my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0)); 03475 unireg_abort(1); 03476 } 03477 } 03478 #endif /* __WIN__ */ 03479 03480 if (init_common_variables(MYSQL_CONFIG_NAME, 03481 argc, argv, load_default_groups)) 03482 unireg_abort(1); // Will do exit 03483 03484 init_signals(); 03485 if (!(opt_specialflag & SPECIAL_NO_PRIOR)) 03486 my_pthread_setprio(pthread_self(),CONNECT_PRIOR); 03487 #if defined(__ia64__) || defined(__ia64) 03488 /* 03489 Peculiar things with ia64 platforms - it seems we only have half the 03490 stack size in reality, so we have to double it here 03491 */ 03492 pthread_attr_setstacksize(&connection_attrib,thread_stack*2); 03493 #else 03494 pthread_attr_setstacksize(&connection_attrib,thread_stack); 03495 #endif 03496 #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE 03497 { 03498 /* Retrieve used stack size; Needed for checking stack overflows */ 03499 size_t stack_size= 0; 03500 pthread_attr_getstacksize(&connection_attrib, &stack_size); 03501 #if defined(__ia64__) || defined(__ia64) 03502 stack_size/= 2; 03503 #endif 03504 /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ 03505 if (stack_size && stack_size < thread_stack) 03506 { 03507 if (global_system_variables.log_warnings) 03508 sql_print_warning("Asked for %ld thread stack, but got %ld", 03509 thread_stack, stack_size); 03510 #if defined(__ia64__) || defined(__ia64) 03511 thread_stack= stack_size*2; 03512 #else 03513 thread_stack= stack_size; 03514 #endif 03515 } 03516 } 03517 #endif 03518 #ifdef __NETWARE__ 03519 /* Increasing stacksize of threads on NetWare */ 03520 pthread_attr_setstacksize(&connection_attrib, NW_THD_STACKSIZE); 03521 #endif 03522 03523 (void) thr_setconcurrency(concurrency); // 10 by default 03524 03525 select_thread=pthread_self(); 03526 select_thread_in_use=1; 03527 init_ssl(); 03528 03529 #ifdef HAVE_LIBWRAP 03530 libwrapName= my_progname+dirname_length(my_progname); 03531 openlog(libwrapName, LOG_PID, LOG_AUTH); 03532 #endif 03533 03534 /* 03535 We have enough space for fiddling with the argv, continue 03536 */ 03537 check_data_home(mysql_real_data_home); 03538 if (my_setwd(mysql_real_data_home,MYF(MY_WME))) 03539 unireg_abort(1); /* purecov: inspected */ 03540 mysql_data_home= mysql_data_home_buff; 03541 mysql_data_home[0]=FN_CURLIB; // all paths are relative from here 03542 mysql_data_home[1]=0; 03543 03544 if ((user_info= check_user(mysqld_user))) 03545 { 03546 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) 03547 if (locked_in_memory) // getuid() == 0 here 03548 set_effective_user(user_info); 03549 else 03550 #endif 03551 set_user(mysqld_user, user_info); 03552 } 03553 03554 if (opt_bin_log && !server_id) 03555 { 03556 server_id= !master_host ? 1 : 2; 03557 #ifdef EXTRA_DEBUG 03558 switch (server_id) { 03559 case 1: 03560 sql_print_warning("\ 03561 You have enabled the binary log, but you haven't set server-id to \ 03562 a non-zero value: we force server id to 1; updates will be logged to the \ 03563 binary log, but connections from slaves will not be accepted."); 03564 break; 03565 case 2: 03566 sql_print_warning("\ 03567 You should set server-id to a non-0 value if master_host is set; \ 03568 we force server id to 2, but this MySQL server will not act as a slave."); 03569 break; 03570 } 03571 #endif 03572 } 03573 03574 if (init_server_components()) 03575 unireg_abort(1); 03576 03577 network_init(); 03578 03579 #ifdef __WIN__ 03580 if (!opt_console) 03581 { 03582 freopen(log_error_file,"a+",stdout); 03583 freopen(log_error_file,"a+",stderr); 03584 FreeConsole(); // Remove window 03585 } 03586 #endif 03587 03588 /* 03589 Initialize my_str_malloc() and my_str_free() 03590 */ 03591 my_str_malloc= &my_str_malloc_mysqld; 03592 my_str_free= &my_str_free_mysqld; 03593 03594 /* 03595 init signals & alarm 03596 After this we can't quit by a simple unireg_abort 03597 */ 03598 error_handler_hook= my_message_sql; 03599 start_signal_handler(); // Creates pidfile 03600 03601 if (acl_init(opt_noacl) || 03602 my_tz_init((THD *)0, default_tz_name, opt_bootstrap)) 03603 { 03604 abort_loop=1; 03605 select_thread_in_use=0; 03606 #ifndef __NETWARE__ 03607 (void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL); 03608 #endif /* __NETWARE__ */ 03609 03610 if (!opt_bootstrap) 03611 (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore 03612 03613 if (unix_sock != INVALID_SOCKET) 03614 unlink(mysqld_unix_port); 03615 exit(1); 03616 } 03617 if (!opt_noacl) 03618 (void) grant_init(); 03619 03620 if (!opt_noacl) 03621 { 03622 plugin_load(); 03623 #ifdef HAVE_DLOPEN 03624 udf_init(); 03625 #endif 03626 } 03627 init_status_vars(); 03628 if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ 03629 opt_skip_slave_start= 1; 03630 /* 03631 init_slave() must be called after the thread keys are created. 03632 Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other 03633 places) assume that active_mi != 0, so let's fail if it's 0 (out of 03634 memory); a message has already been printed. 03635 */ 03636 if (init_slave() && !active_mi) 03637 { 03638 end_thr_alarm(1); // Don't allow alarms 03639 unireg_abort(1); 03640 } 03641 03642 if (opt_bootstrap) 03643 { 03644 select_thread_in_use= 0; // Allow 'kill' to work 03645 bootstrap(stdin); 03646 end_thr_alarm(1); // Don't allow alarms 03647 unireg_abort(bootstrap_error ? 1 : 0); 03648 } 03649 if (opt_init_file) 03650 { 03651 if (read_init_file(opt_init_file)) 03652 { 03653 end_thr_alarm(1); // Don't allow alarms 03654 unireg_abort(1); 03655 } 03656 } 03657 execute_ddl_log_recovery(); 03658 03659 create_shutdown_thread(); 03660 create_maintenance_thread(); 03661 03662 sql_print_information(ER(ER_STARTUP),my_progname,server_version, 03663 ((unix_sock == INVALID_SOCKET) ? (char*) "" 03664 : mysqld_unix_port), 03665 mysqld_port, 03666 MYSQL_COMPILATION_COMMENT); 03667 03668 // Signal threads waiting for server to be started 03669 mysqld_server_started= 1; 03670 pthread_cond_signal(&COND_server_started); 03671 03672 if (!opt_noacl) 03673 { 03674 Events::init(); 03675 } 03676 #if defined(__NT__) || defined(HAVE_SMEM) 03677 handle_connections_methods(); 03678 #else 03679 #ifdef __WIN__ 03680 if (!have_tcpip || opt_disable_networking) 03681 { 03682 sql_print_error("TCP/IP unavailable or disabled with --skip-networking; no available interfaces"); 03683 unireg_abort(1); 03684 } 03685 #endif 03686 handle_connections_sockets(0); 03687 #endif /* __NT__ */ 03688 03689 /* (void) pthread_attr_destroy(&connection_attrib); */ 03690 03691 DBUG_PRINT("quit",("Exiting main thread")); 03692 03693 #ifndef __WIN__ 03694 #ifdef EXTRA_DEBUG2 03695 sql_print_error("Before Lock_thread_count"); 03696 #endif 03697 (void) pthread_mutex_lock(&LOCK_thread_count); 03698 DBUG_PRINT("quit", ("Got thread_count mutex")); 03699 select_thread_in_use=0; // For close_connections 03700 (void) pthread_mutex_unlock(&LOCK_thread_count); 03701 (void) pthread_cond_broadcast(&COND_thread_count); 03702 #ifdef EXTRA_DEBUG2 03703 sql_print_error("After lock_thread_count"); 03704 #endif 03705 #endif /* __WIN__ */ 03706 03707 /* Wait until cleanup is done */ 03708 (void) pthread_mutex_lock(&LOCK_thread_count); 03709 while (!ready_to_exit) 03710 pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); 03711 (void) pthread_mutex_unlock(&LOCK_thread_count); 03712 03713 release_ddl_log(); 03714 #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) 03715 if (Service.IsNT() && start_mode) 03716 Service.Stop(); 03717 else 03718 { 03719 Service.SetShutdownEvent(0); 03720 if (hEventShutdown) 03721 CloseHandle(hEventShutdown); 03722 } 03723 #endif 03724 clean_up(1); 03725 wait_for_signal_thread_to_end(); 03726 clean_up_mutexes(); 03727 my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); 03728 03729 exit(0); 03730 return(0); /* purecov: deadcode */ 03731 } 03732 03733 #endif /* EMBEDDED_LIBRARY */ 03734 03735 03736 /**************************************************************************** 03737 Main and thread entry function for Win32 03738 (all this is needed only to run mysqld as a service on WinNT) 03739 ****************************************************************************/ 03740 03741 #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) 03742 int mysql_service(void *p) 03743 { 03744 if (use_opt_args) 03745 win_main(opt_argc, opt_argv); 03746 else 03747 win_main(Service.my_argc, Service.my_argv); 03748 return 0; 03749 } 03750 03751 03752 /* Quote string if it contains space, else copy */ 03753 03754 static char *add_quoted_string(char *to, const char *from, char *to_end) 03755 { 03756 uint length= (uint) (to_end-to); 03757 03758 if (!strchr(from, ' ')) 03759 return strmake(to, from, length-1); 03760 return strxnmov(to, length-1, "\"", from, "\"", NullS); 03761 } 03762 03763 03764 /* 03765 Handle basic handling of services, like installation and removal 03766 03767 SYNOPSIS 03768 default_service_handling() 03769 argv Pointer to argument list 03770 servicename Internal name of service 03771 displayname Display name of service (in taskbar ?) 03772 file_path Path to this program 03773 startup_option Startup option to mysqld 03774 03775 RETURN VALUES 03776 0 option handled 03777 1 Could not handle option 03778 */ 03779 03780 static bool 03781 default_service_handling(char **argv, 03782 const char *servicename, 03783 const char *displayname, 03784 const char *file_path, 03785 const char *extra_opt, 03786 const char *account_name) 03787 { 03788 char path_and_service[FN_REFLEN+FN_REFLEN+32], *pos, *end; 03789 end= path_and_service + sizeof(path_and_service)-3; 03790 03791 /* We have to quote filename if it contains spaces */ 03792 pos= add_quoted_string(path_and_service, file_path, end); 03793 if (*extra_opt) 03794 { 03795 /* Add (possible quoted) option after file_path */ 03796 *pos++= ' '; 03797 pos= add_quoted_string(pos, extra_opt, end); 03798 } 03799 /* We must have servicename last */ 03800 *pos++= ' '; 03801 (void) add_quoted_string(pos, servicename, end); 03802 03803 if (Service.got_service_option(argv, "install")) 03804 { 03805 Service.Install(1, servicename, displayname, path_and_service, 03806 account_name); 03807 return 0; 03808 } 03809 if (Service.got_service_option(argv, "install-manual")) 03810 { 03811 Service.Install(0, servicename, displayname, path_and_service, 03812 account_name); 03813 return 0; 03814 } 03815 if (Service.got_service_option(argv, "remove")) 03816 { 03817 Service.Remove(servicename); 03818 return 0; 03819 } 03820 return 1; 03821 } 03822 03823 03824 int main(int argc, char **argv) 03825 { 03826 /* 03827 When several instances are running on the same machine, we 03828 need to have an unique named hEventShudown through the 03829 application PID e.g.: MySQLShutdown1890; MySQLShutdown2342 03830 */ 03831 int10_to_str((int) GetCurrentProcessId(),strmov(shutdown_event_name, 03832 "MySQLShutdown"), 10); 03833 03834 /* Must be initialized early for comparison of service name */ 03835 system_charset_info= &my_charset_utf8_general_ci; 03836 03837 if (Service.GetOS()) /* true NT family */ 03838 { 03839 char file_path[FN_REFLEN]; 03840 my_path(file_path, argv[0], ""); /* Find name in path */ 03841 fn_format(file_path,argv[0],file_path,"", 03842 MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); 03843 03844 if (argc == 2) 03845 { 03846 if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, 03847 file_path, "", NULL)) 03848 return 0; 03849 if (Service.IsService(argv[1])) /* Start an optional service */ 03850 { 03851 /* 03852 Only add the service name to the groups read from the config file 03853 if it's not "MySQL". (The default service name should be 'mysqld' 03854 but we started a bad tradition by calling it MySQL from the start 03855 and we are now stuck with it. 03856 */ 03857 if (my_strcasecmp(system_charset_info, argv[1],"mysql")) 03858 load_default_groups[load_default_groups_sz-2]= argv[1]; 03859 start_mode= 1; 03860 Service.Init(argv[1], mysql_service); 03861 return 0; 03862 } 03863 } 03864 else if (argc == 3) /* install or remove any optional service */ 03865 { 03866 if (!default_service_handling(argv, argv[2], argv[2], file_path, "", 03867 NULL)) 03868 return 0; 03869 if (Service.IsService(argv[2])) 03870 { 03871 /* 03872 mysqld was started as 03873 mysqld --defaults-file=my_path\my.ini service-name 03874 */ 03875 use_opt_args=1; 03876 opt_argc= 2; // Skip service-name 03877 opt_argv=argv; 03878 start_mode= 1; 03879 if (my_strcasecmp(system_charset_info, argv[2],"mysql")) 03880 load_default_groups[load_default_groups_sz-2]= argv[2]; 03881 Service.Init(argv[2], mysql_service); 03882 return 0; 03883 } 03884 } 03885 else if (argc == 4 || argc == 5) 03886 { 03887 /* 03888 This may seem strange, because we handle --local-service while 03889 preserving 4.1's behavior of allowing any one other argument that is 03890 passed to the service on startup. (The assumption is that this is 03891 --defaults-file=file, but that was not enforced in 4.1, so we don't 03892 enforce it here.) 03893 */ 03894 const char *extra_opt= NullS; 03895 const char *account_name = NullS; 03896 int index; 03897 for (index = 3; index < argc; index++) 03898 { 03899 if (!strcmp(argv[index], "--local-service")) 03900 account_name= "NT AUTHORITY\\LocalService"; 03901 else 03902 extra_opt= argv[index]; 03903 } 03904 03905 if (argc == 4 || account_name) 03906 if (!default_service_handling(argv, argv[2], argv[2], file_path, 03907 extra_opt, account_name)) 03908 return 0; 03909 } 03910 else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) 03911 { 03912 /* start the default service */ 03913 start_mode= 1; 03914 Service.Init(MYSQL_SERVICENAME, mysql_service); 03915 return 0; 03916 } 03917 } 03918 /* Start as standalone server */ 03919 Service.my_argc=argc; 03920 Service.my_argv=argv; 03921 mysql_service(NULL); 03922 return 0; 03923 } 03924 #endif 03925 03926 03927 /* 03928 Execute all commands from a file. Used by the mysql_install_db script to 03929 create MySQL privilege tables without having to start a full MySQL server. 03930 */ 03931 03932 static void bootstrap(FILE *file) 03933 { 03934 DBUG_ENTER("bootstrap"); 03935 03936 THD *thd= new THD; 03937 thd->bootstrap=1; 03938 my_net_init(&thd->net,(st_vio*) 0); 03939 thd->max_client_packet_length= thd->net.max_packet; 03940 thd->security_ctx->master_access= ~(ulong)0; 03941 thd->thread_id=thread_id++; 03942 thread_count++; 03943 03944 bootstrap_file=file; 03945 #ifndef EMBEDDED_LIBRARY // TODO: Enable this 03946 if (pthread_create(&thd->real_id,&connection_attrib,handle_bootstrap, 03947 (void*) thd)) 03948 { 03949 sql_print_warning("Can't create thread to handle bootstrap"); 03950 bootstrap_error=-1; 03951 DBUG_VOID_RETURN; 03952 } 03953 /* Wait for thread to die */ 03954 (void) pthread_mutex_lock(&LOCK_thread_count); 03955 while (thread_count) 03956 { 03957 (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); 03958 DBUG_PRINT("quit",("One thread died (count=%u)",thread_count)); 03959 } 03960 (void) pthread_mutex_unlock(&LOCK_thread_count); 03961 #else 03962 thd->mysql= 0; 03963 handle_bootstrap((void *)thd); 03964 #endif 03965 03966 DBUG_VOID_RETURN; 03967 } 03968 03969 03970 static bool read_init_file(char *file_name) 03971 { 03972 FILE *file; 03973 DBUG_ENTER("read_init_file"); 03974 DBUG_PRINT("enter",("name: %s",file_name)); 03975 if (!(file=my_fopen(file_name,O_RDONLY,MYF(MY_WME)))) 03976 return(1); 03977 bootstrap(file); 03978 (void) my_fclose(file,MYF(MY_WME)); 03979 return 0; 03980 } 03981 03982 03983 #ifndef EMBEDDED_LIBRARY 03984 /* 03985 Create new thread to handle incoming connection. 03986 03987 SYNOPSIS 03988 create_new_thread() 03989 thd in/out Thread handle of future thread. 03990 03991 DESCRIPTION 03992 This function will create new thread to handle the incoming 03993 connection. If there are idle cached threads one will be used. 03994 'thd' will be pushed into 'threads'. 03995 03996 In single-threaded mode (#define ONE_THREAD) connection will be 03997 handled inside this function. 03998 03999 RETURN VALUE 04000 none 04001 */ 04002 04003 static void create_new_thread(THD *thd) 04004 { 04005 DBUG_ENTER("create_new_thread"); 04006 04007 NET *net=&thd->net; // For easy ref 04008 net->read_timeout = (uint) connect_timeout; 04009 if (protocol_version > 9) 04010 net->return_errno=1; 04011 04012 /* don't allow too many connections */ 04013 if (thread_count - delayed_insert_threads >= max_connections+1 || abort_loop) 04014 { 04015 DBUG_PRINT("error",("Too many connections")); 04016 close_connection(thd, ER_CON_COUNT_ERROR, 1); 04017 delete thd; 04018 DBUG_VOID_RETURN; 04019 } 04020 pthread_mutex_lock(&LOCK_thread_count); 04021 thd->thread_id=thread_id++; 04022 04023 thd->real_id=pthread_self(); // Keep purify happy 04024 04025 /* Start a new thread to handle connection */ 04026 thread_count++; 04027 04028 #ifdef ONE_THREAD 04029 if (test_flags & TEST_NO_THREADS) // For debugging under Linux 04030 { 04031 thread_cache_size=0; // Safety 04032 threads.append(thd); 04033 thd->real_id=pthread_self(); 04034 (void) pthread_mutex_unlock(&LOCK_thread_count); 04035 handle_one_connection((void*) thd); 04036 } 04037 else 04038 #endif 04039 { 04040 if (thread_count-delayed_insert_threads > max_used_connections) 04041 max_used_connections=thread_count-delayed_insert_threads; 04042 04043 if (cached_thread_count > wake_thread) 04044 { 04045 thread_cache.append(thd); 04046 wake_thread++; 04047 pthread_cond_signal(&COND_thread_cache); 04048 } 04049 else 04050 { 04051 int error; 04052 thread_created++; 04053 threads.append(thd); 04054 DBUG_PRINT("info",(("creating thread %d"), thd->thread_id)); 04055 thd->connect_time = time(NULL); 04056 if ((error=pthread_create(&thd->real_id,&connection_attrib, 04057 handle_one_connection, 04058 (void*) thd))) 04059 { 04060 DBUG_PRINT("error", 04061 ("Can't create thread to handle request (error %d)", 04062 error)); 04063 thread_count--; 04064 thd->killed= THD::KILL_CONNECTION; // Safety 04065 (void) pthread_mutex_unlock(&LOCK_thread_count); 04066 statistic_increment(aborted_connects,&LOCK_status); 04067 net_printf_error(thd, ER_CANT_CREATE_THREAD, error); 04068 (void) pthread_mutex_lock(&LOCK_thread_count); 04069 close_connection(thd,0,0); 04070 delete thd; 04071 (void) pthread_mutex_unlock(&LOCK_thread_count); 04072 DBUG_VOID_RETURN; 04073 } 04074 } 04075 (void) pthread_mutex_unlock(&LOCK_thread_count); 04076 04077 } 04078 DBUG_PRINT("info",("Thread created")); 04079 DBUG_VOID_RETURN; 04080 } 04081 #endif /* EMBEDDED_LIBRARY */ 04082 04083 04084 #ifdef SIGNALS_DONT_BREAK_READ 04085 inline void kill_broken_server() 04086 { 04087 /* hack to get around signals ignored in syscalls for problem OS's */ 04088 if ( 04089 #if !defined(__NETWARE__) 04090 unix_sock == INVALID_SOCKET || 04091 #endif 04092 (!opt_disable_networking && ip_sock == INVALID_SOCKET)) 04093 { 04094 select_thread_in_use = 0; 04095 /* The following call will never return */ 04096 kill_server(IF_NETWARE(MYSQL_KILL_SIGNAL, (void*) MYSQL_KILL_SIGNAL)); 04097 } 04098 } 04099 #define MAYBE_BROKEN_SYSCALL kill_broken_server(); 04100 #else 04101 #define MAYBE_BROKEN_SYSCALL 04102 #endif 04103 04104 /* Handle new connections and spawn new process to handle them */ 04105 04106 #ifndef EMBEDDED_LIBRARY 04107 pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused))) 04108 { 04109 my_socket sock,new_sock; 04110 uint error_count=0; 04111 uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1); 04112 fd_set readFDs,clientFDs; 04113 THD *thd; 04114 struct sockaddr_in cAddr; 04115 int ip_flags=0,socket_flags=0,flags; 04116 st_vio *vio_tmp; 04117 DBUG_ENTER("handle_connections_sockets"); 04118 04119 LINT_INIT(new_sock); 04120 04121 (void) my_pthread_getprio(pthread_self()); // For debugging 04122 04123 FD_ZERO(&clientFDs); 04124 if (ip_sock != INVALID_SOCKET) 04125 { 04126 FD_SET(ip_sock,&clientFDs); 04127 #ifdef HAVE_FCNTL 04128 ip_flags = fcntl(ip_sock, F_GETFL, 0); 04129 #endif 04130 } 04131 #ifdef HAVE_SYS_UN_H 04132 FD_SET(unix_sock,&clientFDs); 04133 #ifdef HAVE_FCNTL 04134 socket_flags=fcntl(unix_sock, F_GETFL, 0); 04135 #endif 04136 #endif 04137 04138 DBUG_PRINT("general",("Waiting for connections.")); 04139 MAYBE_BROKEN_SYSCALL; 04140 while (!abort_loop) 04141 { 04142 readFDs=clientFDs; 04143 #ifdef HPUX10 04144 if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0) 04145 continue; 04146 #else 04147 if (select((int) max_used_connection,&readFDs,0,0,0) < 0) 04148 { 04149 if (socket_errno != SOCKET_EINTR) 04150 { 04151 if (!select_errors++ && !abort_loop) /* purecov: inspected */ 04152 sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */ 04153 } 04154 MAYBE_BROKEN_SYSCALL 04155 continue; 04156 } 04157 #endif /* HPUX10 */ 04158 if (abort_loop) 04159 { 04160 MAYBE_BROKEN_SYSCALL; 04161 break; 04162 } 04163 04164 /* Is this a new connection request ? */ 04165 #ifdef HAVE_SYS_UN_H 04166 if (FD_ISSET(unix_sock,&readFDs)) 04167 { 04168 sock = unix_sock; 04169 flags= socket_flags; 04170 } 04171 else 04172 #endif 04173 { 04174 sock = ip_sock; 04175 flags= ip_flags; 04176 } 04177 04178 #if !defined(NO_FCNTL_NONBLOCK) 04179 if (!(test_flags & TEST_BLOCKING)) 04180 { 04181 #if defined(O_NONBLOCK) 04182 fcntl(sock, F_SETFL, flags | O_NONBLOCK); 04183 #elif defined(O_NDELAY) 04184 fcntl(sock, F_SETFL, flags | O_NDELAY); 04185 #endif 04186 } 04187 #endif /* NO_FCNTL_NONBLOCK */ 04188 for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++) 04189 { 04190 size_socket length=sizeof(struct sockaddr_in); 04191 new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr), 04192 &length); 04193 #ifdef __NETWARE__ 04194 // TODO: temporary fix, waiting for TCP/IP fix - DEFECT000303149 04195 if ((new_sock == INVALID_SOCKET) && (socket_errno == EINVAL)) 04196 { 04197 kill_server(SIGTERM); 04198 } 04199 #endif 04200 if (new_sock != INVALID_SOCKET || 04201 (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN)) 04202 break; 04203 MAYBE_BROKEN_SYSCALL; 04204 #if !defined(NO_FCNTL_NONBLOCK) 04205 if (!(test_flags & TEST_BLOCKING)) 04206 { 04207 if (retry == MAX_ACCEPT_RETRY - 1) 04208 fcntl(sock, F_SETFL, flags); // Try without O_NONBLOCK 04209 } 04210 #endif 04211 } 04212 #if !defined(NO_FCNTL_NONBLOCK) 04213 if (!(test_flags & TEST_BLOCKING)) 04214 fcntl(sock, F_SETFL, flags); 04215 #endif 04216 if (new_sock == INVALID_SOCKET) 04217 { 04218 if ((error_count++ & 255) == 0) // This can happen often 04219 sql_perror("Error in accept"); 04220 MAYBE_BROKEN_SYSCALL; 04221 if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE) 04222 sleep(1); // Give other threads some time 04223 continue; 04224 } 04225 04226 #ifdef HAVE_LIBWRAP 04227 { 04228 if (sock == ip_sock) 04229 { 04230 struct request_info req; 04231 signal(SIGCHLD, SIG_DFL); 04232 request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, new_sock, NULL); 04233 my_fromhost(&req); 04234 if (!my_hosts_access(&req)) 04235 { 04236 /* 04237 This may be stupid but refuse() includes an exit(0) 04238 which we surely don't want... 04239 clean_exit() - same stupid thing ... 04240 */ 04241 syslog(deny_severity, "refused connect from %s", 04242 my_eval_client(&req)); 04243 04244 /* 04245 C++ sucks (the gibberish in front just translates the supplied 04246 sink function pointer in the req structure from a void (*sink)(); 04247 to a void(*sink)(int) if you omit the cast, the C++ compiler 04248 will cry... 04249 */ 04250 if (req.sink) 04251 ((void (*)(int))req.sink)(req.fd); 04252 04253 (void) shutdown(new_sock,2); 04254 (void) closesocket(new_sock); 04255 continue; 04256 } 04257 } 04258 } 04259 #endif /* HAVE_LIBWRAP */ 04260 04261 { 04262 size_socket dummyLen; 04263 struct sockaddr dummy; 04264 dummyLen = sizeof(struct sockaddr); 04265 if (getsockname(new_sock,&dummy, &dummyLen) < 0) 04266 { 04267 sql_perror("Error on new connection socket"); 04268 (void) shutdown(new_sock,2); 04269 (void) closesocket(new_sock); 04270 continue; 04271 } 04272 } 04273 04274 /* 04275 ** Don't allow too many connections 04276 */ 04277 04278 if (!(thd= new THD)) 04279 { 04280 (void) shutdown(new_sock,2); 04281 VOID(closesocket(new_sock)); 04282 continue; 04283 } 04284 if (!(vio_tmp=vio_new(new_sock, 04285 sock == unix_sock ? VIO_TYPE_SOCKET : 04286 VIO_TYPE_TCPIP, 04287 sock == unix_sock ? VIO_LOCALHOST: 0)) || 04288 my_net_init(&thd->net,vio_tmp)) 04289 { 04290 if (vio_tmp) 04291 vio_delete(vio_tmp); 04292 else 04293 { 04294 (void) shutdown(new_sock,2); 04295 (void) closesocket(new_sock); 04296 } 04297 delete thd; 04298 continue; 04299 } 04300 if (sock == unix_sock) 04301 thd->security_ctx->host=(char*) my_localhost; 04302 #ifdef __WIN__ 04303 /* Set default wait_timeout */ 04304 ulong wait_timeout= global_system_variables.net_wait_timeout * 1000; 04305 (void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout, 04306 sizeof(wait_timeout)); 04307 #endif 04308 create_new_thread(thd); 04309 } 04310 04311 decrement_handler_count(); 04312 DBUG_RETURN(0); 04313 } 04314 04315 04316 #ifdef __NT__ 04317 pthread_handler_t handle_connections_namedpipes(void *arg) 04318 { 04319 HANDLE hConnectedPipe; 04320 BOOL fConnected; 04321 THD *thd; 04322 my_thread_init(); 04323 DBUG_ENTER("handle_connections_namedpipes"); 04324 (void) my_pthread_getprio(pthread_self()); // For debugging 04325 04326 DBUG_PRINT("general",("Waiting for named pipe connections.")); 04327 while (!abort_loop) 04328 { 04329 /* wait for named pipe connection */ 04330 fConnected = ConnectNamedPipe(hPipe, NULL); 04331 if (abort_loop) 04332 break; 04333 if (!fConnected) 04334 fConnected = GetLastError() == ERROR_PIPE_CONNECTED; 04335 if (!fConnected) 04336 { 04337 CloseHandle(hPipe); 04338 if ((hPipe= CreateNamedPipe(pipe_name, 04339 PIPE_ACCESS_DUPLEX, 04340 PIPE_TYPE_BYTE | 04341 PIPE_READMODE_BYTE | 04342 PIPE_WAIT, 04343 PIPE_UNLIMITED_INSTANCES, 04344 (int) global_system_variables. 04345 net_buffer_length, 04346 (int) global_system_variables. 04347 net_buffer_length, 04348 NMPWAIT_USE_DEFAULT_WAIT, 04349 &saPipeSecurity)) == 04350 INVALID_HANDLE_VALUE) 04351 { 04352 sql_perror("Can't create new named pipe!"); 04353 break; // Abort 04354 } 04355 } 04356 hConnectedPipe = hPipe; 04357 /* create new pipe for new connection */ 04358 if ((hPipe = CreateNamedPipe(pipe_name, 04359 PIPE_ACCESS_DUPLEX, 04360 PIPE_TYPE_BYTE | 04361 PIPE_READMODE_BYTE | 04362 PIPE_WAIT, 04363 PIPE_UNLIMITED_INSTANCES, 04364 (int) global_system_variables.net_buffer_length, 04365 (int) global_system_variables.net_buffer_length, 04366 NMPWAIT_USE_DEFAULT_WAIT, 04367 &saPipeSecurity)) == 04368 INVALID_HANDLE_VALUE) 04369 { 04370 sql_perror("Can't create new named pipe!"); 04371 hPipe=hConnectedPipe; 04372 continue; // We have to try again 04373 } 04374 04375 if (!(thd = new THD)) 04376 { 04377 DisconnectNamedPipe(hConnectedPipe); 04378 CloseHandle(hConnectedPipe); 04379 continue; 04380 } 04381 if (!(thd->net.vio = vio_new_win32pipe(hConnectedPipe)) || 04382 my_net_init(&thd->net, thd->net.vio)) 04383 { 04384 close_connection(thd, ER_OUT_OF_RESOURCES, 1); 04385 delete thd; 04386 continue; 04387 } 04388 /* Host is unknown */ 04389 thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); 04390 create_new_thread(thd); 04391 } 04392 04393 decrement_handler_count(); 04394 DBUG_RETURN(0); 04395 } 04396 #endif /* __NT__ */ 04397 04398 04399 /* 04400 Thread of shared memory's service 04401 04402 SYNOPSIS 04403 handle_connections_shared_memory() 04404 arg Arguments of thread 04405 */ 04406 04407 #ifdef HAVE_SMEM 04408 pthread_handler_t handle_connections_shared_memory(void *arg) 04409 { 04410 /* file-mapping object, use for create shared memory */ 04411 HANDLE handle_connect_file_map= 0; 04412 char *handle_connect_map= 0; // pointer on shared memory 04413 HANDLE event_connect_answer= 0; 04414 ulong smem_buffer_length= shared_memory_buffer_length + 4; 04415 ulong connect_number= 1; 04416 char tmp[63]; 04417 char *suffix_pos; 04418 char connect_number_char[22], *p; 04419 const char *errmsg= 0; 04420 SECURITY_ATTRIBUTES *sa_event= 0, *sa_mapping= 0; 04421 my_thread_init(); 04422 DBUG_ENTER("handle_connections_shared_memorys"); 04423 DBUG_PRINT("general",("Waiting for allocated shared memory.")); 04424 04425 if (my_security_attr_create(&sa_event, &errmsg, 04426 GENERIC_ALL, SYNCHRONIZE | EVENT_MODIFY_STATE)) 04427 goto error; 04428 04429 if (my_security_attr_create(&sa_mapping, &errmsg, 04430 GENERIC_ALL, FILE_MAP_READ | FILE_MAP_WRITE)) 04431 goto error; 04432 04433 /* 04434 The name of event and file-mapping events create agree next rule: 04435 shared_memory_base_name+unique_part 04436 Where: 04437 shared_memory_base_name is unique value for each server 04438 unique_part is unique value for each object (events and file-mapping) 04439 */ 04440 suffix_pos= strxmov(tmp,shared_memory_base_name,"_",NullS); 04441 strmov(suffix_pos, "CONNECT_REQUEST"); 04442 if ((smem_event_connect_request= CreateEvent(sa_event, 04443 FALSE, FALSE, tmp)) == 0) 04444 { 04445 errmsg= "Could not create request event"; 04446 goto error; 04447 } 04448 strmov(suffix_pos, "CONNECT_ANSWER"); 04449 if ((event_connect_answer= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0) 04450 { 04451 errmsg="Could not create answer event"; 04452 goto error; 04453 } 04454 strmov(suffix_pos, "CONNECT_DATA"); 04455 if ((handle_connect_file_map= 04456 CreateFileMapping(INVALID_HANDLE_VALUE, sa_mapping, 04457 PAGE_READWRITE, 0, sizeof(connect_number), tmp)) == 0) 04458 { 04459 errmsg= "Could not create file mapping"; 04460 goto error; 04461 } 04462 if ((handle_connect_map= (char *)MapViewOfFile(handle_connect_file_map, 04463 FILE_MAP_WRITE,0,0, 04464 sizeof(DWORD))) == 0) 04465 { 04466 errmsg= "Could not create shared memory service"; 04467 goto error; 04468 } 04469 04470 while (!abort_loop) 04471 { 04472 /* Wait a request from client */ 04473 WaitForSingleObject(smem_event_connect_request,INFINITE); 04474 04475 /* 04476 it can be after shutdown command 04477 */ 04478 if (abort_loop) 04479 goto error; 04480 04481 HANDLE handle_client_file_map= 0; 04482 char *handle_client_map= 0; 04483 HANDLE event_client_wrote= 0; 04484 HANDLE event_client_read= 0; // for transfer data server <-> client 04485 HANDLE event_server_wrote= 0; 04486 HANDLE event_server_read= 0; 04487 HANDLE event_conn_closed= 0; 04488 THD *thd= 0; 04489 04490 p= int10_to_str(connect_number, connect_number_char, 10); 04491 /* 04492 The name of event and file-mapping events create agree next rule: 04493 shared_memory_base_name+unique_part+number_of_connection 04494 Where: 04495 shared_memory_base_name is uniquel value for each server 04496 unique_part is unique value for each object (events and file-mapping) 04497 number_of_connection is connection-number between server and client 04498 */ 04499 suffix_pos= strxmov(tmp,shared_memory_base_name,"_",connect_number_char, 04500 "_",NullS); 04501 strmov(suffix_pos, "DATA"); 04502 if ((handle_client_file_map= 04503 CreateFileMapping(INVALID_HANDLE_VALUE, sa_mapping, 04504 PAGE_READWRITE, 0, smem_buffer_length, tmp)) == 0) 04505 { 04506 errmsg= "Could not create file mapping"; 04507 goto errorconn; 04508 } 04509 if ((handle_client_map= (char*)MapViewOfFile(handle_client_file_map, 04510 FILE_MAP_WRITE,0,0, 04511 smem_buffer_length)) == 0) 04512 { 04513 errmsg= "Could not create memory map"; 04514 goto errorconn; 04515 } 04516 strmov(suffix_pos, "CLIENT_WROTE"); 04517 if ((event_client_wrote= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0) 04518 { 04519 errmsg= "Could not create client write event"; 04520 goto errorconn; 04521 } 04522 strmov(suffix_pos, "CLIENT_READ"); 04523 if ((event_client_read= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0) 04524 { 04525 errmsg= "Could not create client read event"; 04526 goto errorconn; 04527 } 04528 strmov(suffix_pos, "SERVER_READ"); 04529 if ((event_server_read= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0) 04530 { 04531 errmsg= "Could not create server read event"; 04532 goto errorconn; 04533 } 04534 strmov(suffix_pos, "SERVER_WROTE"); 04535 if ((event_server_wrote= CreateEvent(sa_event, 04536 FALSE, FALSE, tmp)) == 0) 04537 { 04538 errmsg= "Could not create server write event"; 04539 goto errorconn; 04540 } 04541 strmov(suffix_pos, "CONNECTION_CLOSED"); 04542 if ((event_conn_closed= CreateEvent(sa_event, 04543 TRUE, FALSE, tmp)) == 0) 04544 { 04545 errmsg= "Could not create closed connection event"; 04546 goto errorconn; 04547 } 04548 if (abort_loop) 04549 goto errorconn; 04550 if (!(thd= new THD)) 04551 goto errorconn; 04552 /* Send number of connection to client */ 04553 int4store(handle_connect_map, connect_number); 04554 if (!SetEvent(event_connect_answer)) 04555 { 04556 errmsg= "Could not send answer event"; 04557 goto errorconn; 04558 } 04559 /* Set event that client should receive data */ 04560 if (!SetEvent(event_client_read)) 04561 { 04562 errmsg= "Could not set client to read mode"; 04563 goto errorconn; 04564 } 04565 if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net, 04566 handle_client_file_map, 04567 handle_client_map, 04568 event_client_wrote, 04569 event_client_read, 04570 event_server_wrote, 04571 event_server_read, 04572 event_conn_closed)) || 04573 my_net_init(&thd->net, thd->net.vio)) 04574 { 04575 close_connection(thd, ER_OUT_OF_RESOURCES, 1); 04576 errmsg= 0; 04577 goto errorconn; 04578 } 04579 thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); /* Host is unknown */ 04580 create_new_thread(thd); 04581 connect_number++; 04582 continue; 04583 04584 errorconn: 04585 /* Could not form connection; Free used handlers/memort and retry */ 04586 if (errmsg) 04587 { 04588 char buff[180]; 04589 strxmov(buff, "Can't create shared memory connection: ", errmsg, ".", 04590 NullS); 04591 sql_perror(buff); 04592 } 04593 if (handle_client_file_map) 04594 CloseHandle(handle_client_file_map); 04595 if (handle_client_map) 04596 UnmapViewOfFile(handle_client_map); 04597 if (event_server_wrote) 04598 CloseHandle(event_server_wrote); 04599 if (event_server_read) 04600 CloseHandle(event_server_read); 04601 if (event_client_wrote) 04602 CloseHandle(event_client_wrote); 04603 if (event_client_read) 04604 CloseHandle(event_client_read); 04605 if (event_conn_closed) 04606 CloseHandle(event_conn_closed); 04607 delete thd; 04608 } 04609 04610 /* End shared memory handling */ 04611 error: 04612 if (errmsg) 04613 { 04614 char buff[180]; 04615 strxmov(buff, "Can't create shared memory service: ", errmsg, ".", NullS); 04616 sql_perror(buff); 04617 } 04618 my_security_attr_free(sa_event); 04619 my_security_attr_free(sa_mapping); 04620 if (handle_connect_map) UnmapViewOfFile(handle_connect_map); 04621 if (handle_connect_file_map) CloseHandle(handle_connect_file_map); 04622 if (event_connect_answer) CloseHandle(event_connect_answer); 04623 if (smem_event_connect_request) CloseHandle(smem_event_connect_request); 04624 04625 decrement_handler_count(); 04626 DBUG_RETURN(0); 04627 } 04628 #endif /* HAVE_SMEM */ 04629 #endif /* EMBEDDED_LIBRARY */ 04630 04631 04632 /**************************************************************************** 04633 Handle start options 04634 ******************************************************************************/ 04635 04636 enum options_mysqld 04637 { 04638 OPT_ISAM_LOG=256, OPT_SKIP_NEW, 04639 OPT_SKIP_GRANT, OPT_SKIP_LOCK, 04640 OPT_ENABLE_LOCK, OPT_USE_LOCKING, 04641 OPT_SOCKET, OPT_UPDATE_LOG, 04642 OPT_BIN_LOG, OPT_SKIP_RESOLVE, 04643 OPT_SKIP_NETWORKING, OPT_BIN_LOG_INDEX, 04644 OPT_BIND_ADDRESS, OPT_PID_FILE, 04645 OPT_SKIP_PRIOR, OPT_BIG_TABLES, 04646 OPT_STANDALONE, OPT_ONE_THREAD, 04647 OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES, 04648 OPT_SKIP_HOST_CACHE, OPT_SHORT_LOG_FORMAT, 04649 OPT_FLUSH, OPT_SAFE, 04650 OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB, 04651 OPT_STORAGE_ENGINE, OPT_INIT_FILE, 04652 OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG, 04653 OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR, 04654 OPT_BDB_HOME, OPT_BDB_LOG, 04655 OPT_BDB_TMP, OPT_BDB_SYNC, 04656 OPT_BDB_LOCK, OPT_BDB, 04657 OPT_BDB_NO_RECOVER, OPT_BDB_SHARED, 04658 OPT_BDB_DATA_DIRECT, OPT_BDB_LOG_DIRECT, 04659 OPT_MASTER_HOST, OPT_MASTER_USER, 04660 OPT_MASTER_PASSWORD, OPT_MASTER_PORT, 04661 OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY, 04662 OPT_MASTER_RETRY_COUNT, OPT_LOG_TC, OPT_LOG_TC_SIZE, 04663 OPT_MASTER_SSL, OPT_MASTER_SSL_KEY, 04664 OPT_MASTER_SSL_CERT, OPT_MASTER_SSL_CAPATH, 04665 OPT_MASTER_SSL_CIPHER, OPT_MASTER_SSL_CA, 04666 OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB, 04667 OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES, 04668 OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB, 04669 OPT_BINLOG_FORMAT, 04670 #ifndef DBUG_OFF 04671 OPT_BINLOG_SHOW_XID, 04672 #endif 04673 #ifdef HAVE_ROW_BASED_REPLICATION 04674 OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 04675 #endif 04676 OPT_WANT_CORE, OPT_CONCURRENT_INSERT, 04677 OPT_MEMLOCK, OPT_MYISAM_RECOVER, 04678 OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID, 04679 OPT_SKIP_SLAVE_START, OPT_SKIP_INNOBASE, 04680 OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE, 04681 OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE, 04682 OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID, 04683 OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER, 04684 OPT_ABORT_SLAVE_EVENT_COUNT, 04685 OPT_INNODB_DATA_HOME_DIR, 04686 OPT_INNODB_DATA_FILE_PATH, 04687 OPT_INNODB_LOG_GROUP_HOME_DIR, 04688 OPT_INNODB_LOG_ARCH_DIR, 04689 OPT_INNODB_LOG_ARCHIVE, 04690 OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, 04691 OPT_INNODB_FLUSH_METHOD, 04692 OPT_INNODB_DOUBLEWRITE, 04693 OPT_INNODB_CHECKSUMS, 04694 OPT_INNODB_FAST_SHUTDOWN, 04695 OPT_INNODB_FILE_PER_TABLE, OPT_CRASH_BINLOG_INNODB, 04696 OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, 04697 OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, 04698 OPT_SAFE_SHOW_DB, OPT_INNODB_SAFE_BINLOG, 04699 OPT_INNODB, OPT_ISAM, 04700 OPT_ENGINE_CONDITION_PUSHDOWN, 04701 OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, OPT_NDB_USE_EXACT_COUNT, 04702 OPT_NDB_FORCE_SEND, OPT_NDB_AUTOINCREMENT_PREFETCH_SZ, 04703 OPT_NDB_SHM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_NDB_CACHE_CHECK_TIME, 04704 OPT_NDB_MGMD, OPT_NDB_NODEID, 04705 OPT_NDB_DISTRIBUTION, 04706 OPT_NDB_INDEX_STAT_ENABLE, 04707 OPT_NDB_INDEX_STAT_CACHE_ENTRIES, OPT_NDB_INDEX_STAT_UPDATE_FREQ, 04708 OPT_NDB_EXTRA_LOGGING, 04709 OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, 04710 OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, 04711 OPT_NDB_USE_COPYING_ALTER_TABLE, 04712 OPT_SKIP_SAFEMALLOC, 04713 OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE, 04714 OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS, 04715 OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL, 04716 OPT_SAFE_USER_CREATE, OPT_SQL_MODE, 04717 OPT_HAVE_NAMED_PIPE, 04718 OPT_DO_PSTACK, OPT_EVENT_SCHEDULER, OPT_REPORT_HOST, 04719 OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT, 04720 OPT_SHOW_SLAVE_AUTH_INFO, 04721 OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE, 04722 OPT_RPL_RECOVERY_RANK,OPT_INIT_RPL_ROLE, 04723 OPT_RELAY_LOG, OPT_RELAY_LOG_INDEX, OPT_RELAY_LOG_INFO_FILE, 04724 OPT_SLAVE_SKIP_ERRORS, OPT_DES_KEY_FILE, OPT_LOCAL_INFILE, 04725 OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, 04726 OPT_SSL_CAPATH, OPT_SSL_CIPHER, 04727 OPT_BACK_LOG, OPT_BINLOG_CACHE_SIZE, 04728 OPT_CONNECT_TIMEOUT, OPT_DELAYED_INSERT_TIMEOUT, 04729 OPT_DELAYED_INSERT_LIMIT, OPT_DELAYED_QUEUE_SIZE, 04730 OPT_FLUSH_TIME, OPT_FT_MIN_WORD_LEN, OPT_FT_BOOLEAN_SYNTAX, 04731 OPT_FT_MAX_WORD_LEN, OPT_FT_QUERY_EXPANSION_LIMIT, OPT_FT_STOPWORD_FILE, 04732 OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE, 04733 OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE, 04734 OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD, 04735 OPT_LONG_QUERY_TIME, 04736 OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET, 04737 OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE, 04738 OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS, 04739 OPT_MAX_DELAYED_THREADS, OPT_MAX_HEP_TABLE_SIZE, 04740 OPT_MAX_JOIN_SIZE, OPT_MAX_PREPARED_STMT_COUNT, 04741 OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH, 04742 OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS, 04743 OPT_MAX_LENGTH_FOR_SORT_DATA, 04744 OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE, 04745 OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE, 04746 OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, 04747 OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE, 04748 OPT_MYISAM_USE_MMAP, 04749 OPT_MYISAM_STATS_METHOD, 04750 OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT, 04751 OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT, 04752 OPT_OPEN_FILES_LIMIT, 04753 OPT_PRELOAD_BUFFER_SIZE, 04754 OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_MIN_RES_UNIT, OPT_QUERY_CACHE_SIZE, 04755 OPT_QUERY_CACHE_TYPE, OPT_QUERY_CACHE_WLOCK_INVALIDATE, OPT_RECORD_BUFFER, 04756 OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT, 04757 OPT_RELAY_LOG_PURGE, 04758 OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME, 04759 OPT_SLAVE_TRANS_RETRIES, OPT_READONLY, OPT_DEBUGGING, 04760 OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE, 04761 OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE, 04762 OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK, 04763 OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS, 04764 OPT_INNODB_MIRRORED_LOG_GROUPS, 04765 OPT_INNODB_LOG_FILES_IN_GROUP, 04766 OPT_INNODB_LOG_FILE_SIZE, 04767 OPT_INNODB_LOG_BUFFER_SIZE, 04768 OPT_INNODB_BUFFER_POOL_SIZE, 04769 OPT_INNODB_BUFFER_POOL_AWE_MEM_MB, 04770 OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE, 04771 OPT_INNODB_MAX_PURGE_LAG, 04772 OPT_INNODB_FILE_IO_THREADS, 04773 OPT_INNODB_LOCK_WAIT_TIMEOUT, 04774 OPT_INNODB_THREAD_CONCURRENCY, 04775 OPT_INNODB_COMMIT_CONCURRENCY, 04776 OPT_INNODB_FORCE_RECOVERY, 04777 OPT_INNODB_STATUS_FILE, 04778 OPT_INNODB_MAX_DIRTY_PAGES_PCT, 04779 OPT_INNODB_TABLE_LOCKS, 04780 OPT_INNODB_SUPPORT_XA, 04781 OPT_INNODB_OPEN_FILES, 04782 OPT_INNODB_AUTOEXTEND_INCREMENT, 04783 OPT_INNODB_SYNC_SPIN_LOOPS, 04784 OPT_INNODB_CONCURRENCY_TICKETS, 04785 OPT_INNODB_THREAD_SLEEP_DELAY, 04786 OPT_BDB_CACHE_SIZE, 04787 OPT_BDB_CACHE_PARTS, 04788 OPT_BDB_LOG_BUFFER_SIZE, 04789 OPT_BDB_MAX_LOCK, 04790 OPT_BDB_REGION_SIZE, 04791 OPT_ERROR_LOG_FILE, 04792 OPT_DEFAULT_WEEK_FORMAT, 04793 OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_ALLOW_SUSPICIOUS_UDFS, 04794 OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE, 04795 OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE, 04796 OPT_SYNC_FRM, OPT_SYNC_BINLOG, 04797 OPT_SYNC_REPLICATION, 04798 OPT_SYNC_REPLICATION_SLAVE_ID, 04799 OPT_SYNC_REPLICATION_TIMEOUT, 04800 OPT_BDB_NOSYNC, 04801 OPT_ENABLE_SHARED_MEMORY, 04802 OPT_SHARED_MEMORY_BASE_NAME, 04803 OPT_OLD_PASSWORDS, 04804 OPT_OLD_ALTER_TABLE, 04805 OPT_EXPIRE_LOGS_DAYS, 04806 OPT_GROUP_CONCAT_MAX_LEN, 04807 OPT_DEFAULT_COLLATION, 04808 OPT_CHARACTER_SET_CLIENT_HANDSHAKE, 04809 OPT_CHARACTER_SET_FILESYSTEM, 04810 OPT_INIT_CONNECT, 04811 OPT_INIT_SLAVE, 04812 OPT_SECURE_AUTH, 04813 OPT_DATE_FORMAT, 04814 OPT_TIME_FORMAT, 04815 OPT_DATETIME_FORMAT, 04816 OPT_LOG_QUERIES_NOT_USING_INDEXES, 04817 OPT_DEFAULT_TIME_ZONE, 04818 OPT_SYSDATE_IS_NOW, 04819 OPT_OPTIMIZER_SEARCH_DEPTH, 04820 OPT_OPTIMIZER_PRUNE_LEVEL, 04821 OPT_UPDATABLE_VIEWS_WITH_LIMIT, 04822 OPT_SP_AUTOMATIC_PRIVILEGES, 04823 OPT_MAX_SP_RECURSION_DEPTH, 04824 OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET, 04825 OPT_ENABLE_LARGE_PAGES, 04826 OPT_TIMED_MUTEXES, 04827 OPT_OLD_STYLE_USER_LIMITS, 04828 OPT_LOG_SLOW_ADMIN_STATEMENTS, 04829 OPT_TABLE_LOCK_WAIT_TIMEOUT, 04830 OPT_PLUGIN_DIR, 04831 OPT_LOG_OUTPUT, 04832 OPT_PORT_OPEN_TIMEOUT, 04833 OPT_GENERAL_LOG, 04834 OPT_SLOW_LOG, 04835 OPT_MERGE 04836 }; 04837 04838 04839 #define LONG_TIMEOUT ((ulong) 3600L*24L*365L) 04840 04841 struct my_option my_long_options[] = 04842 { 04843 {"help", '?', "Display this help and exit.", 04844 (gptr*) &opt_help, (gptr*) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 04845 0, 0}, 04846 #ifdef HAVE_REPLICATION 04847 {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT, 04848 "Option used by mysql-test for debugging and testing of replication.", 04849 (gptr*) &abort_slave_event_count, (gptr*) &abort_slave_event_count, 04850 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04851 #endif /* HAVE_REPLICATION */ 04852 {"allow-suspicious-udfs", OPT_ALLOW_SUSPICIOUS_UDFS, 04853 "Allows use of UDFs consisting of only one symbol xxx() " 04854 "without corresponding xxx_init() or xxx_deinit(). That also means " 04855 "that one can load any function from any library, for example exit() " 04856 "from libc.so", 04857 (gptr*) &opt_allow_suspicious_udfs, (gptr*) &opt_allow_suspicious_udfs, 04858 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 04859 {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'.", 0, 0, 0, 04860 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 04861 {"auto-increment-increment", OPT_AUTO_INCREMENT, 04862 "Auto-increment columns are incremented by this", 04863 (gptr*) &global_system_variables.auto_increment_increment, 04864 (gptr*) &max_system_variables.auto_increment_increment, 0, GET_ULONG, 04865 OPT_ARG, 1, 1, 65535, 0, 1, 0 }, 04866 {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET, 04867 "Offset added to Auto-increment columns. Used when auto-increment-increment != 1", 04868 (gptr*) &global_system_variables.auto_increment_offset, 04869 (gptr*) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG, 04870 1, 1, 65535, 0, 1, 0 }, 04871 {"automatic-sp-privileges", OPT_SP_AUTOMATIC_PRIVILEGES, 04872 "Creating and dropping stored procedures alters ACLs. Disable with --skip-automatic-sp-privileges.", 04873 (gptr*) &sp_automatic_privileges, (gptr*) &sp_automatic_privileges, 04874 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, 04875 {"basedir", 'b', 04876 "Path to installation directory. All paths are usually resolved relative to this.", 04877 (gptr*) &mysql_home_ptr, (gptr*) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG, 04878 0, 0, 0, 0, 0, 0}, 04879 {"big-tables", OPT_BIG_TABLES, 04880 "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors).", 04881 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 04882 {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.", 04883 (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR, 04884 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04885 {"binlog_format", OPT_BINLOG_FORMAT, 04886 #ifdef HAVE_ROW_BASED_REPLICATION 04887 "Tell the master the form of binary logging to use: either 'row' for " 04888 "row-based binary logging, or 'statement' for statement-based binary " 04889 "logging, or 'mixed'. 'mixed' is statement-based binary logging except " 04890 "for those statements where only row-based is correct: those which " 04891 "involve user-defined functions (i.e. UDFs) or the UUID() function; for " 04892 "those, row-based binary logging is automatically used. " 04893 #ifdef HAVE_NDB_BINLOG 04894 "If ndbcluster is enabled, the default is 'row'." 04895 #endif 04896 #else 04897 "Tell the master the form of binary logging to use: this build " 04898 "supports only statement-based binary logging, so only 'statement' is " 04899 "a legal value." 04900 #endif 04901 , 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04902 {"binlog-do-db", OPT_BINLOG_DO_DB, 04903 "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.", 04904 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04905 {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, 04906 "Tells the master that updates to the given database should not be logged tothe binary log.", 04907 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04908 #ifdef HAVE_ROW_BASED_REPLICATION 04909 {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 04910 "The maximum size of a row-based binary log event in bytes. Rows will be " 04911 "grouped into events smaller than this size if possible. " 04912 "The value has to be a multiple of 256.", 04913 (gptr*) &opt_binlog_rows_event_max_size, 04914 (gptr*) &opt_binlog_rows_event_max_size, 0, 04915 GET_ULONG, REQUIRED_ARG, 04916 /* def_value */ 1024, /* min_value */ 256, /* max_value */ ULONG_MAX, 04917 /* sub_size */ 0, /* block_size */ 256, 04918 /* app_type */ 0 04919 }, 04920 #endif 04921 {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0, 04922 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 04923 {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE, 04924 "Don't ignore client side character set value sent during handshake.", 04925 (gptr*) &opt_character_set_client_handshake, 04926 (gptr*) &opt_character_set_client_handshake, 04927 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, 04928 {"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM, 04929 "Set the filesystem character set.", 04930 (gptr*) &character_set_filesystem_name, 04931 (gptr*) &character_set_filesystem_name, 04932 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04933 {"character-set-server", 'C', "Set the default character set.", 04934 (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, 04935 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04936 {"character-sets-dir", OPT_CHARSETS_DIR, 04937 "Directory where character sets are.", (gptr*) &charsets_dir, 04938 (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04939 {"chroot", 'r', "Chroot mysqld daemon during startup.", 04940 (gptr*) &mysqld_chroot, (gptr*) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG, 04941 0, 0, 0, 0, 0, 0}, 04942 {"collation-server", OPT_DEFAULT_COLLATION, "Set the default collation.", 04943 (gptr*) &default_collation_name, (gptr*) &default_collation_name, 04944 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04945 {"completion-type", OPT_COMPLETION_TYPE, "Default completion type.", 04946 (gptr*) &global_system_variables.completion_type, 04947 (gptr*) &max_system_variables.completion_type, 0, GET_ULONG, 04948 REQUIRED_ARG, 0, 0, 2, 0, 1, 0}, 04949 {"concurrent-insert", OPT_CONCURRENT_INSERT, 04950 "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0", 04951 (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert, 04952 0, GET_LONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, 04953 {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.", 04954 (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 04955 0, 0, 0}, 04956 {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG, 04957 NO_ARG, 0, 0, 0, 0, 0, 0}, 04958 {"datadir", 'h', "Path to the database root.", (gptr*) &mysql_data_home, 04959 (gptr*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04960 #ifndef DBUG_OFF 04961 {"debug", '#', "Debug log.", (gptr*) &default_dbug_option, 04962 (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 04963 #endif 04964 {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).", 04965 (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, 04966 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04967 {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (deprecated option, use --collation-server instead).", 04968 (gptr*) &default_collation_name, (gptr*) &default_collation_name, 04969 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04970 {"default-storage-engine", OPT_STORAGE_ENGINE, 04971 "Set the default storage engine (table type) for tables.", 04972 (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, 04973 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04974 {"default-table-type", OPT_STORAGE_ENGINE, 04975 "(deprecated) Use --default-storage-engine.", 04976 (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, 04977 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 04978 {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.", 04979 (gptr*) &default_tz_name, (gptr*) &default_tz_name, 04980 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 04981 {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.", 04982 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 04983 {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, 04984 "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead).", 04985 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 04986 #ifdef HAVE_OPENSSL 04987 {"des-key-file", OPT_DES_KEY_FILE, 04988 "Load keys for des_encrypt() and des_encrypt from given file.", 04989 (gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG, 04990 0, 0, 0, 0, 0, 0}, 04991 #endif /* HAVE_OPENSSL */ 04992 #ifdef HAVE_REPLICATION 04993 {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT, 04994 "Option used by mysql-test for debugging and testing of replication.", 04995 (gptr*) &disconnect_slave_event_count, 04996 (gptr*) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 04997 0, 0, 0}, 04998 #endif /* HAVE_REPLICATION */ 04999 {"enable-locking", OPT_ENABLE_LOCK, 05000 "Deprecated option, use --external-locking instead.", 05001 (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, 05002 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05003 #ifdef __NT__ 05004 {"enable-named-pipe", OPT_HAVE_NAMED_PIPE, "Enable the named pipe (NT).", 05005 (gptr*) &opt_enable_named_pipe, (gptr*) &opt_enable_named_pipe, 0, GET_BOOL, 05006 NO_ARG, 0, 0, 0, 0, 0, 0}, 05007 #endif 05008 {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure.", 05009 (gptr*) &opt_do_pstack, (gptr*) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, 05010 0, 0, 0, 0}, 05011 {"engine-condition-pushdown", 05012 OPT_ENGINE_CONDITION_PUSHDOWN, 05013 "Push supported query conditions to the storage engine.", 05014 (gptr*) &global_system_variables.engine_condition_pushdown, 05015 (gptr*) &global_system_variables.engine_condition_pushdown, 05016 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05017 {"event-scheduler", OPT_EVENT_SCHEDULER, "Enable/disable the event scheduler.", 05018 (gptr*) &Events::opt_event_scheduler, (gptr*) &Events::opt_event_scheduler, 0, GET_ULONG, 05019 REQUIRED_ARG, 2/*default*/, 0/*min-value*/, 2/*max-value*/, 0, 0, 0}, 05020 {"exit-info", 'T', "Used for debugging; Use at your own risk!", 0, 0, 0, 05021 GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05022 {"external-locking", OPT_USE_LOCKING, "Use system (external) locking (disabled by default). With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running. Disable with --skip-external-locking.", 05023 (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, 05024 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05025 {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands.", 0, 0, 0, 05026 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05027 /* We must always support the next option to make scripts like mysqltest 05028 easier to do */ 05029 {"gdb", OPT_DEBUGGING, 05030 "Set up signals usable for debugging", 05031 (gptr*) &opt_debugging, (gptr*) &opt_debugging, 05032 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05033 {"general-log", OPT_GENERAL_LOG, 05034 "Enable|disable general log", (gptr*) &opt_log, 05035 (gptr*) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05036 #ifdef HAVE_LARGE_PAGES 05037 {"large-pages", OPT_ENABLE_LARGE_PAGES, "Enable support for large pages. \ 05038 Disable with --skip-large-pages.", 05039 (gptr*) &opt_large_pages, (gptr*) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0, 0, 05040 0, 0, 0}, 05041 #endif 05042 {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection", 05043 (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC, 05044 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05045 {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.", 05046 (gptr*) &opt_init_file, (gptr*) &opt_init_file, 0, GET_STR, REQUIRED_ARG, 05047 0, 0, 0, 0, 0, 0}, 05048 {"init-rpl-role", OPT_INIT_RPL_ROLE, "Set the replication role.", 0, 0, 0, 05049 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05050 {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to this master", 05051 (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC, 05052 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05053 {"innodb", OPT_INNODB, "Enable InnoDB (if this version of MySQL supports it). \ 05054 Disable with --skip-innodb (will save memory).", 05055 (gptr*) &opt_innodb, (gptr*) &opt_innodb, 0, GET_BOOL, NO_ARG, OPT_INNODB_DEFAULT, 0, 0, 05056 0, 0, 0}, 05057 #ifdef WITH_INNOBASE_STORAGE_ENGINE 05058 {"innodb_checksums", OPT_INNODB_CHECKSUMS, "Enable InnoDB checksums validation (enabled by default). \ 05059 Disable with --skip-innodb-checksums.", (gptr*) &innobase_use_checksums, 05060 (gptr*) &innobase_use_checksums, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, 05061 #endif 05062 {"innodb_data_file_path", OPT_INNODB_DATA_FILE_PATH, 05063 "Path to individual files and their sizes.", 05064 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05065 #ifdef WITH_INNOBASE_STORAGE_ENGINE 05066 {"innodb_data_home_dir", OPT_INNODB_DATA_HOME_DIR, 05067 "The common part for InnoDB table spaces.", (gptr*) &innobase_data_home_dir, 05068 (gptr*) &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 05069 0}, 05070 {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \ 05071 Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, 05072 (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, 05073 {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN, 05074 "Speeds up the shutdown process of the InnoDB storage engine. Possible " 05075 "values are 0, 1 (faster)" 05076 /* 05077 NetWare can't close unclosed files, can't automatically kill remaining 05078 threads, etc, so on this OS we disable the crash-like InnoDB shutdown. 05079 */ 05080 #ifndef __NETWARE__ 05081 " or 2 (fastest - crash-like)" 05082 #endif 05083 ".", 05084 (gptr*) &innobase_fast_shutdown, 05085 (gptr*) &innobase_fast_shutdown, 0, GET_ULONG, OPT_ARG, 1, 0, 05086 IF_NETWARE(1,2), 0, 0, 0}, 05087 {"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE, 05088 "Stores each InnoDB table to an .ibd file in the database dir.", 05089 (gptr*) &innobase_file_per_table, 05090 (gptr*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05091 {"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, 05092 "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).", 05093 (gptr*) &srv_flush_log_at_trx_commit, 05094 (gptr*) &srv_flush_log_at_trx_commit, 05095 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, 05096 {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, 05097 "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method, 05098 (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 05099 0, 0, 0}, 05100 {"innodb_locks_unsafe_for_binlog", OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, 05101 "Force InnoDB to not use next-key locking, to use only row-level locking.", 05102 (gptr*) &innobase_locks_unsafe_for_binlog, 05103 (gptr*) &innobase_locks_unsafe_for_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05104 {"innodb_log_arch_dir", OPT_INNODB_LOG_ARCH_DIR, 05105 "Where full logs should be archived.", (gptr*) &innobase_log_arch_dir, 05106 (gptr*) &innobase_log_arch_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05107 {"innodb_log_archive", OPT_INNODB_LOG_ARCHIVE, 05108 "Set to 1 if you want to have logs archived.", 0, 0, 0, GET_LONG, OPT_ARG, 05109 0, 0, 0, 0, 0, 0}, 05110 {"innodb_log_group_home_dir", OPT_INNODB_LOG_GROUP_HOME_DIR, 05111 "Path to InnoDB log files.", (gptr*) &innobase_log_group_home_dir, 05112 (gptr*) &innobase_log_group_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 05113 0, 0}, 05114 {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, 05115 "Percentage of dirty pages allowed in bufferpool.", (gptr*) &srv_max_buf_pool_modified_pct, 05116 (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, 05117 {"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG, 05118 "Desired maximum length of the purge queue (0 = no limit)", 05119 (gptr*) &srv_max_purge_lag, 05120 (gptr*) &srv_max_purge_lag, 0, GET_LONG, REQUIRED_ARG, 0, 0, ~0L, 05121 0, 1L, 0}, 05122 {"innodb_status_file", OPT_INNODB_STATUS_FILE, 05123 "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file", 05124 (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file, 05125 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05126 {"innodb_support_xa", OPT_INNODB_SUPPORT_XA, 05127 "Enable InnoDB support for the XA two-phase commit", 05128 (gptr*) &global_system_variables.innodb_support_xa, 05129 (gptr*) &global_system_variables.innodb_support_xa, 05130 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05131 {"innodb_table_locks", OPT_INNODB_TABLE_LOCKS, 05132 "Enable InnoDB locking in LOCK TABLES", 05133 (gptr*) &global_system_variables.innodb_table_locks, 05134 (gptr*) &global_system_variables.innodb_table_locks, 05135 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05136 #endif /* End WITH_INNOBASE_STORAGE_ENGINE */ 05137 {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.", 05138 (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0, 05139 0, 0, 0}, 05140 {"language", 'L', 05141 "Client error messages in given language. May be given as a full path.", 05142 (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG, 05143 0, 0, 0, 0, 0, 0}, 05144 {"local-infile", OPT_LOCAL_INFILE, 05145 "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).", 05146 (gptr*) &opt_local_infile, 05147 (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 05148 1, 0, 0, 0, 0, 0}, 05149 {"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname, 05150 (gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05151 {"log-bin", OPT_BIN_LOG, 05152 "Log update queries in binary format. Optional (but strongly recommended " 05153 "to avoid replication problems if server's hostname changes) argument " 05154 "should be the chosen location for the binary log files.", 05155 (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC, 05156 OPT_ARG, 0, 0, 0, 0, 0, 0}, 05157 {"log-bin-index", OPT_BIN_LOG_INDEX, 05158 "File that holds the names for last binary log files.", 05159 (gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR, 05160 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05161 #ifndef TO_BE_REMOVED_IN_5_1_OR_6_0 05162 /* 05163 In 5.0.6 we introduced the below option, then in 5.0.16 we renamed it to 05164 log-bin-trust-function-creators but kept also the old name for 05165 compatibility; the behaviour was also changed to apply only to functions 05166 (and triggers). In a future release this old name could be removed. 05167 */ 05168 {"log-bin-trust-routine-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, 05169 "(deprecated) Use log-bin-trust-function-creators.", 05170 (gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0, 05171 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05172 #endif 05173 /* 05174 This option starts with "log-bin" to emphasize that it is specific of 05175 binary logging. 05176 */ 05177 {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, 05178 "If equal to 0 (the default), then when --log-bin is used, creation of " 05179 "a stored function (or trigger) is allowed only to users having the SUPER privilege " 05180 "and only if this stored function (trigger) may not break binary logging." 05181 #ifdef HAVE_ROW_BASED_REPLICATION 05182 "Note that if ALL connections to this server ALWAYS use row-based binary " 05183 "logging, the security issues do not exist and the binary logging cannot " 05184 "break, so you can safely set this to 1." 05185 #endif 05186 ,(gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0, 05187 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05188 {"log-error", OPT_ERROR_LOG_FILE, "Error log file.", 05189 (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR, 05190 OPT_ARG, 0, 0, 0, 0, 0, 0}, 05191 {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", 05192 (gptr*) &myisam_log_filename, (gptr*) &myisam_log_filename, 0, GET_STR, 05193 OPT_ARG, 0, 0, 0, 0, 0, 0}, 05194 {"log-long-format", '0', 05195 "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 05196 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05197 #ifdef WITH_CSV_STORAGE_ENGINE 05198 {"log-output", OPT_LOG_OUTPUT, 05199 "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, " 05200 "FILE or NONE.", 05201 (gptr*) &log_output_str, (gptr*) &log_output_str, 0, 05202 GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05203 #endif 05204 {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES, 05205 "Log queries that are executed without benefit of any index to the slow log if it is open.", 05206 (gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes, 05207 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05208 {"log-short-format", OPT_SHORT_LOG_FORMAT, 05209 "Don't log extra information to update and slow-query logs.", 05210 (gptr*) &opt_short_log_format, (gptr*) &opt_short_log_format, 05211 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05212 {"log-slave-updates", OPT_LOG_SLAVE_UPDATES, 05213 "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.", 05214 (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL, 05215 NO_ARG, 0, 0, 0, 0, 0, 0}, 05216 {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS, 05217 "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open.", 05218 (gptr*) &opt_log_slow_admin_statements, 05219 (gptr*) &opt_log_slow_admin_statements, 05220 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05221 {"log-slow-queries", OPT_SLOW_QUERY_LOG, 05222 "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.", 05223 (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG, 05224 0, 0, 0, 0, 0, 0}, 05225 {"log-tc", OPT_LOG_TC, 05226 "Path to transaction coordinator log (used for transactions that affect " 05227 "more than one storage engine, when binary log is disabled)", 05228 (gptr*) &opt_tc_log_file, (gptr*) &opt_tc_log_file, 0, GET_STR, 05229 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05230 #ifdef HAVE_MMAP 05231 {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.", 05232 (gptr*) &opt_tc_log_size, (gptr*) &opt_tc_log_size, 0, GET_ULONG, 05233 REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ~0L, 0, TC_LOG_PAGE_SIZE, 0}, 05234 #endif 05235 {"log-update", OPT_UPDATE_LOG, 05236 "The update log is deprecated since version 5.0, is replaced by the binary \ 05237 log and this option justs turns on --log-bin instead.", 05238 (gptr*) &opt_update_logname, (gptr*) &opt_update_logname, 0, GET_STR, 05239 OPT_ARG, 0, 0, 0, 0, 0, 0}, 05240 {"log-warnings", 'W', "Log some not critical warnings to the log file.", 05241 (gptr*) &global_system_variables.log_warnings, 05242 (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0, 05243 0, 0, 0}, 05244 {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES, 05245 "INSERT/DELETE/UPDATE has lower priority than selects.", 05246 (gptr*) &global_system_variables.low_priority_updates, 05247 (gptr*) &max_system_variables.low_priority_updates, 05248 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05249 {"master-connect-retry", OPT_MASTER_CONNECT_RETRY, 05250 "The number of seconds the slave thread will sleep before retrying to connect to the master in case the master goes down or the connection is lost.", 05251 (gptr*) &master_connect_retry, (gptr*) &master_connect_retry, 0, GET_UINT, 05252 REQUIRED_ARG, 60, 0, 0, 0, 0, 0}, 05253 {"master-host", OPT_MASTER_HOST, 05254 "Master hostname or IP address for replication. If not set, the slave thread will not be started. Note that the setting of master-host will be ignored if there exists a valid master.info file.", 05255 (gptr*) &master_host, (gptr*) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 05256 0, 0, 0, 0}, 05257 {"master-info-file", OPT_MASTER_INFO_FILE, 05258 "The location and name of the file that remembers the master and where the I/O replication \ 05259 thread is in the master's binlogs.", 05260 (gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR, 05261 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05262 {"master-password", OPT_MASTER_PASSWORD, 05263 "The password the slave thread will authenticate with when connecting to the master. If not set, an empty password is assumed.The value in master.info will take precedence if it can be read.", 05264 (gptr*)&master_password, (gptr*)&master_password, 0, 05265 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05266 {"master-port", OPT_MASTER_PORT, 05267 "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT is assumed. If you have not tinkered with configure options, this should be 3306. The value in master.info will take precedence if it can be read.", 05268 (gptr*) &master_port, (gptr*) &master_port, 0, GET_UINT, REQUIRED_ARG, 05269 MYSQL_PORT, 0, 0, 0, 0, 0}, 05270 {"master-retry-count", OPT_MASTER_RETRY_COUNT, 05271 "The number of tries the slave will make to connect to the master before giving up.", 05272 (gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG, 05273 REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0}, 05274 {"master-ssl", OPT_MASTER_SSL, 05275 "Enable the slave to connect to the master using SSL.", 05276 (gptr*) &master_ssl, (gptr*) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 05277 0, 0}, 05278 {"master-ssl-ca", OPT_MASTER_SSL_CA, 05279 "Master SSL CA file. Only applies if you have enabled master-ssl.", 05280 (gptr*) &master_ssl_ca, (gptr*) &master_ssl_ca, 0, GET_STR, OPT_ARG, 05281 0, 0, 0, 0, 0, 0}, 05282 {"master-ssl-capath", OPT_MASTER_SSL_CAPATH, 05283 "Master SSL CA path. Only applies if you have enabled master-ssl.", 05284 (gptr*) &master_ssl_capath, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, 05285 0, 0, 0, 0, 0, 0}, 05286 {"master-ssl-cert", OPT_MASTER_SSL_CERT, 05287 "Master SSL certificate file name. Only applies if you have enabled \ 05288 master-ssl", 05289 (gptr*) &master_ssl_cert, (gptr*) &master_ssl_cert, 0, GET_STR, OPT_ARG, 05290 0, 0, 0, 0, 0, 0}, 05291 {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER, 05292 "Master SSL cipher. Only applies if you have enabled master-ssl.", 05293 (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, 05294 0, 0, 0, 0, 0, 0}, 05295 {"master-ssl-key", OPT_MASTER_SSL_KEY, 05296 "Master SSL keyfile name. Only applies if you have enabled master-ssl.", 05297 (gptr*) &master_ssl_key, (gptr*) &master_ssl_key, 0, GET_STR, OPT_ARG, 05298 0, 0, 0, 0, 0, 0}, 05299 {"master-user", OPT_MASTER_USER, 05300 "The username the slave thread will use for authentication when connecting to the master. The user must have FILE privilege. If the master user is not set, user test is assumed. The value in master.info will take precedence if it can be read.", 05301 (gptr*) &master_user, (gptr*) &master_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 05302 0, 0, 0, 0}, 05303 #ifdef HAVE_REPLICATION 05304 {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS, 05305 "Option used by mysql-test for debugging and testing of replication.", 05306 (gptr*) &max_binlog_dump_events, (gptr*) &max_binlog_dump_events, 0, 05307 GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05308 #endif /* HAVE_REPLICATION */ 05309 {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory, 05310 (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05311 {"merge", OPT_MERGE, "Enable Merge storage engine. Disable with \ 05312 --skip-merge.", 05313 (gptr*) &opt_merge, (gptr*) &opt_merge, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0}, 05314 {"myisam-recover", OPT_MYISAM_RECOVER, 05315 "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.", 05316 (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, 05317 GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05318 {"ndbcluster", OPT_NDBCLUSTER, "Enable NDB Cluster (if this version of MySQL supports it). \ 05319 Disable with --skip-ndbcluster (will save memory).", 05320 (gptr*) &opt_ndbcluster, (gptr*) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 05321 OPT_NDBCLUSTER_DEFAULT, 0, 0, 0, 0, 0}, 05322 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 05323 {"ndb-connectstring", OPT_NDB_CONNECTSTRING, 05324 "Connect string for ndbcluster.", 05325 (gptr*) &opt_ndb_connectstring, 05326 (gptr*) &opt_ndb_connectstring, 05327 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05328 {"ndb-mgmd-host", OPT_NDB_MGMD, 05329 "Set host and port for ndb_mgmd. Syntax: hostname[:port]", 05330 (gptr*) &opt_ndb_mgmd, 05331 (gptr*) &opt_ndb_mgmd, 05332 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05333 {"ndb-nodeid", OPT_NDB_NODEID, 05334 "Nodeid for this mysqlserver in the cluster.", 05335 (gptr*) &opt_ndb_nodeid, 05336 (gptr*) &opt_ndb_nodeid, 05337 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05338 {"ndb-autoincrement-prefetch-sz", OPT_NDB_AUTOINCREMENT_PREFETCH_SZ, 05339 "Specify number of autoincrement values that are prefetched.", 05340 (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, 05341 (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, 05342 0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, 05343 {"ndb-distribution", OPT_NDB_DISTRIBUTION, 05344 "Default distribution for new tables in ndb", 05345 (gptr*) &opt_ndb_distribution, 05346 (gptr*) &opt_ndb_distribution, 05347 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05348 {"ndb-force-send", OPT_NDB_FORCE_SEND, 05349 "Force send of buffers to ndb immediately without waiting for " 05350 "other threads.", 05351 (gptr*) &global_system_variables.ndb_force_send, 05352 (gptr*) &global_system_variables.ndb_force_send, 05353 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05354 {"ndb_force_send", OPT_NDB_FORCE_SEND, 05355 "same as --ndb-force-send.", 05356 (gptr*) &global_system_variables.ndb_force_send, 05357 (gptr*) &global_system_variables.ndb_force_send, 05358 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05359 {"ndb-extra-logging", OPT_NDB_EXTRA_LOGGING, 05360 "Turn on more logging in the error log.", 05361 (gptr*) &ndb_extra_logging, 05362 (gptr*) &ndb_extra_logging, 05363 0, GET_INT, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05364 #ifdef HAVE_NDB_BINLOG 05365 {"ndb-report-thresh-binlog-epoch-slip", OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, 05366 "Threshold on number of epochs to be behind before reporting binlog status. " 05367 "E.g. 3 means that if the difference between what epoch has been received " 05368 "from the storage nodes and what has been applied to the binlog is 3 or more, " 05369 "a status message will be sent to the cluster log.", 05370 (gptr*) &ndb_report_thresh_binlog_epoch_slip, 05371 (gptr*) &ndb_report_thresh_binlog_epoch_slip, 05372 0, GET_ULONG, REQUIRED_ARG, 3, 0, 256, 0, 0, 0}, 05373 {"ndb-report-thresh-binlog-mem-usage", OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, 05374 "Threshold on percentage of free memory before reporting binlog status. E.g. " 05375 "10 means that if amount of available memory for receiving binlog data from " 05376 "the storage nodes goes below 10%, " 05377 "a status message will be sent to the cluster log.", 05378 (gptr*) &ndb_report_thresh_binlog_mem_usage, 05379 (gptr*) &ndb_report_thresh_binlog_mem_usage, 05380 0, GET_ULONG, REQUIRED_ARG, 10, 0, 100, 0, 0, 0}, 05381 #endif 05382 {"ndb-use-exact-count", OPT_NDB_USE_EXACT_COUNT, 05383 "Use exact records count during query planning and for fast " 05384 "select count(*), disable for faster queries.", 05385 (gptr*) &global_system_variables.ndb_use_exact_count, 05386 (gptr*) &global_system_variables.ndb_use_exact_count, 05387 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05388 {"ndb_use_exact_count", OPT_NDB_USE_EXACT_COUNT, 05389 "same as --ndb-use-exact-count.", 05390 (gptr*) &global_system_variables.ndb_use_exact_count, 05391 (gptr*) &global_system_variables.ndb_use_exact_count, 05392 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05393 {"ndb-shm", OPT_NDB_SHM, 05394 "Use shared memory connections when available.", 05395 (gptr*) &opt_ndb_shm, 05396 (gptr*) &opt_ndb_shm, 05397 0, GET_BOOL, OPT_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0}, 05398 {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION, 05399 "Select nodes for transactions in a more optimal way.", 05400 (gptr*) &opt_ndb_optimized_node_selection, 05401 (gptr*) &opt_ndb_optimized_node_selection, 05402 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 05403 { "ndb-cache-check-time", OPT_NDB_CACHE_CHECK_TIME, 05404 "A dedicated thread is created to, at the given millisecons interval, invalidate the query cache if another MySQL server in the cluster has changed the data in the database.", 05405 (gptr*) &opt_ndb_cache_check_time, (gptr*) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG, 05406 0, 0, LONG_TIMEOUT, 0, 1, 0}, 05407 {"ndb-index-stat-enable", OPT_NDB_INDEX_STAT_ENABLE, 05408 "Use ndb index statistics in query optimization.", 05409 (gptr*) &global_system_variables.ndb_index_stat_enable, 05410 (gptr*) &max_system_variables.ndb_index_stat_enable, 05411 0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 0, 0}, 05412 {"ndb-index-stat-cache-entries", OPT_NDB_INDEX_STAT_CACHE_ENTRIES, 05413 "Number of start/end keys to store in statistics memory cache." 05414 " Zero means no cache and forces query of db nodes always.", 05415 (gptr*) &global_system_variables.ndb_index_stat_cache_entries, 05416 (gptr*) &max_system_variables.ndb_index_stat_cache_entries, 05417 0, GET_ULONG, OPT_ARG, 32, 0, ~0L, 0, 0, 0}, 05418 {"ndb-index-stat-update-freq", OPT_NDB_INDEX_STAT_UPDATE_FREQ, 05419 "How often, in the long run, to query db nodes instead of statistics cache." 05420 " For example 20 means every 20th time.", 05421 (gptr*) &global_system_variables.ndb_index_stat_update_freq, 05422 (gptr*) &max_system_variables.ndb_index_stat_update_freq, 05423 0, GET_ULONG, OPT_ARG, 20, 0, ~0L, 0, 0, 0}, 05424 #endif 05425 {"ndb-use-copying-alter-table", 05426 OPT_NDB_USE_COPYING_ALTER_TABLE, 05427 "Force ndbcluster to always copy tables at alter table (should only be used if on-line alter table fails).", 05428 (gptr*) &global_system_variables.ndb_use_copying_alter_table, 05429 (gptr*) &global_system_variables.ndb_use_copying_alter_table, 05430 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05431 {"new", 'n', "Use very new possible 'unsafe' functions.", 05432 (gptr*) &global_system_variables.new_mode, 05433 (gptr*) &max_system_variables.new_mode, 05434 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05435 #ifdef NOT_YET 05436 {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types.", 05437 (gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, 05438 0, 0, 0, 0, 0, 0}, 05439 #endif 05440 {"old-alter-table", OPT_OLD_ALTER_TABLE, 05441 "Use old, non-optimized alter table.", 05442 (gptr*) &global_system_variables.old_alter_table, 05443 (gptr*) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG, 05444 0, 0, 0, 0, 0, 0}, 05445 {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).", 05446 (gptr*) &global_system_variables.old_passwords, 05447 (gptr*) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG, 05448 0, 0, 0, 0, 0, 0}, 05449 #ifdef ONE_THREAD 05450 {"one-thread", OPT_ONE_THREAD, 05451 "Only use one thread (for debugging under Linux).", 0, 0, 0, GET_NO_ARG, 05452 NO_ARG, 0, 0, 0, 0, 0, 0}, 05453 #endif 05454 {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS, 05455 "Enable old-style user limits (before 5.0.3 user resources were counted per each user+host vs. per account)", 05456 (gptr*) &opt_old_style_user_limits, (gptr*) &opt_old_style_user_limits, 05457 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05458 {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", 05459 (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR, 05460 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05461 {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port, 05462 (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05463 {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, 05464 "Maximum time in seconds to wait for the port to become free. " 05465 "(Default: no wait)", (gptr*) &mysqld_port_timeout, 05466 (gptr*) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05467 {"relay-log", OPT_RELAY_LOG, 05468 "The location and name to use for relay logs.", 05469 (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0, 05470 GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05471 {"relay-log-index", OPT_RELAY_LOG_INDEX, 05472 "The location and name to use for the file that keeps a list of the last \ 05473 relay logs.", 05474 (gptr*) &opt_relaylog_index_name, (gptr*) &opt_relaylog_index_name, 0, 05475 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05476 {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, 05477 "The location and name of the file that remembers where the SQL replication \ 05478 thread is in the relay logs.", 05479 (gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR, 05480 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05481 {"replicate-do-db", OPT_REPLICATE_DO_DB, 05482 "Tells the slave thread to restrict replication to the specified database. To specify more than one database, use the directive multiple times, once for each database. Note that this will only work if you do not use cross-database queries such as UPDATE some_db.some_table SET foo='bar' while having selected a different or no database. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-do-table=db_name.%.", 05483 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05484 {"replicate-do-table", OPT_REPLICATE_DO_TABLE, 05485 "Tells the slave thread to restrict replication to the specified table. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates, in contrast to replicate-do-db.", 05486 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05487 {"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB, 05488 "Tells the slave thread to not replicate to the specified database. To specify more than one database to ignore, use the directive multiple times, once for each database. This option will not work if you use cross database updates. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-ignore-table=db_name.%. ", 05489 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05490 {"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE, 05491 "Tells the slave thread to not replicate to the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table. This will work for cross-datbase updates, in contrast to replicate-ignore-db.", 05492 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05493 {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB, 05494 "Updates to a database with a different name than the original. Example: replicate-rewrite-db=master_db_name->slave_db_name.", 05495 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05496 #ifdef HAVE_REPLICATION 05497 {"replicate-same-server-id", OPT_REPLICATE_SAME_SERVER_ID, 05498 "In replication, if set to 1, do not skip events having our server id. \ 05499 Default value is 0 (to break infinite loops in circular replication). \ 05500 Can't be set to 1 if --log-slave-updates is used.", 05501 (gptr*) &replicate_same_server_id, 05502 (gptr*) &replicate_same_server_id, 05503 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05504 #endif 05505 {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, 05506 "Tells the slave thread to restrict replication to the tables that match the specified wildcard pattern. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-do-table=foo%.bar% will replicate only updates to tables in all databases that start with foo and whose table names start with bar.", 05507 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05508 {"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE, 05509 "Tells the slave thread to not replicate to the tables that match the given wildcard pattern. To specify more than one table to ignore, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% will not do updates to tables in databases that start with foo and whose table names start with bar.", 05510 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05511 // In replication, we may need to tell the other servers how to connect 05512 {"report-host", OPT_REPORT_HOST, 05513 "Hostname or IP of the slave to be reported to to the master during slave registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not want the slave to register itself with the master. Note that it is not sufficient for the master to simply read the IP of the slave off the socket once the slave connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the slave from the master or other hosts.", 05514 (gptr*) &report_host, (gptr*) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 05515 0, 0, 0, 0}, 05516 {"report-password", OPT_REPORT_PASSWORD, "Undocumented.", 05517 (gptr*) &report_password, (gptr*) &report_password, 0, GET_STR, 05518 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05519 {"report-port", OPT_REPORT_PORT, 05520 "Port for connecting to slave reported to the master during slave registration. Set it only if the slave is listening on a non-default port or if you have a special tunnel from the master or other clients to the slave. If not sure, leave this option unset.", 05521 (gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG, 05522 MYSQL_PORT, 0, 0, 0, 0, 0}, 05523 {"report-user", OPT_REPORT_USER, "Undocumented.", (gptr*) &report_user, 05524 (gptr*) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05525 {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.", 05526 (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG, 05527 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05528 {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", 05529 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05530 #ifndef TO_BE_DELETED 05531 {"safe-show-database", OPT_SAFE_SHOW_DB, 05532 "Deprecated option; use GRANT SHOW DATABASES instead...", 05533 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05534 #endif 05535 {"safe-user-create", OPT_SAFE_USER_CREATE, 05536 "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", 05537 (gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL, 05538 NO_ARG, 0, 0, 0, 0, 0, 0}, 05539 {"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT, 05540 "Simulate memory shortage when compiled with the --with-debug=full option.", 05541 0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05542 {"secure-auth", OPT_SECURE_AUTH, "Disallow authentication for accounts that have old (pre-4.1) passwords.", 05543 (gptr*) &opt_secure_auth, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 05544 my_bool(0), 0, 0, 0, 0, 0}, 05545 {"server-id", OPT_SERVER_ID, 05546 "Uniquely identifies the server instance in the community of replication partners.", 05547 (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 05548 0, 0, 0}, 05549 {"set-variable", 'O', 05550 "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", 05551 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05552 #ifdef HAVE_SMEM 05553 {"shared-memory", OPT_ENABLE_SHARED_MEMORY, 05554 "Enable the shared memory.",(gptr*) &opt_enable_shared_memory, (gptr*) &opt_enable_shared_memory, 05555 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05556 #endif 05557 #ifdef HAVE_SMEM 05558 {"shared-memory-base-name",OPT_SHARED_MEMORY_BASE_NAME, 05559 "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 05560 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05561 #endif 05562 {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO, 05563 "Show user and password in SHOW SLAVE HOSTS on this master", 05564 (gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0, 05565 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05566 {"skip-grant-tables", OPT_SKIP_GRANT, 05567 "Start without grant tables. This gives all users FULL ACCESS to all tables!", 05568 (gptr*) &opt_noacl, (gptr*) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 05569 0}, 05570 {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0, 05571 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05572 {"skip-locking", OPT_SKIP_LOCK, 05573 "Deprecated option, use --skip-external-locking instead.", 05574 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05575 {"skip-name-resolve", OPT_SKIP_RESOLVE, 05576 "Don't resolve hostnames. All hostnames are IP's or 'localhost'.", 05577 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05578 {"skip-networking", OPT_SKIP_NETWORKING, 05579 "Don't allow connection with TCP/IP.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 05580 0, 0, 0}, 05581 {"skip-new", OPT_SKIP_NEW, "Don't use new, possible wrong routines.", 05582 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05583 #ifndef DBUG_OFF 05584 #ifdef SAFEMALLOC 05585 {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, 05586 "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, 05587 0, 0, 0, 0, 0, 0}, 05588 #endif 05589 #endif 05590 {"skip-show-database", OPT_SKIP_SHOW_DB, 05591 "Don't allow 'SHOW DATABASE' commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 05592 0, 0, 0, 0}, 05593 {"skip-slave-start", OPT_SKIP_SLAVE_START, 05594 "If set, slave is not autostarted.", (gptr*) &opt_skip_slave_start, 05595 (gptr*) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 05596 {"skip-stack-trace", OPT_SKIP_STACK_TRACE, 05597 "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 05598 0, 0, 0, 0}, 05599 {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option. Use --skip-symbolic-links instead.", 05600 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 05601 {"skip-thread-priority", OPT_SKIP_PRIOR, 05602 "Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 05603 0, 0, 0, 0, 0}, 05604 #ifdef HAVE_REPLICATION 05605 {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, 05606 "The location where the slave should put its temporary files when \ 05607 replicating a LOAD DATA INFILE command.", 05608 (gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC, 05609 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05610 {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS, 05611 "Tells the slave thread to continue replication when a query returns an error from the provided list.", 05612 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05613 #endif 05614 {"slow-query-log", OPT_SLOW_LOG, 05615 "Enable|disable slow query log", (gptr*) &opt_slow_log, 05616 (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 05617 {"socket", OPT_SOCKET, "Socket file to use for connection.", 05618 (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR, 05619 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05620 #ifdef HAVE_REPLICATION 05621 {"sporadic-binlog-dump-fail", OPT_SPORADIC_BINLOG_DUMP_FAIL, 05622 "Option used by mysql-test for debugging and testing of replication.", 05623 (gptr*) &opt_sporadic_binlog_dump_fail, 05624 (gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 05625 0}, 05626 #endif /* HAVE_REPLICATION */ 05627 {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME, 05628 "The update log is deprecated since version 5.0, is replaced by the binary \ 05629 log and this option does nothing anymore.", 05630 0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0}, 05631 {"sql-mode", OPT_SQL_MODE, 05632 "Syntax: sql-mode=option[,option[,option...]] where option can be one of: REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, ONLY_FULL_GROUP_BY, NO_UNSIGNED_SUBTRACTION.", 05633 (gptr*) &sql_mode_str, (gptr*) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 05634 0, 0, 0, 0, 0}, 05635 #ifdef HAVE_OPENSSL 05636 #include "sslopt-longopts.h" 05637 #endif 05638 #ifdef __WIN__ 05639 {"standalone", OPT_STANDALONE, 05640 "Dummy option to start as a standalone program (NT).", 0, 0, 0, GET_NO_ARG, 05641 NO_ARG, 0, 0, 0, 0, 0, 0}, 05642 #endif 05643 {"symbolic-links", 's', "Enable symbolic link support.", 05644 (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, 05645 IF_PURIFY(0,1), 0, 0, 0, 0, 0}, 05646 {"sysdate-is-now", OPT_SYSDATE_IS_NOW, 05647 "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.", 05648 (gptr*) &global_system_variables.sysdate_is_now, 05649 0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, 05650 {"tc-heuristic-recover", OPT_TC_HEURISTIC_RECOVER, 05651 "Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.", 05652 (gptr*) &opt_tc_heuristic_recover, (gptr*) &opt_tc_heuristic_recover, 05653 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05654 {"temp-pool", OPT_TEMP_POOL, 05655 "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.", 05656 (gptr*) &use_temp_pool, (gptr*) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, 05657 0, 0, 0, 0, 0}, 05658 {"timed_mutexes", OPT_TIMED_MUTEXES, 05659 "Specify whether to time mutexes (only InnoDB mutexes are currently supported)", 05660 (gptr*) &timed_mutexes, (gptr*) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 05661 0, 0, 0, 0, 0}, 05662 {"tmpdir", 't', 05663 "Path for temporary files. Several paths may be specified, separated by a " 05664 #if defined(__WIN__) || defined(__NETWARE__) 05665 "semicolon (;)" 05666 #else 05667 "colon (:)" 05668 #endif 05669 ", in this case they are used in a round-robin fashion.", 05670 (gptr*) &opt_mysql_tmpdir, 05671 (gptr*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05672 {"transaction-isolation", OPT_TX_ISOLATION, 05673 "Default transaction isolation level.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 05674 0, 0, 0, 0, 0}, 05675 {"use-symbolic-links", 's', "Enable symbolic link support. Deprecated option; use --symbolic-links instead.", 05676 (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, 05677 IF_PURIFY(0,1), 0, 0, 0, 0, 0}, 05678 {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG, 05679 0, 0, 0, 0, 0, 0}, 05680 {"verbose", 'v', "Used with --help option for detailed help", 05681 (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 05682 0, 0}, 05683 {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, 05684 NO_ARG, 0, 0, 0, 0, 0, 0}, 05685 {"warnings", 'W', "Deprecated; use --log-warnings instead.", 05686 (gptr*) &global_system_variables.log_warnings, 05687 (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L, 05688 0, 0, 0}, 05689 { "back_log", OPT_BACK_LOG, 05690 "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.", 05691 (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG, 05692 REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 }, 05693 {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE, 05694 "The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.", 05695 (gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG, 05696 REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0}, 05697 {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE, 05698 "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!", 05699 (gptr*) &global_system_variables.bulk_insert_buff_size, 05700 (gptr*) &max_system_variables.bulk_insert_buff_size, 05701 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0}, 05702 {"connect_timeout", OPT_CONNECT_TIMEOUT, 05703 "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.", 05704 (gptr*) &connect_timeout, (gptr*) &connect_timeout, 05705 0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 }, 05706 { "date_format", OPT_DATE_FORMAT, 05707 "The DATE format (For future).", 05708 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], 05709 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], 05710 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05711 { "datetime_format", OPT_DATETIME_FORMAT, 05712 "The DATETIME/TIMESTAMP format (for future).", 05713 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], 05714 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], 05715 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05716 { "default_week_format", OPT_DEFAULT_WEEK_FORMAT, 05717 "The default week format used by WEEK() functions.", 05718 (gptr*) &global_system_variables.default_week_format, 05719 (gptr*) &max_system_variables.default_week_format, 05720 0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0}, 05721 {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT, 05722 "After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing.", 05723 (gptr*) &delayed_insert_limit, (gptr*) &delayed_insert_limit, 0, GET_ULONG, 05724 REQUIRED_ARG, DELAYED_LIMIT, 1, ~0L, 0, 1, 0}, 05725 {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT, 05726 "How long a INSERT DELAYED thread should wait for INSERT statements before terminating.", 05727 (gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0, 05728 GET_ULONG, REQUIRED_ARG, DELAYED_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, 05729 { "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE, 05730 "What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again.", 05731 (gptr*) &delayed_queue_size, (gptr*) &delayed_queue_size, 0, GET_ULONG, 05732 REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1, 0}, 05733 {"div_precision_increment", OPT_DIV_PRECINCREMENT, 05734 "Precision of the result of '/' operator will be increased on that value.", 05735 (gptr*) &global_system_variables.div_precincrement, 05736 (gptr*) &max_system_variables.div_precincrement, 0, GET_ULONG, 05737 REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0}, 05738 {"expire_logs_days", OPT_EXPIRE_LOGS_DAYS, 05739 "If non-zero, binary logs will be purged after expire_logs_days " 05740 "days; possible purges happen at startup and at binary log rotation.", 05741 (gptr*) &expire_logs_days, 05742 (gptr*) &expire_logs_days, 0, GET_ULONG, 05743 REQUIRED_ARG, 0, 0, 99, 0, 1, 0}, 05744 { "flush_time", OPT_FLUSH_TIME, 05745 "A dedicated thread is created to flush all tables at the given interval.", 05746 (gptr*) &flush_time, (gptr*) &flush_time, 0, GET_ULONG, REQUIRED_ARG, 05747 FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1, 0}, 05748 { "ft_boolean_syntax", OPT_FT_BOOLEAN_SYNTAX, 05749 "List of operators for MATCH ... AGAINST ( ... IN BOOLEAN MODE)", 05750 0, 0, 0, GET_STR, 05751 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05752 { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, 05753 "The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", 05754 (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, 05755 REQUIRED_ARG, HA_FT_MAXCHARLEN, 10, HA_FT_MAXCHARLEN, 0, 1, 0}, 05756 { "ft_min_word_len", OPT_FT_MIN_WORD_LEN, 05757 "The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", 05758 (gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_ULONG, 05759 REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, 0, 1, 0}, 05760 { "ft_query_expansion_limit", OPT_FT_QUERY_EXPANSION_LIMIT, 05761 "Number of best matches to use for query expansion", 05762 (gptr*) &ft_query_expansion_limit, (gptr*) &ft_query_expansion_limit, 0, GET_ULONG, 05763 REQUIRED_ARG, 20, 0, 1000, 0, 1, 0}, 05764 { "ft_stopword_file", OPT_FT_STOPWORD_FILE, 05765 "Use stopwords from this file instead of built-in list.", 05766 (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR, 05767 REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 05768 { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN, 05769 "The maximum length of the result of function group_concat.", 05770 (gptr*) &global_system_variables.group_concat_max_len, 05771 (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG, 05772 REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0}, 05773 #ifdef WITH_INNOBASE_STORAGE_ENGINE 05774 {"innodb_additional_mem_pool_size", OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE, 05775 "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.", 05776 (gptr*) &innobase_additional_mem_pool_size, 05777 (gptr*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG, 05778 1*1024*1024L, 512*1024L, ~0L, 0, 1024, 0}, 05779 {"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT, 05780 "Data file autoextend increment in megabytes", 05781 (gptr*) &srv_auto_extend_increment, 05782 (gptr*) &srv_auto_extend_increment, 05783 0, GET_LONG, REQUIRED_ARG, 8L, 1L, 1000L, 0, 1L, 0}, 05784 {"innodb_buffer_pool_awe_mem_mb", OPT_INNODB_BUFFER_POOL_AWE_MEM_MB, 05785 "If Windows AWE is used, the size of InnoDB buffer pool allocated from the AWE memory.", 05786 (gptr*) &innobase_buffer_pool_awe_mem_mb, (gptr*) &innobase_buffer_pool_awe_mem_mb, 0, 05787 GET_LONG, REQUIRED_ARG, 0, 0, 63000, 0, 1, 0}, 05788 {"innodb_buffer_pool_size", OPT_INNODB_BUFFER_POOL_SIZE, 05789 "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", 05790 (gptr*) &innobase_buffer_pool_size, (gptr*) &innobase_buffer_pool_size, 0, 05791 GET_LL, REQUIRED_ARG, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 0, 05792 1024*1024L, 0}, 05793 {"innodb_commit_concurrency", OPT_INNODB_COMMIT_CONCURRENCY, 05794 "Helps in performance tuning in heavily concurrent environments.", 05795 (gptr*) &srv_commit_concurrency, (gptr*) &srv_commit_concurrency, 05796 0, GET_LONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0}, 05797 {"innodb_concurrency_tickets", OPT_INNODB_CONCURRENCY_TICKETS, 05798 "Number of times a thread is allowed to enter InnoDB within the same \ 05799 SQL query after it has once got the ticket", 05800 (gptr*) &srv_n_free_tickets_to_enter, 05801 (gptr*) &srv_n_free_tickets_to_enter, 05802 0, GET_LONG, REQUIRED_ARG, 500L, 1L, ~0L, 0, 1L, 0}, 05803 {"innodb_file_io_threads", OPT_INNODB_FILE_IO_THREADS, 05804 "Number of file I/O threads in InnoDB.", (gptr*) &innobase_file_io_threads, 05805 (gptr*) &innobase_file_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 4, 64, 0, 05806 1, 0}, 05807 {"innodb_force_recovery", OPT_INNODB_FORCE_RECOVERY, 05808 "Helps to save your data in case the disk image of the database becomes corrupt.", 05809 (gptr*) &innobase_force_recovery, (gptr*) &innobase_force_recovery, 0, 05810 GET_LONG, REQUIRED_ARG, 0, 0, 6, 0, 1, 0}, 05811 {"innodb_lock_wait_timeout", OPT_INNODB_LOCK_WAIT_TIMEOUT, 05812 "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back.", 05813 (gptr*) &innobase_lock_wait_timeout, (gptr*) &innobase_lock_wait_timeout, 05814 0, GET_LONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0}, 05815 {"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE, 05816 "The size of the buffer which InnoDB uses to write log to the log files on disk.", 05817 (gptr*) &innobase_log_buffer_size, (gptr*) &innobase_log_buffer_size, 0, 05818 GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, ~0L, 0, 1024, 0}, 05819 {"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE, 05820 "Size of each log file in a log group.", 05821 (gptr*) &innobase_log_file_size, (gptr*) &innobase_log_file_size, 0, 05822 GET_LL, REQUIRED_ARG, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 0, 05823 1024*1024L, 0}, 05824 {"innodb_log_files_in_group", OPT_INNODB_LOG_FILES_IN_GROUP, 05825 "Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.", 05826 (gptr*) &innobase_log_files_in_group, (gptr*) &innobase_log_files_in_group, 05827 0, GET_LONG, REQUIRED_ARG, 2, 2, 100, 0, 1, 0}, 05828 {"innodb_mirrored_log_groups", OPT_INNODB_MIRRORED_LOG_GROUPS, 05829 "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.", 05830 (gptr*) &innobase_mirrored_log_groups, 05831 (gptr*) &innobase_mirrored_log_groups, 0, GET_LONG, REQUIRED_ARG, 1, 1, 10, 05832 0, 1, 0}, 05833 {"innodb_open_files", OPT_INNODB_OPEN_FILES, 05834 "How many files at the maximum InnoDB keeps open at the same time.", 05835 (gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0, 05836 GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0}, 05837 {"innodb_sync_spin_loops", OPT_INNODB_SYNC_SPIN_LOOPS, 05838 "Count of spin-loop rounds in InnoDB mutexes", 05839 (gptr*) &srv_n_spin_wait_rounds, 05840 (gptr*) &srv_n_spin_wait_rounds, 05841 0, GET_LONG, REQUIRED_ARG, 20L, 0L, ~0L, 0, 1L, 0}, 05842 {"innodb_thread_concurrency", OPT_INNODB_THREAD_CONCURRENCY, 05843 "Helps in performance tuning in heavily concurrent environments. " 05844 "Sets the maximum number of threads allowed inside InnoDB. Value 0" 05845 " will disable the thread throttling.", 05846 (gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency, 05847 0, GET_LONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0}, 05848 {"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY, 05849 "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0" 05850 " disable a sleep", 05851 (gptr*) &srv_thread_sleep_delay, 05852 (gptr*) &srv_thread_sleep_delay, 05853 0, GET_LONG, REQUIRED_ARG, 10000L, 0L, ~0L, 0, 1L, 0}, 05854 #endif /* WITH_INNOBASE_STORAGE_ENGINE */ 05855 {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT, 05856 "The number of seconds the server waits for activity on an interactive connection before closing it.", 05857 (gptr*) &global_system_variables.net_interactive_timeout, 05858 (gptr*) &max_system_variables.net_interactive_timeout, 0, 05859 GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, 05860 {"join_buffer_size", OPT_JOIN_BUFF_SIZE, 05861 "The size of the buffer that is used for full joins.", 05862 (gptr*) &global_system_variables.join_buff_size, 05863 (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, 05864 REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, 05865 IO_SIZE, 0}, 05866 {"key_buffer_size", OPT_KEY_BUFFER_SIZE, 05867 "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", 05868 (gptr*) &dflt_key_cache_var.param_buff_size, 05869 (gptr*) 0, 05870 0, (GET_ULL | GET_ASK_ADDR), 05871 REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, 05872 IO_SIZE, 0}, 05873 {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, 05874 "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", 05875 (gptr*) &dflt_key_cache_var.param_age_threshold, 05876 (gptr*) 0, 05877 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 05878 300, 100, ~0L, 0, 100, 0}, 05879 {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, 05880 "The default size of key cache blocks", 05881 (gptr*) &dflt_key_cache_var.param_block_size, 05882 (gptr*) 0, 05883 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 05884 KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, 05885 {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, 05886 "The minimum percentage of warm blocks in key cache", 05887 (gptr*) &dflt_key_cache_var.param_division_limit, 05888 (gptr*) 0, 05889 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 05890 1, 100, 0, 1, 0}, 05891 {"long_query_time", OPT_LONG_QUERY_TIME, 05892 "Log all queries that have taken more than long_query_time seconds to execute to file.", 05893 (gptr*) &global_system_variables.long_query_time, 05894 (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG, 05895 REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0}, 05896 {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, 05897 "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system", 05898 (gptr*) &lower_case_table_names, 05899 (gptr*) &lower_case_table_names, 0, GET_UINT, OPT_ARG, 05900 #ifdef FN_NO_CASE_SENCE 05901 1 05902 #else 05903 0 05904 #endif 05905 , 0, 2, 0, 1, 0}, 05906 {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, 05907 "Max packetlength to send/receive from to server.", 05908 (gptr*) &global_system_variables.max_allowed_packet, 05909 (gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG, 05910 REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, 05911 {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, 05912 "Can be used to restrict the total size used to cache a multi-transaction query.", 05913 (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0, 05914 GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0}, 05915 {"max_binlog_size", OPT_MAX_BINLOG_SIZE, 05916 "Binary log will be rotated automatically when the size exceeds this \ 05917 value. Will also apply to relay logs if max_relay_log_size is 0. \ 05918 The minimum value for this variable is 4096.", 05919 (gptr*) &max_binlog_size, (gptr*) &max_binlog_size, 0, GET_ULONG, 05920 REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0}, 05921 {"max_connect_errors", OPT_MAX_CONNECT_ERRORS, 05922 "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.", 05923 (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG, 05924 REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0}, 05925 {"max_connections", OPT_MAX_CONNECTIONS, 05926 "The number of simultaneous clients allowed.", (gptr*) &max_connections, 05927 (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1, 05928 0}, 05929 {"max_delayed_threads", OPT_MAX_DELAYED_THREADS, 05930 "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.", 05931 (gptr*) &global_system_variables.max_insert_delayed_threads, 05932 (gptr*) &max_system_variables.max_insert_delayed_threads, 05933 0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0}, 05934 {"max_error_count", OPT_MAX_ERROR_COUNT, 05935 "Max number of errors/warnings to store for a statement.", 05936 (gptr*) &global_system_variables.max_error_count, 05937 (gptr*) &max_system_variables.max_error_count, 05938 0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0}, 05939 {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, 05940 "Don't allow creation of heap tables bigger than this.", 05941 (gptr*) &global_system_variables.max_heap_table_size, 05942 (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULONG, 05943 REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0}, 05944 {"max_join_size", OPT_MAX_JOIN_SIZE, 05945 "Joins that are probably going to read more than max_join_size records return an error.", 05946 (gptr*) &global_system_variables.max_join_size, 05947 (gptr*) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG, 05948 ~0L, 1, ~0L, 0, 1, 0}, 05949 {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA, 05950 "Max number of bytes in sorted records.", 05951 (gptr*) &global_system_variables.max_length_for_sort_data, 05952 (gptr*) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG, 05953 REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, 05954 {"max_prepared_stmt_count", OPT_MAX_PREPARED_STMT_COUNT, 05955 "Maximum number of prepared statements in the server.", 05956 (gptr*) &max_prepared_stmt_count, (gptr*) &max_prepared_stmt_count, 05957 0, GET_ULONG, REQUIRED_ARG, 16382, 0, 1*1024*1024, 0, 1, 0}, 05958 {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE, 05959 "If non-zero: relay log will be rotated automatically when the size exceeds this value; if zero (the default): when the size exceeds max_binlog_size. 0 excepted, the minimum value for this variable is 4096.", 05960 (gptr*) &max_relay_log_size, (gptr*) &max_relay_log_size, 0, GET_ULONG, 05961 REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0}, 05962 { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY, 05963 "Limit assumed max number of seeks when looking up rows based on a key", 05964 (gptr*) &global_system_variables.max_seeks_for_key, 05965 (gptr*) &max_system_variables.max_seeks_for_key, 0, GET_ULONG, 05966 REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0 }, 05967 {"max_sort_length", OPT_MAX_SORT_LENGTH, 05968 "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).", 05969 (gptr*) &global_system_variables.max_sort_length, 05970 (gptr*) &max_system_variables.max_sort_length, 0, GET_ULONG, 05971 REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, 05972 {"max_sp_recursion_depth", OPT_MAX_SP_RECURSION_DEPTH, 05973 "Maximum stored procedure recursion depth. (discussed with docs).", 05974 (gptr*) &global_system_variables.max_sp_recursion_depth, 05975 (gptr*) &max_system_variables.max_sp_recursion_depth, 0, GET_ULONG, 05976 OPT_ARG, 0, 0, 255, 0, 1, 0 }, 05977 {"max_tmp_tables", OPT_MAX_TMP_TABLES, 05978 "Maximum number of temporary tables a client can keep open at a time.", 05979 (gptr*) &global_system_variables.max_tmp_tables, 05980 (gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG, 05981 REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0}, 05982 {"max_user_connections", OPT_MAX_USER_CONNECTIONS, 05983 "The maximum number of active connections for a single user (0 = no limit).", 05984 (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT, 05985 REQUIRED_ARG, 0, 1, ~0, 0, 1, 0}, 05986 {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, 05987 "After this many write locks, allow some read locks to run in between.", 05988 (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG, 05989 REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0}, 05990 {"multi_range_count", OPT_MULTI_RANGE_COUNT, 05991 "Number of key ranges to request at once.", 05992 (gptr*) &global_system_variables.multi_range_count, 05993 (gptr*) &max_system_variables.multi_range_count, 0, 05994 GET_ULONG, REQUIRED_ARG, 256, 1, ~0L, 0, 1, 0}, 05995 {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE, 05996 "Block size to be used for MyISAM index pages.", 05997 (gptr*) &opt_myisam_block_size, 05998 (gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG, 05999 MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 06000 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, 06001 {"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE, 06002 "Default pointer size to be used for MyISAM tables.", 06003 (gptr*) &myisam_data_pointer_size, 06004 (gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, 06005 6, 2, 7, 0, 1, 0}, 06006 {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, 06007 "Deprecated option", 06008 (gptr*) &global_system_variables.myisam_max_extra_sort_file_size, 06009 (gptr*) &max_system_variables.myisam_max_extra_sort_file_size, 06010 0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH, 06011 0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0}, 06012 {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE, 06013 "Don't use the fast sort index method to created index if the temporary file would get bigger than this.", 06014 (gptr*) &global_system_variables.myisam_max_sort_file_size, 06015 (gptr*) &max_system_variables.myisam_max_sort_file_size, 0, 06016 GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE, 06017 0, 1024*1024, 0}, 06018 {"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS, 06019 "Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.", 06020 (gptr*) &global_system_variables.myisam_repair_threads, 06021 (gptr*) &max_system_variables.myisam_repair_threads, 0, 06022 GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0}, 06023 {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE, 06024 "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.", 06025 (gptr*) &global_system_variables.myisam_sort_buff_size, 06026 (gptr*) &max_system_variables.myisam_sort_buff_size, 0, 06027 GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, 06028 {"myisam_use_mmap", OPT_MYISAM_USE_MMAP, 06029 "Use memory mapping for reading and writing MyISAM tables", 06030 (gptr*) &opt_myisam_use_mmap, 06031 (gptr*) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 06032 0, 0, 0, 0, 0}, 06033 {"myisam_stats_method", OPT_MYISAM_STATS_METHOD, 06034 "Specifies how MyISAM index statistics collection code should threat NULLs. " 06035 "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " 06036 "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", 06037 (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, 06038 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 06039 {"net_buffer_length", OPT_NET_BUFFER_LENGTH, 06040 "Buffer length for TCP/IP and socket communication.", 06041 (gptr*) &global_system_variables.net_buffer_length, 06042 (gptr*) &max_system_variables.net_buffer_length, 0, GET_ULONG, 06043 REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0}, 06044 {"net_read_timeout", OPT_NET_READ_TIMEOUT, 06045 "Number of seconds to wait for more data from a connection before aborting the read.", 06046 (gptr*) &global_system_variables.net_read_timeout, 06047 (gptr*) &max_system_variables.net_read_timeout, 0, GET_ULONG, 06048 REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, 06049 {"net_retry_count", OPT_NET_RETRY_COUNT, 06050 "If a read on a communication port is interrupted, retry this many times before giving up.", 06051 (gptr*) &global_system_variables.net_retry_count, 06052 (gptr*) &max_system_variables.net_retry_count,0, 06053 GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0}, 06054 {"net_write_timeout", OPT_NET_WRITE_TIMEOUT, 06055 "Number of seconds to wait for a block to be written to a connection before aborting the write.", 06056 (gptr*) &global_system_variables.net_write_timeout, 06057 (gptr*) &max_system_variables.net_write_timeout, 0, GET_ULONG, 06058 REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, 06059 {"open_files_limit", OPT_OPEN_FILES_LIMIT, 06060 "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.", 06061 (gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG, 06062 REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0}, 06063 {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL, 06064 "Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows.", 06065 (gptr*) &global_system_variables.optimizer_prune_level, 06066 (gptr*) &max_system_variables.optimizer_prune_level, 06067 0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0}, 06068 {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH, 06069 "Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Smaller values than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch to the original find_best (used for testing/comparison).", 06070 (gptr*) &global_system_variables.optimizer_search_depth, 06071 (gptr*) &max_system_variables.optimizer_search_depth, 06072 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, 06073 {"plugin_dir", OPT_PLUGIN_DIR, 06074 "Directory for plugins.", 06075 (gptr*) &opt_plugin_dir_ptr, (gptr*) &opt_plugin_dir_ptr, 0, 06076 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 06077 {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, 06078 "The size of the buffer that is allocated when preloading indexes", 06079 (gptr*) &global_system_variables.preload_buff_size, 06080 (gptr*) &max_system_variables.preload_buff_size, 0, GET_ULONG, 06081 REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0}, 06082 {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE, 06083 "Allocation block size for query parsing and execution", 06084 (gptr*) &global_system_variables.query_alloc_block_size, 06085 (gptr*) &max_system_variables.query_alloc_block_size, 0, GET_ULONG, 06086 REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, 06087 #ifdef HAVE_QUERY_CACHE 06088 {"query_cache_limit", OPT_QUERY_CACHE_LIMIT, 06089 "Don't cache results that are bigger than this.", 06090 (gptr*) &query_cache_limit, (gptr*) &query_cache_limit, 0, GET_ULONG, 06091 REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0}, 06092 {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT, 06093 "minimal size of unit in wich space for results is allocated (last unit will be trimed after writing all result data.", 06094 (gptr*) &query_cache_min_res_unit, (gptr*) &query_cache_min_res_unit, 06095 0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE, 06096 0, (longlong) ULONG_MAX, 0, 1, 0}, 06097 #endif /*HAVE_QUERY_CACHE*/ 06098 {"query_cache_size", OPT_QUERY_CACHE_SIZE, 06099 "The memory allocated to store results from old queries.", 06100 (gptr*) &query_cache_size, (gptr*) &query_cache_size, 0, GET_ULONG, 06101 REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0}, 06102 #ifdef HAVE_QUERY_CACHE 06103 {"query_cache_type", OPT_QUERY_CACHE_TYPE, 06104 "0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT SQL_CACHE ... queries.", 06105 (gptr*) &global_system_variables.query_cache_type, 06106 (gptr*) &max_system_variables.query_cache_type, 06107 0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0}, 06108 {"query_cache_wlock_invalidate", OPT_QUERY_CACHE_WLOCK_INVALIDATE, 06109 "Invalidate queries in query cache on LOCK for write", 06110 (gptr*) &global_system_variables.query_cache_wlock_invalidate, 06111 (gptr*) &max_system_variables.query_cache_wlock_invalidate, 06112 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, 06113 #endif /*HAVE_QUERY_CACHE*/ 06114 {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE, 06115 "Persistent buffer for query parsing and execution", 06116 (gptr*) &global_system_variables.query_prealloc_size, 06117 (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, 06118 REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE, 06119 ~0L, 0, 1024, 0}, 06120 {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE, 06121 "Allocation block size for storing ranges during optimization", 06122 (gptr*) &global_system_variables.range_alloc_block_size, 06123 (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, 06124 REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0}, 06125 {"read_buffer_size", OPT_RECORD_BUFFER, 06126 "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.", 06127 (gptr*) &global_system_variables.read_buff_size, 06128 (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, 06129 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 06130 0}, 06131 {"read_only", OPT_READONLY, 06132 "Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege", 06133 (gptr*) &opt_readonly, 06134 (gptr*) &opt_readonly, 06135 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, 06136 {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER, 06137 "When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.", 06138 (gptr*) &global_system_variables.read_rnd_buff_size, 06139 (gptr*) &max_system_variables.read_rnd_buff_size, 0, 06140 GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD, 06141 SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, 06142 {"record_buffer", OPT_RECORD_BUFFER, 06143 "Alias for read_buffer_size", 06144 (gptr*) &global_system_variables.read_buff_size, 06145 (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, 06146 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, 06147 #ifdef HAVE_REPLICATION 06148 {"relay_log_purge", OPT_RELAY_LOG_PURGE, 06149 "0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.", 06150 (gptr*) &relay_log_purge, 06151 (gptr*) &relay_log_purge, 0, GET_BOOL, NO_ARG, 06152 1, 0, 1, 0, 1, 0}, 06153 {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, 06154 "Maximum space to use for all relay logs.", 06155 (gptr*) &relay_log_space_limit, 06156 (gptr*) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L, 06157 (longlong) ULONG_MAX, 0, 1, 0}, 06158 {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL, 06159 "Use compression on master/slave protocol.", 06160 (gptr*) &opt_slave_compressed_protocol, 06161 (gptr*) &opt_slave_compressed_protocol, 06162 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, 06163 {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT, 06164 "Number of seconds to wait for more data from a master/slave connection before aborting the read.", 06165 (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0, 06166 GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, 06167 {"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES, 06168 "Number of times the slave SQL thread will retry a transaction in case " 06169 "it failed with a deadlock or elapsed lock wait timeout, " 06170 "before giving up and stopping.", 06171 (gptr*) &slave_trans_retries, (gptr*) &slave_trans_retries, 0, 06172 GET_ULONG, REQUIRED_ARG, 10L, 0L, (longlong) ULONG_MAX, 0, 1, 0}, 06173 #endif /* HAVE_REPLICATION */ 06174 {"slow_launch_time", OPT_SLOW_LAUNCH_TIME, 06175 "If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.", 06176 (gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG, 06177 REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0}, 06178 {"sort_buffer_size", OPT_SORT_BUFFER, 06179 "Each thread that needs to do a sort allocates a buffer of this size.", 06180 (gptr*) &global_system_variables.sortbuff_size, 06181 (gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG, 06182 MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD, 06183 1, 0}, 06184 {"sync-binlog", OPT_SYNC_BINLOG, 06185 "Synchronously flush binary log to disk after every #th event. " 06186 "Use 0 (default) to disable synchronous flushing.", 06187 (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG, 06188 REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, 06189 {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.", 06190 (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, 06191 0, 0, 0, 0}, 06192 {"table_cache", OPT_TABLE_OPEN_CACHE, 06193 "Deprecated; use --table_open_cache instead.", 06194 (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG, 06195 REQUIRED_ARG, 64, 1, 512*1024L, 0, 1, 0}, 06196 {"table_definition_cache", OPT_TABLE_DEF_CACHE, 06197 "The number of cached table definitions.", 06198 (gptr*) &table_def_size, (gptr*) &table_def_size, 06199 0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0}, 06200 {"table_open_cache", OPT_TABLE_OPEN_CACHE, 06201 "The number of cached open tables.", 06202 (gptr*) &table_cache_size, (gptr*) &table_cache_size, 06203 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L, 0, 1, 0}, 06204 {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT, 06205 "Timeout in seconds to wait for a table level lock before returning an " 06206 "error. Used only if the connection has active cursors.", 06207 (gptr*) &table_lock_wait_timeout, (gptr*) &table_lock_wait_timeout, 06208 0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0}, 06209 {"thread_cache_size", OPT_THREAD_CACHE_SIZE, 06210 "How many threads we should keep in a cache for reuse.", 06211 (gptr*) &thread_cache_size, (gptr*) &thread_cache_size, 0, GET_ULONG, 06212 REQUIRED_ARG, 0, 0, 16384, 0, 1, 0}, 06213 {"thread_concurrency", OPT_THREAD_CONCURRENCY, 06214 "Permits the application to give the threads system a hint for the desired number of threads that should be run at the same time.", 06215 (gptr*) &concurrency, (gptr*) &concurrency, 0, GET_ULONG, REQUIRED_ARG, 06216 DEFAULT_CONCURRENCY, 1, 512, 0, 1, 0}, 06217 {"thread_stack", OPT_THREAD_STACK, 06218 "The stack size for each thread.", (gptr*) &thread_stack, 06219 (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, 06220 1024L*128L, ~0L, 0, 1024, 0}, 06221 { "time_format", OPT_TIME_FORMAT, 06222 "The TIME format (for future).", 06223 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], 06224 (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], 06225 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 06226 {"tmp_table_size", OPT_TMP_TABLE_SIZE, 06227 "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", 06228 (gptr*) &global_system_variables.tmp_table_size, 06229 (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG, 06230 REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, 06231 {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, 06232 "Allocation block size for transactions to be stored in binary log", 06233 (gptr*) &global_system_variables.trans_alloc_block_size, 06234 (gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, 06235 REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, 06236 {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE, 06237 "Persistent buffer for transactions to be stored in binary log", 06238 (gptr*) &global_system_variables.trans_prealloc_size, 06239 (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, 06240 REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, 06241 {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT, 06242 "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).", 06243 (gptr*) &global_system_variables.updatable_views_with_limit, 06244 (gptr*) &max_system_variables.updatable_views_with_limit, 06245 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 1, 0}, 06246 {"wait_timeout", OPT_WAIT_TIMEOUT, 06247 "The number of seconds the server waits for activity on a connection before closing it.", 06248 (gptr*) &global_system_variables.net_wait_timeout, 06249 (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG, 06250 REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT), 06251 0, 1, 0}, 06252 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} 06253 }; 06254 06255 static int show_question(THD *thd, SHOW_VAR *var, char *buff) 06256 { 06257 var->type= SHOW_LONGLONG; 06258 var->value= (char *)&thd->query_id; 06259 return 0; 06260 } 06261 06262 static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff) 06263 { 06264 var->type= SHOW_MY_BOOL; 06265 var->value= (char *)&thd->net.compress; 06266 return 0; 06267 } 06268 06269 static int show_starttime(THD *thd, SHOW_VAR *var, char *buff) 06270 { 06271 var->type= SHOW_LONG; 06272 var->value= buff; 06273 *((long *)buff)= (long) (thd->query_start() - start_time); 06274 return 0; 06275 } 06276 06277 #ifdef HAVE_REPLICATION 06278 static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff) 06279 { 06280 var->type= SHOW_CHAR; 06281 var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]); 06282 return 0; 06283 } 06284 06285 static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff) 06286 { 06287 var->type= SHOW_CHAR; 06288 pthread_mutex_lock(&LOCK_active_mi); 06289 var->value= const_cast<char*>((active_mi && active_mi->slave_running && 06290 active_mi->rli.slave_running) ? "ON" : "OFF"); 06291 pthread_mutex_unlock(&LOCK_active_mi); 06292 return 0; 06293 } 06294 06295 static int show_slave_retried_trans(THD *thd, SHOW_VAR *var, char *buff) 06296 { 06297 /* 06298 TODO: with multimaster, have one such counter per line in 06299 SHOW SLAVE STATUS, and have the sum over all lines here. 06300 */ 06301 pthread_mutex_lock(&LOCK_active_mi); 06302 if (active_mi) 06303 { 06304 var->type= SHOW_LONG; 06305 var->value= buff; 06306 pthread_mutex_lock(&active_mi->rli.data_lock); 06307 *((long *)buff)= (long)active_mi->rli.retried_trans; 06308 pthread_mutex_unlock(&active_mi->rli.data_lock); 06309 } 06310 else 06311 var->type= SHOW_UNDEF; 06312 pthread_mutex_unlock(&LOCK_active_mi); 06313 return 0; 06314 } 06315 #endif /* HAVE_REPLICATION */ 06316 06317 static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff) 06318 { 06319 var->type= SHOW_LONG; 06320 var->value= buff; 06321 *((long *)buff)= (long)cached_open_tables(); 06322 return 0; 06323 } 06324 06325 static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff) 06326 { 06327 var->type= SHOW_LONG; 06328 var->value= buff; 06329 *((long *)buff)= (long)cached_table_definitions(); 06330 return 0; 06331 } 06332 06333 #ifdef HAVE_OPENSSL 06334 /* Functions relying on CTX */ 06335 static int show_ssl_ctx_sess_accept(THD *thd, SHOW_VAR *var, char *buff) 06336 { 06337 var->type= SHOW_LONG; 06338 var->value= buff; 06339 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06340 SSL_CTX_sess_accept(ssl_acceptor_fd->ssl_context)); 06341 return 0; 06342 } 06343 06344 static int show_ssl_ctx_sess_accept_good(THD *thd, SHOW_VAR *var, char *buff) 06345 { 06346 var->type= SHOW_LONG; 06347 var->value= buff; 06348 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06349 SSL_CTX_sess_accept_good(ssl_acceptor_fd->ssl_context)); 06350 return 0; 06351 } 06352 06353 static int show_ssl_ctx_sess_connect_good(THD *thd, SHOW_VAR *var, char *buff) 06354 { 06355 var->type= SHOW_LONG; 06356 var->value= buff; 06357 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06358 SSL_CTX_sess_connect_good(ssl_acceptor_fd->ssl_context)); 06359 return 0; 06360 } 06361 06362 static int show_ssl_ctx_sess_accept_renegotiate(THD *thd, SHOW_VAR *var, char *buff) 06363 { 06364 var->type= SHOW_LONG; 06365 var->value= buff; 06366 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06367 SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context)); 06368 return 0; 06369 } 06370 06371 static int show_ssl_ctx_sess_connect_renegotiate(THD *thd, SHOW_VAR *var, char *buff) 06372 { 06373 var->type= SHOW_LONG; 06374 var->value= buff; 06375 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06376 SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd->ssl_context)); 06377 return 0; 06378 } 06379 06380 static int show_ssl_ctx_sess_cb_hits(THD *thd, SHOW_VAR *var, char *buff) 06381 { 06382 var->type= SHOW_LONG; 06383 var->value= buff; 06384 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06385 SSL_CTX_sess_cb_hits(ssl_acceptor_fd->ssl_context)); 06386 return 0; 06387 } 06388 06389 static int show_ssl_ctx_sess_hits(THD *thd, SHOW_VAR *var, char *buff) 06390 { 06391 var->type= SHOW_LONG; 06392 var->value= buff; 06393 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06394 SSL_CTX_sess_hits(ssl_acceptor_fd->ssl_context)); 06395 return 0; 06396 } 06397 06398 static int show_ssl_ctx_sess_cache_full(THD *thd, SHOW_VAR *var, char *buff) 06399 { 06400 var->type= SHOW_LONG; 06401 var->value= buff; 06402 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06403 SSL_CTX_sess_cache_full(ssl_acceptor_fd->ssl_context)); 06404 return 0; 06405 } 06406 06407 static int show_ssl_ctx_sess_misses(THD *thd, SHOW_VAR *var, char *buff) 06408 { 06409 var->type= SHOW_LONG; 06410 var->value= buff; 06411 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06412 SSL_CTX_sess_misses(ssl_acceptor_fd->ssl_context)); 06413 return 0; 06414 } 06415 06416 static int show_ssl_ctx_sess_timeouts(THD *thd, SHOW_VAR *var, char *buff) 06417 { 06418 var->type= SHOW_LONG; 06419 var->value= buff; 06420 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06421 SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context)); 06422 return 0; 06423 } 06424 06425 static int show_ssl_ctx_sess_number(THD *thd, SHOW_VAR *var, char *buff) 06426 { 06427 var->type= SHOW_LONG; 06428 var->value= buff; 06429 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06430 SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context)); 06431 return 0; 06432 } 06433 06434 static int show_ssl_ctx_sess_connect(THD *thd, SHOW_VAR *var, char *buff) 06435 { 06436 var->type= SHOW_LONG; 06437 var->value= buff; 06438 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06439 SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context)); 06440 return 0; 06441 } 06442 06443 static int show_ssl_ctx_sess_get_cache_size(THD *thd, SHOW_VAR *var, char *buff) 06444 { 06445 var->type= SHOW_LONG; 06446 var->value= buff; 06447 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06448 SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context)); 06449 return 0; 06450 } 06451 06452 static int show_ssl_ctx_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff) 06453 { 06454 var->type= SHOW_LONG; 06455 var->value= buff; 06456 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06457 SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context)); 06458 return 0; 06459 } 06460 06461 static int show_ssl_ctx_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff) 06462 { 06463 var->type= SHOW_LONG; 06464 var->value= buff; 06465 *((long *)buff)= (!ssl_acceptor_fd ? 0 : 06466 SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context)); 06467 return 0; 06468 } 06469 06470 static int show_ssl_ctx_get_session_cache_mode(THD *thd, SHOW_VAR *var, char *buff) 06471 { 06472 var->type= SHOW_CHAR; 06473 if (!ssl_acceptor_fd) 06474 var->value= const_cast<char*>("NONE"); 06475 else 06476 switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context)) 06477 { 06478 case SSL_SESS_CACHE_OFF: 06479 var->value= const_cast<char*>("OFF"); break; 06480 case SSL_SESS_CACHE_CLIENT: 06481 var->value= const_cast<char*>("CLIENT"); break; 06482 case SSL_SESS_CACHE_SERVER: 06483 var->value= const_cast<char*>("SERVER"); break; 06484 case SSL_SESS_CACHE_BOTH: 06485 var->value= const_cast<char*>("BOTH"); break; 06486 case SSL_SESS_CACHE_NO_AUTO_CLEAR: 06487 var->value= const_cast<char*>("NO_AUTO_CLEAR"); break; 06488 case SSL_SESS_CACHE_NO_INTERNAL_LOOKUP: 06489 var->value= const_cast<char*>("NO_INTERNAL_LOOKUP"); break; 06490 default: 06491 var->value= const_cast<char*>("Unknown"); break; 06492 } 06493 return 0; 06494 } 06495 06496 /* Functions relying on SSL */ 06497 static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff) 06498 { 06499 var->type= SHOW_CHAR; 06500 var->value= const_cast<char*>(thd->net.vio->ssl_arg ? 06501 SSL_get_version((SSL*) thd->net.vio->ssl_arg) : ""); 06502 return 0; 06503 } 06504 06505 static int show_ssl_session_reused(THD *thd, SHOW_VAR *var, char *buff) 06506 { 06507 var->type= SHOW_LONG; 06508 var->value= buff; 06509 *((long *)buff)= (long)thd->net.vio->ssl_arg ? 06510 SSL_session_reused((SSL*) thd->net.vio->ssl_arg) : 06511 0; 06512 return 0; 06513 } 06514 06515 static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff) 06516 { 06517 var->type= SHOW_LONG; 06518 var->value= buff; 06519 *((long *)buff)= (long)thd->net.vio->ssl_arg ? 06520 SSL_get_default_timeout((SSL*)thd->net.vio->ssl_arg) : 06521 0; 06522 return 0; 06523 } 06524 06525 static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff) 06526 { 06527 var->type= SHOW_LONG; 06528 var->value= buff; 06529 *((long *)buff)= (long)thd->net.vio->ssl_arg ? 06530 SSL_get_verify_mode((SSL*)thd->net.vio->ssl_arg) : 06531 0; 06532 return 0; 06533 } 06534 06535 static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff) 06536 { 06537 var->type= SHOW_LONG; 06538 var->value= buff; 06539 *((long *)buff)= (long)thd->net.vio->ssl_arg ? 06540 SSL_get_verify_depth((SSL*)thd->net.vio->ssl_arg) : 06541 0; 06542 return 0; 06543 } 06544 06545 static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff) 06546 { 06547 var->type= SHOW_CHAR; 06548 var->value= const_cast<char*>(thd->net.vio->ssl_arg ? 06549 SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : ""); 06550 return 0; 06551 } 06552 06553 static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff) 06554 { 06555 var->type= SHOW_CHAR; 06556 var->value= buff; 06557 if (thd->net.vio->ssl_arg) 06558 { 06559 int i; 06560 const char *p; 06561 char *end= buff + SHOW_VAR_FUNC_BUFF_SIZE; 06562 for (i=0; (p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i)) && 06563 buff < end; i++) 06564 { 06565 buff= strnmov(buff, p, end-buff-1); 06566 *buff++= ':'; 06567 } 06568 if (i) 06569 buff--; 06570 } 06571 *buff=0; 06572 return 0; 06573 } 06574 06575 #endif /* HAVE_OPENSSL */ 06576 06577 #ifdef WITH_INNOBASE_STORAGE_ENGINE 06578 int innodb_export_status(void); 06579 static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) 06580 { 06581 innodb_export_status(); 06582 var->type= SHOW_ARRAY; 06583 var->value= (char *) &innodb_status_variables; 06584 return 0; 06585 } 06586 #endif 06587 06588 SHOW_VAR status_vars[]= { 06589 {"Aborted_clients", (char*) &aborted_threads, SHOW_LONG}, 06590 {"Aborted_connects", (char*) &aborted_connects, SHOW_LONG}, 06591 {"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG}, 06592 {"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG}, 06593 {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONG_STATUS}, 06594 {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONG_STATUS}, 06595 {"Com_admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS}, 06596 {"Com_alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS}, 06597 {"Com_alter_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS}, 06598 {"Com_alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS}, 06599 {"Com_analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS}, 06600 {"Com_backup_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BACKUP_TABLE]), SHOW_LONG_STATUS}, 06601 {"Com_begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS}, 06602 {"Com_change_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS}, 06603 {"Com_change_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_MASTER]), SHOW_LONG_STATUS}, 06604 {"Com_check", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS}, 06605 {"Com_checksum", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS}, 06606 {"Com_commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMMIT]), SHOW_LONG_STATUS}, 06607 {"Com_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS}, 06608 {"Com_create_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_EVENT]), SHOW_LONG_STATUS}, 06609 {"Com_create_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_FUNCTION]), SHOW_LONG_STATUS}, 06610 {"Com_create_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS}, 06611 {"Com_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS}, 06612 {"Com_dealloc_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DEALLOCATE_PREPARE]), SHOW_LONG_STATUS}, 06613 {"Com_delete", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE]), SHOW_LONG_STATUS}, 06614 {"Com_delete_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS}, 06615 {"Com_do", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DO]), SHOW_LONG_STATUS}, 06616 {"Com_drop_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_DB]), SHOW_LONG_STATUS}, 06617 {"Com_drop_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_EVENT]), SHOW_LONG_STATUS}, 06618 {"Com_drop_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_FUNCTION]), SHOW_LONG_STATUS}, 06619 {"Com_drop_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS}, 06620 {"Com_drop_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS}, 06621 {"Com_drop_user", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_USER]), SHOW_LONG_STATUS}, 06622 {"Com_execute_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EXECUTE]), SHOW_LONG_STATUS}, 06623 {"Com_flush", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS}, 06624 {"Com_grant", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GRANT]), SHOW_LONG_STATUS}, 06625 {"Com_ha_close", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_CLOSE]), SHOW_LONG_STATUS}, 06626 {"Com_ha_open", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_OPEN]), SHOW_LONG_STATUS}, 06627 {"Com_ha_read", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_READ]), SHOW_LONG_STATUS}, 06628 {"Com_help", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HELP]), SHOW_LONG_STATUS}, 06629 {"Com_insert", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT]), SHOW_LONG_STATUS}, 06630 {"Com_insert_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS}, 06631 {"Com_kill", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_KILL]), SHOW_LONG_STATUS}, 06632 {"Com_load", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD]), SHOW_LONG_STATUS}, 06633 {"Com_load_master_data", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD_MASTER_DATA]), SHOW_LONG_STATUS}, 06634 {"Com_load_master_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD_MASTER_TABLE]), SHOW_LONG_STATUS}, 06635 {"Com_lock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS}, 06636 {"Com_optimize", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS}, 06637 {"Com_preload_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PRELOAD_KEYS]), SHOW_LONG_STATUS}, 06638 {"Com_prepare_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PREPARE]), SHOW_LONG_STATUS}, 06639 {"Com_purge", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE]), SHOW_LONG_STATUS}, 06640 {"Com_purge_before_date", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BEFORE]), SHOW_LONG_STATUS}, 06641 {"Com_rename_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS}, 06642 {"Com_repair", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPAIR]), SHOW_LONG_STATUS}, 06643 {"Com_replace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE]), SHOW_LONG_STATUS}, 06644 {"Com_replace_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS}, 06645 {"Com_reset", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESET]), SHOW_LONG_STATUS}, 06646 {"Com_restore_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESTORE_TABLE]), SHOW_LONG_STATUS}, 06647 {"Com_revoke", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE]), SHOW_LONG_STATUS}, 06648 {"Com_revoke_all", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE_ALL]), SHOW_LONG_STATUS}, 06649 {"Com_rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS}, 06650 {"Com_savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS}, 06651 {"Com_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS}, 06652 {"Com_set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS}, 06653 {"Com_show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS}, 06654 {"Com_show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS}, 06655 {"Com_show_charsets", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS}, 06656 {"Com_show_collations", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS}, 06657 {"Com_show_column_types", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLUMN_TYPES]), SHOW_LONG_STATUS}, 06658 {"Com_show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS}, 06659 {"Com_show_create_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_EVENT]), SHOW_LONG_STATUS}, 06660 {"Com_show_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS}, 06661 {"Com_show_databases", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS}, 06662 {"Com_show_engine_logs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_LOGS]), SHOW_LONG_STATUS}, 06663 {"Com_show_engine_mutex", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_MUTEX]), SHOW_LONG_STATUS}, 06664 {"Com_show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS}, 06665 {"Com_show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS}, 06666 {"Com_show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS}, 06667 {"Com_show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS}, 06668 {"Com_show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS}, 06669 {"Com_show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS}, 06670 {"Com_show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS}, 06671 {"Com_show_new_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NEW_MASTER]), SHOW_LONG_STATUS}, 06672 {"Com_show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS}, 06673 {"Com_show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS}, 06674 {"Com_show_privileges", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PRIVILEGES]), SHOW_LONG_STATUS}, 06675 {"Com_show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS}, 06676 {"Com_show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS}, 06677 {"Com_show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS}, 06678 {"Com_show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS}, 06679 {"Com_show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS}, 06680 {"Com_show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS}, 06681 {"Com_show_triggers", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TRIGGERS]), SHOW_LONG_STATUS}, 06682 {"Com_show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS}, 06683 {"Com_show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS}, 06684 {"Com_slave_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS}, 06685 {"Com_slave_stop", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS}, 06686 {"Com_stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS}, 06687 {"Com_stmt_execute", (char*) offsetof(STATUS_VAR, com_stmt_execute), SHOW_LONG_STATUS}, 06688 {"Com_stmt_fetch", (char*) offsetof(STATUS_VAR, com_stmt_fetch), SHOW_LONG_STATUS}, 06689 {"Com_stmt_prepare", (char*) offsetof(STATUS_VAR, com_stmt_prepare), SHOW_LONG_STATUS}, 06690 {"Com_stmt_reset", (char*) offsetof(STATUS_VAR, com_stmt_reset), SHOW_LONG_STATUS}, 06691 {"Com_stmt_send_long_data", (char*) offsetof(STATUS_VAR, com_stmt_send_long_data), SHOW_LONG_STATUS}, 06692 {"Com_truncate", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS}, 06693 {"Com_unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS}, 06694 {"Com_update", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS}, 06695 {"Com_update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS}, 06696 {"Com_xa_commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_COMMIT]),SHOW_LONG_STATUS}, 06697 {"Com_xa_end", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_END]),SHOW_LONG_STATUS}, 06698 {"Com_xa_prepare", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_PREPARE]),SHOW_LONG_STATUS}, 06699 {"Com_xa_recover", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_RECOVER]),SHOW_LONG_STATUS}, 06700 {"Com_xa_rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_ROLLBACK]),SHOW_LONG_STATUS}, 06701 {"Com_xa_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_START]),SHOW_LONG_STATUS}, 06702 {"Compression", (char*) &show_net_compression, SHOW_FUNC}, 06703 {"Connections", (char*) &thread_id, SHOW_LONG_NOFLUSH}, 06704 {"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS}, 06705 {"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG}, 06706 {"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS}, 06707 {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, 06708 {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH}, 06709 {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG}, 06710 {"Flush_commands", (char*) &refresh_version, SHOW_LONG_NOFLUSH}, 06711 {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS}, 06712 {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS}, 06713 {"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS}, 06714 {"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS}, 06715 {"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS}, 06716 {"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS}, 06717 {"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS}, 06718 {"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS}, 06719 {"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS}, 06720 {"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS}, 06721 {"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS}, 06722 {"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS}, 06723 {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS}, 06724 {"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS}, 06725 {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS}, 06726 #ifdef WITH_INNOBASE_STORAGE_ENGINE 06727 {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC}, 06728 #endif /* WITH_INNOBASE_STORAGE_ENGINE */ 06729 {"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG}, 06730 {"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG}, 06731 {"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG}, 06732 {"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG}, 06733 {"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG}, 06734 {"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG}, 06735 {"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG}, 06736 {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, 06737 {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, 06738 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 06739 {"Ndb", (char*) &ndb_status_variables, SHOW_ARRAY}, 06740 #endif /* WITH_NDBCLUSTER_STORAGE_ENGINE */ 06741 {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH}, 06742 {"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH}, 06743 {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH}, 06744 {"Open_table_definitions", (char*) &show_table_definitions, SHOW_FUNC}, 06745 {"Open_tables", (char*) &show_open_tables, SHOW_FUNC}, 06746 {"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS}, 06747 #ifdef HAVE_QUERY_CACHE 06748 {"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, SHOW_LONG_NOFLUSH}, 06749 {"Qcache_free_memory", (char*) &query_cache.free_memory, SHOW_LONG_NOFLUSH}, 06750 {"Qcache_hits", (char*) &query_cache.hits, SHOW_LONG}, 06751 {"Qcache_inserts", (char*) &query_cache.inserts, SHOW_LONG}, 06752 {"Qcache_lowmem_prunes", (char*) &query_cache.lowmem_prunes, SHOW_LONG}, 06753 {"Qcache_not_cached", (char*) &query_cache.refused, SHOW_LONG}, 06754 {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_NOFLUSH}, 06755 {"Qcache_total_blocks", (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH}, 06756 #endif /*HAVE_QUERY_CACHE*/ 06757 {"Questions", (char*) &show_question, SHOW_FUNC}, 06758 #ifdef HAVE_REPLICATION 06759 {"Rpl_status", (char*) &show_rpl_status, SHOW_FUN

