Commit 051c1326 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: sysvar, SHOW_VALUE_IN_HELP->GETOPT_ONLY_HELP

replace flag SHOW_VALUE_IN_HELP (that's not really an
independendent flag, as it should only be used for
NO_CMD_LINE sysvars) with a special getopt.id type.
parent db2399b0
......@@ -8265,9 +8265,9 @@ static void print_help()
my_print_help((my_option*) all_options.buffer);
/* Add variables that can be shown but not changed, like version numbers */
/* Add variables that must be shown but not changed, like version numbers */
pop_dynamic(&all_options);
sys_var_add_options(&all_options, sys_var::SHOW_VALUE_IN_HELP);
sys_var_add_options(&all_options, sys_var::GETOPT_ONLY_HELP);
sort_dynamic(&all_options, (qsort_cmp) option_cmp);
add_terminator(&all_options);
my_print_variables((my_option*) all_options.buffer);
......
......@@ -61,7 +61,9 @@ class sys_var
sys_var *next;
LEX_CSTRING name;
enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023,
READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096, SHOW_VALUE_IN_HELP=8192 };
READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096 };
enum { NO_GETOPT=-1, GETOPT_ONLY_HELP=-2 };
/**
Enumeration type to indicate for a system variable whether
it will be written to the binlog or not.
......@@ -143,9 +145,23 @@ class sys_var
}
bool register_option(DYNAMIC_ARRAY *array, int parse_flags)
{
return ((((option.id != -1) && ((flags & PARSE_EARLY) == parse_flags)) ||
(flags & parse_flags)) &&
insert_dynamic(array, (uchar*)&option));
DBUG_ASSERT(parse_flags == GETOPT_ONLY_HELP ||
parse_flags == PARSE_EARLY || parse_flags == 0);
if (option.id == NO_GETOPT)
return 0;
if (parse_flags == GETOPT_ONLY_HELP)
{
if (option.id != GETOPT_ONLY_HELP)
return 0;
}
else
{
if (option.id == GETOPT_ONLY_HELP)
return 0;
if ((flags & PARSE_EARLY) != parse_flags)
return 0;
}
return insert_dynamic(array, (uchar*)&option);
}
void do_deprecated_warning(THD *thd);
......
......@@ -1077,8 +1077,8 @@ static Sys_var_keycache Sys_key_cache_age_threshold(
static Sys_var_mybool Sys_large_files_support(
"large_files_support",
"Whether mysqld was compiled with options for large file support",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(opt_large_files),
NO_CMD_LINE, DEFAULT(sizeof(my_off_t) > 4));
READ_ONLY GLOBAL_VAR(opt_large_files),
CMD_LINE_HELP_ONLY, DEFAULT(sizeof(my_off_t) > 4));
static Sys_var_uint Sys_large_page_size(
"large_page_size",
......@@ -1222,8 +1222,8 @@ static Sys_var_mybool Sys_lower_case_file_system(
"lower_case_file_system",
"Case sensitivity of file names on the file system where the "
"data directory is located",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(lower_case_file_system),
NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(lower_case_file_system),
CMD_LINE_HELP_ONLY,
DEFAULT(FALSE));
static Sys_var_uint Sys_lower_case_table_names(
......@@ -2271,7 +2271,7 @@ static Sys_var_ulong Sys_preload_buff_size(
static Sys_var_uint Sys_protocol_version(
"protocol_version",
"The version of the client/server protocol used by the MySQL server",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(protocol_version), NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(protocol_version), CMD_LINE_HELP_ONLY,
VALID_RANGE(0, ~0), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1));
static Sys_var_proxy_user Sys_proxy_user(
......@@ -3026,8 +3026,8 @@ static Sys_var_mybool Sys_sync_frm(
static char *system_time_zone_ptr;
static Sys_var_charptr Sys_system_time_zone(
"system_time_zone", "The server system time zone",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(system_time_zone_ptr),
NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(system_time_zone_ptr),
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(system_time_zone));
static Sys_var_ulong Sys_table_def_size(
......@@ -3237,35 +3237,34 @@ static Sys_var_mybool Sys_timed_mutexes(
static char *server_version_ptr;
static Sys_var_charptr Sys_version(
"version", "Server version",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(server_version_ptr),
NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(server_version_ptr),
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(server_version));
static char *server_version_comment_ptr;
static Sys_var_charptr Sys_version_comment(
"version_comment", "version_comment",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(server_version_comment_ptr),
NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(server_version_comment_ptr),
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(MYSQL_COMPILATION_COMMENT));
static char *server_version_compile_machine_ptr;
static Sys_var_charptr Sys_version_compile_machine(
"version_compile_machine", "version_compile_machine",
READ_ONLY SHOW_VALUE_IN_HELP
GLOBAL_VAR(server_version_compile_machine_ptr), NO_CMD_LINE,
IN_SYSTEM_CHARSET, DEFAULT(MACHINE_TYPE));
READ_ONLY GLOBAL_VAR(server_version_compile_machine_ptr),
CMD_LINE_HELP_ONLY, IN_SYSTEM_CHARSET, DEFAULT(MACHINE_TYPE));
static char *server_version_compile_os_ptr;
static Sys_var_charptr Sys_version_compile_os(
"version_compile_os", "version_compile_os",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(server_version_compile_os_ptr),
NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(server_version_compile_os_ptr),
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(SYSTEM_TYPE));
static char *malloc_library;
static Sys_var_charptr Sys_malloc_library(
"version_malloc_library", "Version of the used malloc library",
READ_ONLY SHOW_VALUE_IN_HELP GLOBAL_VAR(malloc_library), NO_CMD_LINE,
READ_ONLY GLOBAL_VAR(malloc_library), CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(MALLOC_LIBRARY));
static Sys_var_ulong Sys_net_wait_timeout(
......
......@@ -41,7 +41,8 @@
#define GLOBAL_VAR(X) sys_var::GLOBAL, (((char*)&(X))-(char*)&global_system_variables), sizeof(X)
#define SESSION_VAR(X) sys_var::SESSION, offsetof(SV, X), sizeof(((SV *)0)->X)
#define SESSION_ONLY(X) sys_var::ONLY_SESSION, offsetof(SV, X), sizeof(((SV *)0)->X)
#define NO_CMD_LINE CMD_LINE(NO_ARG, -1)
#define NO_CMD_LINE CMD_LINE(NO_ARG, sys_var::NO_GETOPT)
#define CMD_LINE_HELP_ONLY CMD_LINE(NO_ARG, sys_var::GETOPT_ONLY_HELP)
/*
the define below means that there's no *second* mutex guard,
LOCK_global_system_variables always guards all system variables
......@@ -56,7 +57,6 @@
// this means that Sys_var_charptr initial value was malloc()ed
#define PREALLOCATED sys_var::ALLOCATED+
#define PARSED_EARLY sys_var::PARSE_EARLY+
#define SHOW_VALUE_IN_HELP sys_var::SHOW_VALUE_IN_HELP+
/*
Sys_var_bit meaning is reversed, like in
......@@ -84,8 +84,8 @@
#define SYSVAR_ASSERT(X) \
while(!(X)) \
{ \
fprintf(stderr, "Sysvar '%s' failed '%s'\n", name_arg, #X); \
DBUG_ABORT(); \
fprintf(stderr, "Sysvar '%s' failed '%s'\n", name_arg, #X); \
DBUG_ABORT(); \
exit(255); \
}
......@@ -368,7 +368,7 @@ class Sys_var_mybool: public Sys_var_typelib
option.var_type= GET_BOOL;
global_var(my_bool)= def_val;
SYSVAR_ASSERT(def_val < 2);
SYSVAR_ASSERT(getopt.arg_type == OPT_ARG || getopt.id == -1);
SYSVAR_ASSERT(getopt.arg_type == OPT_ARG || getopt.id < 0);
SYSVAR_ASSERT(size == sizeof(my_bool));
}
bool session_update(THD *thd, set_var *var)
......@@ -510,7 +510,7 @@ class Sys_var_proxy_user: public sys_var
Sys_var_proxy_user(const char *name_arg,
const char *comment, enum charset_enum is_os_charset_arg)
: sys_var(&all_sys_vars, name_arg, comment,
sys_var::READONLY+sys_var::ONLY_SESSION, 0, -1,
sys_var::READONLY+sys_var::ONLY_SESSION, 0, NO_GETOPT,
NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
NULL, NULL, NULL)
{
......@@ -569,7 +569,7 @@ class Sys_var_rpl_filter: public sys_var
public:
Sys_var_rpl_filter(const char *name, int getopt_id, const char *comment)
: sys_var(&all_sys_vars, name, comment, sys_var::GLOBAL, 0, -1,
: sys_var(&all_sys_vars, name, comment, sys_var::GLOBAL, 0, NO_GETOPT,
NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
NULL, NULL, NULL), opt_id(getopt_id)
{
......@@ -1329,7 +1329,7 @@ class Sys_var_plugin: public sys_var
{
option.var_type= GET_STR;
SYSVAR_ASSERT(size == sizeof(plugin_ref));
SYSVAR_ASSERT(getopt.id == -1); // force NO_CMD_LINE
SYSVAR_ASSERT(getopt.id < 0); // force NO_CMD_LINE
}
bool do_check(THD *thd, set_var *var)
{
......@@ -1542,7 +1542,7 @@ class Sys_var_bit: public Sys_var_typelib
bitmask= reverse_semantics ? ~bitmask_arg : bitmask_arg;
set(global_var_ptr(), def_val);
SYSVAR_ASSERT(def_val < 2);
SYSVAR_ASSERT(getopt.id == -1); // force NO_CMD_LINE
SYSVAR_ASSERT(getopt.id < 0); // force NO_CMD_LINE
SYSVAR_ASSERT(size == sizeof(ulonglong));
}
bool session_update(THD *thd, set_var *var)
......@@ -1612,7 +1612,7 @@ class Sys_var_session_special: public Sys_var_ulonglong
read_func(read_func_arg), update_func(update_func_arg)
{
SYSVAR_ASSERT(scope() == ONLY_SESSION);
SYSVAR_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake
SYSVAR_ASSERT(getopt.id < 0); // NO_CMD_LINE, because the offset is fake
}
bool session_update(THD *thd, set_var *var)
{ return update_func(thd, var); }
......@@ -1662,7 +1662,7 @@ class Sys_var_session_special_double: public Sys_var_double
read_func(read_func_arg), update_func(update_func_arg)
{
SYSVAR_ASSERT(scope() == ONLY_SESSION);
SYSVAR_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake
SYSVAR_ASSERT(getopt.id < 0); // NO_CMD_LINE, because the offset is fake
}
bool session_update(THD *thd, set_var *var)
{ return update_func(thd, var); }
......@@ -1715,7 +1715,7 @@ class Sys_var_have: public sys_var
substitute)
{
SYSVAR_ASSERT(scope() == GLOBAL);
SYSVAR_ASSERT(getopt.id == -1);
SYSVAR_ASSERT(getopt.id < 0);
SYSVAR_ASSERT(lock == 0);
SYSVAR_ASSERT(binlog_status_arg == VARIABLE_NOT_IN_BINLOG);
SYSVAR_ASSERT(is_readonly());
......@@ -1792,7 +1792,7 @@ class Sys_var_struct: public sys_var
thus all struct command-line options should be added manually
to my_long_options in mysqld.cc
*/
SYSVAR_ASSERT(getopt.id == -1);
SYSVAR_ASSERT(getopt.id < 0);
SYSVAR_ASSERT(size == sizeof(void *));
}
bool do_check(THD *thd, set_var *var)
......@@ -1854,7 +1854,7 @@ class Sys_var_tz: public sys_var
lock, binlog_status_arg, on_check_func, on_update_func,
substitute)
{
SYSVAR_ASSERT(getopt.id == -1);
SYSVAR_ASSERT(getopt.id < 0);
SYSVAR_ASSERT(size == sizeof(Time_zone *));
}
bool do_check(THD *thd, set_var *var)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment