Commit b642bb1f authored by unknown's avatar unknown

1. sys_variables[] array is removed.

2. All have_xxx variables are now selectable.


sql/set_var.cc:
  1. sys_have_xxx variables added.
  2. Removed sys_var *sys_variables[] array as we don't need it any more.
  3. void set_var_init() changed to use sys_var_xxx chain insted of sys_variables[] array.
sql/set_var.h:
  1. add_sys_var() method added to the sys_var class. It's called from constructors
  to chain all successor objects. The first one is stored in the 'static sys_var *first'.
  The total number of variables is in the 'static uint sys_vars'. Each sys_var successor object
  has the 'sys_var *next' pointer to the next one in the chain. 
  2. sys_var_have_variable class introduced to make all have_xxx variables selectable.
sql/sql_lex.cc:
  trg_new_row_fake_var(0, 0) replaced with '(sys_var*) 0x01' as we don't want to have such fake variables in the sys_var_xxx chain.
sql/sql_lex.h:
  Proper use of the changed trg_new_row_fake_var.
sql/sql_yacc.yy:
  Proper use of the changed trg_new_row_fake_var.
parent 65ab8b01
This diff is collapsed.
......@@ -39,6 +39,9 @@ typedef byte *(*sys_value_ptr_func)(THD *thd);
class sys_var
{
public:
static sys_var *first;
static uint sys_vars;
sys_var *next;
struct my_option *option_limits; /* Updated by by set_var_init() */
uint name_length; /* Updated by by set_var_init() */
const char *name;
......@@ -48,12 +51,18 @@ class sys_var
sys_var(const char *name_arg)
:name(name_arg), after_update(0)
, no_support_one_shot(1)
{}
{ add_sys_var(); }
sys_var(const char *name_arg,sys_after_update_func func)
:name(name_arg), after_update(func)
, no_support_one_shot(1)
{}
{ add_sys_var(); }
virtual ~sys_var() {}
void add_sys_var()
{
next= first;
first= this;
sys_vars++;
}
virtual bool check(THD *thd, set_var *var);
bool check_enum(THD *thd, set_var *var, TYPELIB *enum_names);
bool check_set(THD *thd, set_var *var, TYPELIB *enum_names);
......@@ -701,6 +710,30 @@ class sys_var_readonly: public sys_var
bool is_readonly() const { return 1; }
};
class sys_var_have_variable: public sys_var
{
SHOW_COMP_OPTION *have_variable;
public:
sys_var_have_variable(const char *variable_name,
SHOW_COMP_OPTION *have_variable_arg):
sys_var(variable_name),
have_variable(have_variable_arg)
{ }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
{
return (byte*) show_comp_option_name[*have_variable];
}
bool update(THD *thd, set_var *var) { return 1; }
bool check_default(enum_var_type type) { return 1; }
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
bool check_update_type(Item_result type) { return 1; }
SHOW_TYPE type() { return SHOW_CHAR; }
bool is_readonly() const { return 1; }
};
class sys_var_thd_time_zone :public sys_var_thd
{
public:
......
......@@ -28,7 +28,8 @@
We are using pointer to this variable for distinguishing between assignment
to NEW row field (when parsing trigger definition) and structured variable.
*/
sys_var_long_ptr trg_new_row_fake_var(0, 0);
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
/* Macros to look like lex */
......
......@@ -702,7 +702,7 @@ struct st_trg_chistics
enum trg_event_type event;
};
extern sys_var_long_ptr trg_new_row_fake_var;
extern sys_var *trg_new_row_fake_var;
enum xa_option_words {XA_NONE, XA_JOIN, XA_RESUME, XA_ONE_PHASE,
XA_SUSPEND, XA_FOR_MIGRATE};
......
......@@ -8529,7 +8529,7 @@ sys_option_value:
{
LEX *lex=Lex;
if ($2.var == &trg_new_row_fake_var)
if ($2.var == trg_new_row_fake_var)
{
/* We are in trigger and assigning value to field of new row */
Item *it;
......@@ -8750,7 +8750,7 @@ internal_variable_name:
YYABORT;
}
/* This special combination will denote field of NEW row */
$$.var= &trg_new_row_fake_var;
$$.var= trg_new_row_fake_var;
$$.base_name= $3;
}
else
......
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