~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.h

  • Committer: Brian Aker
  • Date: 2009-06-11 22:06:29 UTC
  • mfrom: (1055.2.24 working)
  • Revision ID: brian@gaz-20090611220629-ct55qcmaiiuxrjaq
Merge Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
typedef struct system_variables SV;
42
42
typedef struct my_locale_st MY_LOCALE;
43
43
 
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;
46
47
 
47
48
typedef int (*sys_check_func)(Session *,  set_var *);
48
49
typedef bool (*sys_update_func)(Session *, set_var *);
52
53
 
53
54
static const std::vector<std::string> empty_aliases;
54
55
 
55
 
 
56
56
struct sys_var_chain
57
57
{
58
58
  sys_var *first;
59
59
  sys_var *last;
60
60
};
61
61
 
 
62
/**
 
63
 * A class which represents a variable, either global or 
 
64
 * session-local.
 
65
 */
62
66
class sys_var
63
67
{
64
 
public:
 
68
protected:
 
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? */
65
73
  sys_var *next;
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;
69
 
 
70
 
  sys_after_update_func after_update;
 
74
public:
71
75
  sys_var(const char *name_arg, sys_after_update_func func= NULL)
72
 
    :name(name_arg), after_update(func),
 
76
    :
 
77
    name(name_arg),
 
78
    after_update(func),
73
79
    m_allow_empty_value(true)
74
80
  {}
75
81
  virtual ~sys_var() {}
82
88
    chain_arg->last= this;
83
89
  }
84
90
 
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; }
88
 
 
 
91
  /** 
 
92
   * Returns the name of the variable.
 
93
   *
 
94
   * @note 
 
95
   *
 
96
   * So that we can exist in a Registry. We really need to formalize that 
 
97
   */
 
98
  inline const std::string &getName() const
 
99
  {
 
100
    return name;
 
101
  }
 
102
  /**
 
103
   * Returns a vector of strings representing aliases
 
104
   * for this variable's name.
 
105
   */
 
106
  const std::vector<std::string>& getAliases() const
 
107
  {
 
108
    return empty_aliases;
 
109
  }
 
110
  /**
 
111
   * Returns a pointer to the next sys_var, or NULL if none.
 
112
   */
 
113
  inline sys_var *getNext() const
 
114
  {
 
115
    return next;
 
116
  }
 
117
  /**
 
118
   * Sets the pointer to the next sys_var.
 
119
   *
 
120
   * @param Pointer to the next sys_var, or NULL if you set the tail...
 
121
   */
 
122
  inline void setNext(sys_var *in_next)
 
123
  {
 
124
    next= in_next;
 
125
  }
 
126
  /**
 
127
   * Returns a pointer to the variable's option limits
 
128
   */
 
129
  inline struct my_option *getOptionLimits() const
 
130
  {
 
131
    return option_limits;
 
132
  }
 
133
  /**
 
134
   * Sets the pointer to the variable's option limits
 
135
   *
 
136
   * @param Pointer to the option limits my_option variable
 
137
   */
 
138
  inline void setOptionLimits(struct my_option *in_option_limits)
 
139
  {
 
140
    option_limits= in_option_limits;
 
141
  }
 
142
  /** 
 
143
   * Returns the function pointer for after update trigger, or NULL if none.
 
144
   */
 
145
  inline sys_after_update_func getAfterUpdateTrigger() const
 
146
  {
 
147
    return after_update;
 
148
  }
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)
94
154
  {}
95
 
  virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
 
155
  virtual SHOW_TYPE show_type()
 
156
  {
 
157
    return SHOW_UNDEF;
 
158
  }
96
159
  virtual unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
97
 
  { return 0; }
 
160
  {
 
161
    return 0;
 
162
  }
98
163
  virtual bool check_type(enum_var_type type)
99
 
  { return type != OPT_GLOBAL; }                /* Error if not GLOBAL */
 
164
  {
 
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 */
 
168
  {
 
169
    return type != INT_RESULT;
 
170
  }             /* Assume INT */
102
171
  virtual bool check_default(enum_var_type)
103
 
  { return option_limits == 0; }
 
172
  {
 
173
    return option_limits == 0;
 
174
  }
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; }
108
 
 
109
 
protected:
110
 
  void set_allow_empty_value(bool allow_empty_value)
111
 
  {
112
 
    m_allow_empty_value= allow_empty_value;
113
 
  }
114
 
 
115
 
private:
116
 
  bool m_allow_empty_value;
 
176
  virtual bool is_struct()
 
177
  {
 
178
    return 0;
 
179
  }
 
180
  virtual bool is_readonly() const
 
181
  {
 
182
    return 0;
 
183
  }
 
184
  virtual sys_var_pluginvar *cast_pluginvar()
 
185
  {
 
186
    return 0;
 
187
  }
117
188
};
118
189
 
119
 
 
120
 
/*
121
 
  A base class for all variables that require its access to
122
 
  be guarded with a mutex.
123
 
*/
124
 
 
 
190
/**
 
191
 * A base class for all variables that require its access to
 
192
 * be guarded with a mutex.
 
193
 */
125
194
class sys_var_global: public sys_var
126
195
{
127
196
protected:
128
197
  pthread_mutex_t *guard;
129
198
public:
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) {}
 
202
    :
 
203
      sys_var(name_arg, after_update_arg), 
 
204
      guard(guard_arg) 
 
205
  {}
133
206
};
134
207
 
135
 
 
136
208
class sys_var_uint32_t_ptr :public sys_var
137
209
{
138
210
  uint32_t *value;
865
937
  {
866
938
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
867
939
  }
868
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
869
 
                           const LEX_STRING *base);
870
940
};
871
941
 
872
942
class sys_var_session_lc_time_names :public sys_var_session
906
976
  /* light check for PS */
907
977
};
908
978
 
909
 
 
910
979
/* MySQL internal variables */
911
 
 
912
980
class set_var :public set_var_base
913
981
{
914
982
public:
987
1055
                                                   unsigned char*));
988
1056
};
989
1057
 
990
 
/* updated in sql_acl.cc */
991
 
 
992
 
extern sys_var_session_bool sys_old_alter_table;
993
1058
extern LEX_STRING default_key_cache_base;
994
1059
 
995
1060
/* For sql_yacc */