Commit 20056897 authored by Sergei Golubchik's avatar Sergei Golubchik

sys_vars changes and cleanups

parent e44fefc7
...@@ -6180,6 +6180,10 @@ struct my_option my_long_options[]= ...@@ -6180,6 +6180,10 @@ struct my_option my_long_options[]=
option if compiled with valgrind support. option if compiled with valgrind support.
*/ */
IF_VALGRIND(0,1), 0, 0, 0, 0, 0}, IF_VALGRIND(0,1), 0, 0, 0, 0, 0},
{"sync_sys", 0,
"Enable/disable system sync calls. Should only be turned off when running "
"tests or debugging!!",
&opt_sync, &opt_sync, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"sysdate-is-now", 0, {"sysdate-is-now", 0,
"Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. " "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. "
"Since 5.0, SYSDATE() returns a `dynamic' value different for different " "Since 5.0, SYSDATE() returns a `dynamic' value different for different "
...@@ -7496,7 +7500,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) ...@@ -7496,7 +7500,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
opt < my_long_options + array_elements(my_long_options) - 1; opt < my_long_options + array_elements(my_long_options) - 1;
opt++) opt++)
insert_dynamic(&all_options, (uchar*) opt); insert_dynamic(&all_options, (uchar*) opt);
sys_var_add_options(&all_options, sys_var::PARSE_NORMAL); sys_var_add_options(&all_options, 0);
add_terminator(&all_options); add_terminator(&all_options);
/* Skip unknown options so that they may be processed later by plugins */ /* Skip unknown options so that they may be processed later by plugins */
......
...@@ -60,13 +60,13 @@ static void scheduler_wait_lock_end(void) { ...@@ -60,13 +60,13 @@ static void scheduler_wait_lock_end(void) {
static void scheduler_wait_sync_begin(void) { static void scheduler_wait_sync_begin(void) {
THD *thd=current_thd; THD *thd=current_thd;
scheduler_functions *func= thd->scheduler; scheduler_functions *func= thd ? thd->scheduler : thread_scheduler;
MYSQL_CALLBACK(func, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK)); MYSQL_CALLBACK(func, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
} }
static void scheduler_wait_sync_end(void) { static void scheduler_wait_sync_end(void) {
THD *thd=current_thd; THD *thd=current_thd;
scheduler_functions *func= thd->scheduler; scheduler_functions *func= thd ? thd->scheduler : thread_scheduler;
MYSQL_CALLBACK(func, thd_wait_end, (thd)); MYSQL_CALLBACK(func, thd_wait_end, (thd));
} }
}; };
......
...@@ -137,7 +137,6 @@ void sys_var_end() ...@@ -137,7 +137,6 @@ void sys_var_end()
@param deprecated_version if not 0 - when this variable will go away @param deprecated_version if not 0 - when this variable will go away
@param substitute if not 0 - what one should use instead when this @param substitute if not 0 - what one should use instead when this
deprecated variable deprecated variable
@param parse_flag either PARSE_EARLY or PARSE_NORMAL
*/ */
sys_var::sys_var(sys_var_chain *chain, const char *name_arg, sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
const char *comment, int flags_arg, ptrdiff_t off, const char *comment, int flags_arg, ptrdiff_t off,
...@@ -146,11 +145,10 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg, ...@@ -146,11 +145,10 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
PolyLock *lock, enum binlog_status_enum binlog_status_arg, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
on_check_function on_check_func, on_check_function on_check_func,
on_update_function on_update_func, on_update_function on_update_func,
uint deprecated_version, const char *substitute, uint deprecated_version, const char *substitute) :
int parse_flag) :
next(0), next(0),
binlog_status(binlog_status_arg), binlog_status(binlog_status_arg),
flags(flags_arg), m_parse_flag(parse_flag), show_val_type(show_val_type_arg), flags(flags_arg), show_val_type(show_val_type_arg),
guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func), guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func),
is_os_charset(FALSE) is_os_charset(FALSE)
{ {
...@@ -163,7 +161,7 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg, ...@@ -163,7 +161,7 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
in the first (PARSE_EARLY) stage. in the first (PARSE_EARLY) stage.
See handle_options() for details. See handle_options() for details.
*/ */
DBUG_ASSERT(parse_flag == PARSE_NORMAL || getopt_id <= 0 || getopt_id >= 255); DBUG_ASSERT(!(flags & PARSE_EARLY) || getopt_id <= 0 || getopt_id >= 255);
name.str= name_arg; // ER_NO_DEFAULT relies on 0-termination of name_arg name.str= name_arg; // ER_NO_DEFAULT relies on 0-termination of name_arg
name.length= strlen(name_arg); // and so does this. name.length= strlen(name_arg); // and so does this.
......
...@@ -59,9 +59,7 @@ public: ...@@ -59,9 +59,7 @@ public:
sys_var *next; sys_var *next;
LEX_CSTRING name; LEX_CSTRING name;
enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023, enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023,
READONLY=1024, ALLOCATED=2048 }; READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096 };
static const int PARSE_EARLY= 1;
static const int PARSE_NORMAL= 2;
/** /**
Enumeration type to indicate for a system variable whether Enumeration type to indicate for a system variable whether
it will be written to the binlog or not. it will be written to the binlog or not.
...@@ -74,7 +72,6 @@ protected: ...@@ -74,7 +72,6 @@ protected:
typedef bool (*on_update_function)(sys_var *self, THD *thd, enum_var_type type); typedef bool (*on_update_function)(sys_var *self, THD *thd, enum_var_type type);
int flags; ///< or'ed flag_enum values int flags; ///< or'ed flag_enum values
int m_parse_flag; ///< either PARSE_EARLY or PARSE_NORMAL.
const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc
my_option option; ///< min, max, default values are stored here my_option option; ///< min, max, default values are stored here
PolyLock *guard; ///< *second* lock that protects the variable PolyLock *guard; ///< *second* lock that protects the variable
...@@ -90,7 +87,7 @@ public: ...@@ -90,7 +87,7 @@ public:
enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg, enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg,
longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
on_check_function on_check_func, on_update_function on_update_func, on_check_function on_check_func, on_update_function on_update_func,
uint deprecated_version, const char *substitute, int parse_flag); uint deprecated_version, const char *substitute);
virtual ~sys_var() {} virtual ~sys_var() {}
...@@ -133,7 +130,7 @@ public: ...@@ -133,7 +130,7 @@ public:
} }
bool register_option(DYNAMIC_ARRAY *array, int parse_flags) bool register_option(DYNAMIC_ARRAY *array, int parse_flags)
{ {
return (option.id != -1) && (m_parse_flag & parse_flags) && return (option.id != -1) && ((flags & PARSE_EARLY) == parse_flags) &&
insert_dynamic(array, (uchar*)&option); insert_dynamic(array, (uchar*)&option);
} }
......
...@@ -243,7 +243,7 @@ public: ...@@ -243,7 +243,7 @@ public:
(plugin_var_arg->flags & PLUGIN_VAR_THDLOCAL ? SESSION : GLOBAL) | (plugin_var_arg->flags & PLUGIN_VAR_THDLOCAL ? SESSION : GLOBAL) |
(plugin_var_arg->flags & PLUGIN_VAR_READONLY ? READONLY : 0), (plugin_var_arg->flags & PLUGIN_VAR_READONLY ? READONLY : 0),
0, -1, NO_ARG, pluginvar_show_type(plugin_var_arg), 0, 0, 0, -1, NO_ARG, pluginvar_show_type(plugin_var_arg), 0, 0,
VARIABLE_NOT_IN_BINLOG, 0, 0, 0, 0, PARSE_NORMAL), VARIABLE_NOT_IN_BINLOG, 0, 0, 0, 0),
plugin_var(plugin_var_arg), orig_pluginvar_name(plugin_var_arg->name) plugin_var(plugin_var_arg), orig_pluginvar_name(plugin_var_arg->name)
{ plugin_var->name= name_arg; } { plugin_var->name= name_arg; }
sys_var_pluginvar *cast_pluginvar() { return this; } sys_var_pluginvar *cast_pluginvar() { return this; }
......
This diff is collapsed.
This diff is collapsed.
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