diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 246 |
1 files changed, 152 insertions, 94 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7a988f1cbad..8af23d7fb2b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -178,39 +178,41 @@ int initgroups(const char *,unsigned int); #ifdef HAVE_FP_EXCEPT // Fix type conflict typedef fp_except fp_except_t; #endif +#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ +#ifdef HAVE_SYS_FPU_H +/* for IRIX to use set_fpc_csr() */ +#include <sys/fpu.h> +#endif -/** - We can't handle floating point exceptions with threads, so disable - this on freebsd. -*/ -inline void set_proper_floating_point_mode() +inline void setup_fpu() { - /* Don't fall for overflow, underflow,divide-by-zero or loss of precision */ +#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) + /* We can't handle floating point exceptions with threads, so disable + this on freebsd + Don't fall for overflow, underflow,divide-by-zero or loss of precision + */ #if defined(__i386__) fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP)); #else - fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | - FP_X_IMP)); -#endif -} -#elif defined(__sgi) -/* for IRIX to use set_fpc_csr() */ -#include <sys/fpu.h> + fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | + FP_X_IMP)); +#endif /* __i386__ */ +#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ -inline void set_proper_floating_point_mode() -{ +#ifdef HAVE_FESETROUND + /* Set FPU rounding mode to "round-to-nearest" */ + fesetround(FE_TONEAREST); +#endif /* HAVE_FESETROUND */ + +#if defined(__sgi) && defined(HAVE_SYS_FPU_H) /* Enable denormalized DOUBLE values support for IRIX */ - { - union fpc_csr n; - n.fc_word = get_fpc_csr(); - n.fc_struct.flush = 0; - set_fpc_csr(n.fc_word); - } + union fpc_csr n; + n.fc_word = get_fpc_csr(); + n.fc_struct.flush = 0; + set_fpc_csr(n.fc_word); +#endif } -#else -#define set_proper_floating_point_mode() -#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ } /* cplusplus */ @@ -381,7 +383,7 @@ static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; /* Global variables */ -bool opt_update_log, opt_bin_log; +bool opt_update_log, opt_bin_log, opt_ignore_builtin_innodb= 0; my_bool opt_log, opt_slow_log; ulong log_output_options; my_bool opt_log_queries_not_using_indexes= 0; @@ -692,6 +694,8 @@ bool mysqld_embedded=0; bool mysqld_embedded=1; #endif +static my_bool plugins_are_initialized= FALSE; + #ifndef DBUG_OFF static const char* default_dbug_option; #endif @@ -744,12 +748,12 @@ uint connection_count= 0, extra_connection_count= 0; pthread_handler_t signal_hand(void *arg); static int mysql_init_variables(void); -static void get_options(int *argc,char **argv); +static int get_options(int *argc,char **argv); extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *); static void set_server_version(void); static int init_thread_environment(); static char *get_relative_path(const char *path); -static void fix_paths(void); +static int fix_paths(void); pthread_handler_t handle_connections_sockets(void *arg); pthread_handler_t kill_server_thread(void *arg); static void bootstrap(FILE *file); @@ -763,7 +767,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg); pthread_handler_t handle_slave(void *arg); static ulong find_bit_type(const char *x, TYPELIB *bit_lib); static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, - const char *option); + const char *option, int *error); static void clean_up(bool print_message); static int test_if_case_insensitive(const char *dir_name); static void register_mutex_order(); @@ -1190,10 +1194,10 @@ extern "C" void unireg_abort(int exit_code) { DBUG_ENTER("unireg_abort"); + if (opt_help) + usage(); if (exit_code) sql_print_error("Aborting\n"); - else if (opt_help) - usage(); clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */ DBUG_PRINT("quit",("done with cleanup in unireg_abort")); wait_for_signal_thread_to_end(); @@ -1201,7 +1205,8 @@ extern "C" void unireg_abort(int exit_code) my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); exit(exit_code); /* purecov: inspected */ } -#endif + +#endif /*EMBEDDED_LIBRARY*/ void clean_up(bool print_message) @@ -3311,7 +3316,8 @@ static int init_common_variables(const char *conf_file_name, int argc, load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; defaults_argc=argc; - get_options(&defaults_argc, defaults_argv); + if (get_options(&defaults_argc, defaults_argv)) + return 1; set_server_version(); DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, @@ -3764,7 +3770,7 @@ static int init_server_components() query_cache_init(); query_cache_resize(query_cache_size); my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2); - set_proper_floating_point_mode(); + setup_fpu(); init_thr_lock(); my_uuid_init((ulong) (my_rnd(&sql_rand))*12345,12345); #ifdef HAVE_REPLICATION @@ -3794,7 +3800,10 @@ static int init_server_components() #ifndef EMBEDDED_LIBRARY if (freopen(log_error_file, "a+", stdout)) #endif + { freopen(log_error_file, "a+", stderr); + setbuf(stderr, NULL); + } } } @@ -3946,12 +3955,15 @@ server."); if (ha_init_errors()) DBUG_RETURN(1); - if (plugin_init(&defaults_argc, defaults_argv, - (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) | - (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0))) - { - sql_print_error("Failed to initialize plugins."); - unireg_abort(1); + { + if (plugin_init(&defaults_argc, defaults_argv, + (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) | + (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0))) + { + sql_print_error("Failed to initialize plugins."); + unireg_abort(1); + } + plugins_are_initialized= TRUE; /* Don't separate from init function */ } if (opt_help) @@ -4425,6 +4437,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); { freopen(log_error_file,"a+",stdout); freopen(log_error_file,"a+",stderr); + setbuf(stderr, NULL); FreeConsole(); // Remove window } #endif @@ -5724,7 +5737,8 @@ enum options_mysqld OPT_DEADLOCK_TIMEOUT_SHORT, OPT_DEADLOCK_TIMEOUT_LONG, OPT_GENERAL_LOG_FILE, - OPT_SLOW_QUERY_LOG_FILE + OPT_SLOW_QUERY_LOG_FILE, + OPT_IGNORE_BUILTIN_INNODB }; @@ -5964,6 +5978,9 @@ Disable with --skip-large-pages.", (uchar**) &opt_large_pages, (uchar**) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"ignore-builtin-innodb", OPT_IGNORE_BUILTIN_INNODB , + "Disable initialization of builtin InnoDB plugin", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection", (uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -6412,7 +6429,7 @@ Can't be set to 1 if --log-slave-updates is used.", GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, "Uniquely identifies the server instance in the community of replication partners.", - (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, + (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, UINT_MAX32, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", @@ -7602,7 +7619,8 @@ static void usage(void) default_collation_name= (char*) default_charset_info->name; print_version(); puts("\ -Copyright (C) 2000-2008 MySQL AB, Monty and others, 2008-2009 Sun Microsystems, Inc.\n\ +Copyright (C) 2000-2008 MySQL AB, by Monty and others\n\ +Copyright (C) 2008 Sun Microsystems, Inc.\n\ This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ and you are welcome to modify and redistribute it under the GPL license\n\n\ Starts the MySQL database server\n"); @@ -7632,6 +7650,13 @@ Starts the MySQL database server\n"); /* Print out all the options including plugin supplied options */ my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option)); + if (! plugins_are_initialized) + { + puts("\n\ +Plugins have parameters that are not reflected in this list\n\ +because execution stopped before plugins were initialized."); + } + puts("\n\ To see what values a running MySQL server is using, type\n\ 'mysqladmin variables' instead of 'mysqld --verbose --help'."); @@ -7658,6 +7683,7 @@ To see what values a running MySQL server is using, type\n\ static int mysql_init_variables(void) { + int error; /* Things reset to zero */ opt_skip_slave_start= opt_reckless_slave = 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; @@ -7670,6 +7696,7 @@ static int mysql_init_variables(void) log_output_options= find_bit_type(log_output_str, &log_output_typelib); opt_bin_log= 0; opt_disable_networking= opt_skip_show_db=0; + opt_ignore_builtin_innodb= 0; opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0; opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name ! opt_secure_auth= 0; @@ -7717,7 +7744,10 @@ static int mysql_init_variables(void) delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; slave_exec_mode_options= 0; slave_exec_mode_options= (uint) - find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL); + find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL, + &error); + if (error) + return 1; opt_specialflag= SPECIAL_ENGLISH; unix_sock= base_ip_sock= extra_ip_sock= INVALID_SOCKET; mysql_home_ptr= mysql_home; @@ -7928,6 +7958,8 @@ mysqld_get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { + int error; + switch(optid) { #ifndef DBUG_OFF case '#': @@ -7981,7 +8013,9 @@ mysqld_get_one_option(int optid, break; case OPT_SLAVE_EXEC_MODE: slave_exec_mode_options= (uint) - find_bit_type_or_exit(argument, &slave_exec_mode_typelib, ""); + find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "", &error); + if (error) + return 1; break; #endif case OPT_SAFEMALLOC_MEM_LIMIT: @@ -8010,6 +8044,9 @@ mysqld_get_one_option(int optid, case (int) OPT_BIG_TABLES: thd_startup_options|=OPTION_BIG_TABLES; break; + case (int) OPT_IGNORE_BUILTIN_INNODB: + opt_ignore_builtin_innodb= 1; + break; case (int) OPT_ISAM_LOG: opt_myisam_log=1; break; @@ -8048,18 +8085,16 @@ mysqld_get_one_option(int optid, if (!(p= strstr(argument, "->"))) { - fprintf(stderr, - "Bad syntax in replicate-rewrite-db - missing '->'!\n"); - exit(1); + sql_print_error("Bad syntax in replicate-rewrite-db - missing '->'!\n"); + return 1; } val= p--; while (my_isspace(mysqld_charset, *p) && p > argument) *p-- = 0; if (p == argument) { - fprintf(stderr, - "Bad syntax in replicate-rewrite-db - empty FROM db!\n"); - exit(1); + sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!\n"); + return 1; } *val= 0; val+= 2; @@ -8067,9 +8102,8 @@ mysqld_get_one_option(int optid, *val++; if (!*val) { - fprintf(stderr, - "Bad syntax in replicate-rewrite-db - empty TO db!\n"); - exit(1); + sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n"); + return 1; } rpl_filter->add_db_rewrite(key, val); @@ -8099,8 +8133,8 @@ mysqld_get_one_option(int optid, { if (rpl_filter->add_do_table(argument)) { - fprintf(stderr, "Could not add do table rule '%s'!\n", argument); - exit(1); + sql_print_error("Could not add do table rule '%s'!\n", argument); + return 1; } break; } @@ -8108,8 +8142,8 @@ mysqld_get_one_option(int optid, { if (rpl_filter->add_wild_do_table(argument)) { - fprintf(stderr, "Could not add do table rule '%s'!\n", argument); - exit(1); + sql_print_error("Could not add do table rule '%s'!\n", argument); + return 1; } break; } @@ -8117,8 +8151,8 @@ mysqld_get_one_option(int optid, { if (rpl_filter->add_wild_ignore_table(argument)) { - fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument); - exit(1); + sql_print_error("Could not add ignore table rule '%s'!\n", argument); + return 1; } break; } @@ -8126,8 +8160,8 @@ mysqld_get_one_option(int optid, { if (rpl_filter->add_ignore_table(argument)) { - fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument); - exit(1); + sql_print_error("Could not add ignore table rule '%s'!\n", argument); + return 1; } break; } @@ -8148,7 +8182,9 @@ mysqld_get_one_option(int optid, { log_output_str= argument; log_output_options= - find_bit_type_or_exit(argument, &log_output_typelib, opt->name); + find_bit_type_or_exit(argument, &log_output_typelib, opt->name, &error); + if (error) + return 1; } break; } @@ -8158,7 +8194,7 @@ mysqld_get_one_option(int optid, sql_perror("Event scheduler is not supported in embedded build."); #else if (Events::set_opt_event_scheduler(argument)) - exit(1); + return 1; #endif break; case (int) OPT_SKIP_NEW: @@ -8197,7 +8233,7 @@ mysqld_get_one_option(int optid, case (int) OPT_SKIP_NETWORKING: #if defined(__NETWARE__) sql_perror("Can't start server: skip-networking option is currently not supported on NetWare"); - exit(1); + return 1; #endif opt_disable_networking=1; mysqld_port= mysqld_extra_port= 0; @@ -8264,8 +8300,8 @@ mysqld_get_one_option(int optid, case OPT_MASTER_SSL_CA: if (!slave_warning_issued) //only show the warning once { - slave_warning_issued = true; - WARN_DEPRECATED(NULL, "5.2", "for replication startup options", + slave_warning_issued = true; + WARN_DEPRECATED(NULL, "6.0", "for replication startup options", "'CHANGE MASTER'"); } break; @@ -8368,7 +8404,10 @@ mysqld_get_one_option(int optid, { myisam_recover_options_str=argument; myisam_recover_options= - find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name); + find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name, + &error); + if (error) + return 1; } ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; break; @@ -8414,7 +8453,9 @@ mysqld_get_one_option(int optid, { sql_mode_str= argument; global_system_variables.sql_mode= - find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name); + find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name, &error); + if (error) + return 1; global_system_variables.sql_mode= fix_sql_mode(global_system_variables. sql_mode); break; @@ -8458,13 +8499,17 @@ mysqld_get_one_option(int optid, /** Handle arguments for multiple key caches. */ -extern "C" uchar **mysql_getopt_value(const char *keyname, uint key_length, - const struct my_option *option); +extern "C" int mysql_getopt_value(uchar **value, + const char *keyname, uint key_length, + const struct my_option *option, + int *error); -uchar* * +static uchar* * mysql_getopt_value(const char *keyname, uint key_length, - const struct my_option *option) + const struct my_option *option, int *error) { + if (error) + *error= 0; switch (option->id) { case OPT_KEY_BUFFER_SIZE: case OPT_KEY_CACHE_BLOCK_SIZE: @@ -8473,7 +8518,11 @@ mysql_getopt_value(const char *keyname, uint key_length, { KEY_CACHE *key_cache; if (!(key_cache= get_or_create_key_cache(keyname, key_length))) - exit(1); + { + if (error) + *error= EXIT_OUT_OF_MEMORY; + return 0; + } switch (option->id) { case OPT_KEY_BUFFER_SIZE: return (uchar**) &key_cache->param_buff_size; @@ -8511,7 +8560,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...) @todo - FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code? */ -static void get_options(int *argc,char **argv) +static int get_options(int *argc,char **argv) { int ho_error; @@ -8525,7 +8574,7 @@ static void get_options(int *argc,char **argv) if ((ho_error= handle_options(argc, &argv, my_long_options, mysqld_get_one_option))) - exit(ho_error); + return ho_error; (*argc)++; /* add back one for the progname handle_options removes */ /* no need to do this for argv as we are discarding it. */ @@ -8564,7 +8613,8 @@ static void get_options(int *argc,char **argv) max_allowed_packet= global_system_variables.max_allowed_packet; net_buffer_length= global_system_variables.net_buffer_length; #endif - fix_paths(); + if (fix_paths()) + return 1; /* Set some global variables from the global_system_variables @@ -8592,7 +8642,7 @@ static void get_options(int *argc,char **argv) &global_system_variables.time_format) || init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME, &global_system_variables.datetime_format)) - exit(1); + return 1; #ifdef EMBEDDED_LIBRARY one_thread_scheduler(&thread_scheduler); @@ -8610,6 +8660,7 @@ static void get_options(int *argc,char **argv) &extra_max_connections, &extra_connection_count); #endif + return 0; } @@ -8673,7 +8724,7 @@ fn_format_relative_to_data_home(char * to, const char *name, } -static void fix_paths(void) +static int fix_paths(void) { char buff[FN_REFLEN],*pos; convert_dirname(mysql_home,mysql_home,NullS); @@ -8720,12 +8771,12 @@ static void fix_paths(void) charsets_dir=mysql_charsets_dir; if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) - exit(1); + return 1; #ifdef HAVE_REPLICATION if (!slave_load_tmpdir) { if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE)))) - exit(1); + return 1; } #endif /* HAVE_REPLICATION */ /* @@ -8738,30 +8789,37 @@ static void fix_paths(void) my_free(opt_secure_file_priv, MYF(0)); opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); } + return 0; } static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, - const char *option) + const char *option, int *error) { - ulong res; - + ulong result; const char **ptr; - - if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0) + + *error= 0; + if ((result= find_bit_type(x, bit_lib)) == ~(ulong) 0) { + char *buff= (char *) my_alloca(2048); + char *cbuf; ptr= bit_lib->type_names; - if (!*x) - fprintf(stderr, "No option given to %s\n", option); - else - fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x); - fprintf(stderr, "Alternatives are: '%s'", *ptr); + cbuf= buff + ((!*x) ? + my_snprintf(buff, 2048, "No option given to %s\n", option) : + my_snprintf(buff, 2048, "Wrong option to %s. Option(s) given: %s\n", + option, x)); + cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), "Alternatives are: '%s'", *ptr); while (*++ptr) - fprintf(stderr, ",'%s'", *ptr); - fprintf(stderr, "\n"); - exit(1); + cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), ",'%s'", *ptr); + my_snprintf(cbuf, 2048 - (cbuf-buff), "\n"); + sql_perror(buff); + *error= 1; + my_afree(buff); + return 0; } - return res; + + return result; } |