diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index de424375ea4..7ab765b5a7b 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -412,7 +412,7 @@ The following options may be given as the first argument: Maximum number of prepared statements in the server --max-relay-log-size=# relay log will be rotated automatically when the size - exceeds this value. If 0 are startup, it's set to + exceeds this value. If 0 at startup, it's set to max_binlog_size --max-seeks-for-key=# Limit assumed max number of seeks when looking up rows diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 51a7206da58..731e1711d51 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1866,7 +1866,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_LONG_DATA_SIZE SESSION_VALUE NULL GLOBAL_VALUE 1048576 -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE 1048576 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED @@ -3784,7 +3784,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME THREAD_HANDLING SESSION_VALUE NULL GLOBAL_VALUE no-threads -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE one-thread-per-connection VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index b43d1bd9ede..49edf5a2224 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -2020,7 +2020,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_LONG_DATA_SIZE SESSION_VALUE NULL GLOBAL_VALUE 1048576 -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE 1048576 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED @@ -2048,11 +2048,11 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_RELAY_LOG_SIZE SESSION_VALUE 1073741824 GLOBAL_VALUE 1073741824 -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE 1073741824 VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT relay log will be rotated automatically when the size exceeds this value. If 0 are startup, it's set to max_binlog_size +VARIABLE_COMMENT relay log will be rotated automatically when the size exceeds this value. If 0 at startup, it's set to max_binlog_size NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 1073741824 NUMERIC_BLOCK_SIZE 4096 @@ -3336,7 +3336,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME RELAY_LOG SESSION_VALUE NULL GLOBAL_VALUE mysqld-relay-bin -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR @@ -3350,7 +3350,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME RELAY_LOG_INDEX SESSION_VALUE NULL GLOBAL_VALUE mysqld-relay-bin.index -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR @@ -3560,7 +3560,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME REPORT_PORT SESSION_VALUE NULL GLOBAL_VALUE MASTER_MYPORT -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT UNSIGNED @@ -3784,7 +3784,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_LOAD_TMPDIR SESSION_VALUE NULL GLOBAL_VALUE PATH -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE_ORIGIN AUTO DEFAULT_VALUE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0aaaded4203..b21c588abe1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2278,10 +2278,13 @@ static void set_ports() #if MYSQL_PORT_DEFAULT == 0 struct servent *serv_ptr; if ((serv_ptr= getservbyname("mysql", "tcp"))) - mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ + SYSVAR_AUTOSIZE(mysqld_port, ntohs((u_short) serv_ptr->s_port)); #endif if ((env = getenv("MYSQL_TCP_PORT"))) - mysqld_port= (uint) atoi(env); /* purecov: inspected */ + { + mysqld_port= (uint) atoi(env); + mark_sys_var_value_origin(&mysqld_port, sys_var::ENV); + } } if (!mysqld_unix_port) { @@ -2291,7 +2294,10 @@ static void set_ports() mysqld_unix_port= (char*) MYSQL_UNIX_ADDR; #endif if ((env = getenv("MYSQL_UNIX_PORT"))) - mysqld_unix_port= env; /* purecov: inspected */ + { + mysqld_unix_port= env; + mark_sys_var_value_origin(&mysqld_unix_port, sys_var::ENV); + } } } @@ -2582,7 +2588,7 @@ static void network_init(void) if (report_port == 0) { - report_port= mysqld_port; + SYSVAR_AUTOSIZE(report_port, mysqld_port); } #ifndef DBUG_OFF if (!opt_disable_networking) @@ -4002,6 +4008,10 @@ static int init_common_variables() return 1; } +#if defined(HAVE_POOL_OF_THREADS) && !defined(_WIN32) + SYSVAR_AUTOSIZE(threadpool_size, my_getncpus()); +#endif + if (init_thread_environment() || mysql_init_variables()) return 1; @@ -4086,11 +4096,9 @@ static int init_common_variables() } #endif /* WITH_WSREP */ - if (!*pidfile_name) - { - strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5); - strmov(fn_ext(pidfile_name),".pid"); // Add proper extension - } + strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5); + strmov(fn_ext(pidfile_name),".pid"); // Add proper extension + SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); /* The default-storage-engine entry in my_long_options should have a @@ -4160,20 +4168,18 @@ static int init_common_variables() #ifdef HAVE_LARGE_PAGES /* Initialize large page size */ - if (opt_large_pages && (opt_large_page_size= my_get_large_page_size())) + if (opt_large_pages) { + SYSVAR_AUTOSIZE(opt_large_page_size, my_get_large_page_size()); + if (opt_large_page_size) + { DBUG_PRINT("info", ("Large page set, large_page_size = %d", opt_large_page_size)); my_use_large_pages= 1; my_large_page_size= opt_large_page_size; - } - else - { - opt_large_pages= 0; - /* - Either not configured to use large pages or Linux haven't - been compiled with large page support - */ + } + else + SYSVAR_AUTOSIZE(opt_large_pages, 0); } #endif /* HAVE_LARGE_PAGES */ #ifdef HAVE_SOLARIS_LARGE_PAGES @@ -4257,16 +4263,17 @@ static int init_common_variables() If we have requested too much file handles than we bring max_connections in supported bounds. */ - max_connections= (ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2, - max_connections); + SYSVAR_AUTOSIZE(max_connections, + (ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2, max_connections)); /* Decrease tc_size according to max_connections, but not below TABLE_OPEN_CACHE_MIN. Outer MY_MIN() ensures that we never increase tc_size automatically (that could happen if max_connections is decreased above). */ - tc_size= (ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2, - TABLE_OPEN_CACHE_MIN), tc_size); + SYSVAR_AUTOSIZE(tc_size, + (ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2, + TABLE_OPEN_CACHE_MIN), tc_size)); DBUG_PRINT("warning", ("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", files, max_connections, tc_size)); @@ -4277,7 +4284,7 @@ static int init_common_variables() else if (global_system_variables.log_warnings) sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); } - open_files_limit= files; + SYSVAR_AUTOSIZE(open_files_limit, files); } unireg_init(opt_specialflag); /* Set up extern variabels */ if (!(my_default_lc_messages= @@ -4407,7 +4414,8 @@ static int init_common_variables() get corrupted if accesses with names of different case. */ DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names)); - lower_case_file_system= test_if_case_insensitive(mysql_real_data_home); + SYSVAR_AUTOSIZE(lower_case_file_system, + test_if_case_insensitive(mysql_real_data_home)); if (!lower_case_table_names && lower_case_file_system == 1) { if (lower_case_table_names_used) @@ -4423,8 +4431,9 @@ You should consider changing lower_case_table_names to 1 or 2", else { if (global_system_variables.log_warnings) - sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); - lower_case_table_names= 2; + sql_print_warning("Setting lower_case_table_names=2 because file " + "system for %s is case insensitive", mysql_real_data_home); + SYSVAR_AUTOSIZE(lower_case_table_names, 2); } } else if (lower_case_table_names == 2 && @@ -4435,7 +4444,7 @@ You should consider changing lower_case_table_names to 1 or 2", "the file system '%s' is case sensitive. Now setting " "lower_case_table_names to 0 to avoid future problems.", mysql_real_data_home); - lower_case_table_names= 0; + SYSVAR_AUTOSIZE(lower_case_table_names, 0); } else { @@ -4774,16 +4783,17 @@ static int init_server_components() if (opt_error_log && !opt_abort) { if (!log_error_file_ptr[0]) + { fn_format(log_error_file, pidfile_name, mysql_data_home, ".err", MY_REPLACE_EXT); /* replace '.' by '.err', bug#4997 */ + SYSVAR_AUTOSIZE(log_error_file_ptr, log_error_file); + } else + { fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err", MY_UNPACK_FILENAME | MY_SAFE_PATH); - /* - _ptr may have been set to my_disabled_option or "" if no argument was - passed, but we need to show the real name in SHOW VARIABLES: - */ - log_error_file_ptr= log_error_file; + log_error_file_ptr= log_error_file; + } if (!log_error_file[0]) opt_error_log= 0; // Too long file name else @@ -5068,7 +5078,8 @@ a file name for --log-bin-index option", opt_binlog_index_name); /* purecov: begin inspected */ sql_print_error("CSV engine is not present, falling back to the " "log files"); - log_output_options= (log_output_options & ~LOG_TABLE) | LOG_FILE; + SYSVAR_AUTOSIZE(log_output_options, + (log_output_options & ~LOG_TABLE) | LOG_FILE); /* purecov: end */ } @@ -5518,8 +5529,11 @@ int mysqld_main(int argc, char **argv) init_signals(); - my_thread_stack_size= my_setstacksize(&connection_attrib, - my_thread_stack_size); + ulonglong new_thread_stack_size; + new_thread_stack_size= my_setstacksize(&connection_attrib, + my_thread_stack_size); + if (new_thread_stack_size != my_thread_stack_size) + SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size); (void) thr_setconcurrency(concurrency); // 10 by default @@ -5555,7 +5569,7 @@ int mysqld_main(int argc, char **argv) if (opt_bin_log && !global_system_variables.server_id) { - global_system_variables.server_id= ::server_id= 1; + SYSVAR_AUTOSIZE(global_system_variables.server_id, ::server_id= 1); #ifdef EXTRA_DEBUG sql_print_warning("You have enabled the binary log, but you haven't set " "server-id to a non-zero value: we force server id to 1; " @@ -8400,7 +8414,6 @@ static int mysql_init_variables(void) opt_specialflag= SPECIAL_ENGLISH; unix_sock= base_ip_sock= extra_ip_sock= MYSQL_INVALID_SOCKET; mysql_home_ptr= mysql_home; - pidfile_name_ptr= pidfile_name; log_error_file_ptr= log_error_file; protocol_version= PROTOCOL_VERSION; what_to_log= ~ (1L << (uint) COM_TIME); @@ -8539,6 +8552,7 @@ static int mysql_init_variables(void) if (!(tmpenv = getenv("MY_BASEDIR_VERSION"))) tmpenv = DEFAULT_MYSQL_HOME; strmake_buf(mysql_home, tmpenv); + mark_sys_var_value_origin(&mysql_home_ptr, sys_var::ENV); #endif if (wsrep_init_vars()) @@ -8589,8 +8603,8 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) "in later versions.", opt->name); break; case 'a': - global_system_variables.sql_mode= MODE_ANSI; - global_system_variables.tx_isolation= ISO_SERIALIZABLE; + SYSVAR_AUTOSIZE(global_system_variables.sql_mode, MODE_ANSI); + SYSVAR_AUTOSIZE(global_system_variables.tx_isolation, ISO_SERIALIZABLE); break; case 'b': strmake_buf(mysql_home, argument); @@ -8651,22 +8665,33 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) return 1; } if (log_error_file_ptr != disabled_my_option) - log_error_file_ptr= opt_log_basename; + SYSVAR_AUTOSIZE(log_error_file_ptr, opt_log_basename); make_default_log_name(&opt_logname, ".log", false); make_default_log_name(&opt_slow_logname, "-slow.log", false); make_default_log_name(&opt_bin_logname, "-bin", true); make_default_log_name(&opt_binlog_index_name, "-bin.index", true); + mark_sys_var_value_origin(&opt_logname, sys_var::AUTO); + mark_sys_var_value_origin(&opt_slow_logname, sys_var::AUTO); + if (!opt_logname || !opt_slow_logname || !opt_bin_logname || + !opt_binlog_index_name) + return 1; + +#ifdef HAVE_REPLICATION make_default_log_name(&opt_relay_logname, "-relay-bin", true); make_default_log_name(&opt_relaylog_index_name, "-relay-bin.index", true); + mark_sys_var_value_origin(&opt_relay_logname, sys_var::AUTO); + mark_sys_var_value_origin(&opt_relaylog_index_name, sys_var::AUTO); + if (!opt_relay_logname || !opt_relaylog_index_name) + return 1; +#endif - pidfile_name_ptr= pidfile_name; + SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); strmake(pidfile_name, argument, sizeof(pidfile_name)-5); strmov(fn_ext(pidfile_name),".pid"); /* check for errors */ - if (!opt_bin_logname || !opt_relaylog_index_name || ! opt_logname || - ! opt_slow_logname || !pidfile_name_ptr) + if (!pidfile_name_ptr) return 1; // out of memory error break; } @@ -8762,11 +8787,11 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) #endif /* HAVE_REPLICATION */ case (int) OPT_SAFE: opt_specialflag|= SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC; - delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; - myisam_recover_options= HA_RECOVER_DEFAULT; + SYSVAR_AUTOSIZE(delay_key_write_options, (uint) DELAY_KEY_WRITE_NONE); + SYSVAR_AUTOSIZE(myisam_recover_options, HA_RECOVER_DEFAULT); ha_open_options&= ~(HA_OPEN_DELAY_KEY_WRITE); #ifdef HAVE_QUERY_CACHE - query_cache_size=0; + SYSVAR_AUTOSIZE(query_cache_size, 0); #endif sql_print_warning("The syntax '--safe-mode' is deprecated and will be " "removed in a future release."); @@ -9122,7 +9147,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) if (mysqld_chroot) set_root(mysqld_chroot); #else - thread_handling = SCHEDULER_NO_THREADS; + SYSVAR_AUTOSIZE(thread_handling, SCHEDULER_NO_THREADS); max_allowed_packet= global_system_variables.max_allowed_packet; net_buffer_length= global_system_variables.net_buffer_length; #endif @@ -9174,7 +9199,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) /* workaround: disable thread pool on XP */ if (GetProcAddress(GetModuleHandle("kernel32"),"CreateThreadpool") == 0 && thread_handling > SCHEDULER_NO_THREADS) - thread_handling = SCHEDULER_ONE_THREAD_PER_CONNECTION; + SYSVAR_AUTOSIZE(thread_handling, SCHEDULER_ONE_THREAD_PER_CONNECTION); #endif if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION) @@ -9198,16 +9223,19 @@ static int get_options(int *argc_ptr, char ***argv_ptr) value of max_allowed_packet. */ if (!max_long_data_size_used) - max_long_data_size= global_system_variables.max_allowed_packet; + SYSVAR_AUTOSIZE(max_long_data_size, + global_system_variables.max_allowed_packet); /* Remember if max_user_connections was 0 at startup */ max_user_connections_checking= global_system_variables.max_user_connections != 0; +#ifdef HAVE_REPLICATION { sys_var *max_relay_log_size_var, *max_binlog_size_var; /* If max_relay_log_size is 0, then set it to max_binlog_size */ if (!global_system_variables.max_relay_log_size) - global_system_variables.max_relay_log_size= max_binlog_size; + SYSVAR_AUTOSIZE(global_system_variables.max_relay_log_size, + max_binlog_size); /* Fix so that DEFAULT and limit checking works with max_relay_log_size @@ -9224,12 +9252,13 @@ static int get_options(int *argc_ptr, char ***argv_ptr) max_binlog_size_var->option.def_value; } } +#endif /* Ensure that some variables are not set higher than needed */ if (back_log > max_connections) - back_log= max_connections; + SYSVAR_AUTOSIZE(back_log, max_connections); if (thread_cache_size > max_connections) - thread_cache_size= max_connections; + SYSVAR_AUTOSIZE(thread_cache_size, max_connections); return 0; } @@ -9397,13 +9426,18 @@ static int fix_paths(void) /* If --character-sets-dir isn't given, use shared library dir */ if (charsets_dir) + { strmake_buf(mysql_charsets_dir, charsets_dir); + charsets_dir= mysql_charsets_dir; + } else + { strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff, CHARSET_DIR, NullS); + SYSVAR_AUTOSIZE(charsets_dir, mysql_charsets_dir); + } (void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff); convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS); - charsets_dir=mysql_charsets_dir; if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) DBUG_RETURN(1); @@ -9411,7 +9445,7 @@ static int fix_paths(void) opt_mysql_tmpdir= mysql_tmpdir; #ifdef HAVE_REPLICATION if (!slave_load_tmpdir) - slave_load_tmpdir= mysql_tmpdir; + SYSVAR_AUTOSIZE(slave_load_tmpdir, mysql_tmpdir); #endif /* HAVE_REPLICATION */ /* Convert the secure-file-priv option to system format, allowing diff --git a/sql/set_var.cc b/sql/set_var.cc index 95508d25a0f..bae65118112 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -964,7 +964,6 @@ static void store_var(Field *field, sys_var *var, enum_var_type scope, var->value_ptr(field->table->in_use, scope, &null_lex_str)); } - int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) { char name_buffer[NAME_CHAR_LEN]; @@ -1010,7 +1009,8 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) { STRING_WITH_LEN("CONFIG") }, { STRING_WITH_LEN("AUTO") }, { STRING_WITH_LEN("SQL") }, - { STRING_WITH_LEN("COMPILE-TIME") } + { STRING_WITH_LEN("COMPILE-TIME") }, + { STRING_WITH_LEN("ENVIRONMENT") } }; const LEX_CSTRING *origin= origins + var->value_origin; fields[3]->store(origin->str, origin->length, scs); @@ -1144,3 +1144,30 @@ end: return res; } +/* + This is a simple and inefficient helper that sets sys_var::value_origin + for a specific sysvar. + It should *only* be used on server startup, if you need to do this later, + get yourself a pointer to your sysvar (see e.g. Sys_autocommit_ptr) + and update it directly. +*/ + +void mark_sys_var_value_origin(void *ptr, enum sys_var::where here) +{ + bool found= false; + DBUG_ASSERT(!mysqld_server_started); // only to be used during startup + + for (uint i= 0; i < system_variable_hash.records; i++) + { + sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i); + if (var->option.value == ptr) + { + found= true; + var->value_origin= here; + /* don't break early, search for all matches */ + } + } + + DBUG_ASSERT(found); // variable must have been found +} + diff --git a/sql/set_var.h b/sql/set_var.h index b74578cd345..e48f394c316 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -63,7 +63,7 @@ public: enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023, READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096 }; enum { NO_GETOPT=-1, GETOPT_ONLY_HELP=-2 }; - enum where { CONFIG, AUTO, SQL, COMPILE_TIME }; + enum where { CONFIG, AUTO, SQL, COMPILE_TIME, ENV }; /** Enumeration type to indicate for a system variable whether @@ -392,6 +392,14 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond); sys_var *find_sys_var(THD *thd, const char *str, uint length=0); int sql_set_variables(THD *thd, List *var_list); +#define SYSVAR_AUTOSIZE(VAR,VAL) \ + do { \ + VAR= (VAL); \ + mark_sys_var_value_origin(&VAR, sys_var::AUTO); \ + } while(0) + +void mark_sys_var_value_origin(void *ptr, enum sys_var::where here); + bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type); ulonglong expand_sql_mode(ulonglong sql_mode); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1b995fd648d..cc2a2549daf 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1168,6 +1168,8 @@ static bool acl_load(THD *thd, TABLE_LIST *tables) mysql_mutex_unlock(&LOCK_global_system_variables); else { + extern sys_var *Sys_old_passwords_ptr; + Sys_old_passwords_ptr->value_origin= sys_var::AUTO; global_system_variables.old_passwords= 1; mysql_mutex_unlock(&LOCK_global_system_variables); sql_print_warning("mysql.user table is not updated to new password format; " diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7fa0f4cb29a..c8b589e0fd6 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2121,6 +2121,7 @@ static Sys_var_mybool Sys_old_passwords( "Use old password encryption method (needed for 4.0 and older clients)", SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_old_passwords)); +export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc static Sys_var_ulong Sys_open_files_limit( "open_files_limit", @@ -3135,7 +3136,7 @@ static Sys_var_uint Sys_threadpool_size( "This parameter is roughly equivalent to maximum number of concurrently " "executing threads (threads in a waiting state do not count as executing).", GLOBAL_VAR(threadpool_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, MAX_THREAD_GROUPS), DEFAULT(my_getncpus()), BLOCK_SIZE(1), + VALID_RANGE(1, MAX_THREAD_GROUPS), DEFAULT(8), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_threadpool_size), ON_UPDATE(fix_threadpool_size) ); @@ -4328,7 +4329,7 @@ static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi) static Sys_var_multi_source_ulong Sys_max_relay_log_size( "max_relay_log_size", "relay log will be rotated automatically when the " - "size exceeds this value. If 0 are startup, it's " + "size exceeds this value. If 0 at startup, it's " "set to max_binlog_size", SESSION_VAR(max_relay_log_size), CMD_LINE(REQUIRED_ARG), diff --git a/storage/perfschema/pfs_autosize.cc b/storage/perfschema/pfs_autosize.cc index 38bd36d8321..9bf70ceb216 100644 --- a/storage/perfschema/pfs_autosize.cc +++ b/storage/perfschema/pfs_autosize.cc @@ -21,6 +21,7 @@ #include "my_global.h" #include "sql_const.h" #include "pfs_server.h" +#include "set_var.h" #include using std::min; @@ -206,7 +207,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) { count= handle; - p->m_table_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_table_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } if (p->m_table_share_sizing < 0) @@ -214,62 +216,74 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) count= share; count= max(count, h->m_min_number_of_tables); - p->m_table_share_sizing= apply_load_factor(count, h->m_load_factor_static); + SYSVAR_AUTOSIZE(p->m_table_share_sizing, + apply_load_factor(count, h->m_load_factor_static)); } if (p->m_account_sizing < 0) { - p->m_account_sizing= h->m_account_sizing; + SYSVAR_AUTOSIZE(p->m_account_sizing, + h->m_account_sizing); } if (p->m_user_sizing < 0) { - p->m_user_sizing= h->m_user_sizing; + SYSVAR_AUTOSIZE(p->m_user_sizing, + h->m_user_sizing); } if (p->m_host_sizing < 0) { - p->m_host_sizing= h->m_host_sizing; + SYSVAR_AUTOSIZE(p->m_host_sizing, + h->m_host_sizing); } if (p->m_events_waits_history_sizing < 0) { - p->m_events_waits_history_sizing= h->m_events_waits_history_sizing; + SYSVAR_AUTOSIZE(p->m_events_waits_history_sizing, + h->m_events_waits_history_sizing); } if (p->m_events_waits_history_long_sizing < 0) { - p->m_events_waits_history_long_sizing= h->m_events_waits_history_long_sizing; + SYSVAR_AUTOSIZE(p->m_events_waits_history_long_sizing, + h->m_events_waits_history_long_sizing); } if (p->m_events_stages_history_sizing < 0) { - p->m_events_stages_history_sizing= h->m_events_stages_history_sizing; + SYSVAR_AUTOSIZE(p->m_events_stages_history_sizing, + h->m_events_stages_history_sizing); } if (p->m_events_stages_history_long_sizing < 0) { - p->m_events_stages_history_long_sizing= h->m_events_stages_history_long_sizing; + SYSVAR_AUTOSIZE(p->m_events_stages_history_long_sizing, + h->m_events_stages_history_long_sizing); } if (p->m_events_statements_history_sizing < 0) { - p->m_events_statements_history_sizing= h->m_events_statements_history_sizing; + SYSVAR_AUTOSIZE(p->m_events_statements_history_sizing, + h->m_events_statements_history_sizing); } if (p->m_events_statements_history_long_sizing < 0) { - p->m_events_statements_history_long_sizing= h->m_events_statements_history_long_sizing; + SYSVAR_AUTOSIZE(p->m_events_statements_history_long_sizing, + h->m_events_statements_history_long_sizing); } if (p->m_digest_sizing < 0) { - p->m_digest_sizing= h->m_digest_sizing; + SYSVAR_AUTOSIZE(p->m_digest_sizing, + h->m_digest_sizing); } if (p->m_session_connect_attrs_sizing < 0) { - p->m_session_connect_attrs_sizing= h->m_session_connect_attrs_sizing; + SYSVAR_AUTOSIZE(p->m_session_connect_attrs_sizing, + h->m_session_connect_attrs_sizing); } if (p->m_mutex_sizing < 0) @@ -279,7 +293,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + handle * mutex_per_handle + share * mutex_per_share; - p->m_mutex_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_mutex_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } if (p->m_rwlock_sizing < 0) @@ -289,7 +304,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + handle * rwlock_per_handle + share * rwlock_per_share; - p->m_rwlock_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_rwlock_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } if (p->m_cond_sizing < 0) @@ -300,7 +316,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + handle * cond_per_handle + share * cond_per_share; - p->m_cond_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_cond_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } if (p->m_file_sizing < 0) @@ -311,7 +328,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + share * file_per_share; count= max(count, file); - p->m_file_sizing= apply_load_factor(count, h->m_load_factor_normal); + SYSVAR_AUTOSIZE(p->m_file_sizing, + apply_load_factor(count, h->m_load_factor_normal)); } if (p->m_socket_sizing < 0) @@ -321,7 +339,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + handle * socket_per_handle + share * socket_per_share; - p->m_socket_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_socket_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } if (p->m_thread_sizing < 0) @@ -331,7 +350,8 @@ static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h) + handle * thread_per_handle + share * thread_per_share; - p->m_thread_sizing= apply_load_factor(count, h->m_load_factor_volatile); + SYSVAR_AUTOSIZE(p->m_thread_sizing, + apply_load_factor(count, h->m_load_factor_volatile)); } } diff --git a/storage/perfschema/unittest/stub_server_misc.h b/storage/perfschema/unittest/stub_server_misc.h index 946da533727..6bf7d0219ae 100644 --- a/storage/perfschema/unittest/stub_server_misc.h +++ b/storage/perfschema/unittest/stub_server_misc.h @@ -26,3 +26,8 @@ extern "C" void compute_md5_hash(char *, const char *, int) { } +struct sys_var { enum where { AUTO }; }; +void mark_sys_var_value_origin(void *ptr, enum sys_var::where here) +{ +} +