41
41
typedef struct system_variables SV;
42
42
typedef struct my_locale_st MY_LOCALE;
44
extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib,
45
optimizer_switch_typelib, slave_exec_mode_typelib;
44
extern TYPELIB bool_typelib;
45
extern TYPELIB delay_key_write_typelib;
46
extern TYPELIB optimizer_switch_typelib;
47
48
typedef int (*sys_check_func)(Session *, set_var *);
48
49
typedef bool (*sys_update_func)(Session *, set_var *);
53
54
static const std::vector<std::string> empty_aliases;
56
56
struct sys_var_chain
63
* A class which represents a variable, either global or
69
const std::string name; /**< The name of the variable */
70
sys_after_update_func after_update; /**< Function pointer triggered after the variable's value is updated */
71
struct my_option *option_limits; /**< Updated by by set_var_init() */
72
bool m_allow_empty_value; /**< Does variable allow an empty value? */
66
struct my_option *option_limits; /* Updated by by set_var_init() */
67
uint32_t name_length; /* Updated by by set_var_init() */
68
const std::string name;
70
sys_after_update_func after_update;
71
75
sys_var(const char *name_arg, sys_after_update_func func= NULL)
72
:name(name_arg), after_update(func),
73
79
m_allow_empty_value(true)
75
81
virtual ~sys_var() {}
82
88
chain_arg->last= this;
85
/* So that we can exist in a Registry. We really need to formalize that */
86
std::string getName() const { return name; }
87
const std::vector<std::string>& getAliases() const { return empty_aliases; }
92
* Returns the name of the variable.
96
* So that we can exist in a Registry. We really need to formalize that
98
inline const std::string &getName() const
103
* Returns a vector of strings representing aliases
104
* for this variable's name.
106
const std::vector<std::string>& getAliases() const
108
return empty_aliases;
111
* Returns a pointer to the next sys_var, or NULL if none.
113
inline sys_var *getNext() const
118
* Sets the pointer to the next sys_var.
120
* @param Pointer to the next sys_var, or NULL if you set the tail...
122
inline void setNext(sys_var *in_next)
127
* Returns a pointer to the variable's option limits
129
inline struct my_option *getOptionLimits() const
131
return option_limits;
134
* Sets the pointer to the variable's option limits
136
* @param Pointer to the option limits my_option variable
138
inline void setOptionLimits(struct my_option *in_option_limits)
140
option_limits= in_option_limits;
143
* Returns the function pointer for after update trigger, or NULL if none.
145
inline sys_after_update_func getAfterUpdateTrigger() const
89
149
virtual bool check(Session *session, set_var *var);
90
150
bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
91
151
bool check_set(Session *session, set_var *var, TYPELIB *enum_names);
92
152
virtual bool update(Session *session, set_var *var)=0;
93
153
virtual void set_default(Session *, enum_var_type)
95
virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
155
virtual SHOW_TYPE show_type()
96
159
virtual unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
98
163
virtual bool check_type(enum_var_type type)
99
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
165
return type != OPT_GLOBAL;
166
} /* Error if not GLOBAL */
100
167
virtual bool check_update_type(Item_result type)
101
{ return type != INT_RESULT; } /* Assume INT */
169
return type != INT_RESULT;
102
171
virtual bool check_default(enum_var_type)
103
{ return option_limits == 0; }
173
return option_limits == 0;
104
175
Item *item(Session *session, enum_var_type type, const LEX_STRING *base);
105
virtual bool is_struct() { return 0; }
106
virtual bool is_readonly() const { return 0; }
107
virtual sys_var_pluginvar *cast_pluginvar() { return 0; }
110
void set_allow_empty_value(bool allow_empty_value)
112
m_allow_empty_value= allow_empty_value;
116
bool m_allow_empty_value;
176
virtual bool is_struct()
180
virtual bool is_readonly() const
184
virtual sys_var_pluginvar *cast_pluginvar()
121
A base class for all variables that require its access to
122
be guarded with a mutex.
191
* A base class for all variables that require its access to
192
* be guarded with a mutex.
125
194
class sys_var_global: public sys_var
128
197
pthread_mutex_t *guard;
130
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg,
199
sys_var_global(const char *name_arg,
200
sys_after_update_func after_update_arg,
131
201
pthread_mutex_t *guard_arg)
132
:sys_var(name_arg, after_update_arg), guard(guard_arg) {}
203
sys_var(name_arg, after_update_arg),
136
208
class sys_var_uint32_t_ptr :public sys_var