~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

  • Committer: Mark Atwood
  • Date: 2011-11-11 18:23:18 UTC
  • mfrom: (2456.1.5 rf)
  • Revision ID: me@mark.atwood.name-20111111182318-skgcp9ce65fd2goa
mergeĀ lp:~olafvdspek/drizzle/refactor11

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
 
95
95
namespace
96
96
{
97
 
static size_t revno= DRIZZLE7_VC_REVNO;
98
 
static size_t release_id= DRIZZLE7_RELEASE_ID;
 
97
  static size_t revno= DRIZZLE7_VC_REVNO;
 
98
  static size_t release_id= DRIZZLE7_RELEASE_ID;
99
99
}
100
100
 
101
101
const char *bool_type_names[]= { "OFF", "ON", NULL };
104
104
  array_elements(bool_type_names)-1, "", bool_type_names, NULL
105
105
};
106
106
 
107
 
static bool set_option_bit(Session *session, set_var *var);
108
 
static bool set_option_autocommit(Session *session, set_var *var);
109
 
static int  check_pseudo_thread_id(Session *session, set_var *var);
110
 
static int check_tx_isolation(Session *session, set_var *var);
111
 
static void fix_tx_isolation(Session *session, sql_var_t type);
112
 
static int check_completion_type(Session *session, set_var *var);
113
 
static void fix_completion_type(Session *session, sql_var_t type);
114
 
static void fix_max_join_size(Session *session, sql_var_t type);
115
 
static void fix_session_mem_root(Session *session, sql_var_t type);
116
 
static void fix_server_id(Session *session, sql_var_t type);
117
 
void throw_bounds_warning(Session *session, bool fixed, bool unsignd, const std::string &name, int64_t val);
118
 
static unsigned char *get_error_count(Session *session);
119
 
static unsigned char *get_warning_count(Session *session);
120
 
static unsigned char *get_tmpdir(Session *session);
 
107
static bool set_option_bit(Session*, set_var*);
 
108
static bool set_option_autocommit(Session*, set_var*);
 
109
static int  check_pseudo_thread_id(Session*, set_var*);
 
110
static int check_tx_isolation(Session*, set_var*);
 
111
static void fix_tx_isolation(Session*, sql_var_t);
 
112
static int check_completion_type(Session*, set_var*);
 
113
static void fix_max_join_size(Session*, sql_var_t);
 
114
static void fix_session_mem_root(Session*, sql_var_t);
 
115
void throw_bounds_warning(Session*, bool fixed, bool unsignd, const std::string &name, int64_t);
 
116
static unsigned char *get_error_count(Session*);
 
117
static unsigned char *get_warning_count(Session*);
 
118
static unsigned char *get_tmpdir(Session*);
121
119
 
122
120
/*
123
121
  Variable definition list
129
127
  it in the constructor (see sys_var class for details).
130
128
*/
131
129
static sys_var_session_uint64_t
132
 
sys_auto_increment_increment("auto_increment_increment",
133
 
                             &drizzle_system_variables::auto_increment_increment);
 
130
sys_auto_increment_increment("auto_increment_increment", &drizzle_system_variables::auto_increment_increment);
134
131
static sys_var_session_uint64_t
135
 
sys_auto_increment_offset("auto_increment_offset",
136
 
                          &drizzle_system_variables::auto_increment_offset);
 
132
sys_auto_increment_offset("auto_increment_offset", &drizzle_system_variables::auto_increment_offset);
137
133
 
138
134
static sys_var_fs_path sys_basedir("basedir", basedir);
139
135
static sys_var_fs_path sys_pid_file("pid_file", pid_file);
140
136
static sys_var_fs_path sys_plugin_dir("plugin_dir", plugin_dir);
141
137
 
142
 
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack",
143
 
                                                      &my_thread_stack_size);
 
138
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack", &my_thread_stack_size);
144
139
static sys_var_constrained_value_readonly<uint32_t> sys_back_log("back_log", back_log);
145
140
 
146
 
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size",
147
 
                                                          &drizzle_system_variables::bulk_insert_buff_size);
148
 
static sys_var_session_uint32_t sys_completion_type("completion_type",
149
 
                                                    &drizzle_system_variables::completion_type,
150
 
                                                    check_completion_type,
151
 
                                                    fix_completion_type);
 
141
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size", &drizzle_system_variables::bulk_insert_buff_size);
 
142
static sys_var_session_uint32_t sys_completion_type("completion_type", &drizzle_system_variables::completion_type, check_completion_type);
152
143
static sys_var_collation_sv
153
144
sys_collation_server("collation_server", &drizzle_system_variables::collation_server, &default_charset_info);
154
 
static sys_var_fs_path       sys_datadir("datadir", getDataHome());
155
 
 
156
 
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size",
157
 
                                                     &drizzle_system_variables::join_buff_size);
158
 
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet",
159
 
                                                       &drizzle_system_variables::max_allowed_packet);
160
 
static sys_var_session_uint64_t sys_max_error_count("max_error_count",
161
 
                                                  &drizzle_system_variables::max_error_count);
162
 
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size",
163
 
                                                        &drizzle_system_variables::max_heap_table_size);
164
 
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id",
165
 
                                              &drizzle_system_variables::pseudo_thread_id,
166
 
                                              0, check_pseudo_thread_id);
167
 
static sys_var_session_ha_rows  sys_max_join_size("max_join_size",
168
 
                                                  &drizzle_system_variables::max_join_size,
169
 
                                                  fix_max_join_size);
170
 
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key",
171
 
                                                      &drizzle_system_variables::max_seeks_for_key);
172
 
static sys_var_session_uint64_t   sys_max_length_for_sort_data("max_length_for_sort_data",
173
 
                                                               &drizzle_system_variables::max_length_for_sort_data);
174
 
static sys_var_session_size_t   sys_max_sort_length("max_sort_length",
175
 
                                                    &drizzle_system_variables::max_sort_length);
176
 
static sys_var_uint64_t_ptr     sys_max_write_lock_count("max_write_lock_count",
177
 
                                                 &max_write_lock_count);
178
 
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit",
179
 
                                                           &drizzle_system_variables::min_examined_row_limit);
180
 
 
181
 
/* these two cannot be static */
182
 
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level",
183
 
                                                      &drizzle_system_variables::optimizer_prune_level);
184
 
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth",
185
 
                                                           &drizzle_system_variables::optimizer_search_depth);
186
 
 
187
 
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size",
188
 
                                                      &drizzle_system_variables::preload_buff_size);
189
 
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size",
190
 
                                                   &drizzle_system_variables::read_buff_size);
191
 
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size",
192
 
                                                       &drizzle_system_variables::read_rnd_buff_size);
193
 
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment",
194
 
                                                      &drizzle_system_variables::div_precincrement);
195
 
 
196
 
static sys_var_session_size_t   sys_range_alloc_block_size("range_alloc_block_size",
197
 
                                                           &drizzle_system_variables::range_alloc_block_size);
198
 
 
199
 
static sys_var_session_bool sys_replicate_query("replicate_query",
200
 
                                                &drizzle_system_variables::replicate_query);
201
 
 
202
 
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size",
203
 
                                                           &drizzle_system_variables::query_alloc_block_size,
204
 
                                                           NULL, fix_session_mem_root);
205
 
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size",
206
 
                                                        &drizzle_system_variables::query_prealloc_size,
207
 
                                                        NULL, fix_session_mem_root);
 
145
static sys_var_fs_path sys_datadir("datadir", getDataHome());
 
146
 
 
147
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size", &drizzle_system_variables::join_buff_size);
 
148
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet", &drizzle_system_variables::max_allowed_packet);
 
149
static sys_var_session_uint64_t sys_max_error_count("max_error_count", &drizzle_system_variables::max_error_count);
 
150
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size", &drizzle_system_variables::max_heap_table_size);
 
151
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id", &drizzle_system_variables::pseudo_thread_id, 0, check_pseudo_thread_id);
 
152
static sys_var_session_ha_rows  sys_max_join_size("max_join_size", &drizzle_system_variables::max_join_size, fix_max_join_size);
 
153
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key", &drizzle_system_variables::max_seeks_for_key);
 
154
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data", &drizzle_system_variables::max_length_for_sort_data);
 
155
static sys_var_session_size_t   sys_max_sort_length("max_sort_length", &drizzle_system_variables::max_sort_length);
 
156
static sys_var_uint64_t_ptr     sys_max_write_lock_count("max_write_lock_count", &max_write_lock_count);
 
157
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit", &drizzle_system_variables::min_examined_row_limit);
 
158
 
 
159
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level", &drizzle_system_variables::optimizer_prune_level);
 
160
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth", &drizzle_system_variables::optimizer_search_depth);
 
161
 
 
162
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size", &drizzle_system_variables::preload_buff_size);
 
163
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size", &drizzle_system_variables::read_buff_size);
 
164
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size", &drizzle_system_variables::read_rnd_buff_size);
 
165
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment", &drizzle_system_variables::div_precincrement);
 
166
 
 
167
static sys_var_session_size_t   sys_range_alloc_block_size("range_alloc_block_size", &drizzle_system_variables::range_alloc_block_size);
 
168
 
 
169
static sys_var_session_bool sys_replicate_query("replicate_query", &drizzle_system_variables::replicate_query);
 
170
 
 
171
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size", &drizzle_system_variables::query_alloc_block_size, NULL, fix_session_mem_root);
 
172
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size", &drizzle_system_variables::query_prealloc_size, NULL, fix_session_mem_root);
208
173
static sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
209
174
 
210
 
static sys_var_fs_path sys_secure_file_priv("secure_file_priv",
211
 
                                            secure_file_priv);
212
 
 
213
 
static sys_var_const_str_ptr sys_scheduler("scheduler",
214
 
                                           (char**)&opt_scheduler);
215
 
 
216
 
static sys_var_uint32_t_ptr  sys_server_id("server_id", &server_id,
217
 
                                           fix_server_id);
 
175
static sys_var_fs_path sys_secure_file_priv("secure_file_priv", secure_file_priv);
 
176
static sys_var_const_str_ptr sys_scheduler("scheduler", (char**)&opt_scheduler);
 
177
 
 
178
static sys_var_uint32_t_ptr  sys_server_id("server_id", &server_id);
218
179
 
219
180
static sys_var_const_string sys_server_uuid("server_uuid", server_uuid);
220
181
 
221
 
static sys_var_session_size_t   sys_sort_buffer("sort_buffer_size",
222
 
                                                &drizzle_system_variables::sortbuff_size);
223
 
 
224
 
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold",
225
 
                                                                &transaction_message_threshold);
226
 
 
227
 
static sys_var_session_storage_engine sys_storage_engine("storage_engine",
228
 
                                       &drizzle_system_variables::storage_engine);
229
 
static sys_var_size_t_ptr       sys_table_def_size("table_definition_cache",
230
 
                                             &table_def_size);
231
 
static sys_var_uint64_t_ptr     sys_table_cache_size("table_open_cache",
232
 
                                             &table_cache_size);
233
 
static sys_var_uint64_t_ptr     sys_table_lock_wait_timeout("table_lock_wait_timeout",
234
 
                                                    &table_lock_wait_timeout);
 
182
static sys_var_session_size_t   sys_sort_buffer("sort_buffer_size", &drizzle_system_variables::sortbuff_size);
 
183
 
 
184
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold", &transaction_message_threshold);
 
185
 
 
186
static sys_var_session_storage_engine sys_storage_engine("storage_engine", &drizzle_system_variables::storage_engine);
 
187
static sys_var_size_t_ptr       sys_table_def_size("table_definition_cache", &table_def_size);
 
188
static sys_var_uint64_t_ptr     sys_table_cache_size("table_open_cache", &table_cache_size);
 
189
static sys_var_uint64_t_ptr     sys_table_lock_wait_timeout("table_lock_wait_timeout", &table_lock_wait_timeout);
235
190
static sys_var_session_enum     sys_tx_isolation("tx_isolation",
236
191
                                             &drizzle_system_variables::tx_isolation,
237
192
                                             &tx_isolation_typelib,
242
197
static sys_var_bool_ptr  sys_timed_mutexes("timed_mutexes", &internal::timed_mutexes);
243
198
static sys_var_const_str  sys_version("version", version().c_str());
244
199
 
245
 
static sys_var_const_str        sys_version_comment("version_comment",
246
 
                                            COMPILATION_COMMENT);
247
 
static sys_var_const_str        sys_version_compile_machine("version_compile_machine",
248
 
                                                      HOST_CPU);
249
 
static sys_var_const_str        sys_version_compile_os("version_compile_os",
250
 
                                                 HOST_OS);
251
 
static sys_var_const_str        sys_version_compile_vendor("version_compile_vendor",
252
 
                                                 HOST_VENDOR);
 
200
static sys_var_const_str sys_version_comment("version_comment", COMPILATION_COMMENT);
 
201
static sys_var_const_str sys_version_compile_machine("version_compile_machine", HOST_CPU);
 
202
static sys_var_const_str sys_version_compile_os("version_compile_os", HOST_OS);
 
203
static sys_var_const_str sys_version_compile_vendor("version_compile_vendor", HOST_VENDOR);
253
204
 
254
205
/* Variables that are bits in Session */
255
206
 
256
 
sys_var_session_bit sys_autocommit("autocommit", 0,
257
 
                               set_option_autocommit,
258
 
                               OPTION_NOT_AUTOCOMMIT,
259
 
                               1);
260
 
static sys_var_session_bit      sys_big_selects("sql_big_selects", 0,
261
 
                                        set_option_bit,
262
 
                                        OPTION_BIG_SELECTS);
263
 
static sys_var_session_bit      sys_sql_warnings("sql_warnings", 0,
264
 
                                         set_option_bit,
265
 
                                         OPTION_WARNINGS);
266
 
static sys_var_session_bit      sys_sql_notes("sql_notes", 0,
267
 
                                         set_option_bit,
268
 
                                         OPTION_SQL_NOTES);
269
 
static sys_var_session_bit      sys_buffer_results("sql_buffer_result", 0,
270
 
                                           set_option_bit,
271
 
                                           OPTION_BUFFER_RESULT);
272
 
static sys_var_session_bit      sys_foreign_key_checks("foreign_key_checks", 0,
273
 
                                               set_option_bit,
274
 
                                               OPTION_NO_FOREIGN_KEY_CHECKS, 1);
275
 
static sys_var_session_bit      sys_unique_checks("unique_checks", 0,
276
 
                                          set_option_bit,
277
 
                                          OPTION_RELAXED_UNIQUE_CHECKS, 1);
 
207
sys_var_session_bit sys_autocommit("autocommit", 0, set_option_autocommit, OPTION_NOT_AUTOCOMMIT, 1);
 
208
static sys_var_session_bit sys_big_selects("sql_big_selects", 0, set_option_bit, OPTION_BIG_SELECTS);
 
209
static sys_var_session_bit sys_sql_warnings("sql_warnings", 0, set_option_bit, OPTION_WARNINGS);
 
210
static sys_var_session_bit sys_sql_notes("sql_notes", 0, set_option_bit, OPTION_SQL_NOTES);
 
211
static sys_var_session_bit sys_buffer_results("sql_buffer_result", 0, set_option_bit, OPTION_BUFFER_RESULT);
 
212
static sys_var_session_bit sys_foreign_key_checks("foreign_key_checks", 0, set_option_bit, OPTION_NO_FOREIGN_KEY_CHECKS, 1);
 
213
static sys_var_session_bit sys_unique_checks("unique_checks", 0, set_option_bit, OPTION_RELAXED_UNIQUE_CHECKS, 1);
278
214
/* Local state variables */
279
215
 
280
 
static sys_var_session_ha_rows  sys_select_limit("sql_select_limit",
281
 
                                                 &drizzle_system_variables::select_limit);
 
216
static sys_var_session_ha_rows  sys_select_limit("sql_select_limit", &drizzle_system_variables::select_limit);
282
217
static sys_var_timestamp sys_timestamp("timestamp");
283
218
static sys_var_last_insert_id
284
219
sys_last_insert_id("last_insert_id");
302
237
  statement-based logging mode: t will be different on master and
303
238
  slave).
304
239
*/
305
 
static sys_var_readonly sys_error_count("error_count",
306
 
                                        OPT_SESSION,
307
 
                                        SHOW_INT,
308
 
                                        get_error_count);
309
 
static sys_var_readonly sys_warning_count("warning_count",
310
 
                                          OPT_SESSION,
311
 
                                          SHOW_INT,
312
 
                                          get_warning_count);
 
240
static sys_var_readonly sys_error_count("error_count", OPT_SESSION, SHOW_INT, get_error_count);
 
241
static sys_var_readonly sys_warning_count("warning_count", OPT_SESSION, SHOW_INT, get_warning_count);
313
242
 
314
 
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len",
315
 
                                                  &drizzle_system_variables::group_concat_max_len);
 
243
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len", &drizzle_system_variables::group_concat_max_len);
316
244
 
317
245
/* Global read-only variable containing hostname */
318
246
static sys_var_const_string sys_hostname("hostname", getServerHostname());
326
254
{
327
255
  if (check_func)
328
256
  {
329
 
    int res;
330
 
    if ((res=(*check_func)(session, var)) < 0)
 
257
    int res= (*check_func)(session, var);
 
258
    if (res < 0)
331
259
      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
332
260
    return res;
333
261
  }
337
265
 
338
266
bool sys_var_str::check(Session *session, set_var *var)
339
267
{
340
 
  if (!check_func)
 
268
  if (not check_func)
341
269
    return 0;
342
270
 
343
 
  int res;
344
 
  if ((res=(*check_func)(session, var)) < 0)
 
271
  int res= (*check_func)(session, var);
 
272
  if (res < 0)
345
273
    my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
346
274
  return res;
347
275
}
348
276
 
349
277
bool sys_var_std_string::check(Session *session, set_var *var)
350
278
{
351
 
  if (check_func == NULL)
352
 
  {
 
279
  if (not check_func)
353
280
    return false;
354
 
  }
355
281
 
356
 
  int res= (*check_func)(session, var);
357
 
  if (res != 0)
 
282
  if ((*check_func)(session, var))
358
283
  {
359
284
    my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
360
285
    return true;
407
332
    session->session_tx_isolation= (enum_tx_isolation) session->variables.tx_isolation;
408
333
}
409
334
 
410
 
static void fix_completion_type(Session *, sql_var_t) {}
411
 
 
412
335
static int check_completion_type(Session *, set_var *var)
413
336
{
414
337
  int64_t val= var->value->val_int();
429
352
}
430
353
 
431
354
 
432
 
static void fix_server_id(Session *, sql_var_t)
433
 
{
434
 
}
435
 
 
436
355
void throw_bounds_warning(Session *session, bool fixed, bool unsignd, const std::string &name, int64_t val)
437
356
{
438
357
  if (not fixed)