Merge lp:~mordred/drizzle/plugin-use-sys-var into lp:drizzle/7.0

Proposed by Monty Taylor
Status: Merged
Approved by: Brian Aker
Approved revision: no longer in the source branch.
Merged at revision: 1923
Proposed branch: lp:~mordred/drizzle/plugin-use-sys-var
Merge into: lp:drizzle/7.0
Diff against target: 854 lines (+173/-310)
12 files modified
Makefile.am (+0/-2)
drizzled/set_var.cc (+22/-6)
drizzled/sys_var.cc (+12/-5)
drizzled/sys_var.h (+47/-11)
m4/pandora_vc_build.m4 (+1/-0)
plugin/blitzdb/ha_blitz.cc (+11/-19)
plugin/haildb/haildb_engine.cc (+16/-47)
plugin/multi_thread/multi_thread.cc (+5/-28)
plugin/myisam/ha_myisam.cc (+13/-45)
plugin/transaction_log/module.cc (+44/-146)
po/POTFILES.in (+1/-0)
tests/r/variables.result (+1/-1)
To merge this branch: bzr merge lp:~mordred/drizzle/plugin-use-sys-var
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+40478@code.launchpad.net

Description of the change

Migrated several plugins to use sys_var directly.

To post a comment you must log in.
1920. By Patrick Crews

Rollup merge of Andrew's patches

1921. By Patrick Crews

Updated translations

1922. By Brian Aker

Rollup patch around using shared_ptr with Table messages.

1923. By Brian Aker

Merge in changes from Monty for sys var.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2010-10-22 17:58:46 +0000
3+++ Makefile.am 2010-11-11 01:16:06 +0000
4@@ -139,8 +139,6 @@
5 find . -name '*.gcno' | xargs rm -f
6 -rm -rf docs/api docs/dev docs/_build docs/doctrees
7
8-ChangeLog:
9- bzr log --gnu > ChangeLog
10 include config/lint-source.am
11 include config/lcov.am
12
13
14=== modified file 'drizzled/set_var.cc'
15--- drizzled/set_var.cc 2010-10-25 20:36:07 +0000
16+++ drizzled/set_var.cc 2010-11-11 01:16:06 +0000
17@@ -18,6 +18,10 @@
18 */
19
20 #include "config.h"
21+
22+#include <boost/lexical_cast.hpp>
23+#include <string>
24+
25 #include "drizzled/session.h"
26 #include "drizzled/item/string.h"
27 #include "drizzled/sql_list.h"
28@@ -143,12 +147,24 @@
29 */
30 int set_var::update(Session *session)
31 {
32- if (! value)
33- var->set_default(session, type);
34- else if (var->update(session, this))
35- return -1; // should never happen
36- if (var->getAfterUpdateTrigger())
37- (*var->getAfterUpdateTrigger())(session, type);
38+ try
39+ {
40+ if (! value)
41+ var->set_default(session, type);
42+ else if (var->update(session, this))
43+ return -1; // should never happen
44+ if (var->getAfterUpdateTrigger())
45+ (*var->getAfterUpdateTrigger())(session, type);
46+ }
47+ catch (boost::exception &)
48+ {
49+ /* TODO: Fix this to be typesafe once we have properly typed set_var */
50+ string new_val= boost::lexical_cast<string>(save_result.uint32_t_value);
51+ push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
52+ ER_TRUNCATED_WRONG_VALUE,
53+ ER(ER_TRUNCATED_WRONG_VALUE), var->getName().c_str(),
54+ new_val.c_str());
55+ }
56 return 0;
57 }
58
59
60=== modified file 'drizzled/sys_var.cc'
61--- drizzled/sys_var.cc 2010-10-30 23:28:13 +0000
62+++ drizzled/sys_var.cc 2010-11-11 01:16:06 +0000
63@@ -541,11 +541,18 @@
64
65 void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
66 {
67- bool not_used;
68- LOCK_global_system_variables.lock();
69- *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
70- option_limits, &not_used);
71- LOCK_global_system_variables.unlock();
72+ if (have_default_value)
73+ {
74+ *value= default_value;
75+ }
76+ else
77+ {
78+ bool not_used;
79+ LOCK_global_system_variables.lock();
80+ *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
81+ option_limits, &not_used);
82+ LOCK_global_system_variables.unlock();
83+ }
84 }
85
86
87
88=== modified file 'drizzled/sys_var.h'
89--- drizzled/sys_var.h 2010-10-30 23:28:13 +0000
90+++ drizzled/sys_var.h 2010-11-11 01:16:06 +0000
91@@ -94,10 +94,11 @@
92 struct option *option_limits; /**< Updated by by sys_var_init() */
93 bool m_allow_empty_value; /**< Does variable allow an empty value? */
94 public:
95- sys_var(const std::string name_arg, sys_after_update_func func= NULL)
96+ sys_var(const std::string &name_arg, sys_after_update_func func= NULL)
97 :
98 name(name_arg),
99 after_update(func),
100+ option_limits(NULL),
101 m_allow_empty_value(true)
102 {}
103 virtual ~sys_var() {}
104@@ -228,16 +229,50 @@
105 class sys_var_uint64_t_ptr :public sys_var
106 {
107 uint64_t *value;
108+ const uint64_t default_value;
109+ bool have_default_value;
110 public:
111- sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg)
112- :sys_var(name_arg),value(value_ptr_arg)
113- { }
114- sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg,
115- sys_after_update_func func)
116- :sys_var(name_arg,func), value(value_ptr_arg)
117- { }
118+ sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg) :
119+ sys_var(name_arg),
120+ value(value_ptr_arg),
121+ default_value(0),
122+ have_default_value(false)
123+ { }
124+
125+ sys_var_uint64_t_ptr(const char *name_arg,
126+ uint64_t *value_ptr_arg,
127+ const uint64_t default_value_in) :
128+ sys_var(name_arg),
129+ value(value_ptr_arg),
130+ default_value(default_value_in),
131+ have_default_value(true)
132+ { }
133+
134+ sys_var_uint64_t_ptr(const char *name_arg,
135+ uint64_t *value_ptr_arg,
136+ sys_after_update_func func) :
137+ sys_var(name_arg,func),
138+ value(value_ptr_arg),
139+ default_value(0),
140+ have_default_value(false)
141+ { }
142+
143+ sys_var_uint64_t_ptr(const char *name_arg,
144+ uint64_t *value_ptr_arg,
145+ sys_after_update_func func,
146+ const uint64_t default_value_in) :
147+ sys_var(name_arg,func),
148+ value(value_ptr_arg),
149+ default_value(default_value_in),
150+ have_default_value(true)
151+ { }
152+
153 bool update(Session *session, set_var *var);
154 void set_default(Session *session, sql_var_t type);
155+ virtual bool check_default(sql_var_t)
156+ {
157+ return (not have_default_value) && option_limits == 0;
158+ }
159 SHOW_TYPE show_type() { return SHOW_LONGLONG; }
160 unsigned char *value_ptr(Session *, sql_var_t,
161 const LEX_STRING *)
162@@ -266,9 +301,10 @@
163 {
164 public:
165 bool *value;
166- sys_var_bool_ptr(const char *name_arg, bool *value_arg)
167- :sys_var(name_arg),value(value_arg)
168- { }
169+ sys_var_bool_ptr(const std::string &name_arg, bool *value_arg,
170+ sys_after_update_func func= NULL) :
171+ sys_var(name_arg, func), value(value_arg)
172+ { }
173 bool check(Session *session, set_var *var)
174 {
175 return check_enum(session, var, &bool_typelib);
176
177=== modified file 'm4/pandora_vc_build.m4'
178--- m4/pandora_vc_build.m4 2010-04-22 02:46:23 +0000
179+++ m4/pandora_vc_build.m4 2010-11-11 01:16:06 +0000
180@@ -53,6 +53,7 @@
181 PANDORA_VC_REVNO="${PANDORA_BZR_REVNO}"
182 PANDORA_VC_REVID=`bzr log -r-1 --show-ids | grep revision-id | cut -f2 -d' ' | head -1`
183 PANDORA_VC_BRANCH=`bzr nick`
184+ bzr log --gnu > ChangeLog
185 fi
186 fi
187
188
189=== modified file 'plugin/blitzdb/ha_blitz.cc'
190--- plugin/blitzdb/ha_blitz.cc 2010-11-07 04:38:53 +0000
191+++ plugin/blitzdb/ha_blitz.cc 2010-11-11 01:16:06 +0000
192@@ -22,6 +22,7 @@
193
194 using namespace std;
195 using namespace drizzled;
196+namespace po= boost::program_options;
197
198 static pthread_mutex_t blitz_utility_mutex;
199
200@@ -1478,6 +1479,8 @@
201
202 pthread_mutex_init(&blitz_utility_mutex, NULL);
203 context.add(blitz_engine);
204+ context.registerVariable(new sys_var_uint64_t_ptr("estimated-rows",
205+ &blitz_estimated_rows));
206 return 0;
207 }
208
209@@ -1497,22 +1500,11 @@
210 return true;
211 }
212
213-static DRIZZLE_SYSVAR_ULONGLONG (
214- estimated_rows,
215- blitz_estimated_rows,
216- PLUGIN_VAR_RQCMDARG,
217- "Estimated number of rows that a BlitzDB table will store.",
218- NULL,
219- NULL,
220- 0,
221- 0,
222- UINT64_MAX,
223- 0
224-);
225-
226-static drizzle_sys_var *blitz_system_variables[] = {
227- DRIZZLE_SYSVAR(estimated_rows),
228- NULL
229-};
230-
231-DRIZZLE_PLUGIN(blitz_init, blitz_system_variables, NULL);
232+static void blitz_init_options(drizzled::module::option_context &context)
233+{
234+ context("estimated-rows",
235+ po::value<uint64_t>(&blitz_estimated_rows)->default_value(0),
236+ N_("Estimated number of rows that a BlitzDB table will store."));
237+}
238+
239+DRIZZLE_PLUGIN(blitz_init, NULL, blitz_init_options);
240
241=== modified file 'plugin/haildb/haildb_engine.cc'
242--- plugin/haildb/haildb_engine.cc 2010-11-02 17:19:41 +0000
243+++ plugin/haildb/haildb_engine.cc 2010-11-11 01:16:06 +0000
244@@ -2818,11 +2818,8 @@
245 return err;
246 }
247
248-static bool innobase_use_checksums= true;
249-static char* innobase_data_home_dir = NULL;
250 static char* innobase_log_group_home_dir = NULL;
251 static bool innobase_use_doublewrite= true;
252-static unsigned long srv_io_capacity= 200;
253 static unsigned long innobase_fast_shutdown= 1;
254 static bool srv_file_per_table= false;
255 static bool innobase_adaptive_hash_index;
256@@ -2848,6 +2845,10 @@
257 static buffer_pool_constraint innobase_buffer_pool_size;
258 typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
259 static additional_mem_pool_constraint innobase_additional_mem_pool_size;
260+static bool innobase_use_checksums= true;
261+typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
262+static io_capacity_constraint srv_io_capacity;
263+
264 static long innobase_open_files;
265 static long innobase_force_recovery;
266 static long innobase_log_buffer_size;
267@@ -2877,15 +2878,6 @@
268 innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
269 srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
270
271- if (vm.count("io-capacity"))
272- {
273- if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
274- {
275- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
276- return 1;
277- }
278- }
279-
280 if (vm.count("fast-shutdown"))
281 {
282 if (innobase_fast_shutdown > 2)
283@@ -3016,11 +3008,6 @@
284 }
285 }
286
287- if (vm.count("data-home-dir"))
288- {
289- innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
290- }
291-
292 if (vm.count("file-format"))
293 {
294 innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
295@@ -3047,9 +3034,10 @@
296 if (err != DB_SUCCESS)
297 goto haildb_error;
298
299- if (innobase_data_home_dir)
300+
301+ if (vm.count("data-home-dir"))
302 {
303- err= ib_cfg_set_text("data_home_dir", innobase_data_home_dir);
304+ err= ib_cfg_set_text("data_home_dir", vm["data-home-dir"].as<string>().c_str());
305 if (err != DB_SUCCESS)
306 goto haildb_error;
307 }
308@@ -3116,7 +3104,7 @@
309 if (err != DB_SUCCESS)
310 goto haildb_error;
311
312- err= ib_cfg_set_int("io_capacity", srv_io_capacity);
313+ err= ib_cfg_set_int("io_capacity", static_cast<unsigned int>(srv_io_capacity));
314 if (err != DB_SUCCESS)
315 goto haildb_error;
316
317@@ -3214,6 +3202,13 @@
318 context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
319 context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
320 context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
321+ context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
322+ &innobase_use_checksums));
323+ context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
324+ &innobase_use_doublewrite));
325+ context.registerVariable(new sys_var_const_string_val("data_home_dir",
326+ vm.count("data-home-dir") ? vm["data-home-dir"].as<string>() : ""));
327+ context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
328
329 haildb_datadict_dump_func_initialize(context);
330 config_table_function_initialize(context);
331@@ -3344,28 +3339,6 @@
332 innobase_create_status_file= status_file_enabled;
333 }
334
335-static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
336- PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
337- "Enable HailDB checksums validation (enabled by default). "
338- "Disable with --skip-haildb-checksums.",
339- NULL, NULL, true);
340-
341-static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
342- PLUGIN_VAR_READONLY,
343- "The common part for HailDB table spaces.",
344- NULL, NULL, NULL);
345-
346-static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
347- PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
348- "Enable HailDB doublewrite buffer (enabled by default). "
349- "Disable with --skip-haildb-doublewrite.",
350- NULL, NULL, true);
351-
352-static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
353- PLUGIN_VAR_RQCMDARG,
354- "Number of IOPs the server can do. Tunes the background IO rate",
355- NULL, NULL, 200, 100, ~0L, 0);
356-
357 static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
358 PLUGIN_VAR_OPCMDARG,
359 "Speeds up the shutdown process of the HailDB storage engine. Possible "
360@@ -3518,7 +3491,7 @@
361 context("disable-doublewrite",
362 N_("Disable HailDB doublewrite buffer (enabled by default)."));
363 context("io-capacity",
364- po::value<unsigned long>(&srv_io_capacity)->default_value(200),
365+ po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
366 N_("Number of IOPs the server can do. Tunes the background IO rate"));
367 context("fast-shutdown",
368 po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
369@@ -3596,10 +3569,6 @@
370 }
371
372 static drizzle_sys_var* innobase_system_variables[]= {
373- DRIZZLE_SYSVAR(checksums),
374- DRIZZLE_SYSVAR(data_home_dir),
375- DRIZZLE_SYSVAR(doublewrite),
376- DRIZZLE_SYSVAR(io_capacity),
377 DRIZZLE_SYSVAR(fast_shutdown),
378 DRIZZLE_SYSVAR(file_per_table),
379 DRIZZLE_SYSVAR(file_format),
380
381=== modified file 'plugin/multi_thread/multi_thread.cc'
382--- plugin/multi_thread/multi_thread.cc 2010-10-30 20:52:53 +0000
383+++ plugin/multi_thread/multi_thread.cc 2010-11-11 01:16:06 +0000
384@@ -28,10 +28,8 @@
385 using namespace drizzled;
386
387 /* Configuration variables. */
388-static uint32_t max_threads;
389-
390-/* Global's (TBR) */
391-static MultiThreadScheduler *scheduler= NULL;
392+typedef constrained_check<uint32_t, 4096, 1> max_threads_constraint;
393+static max_threads_constraint max_threads;
394
395 namespace drizzled
396 {
397@@ -130,39 +128,18 @@
398 static int init(drizzled::module::Context &context)
399 {
400
401- const module::option_map &vm= context.getOptions();
402- if (vm.count("max-threads"))
403- {
404- if (max_threads > 4096 || max_threads < 1)
405- {
406- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-threads\n"));
407- return 1;
408- }
409- }
410-
411- scheduler= new MultiThreadScheduler("multi_thread");
412- context.add(scheduler);
413+ context.add(new MultiThreadScheduler("multi_thread"));
414
415 return 0;
416 }
417
418-static DRIZZLE_SYSVAR_UINT(max_threads, max_threads,
419- PLUGIN_VAR_RQCMDARG,
420- N_("Maximum number of user threads available."),
421- NULL, NULL, 2048, 1, 4096, 0);
422-
423 static void init_options(drizzled::module::option_context &context)
424 {
425 context("max-threads",
426- po::value<uint32_t>(&max_threads)->default_value(2048),
427+ po::value<max_threads_constraint>(&max_threads)->default_value(2048),
428 N_("Maximum number of user threads available."));
429 }
430
431-static drizzle_sys_var* sys_variables[]= {
432- DRIZZLE_SYSVAR(max_threads),
433- NULL
434-};
435-
436 DRIZZLE_DECLARE_PLUGIN
437 {
438 DRIZZLE_VERSION_ID,
439@@ -172,7 +149,7 @@
440 "One Thread Per Session Scheduler",
441 PLUGIN_LICENSE_GPL,
442 init, /* Plugin Init */
443- sys_variables, /* system variables */
444+ NULL, /* system variables */
445 init_options /* config options */
446 }
447 DRIZZLE_DECLARE_PLUGIN_END;
448
449=== modified file 'plugin/myisam/ha_myisam.cc'
450--- plugin/myisam/ha_myisam.cc 2010-11-08 20:00:45 +0000
451+++ plugin/myisam/ha_myisam.cc 2010-11-11 01:16:06 +0000
452@@ -58,7 +58,8 @@
453 static uint32_t myisam_key_cache_division_limit;
454 static uint32_t myisam_key_cache_age_threshold;
455 static uint64_t max_sort_file_size;
456-static uint64_t sort_buffer_size;
457+typedef constrained_check<size_t, SIZE_MAX, 1024, 1024> sort_buffer_constraint;
458+static sort_buffer_constraint sort_buffer_size;
459
460 void st_mi_isam_share::setKeyCache()
461 {
462@@ -700,7 +701,7 @@
463 param.using_global_keycache = 1;
464 param.session= session;
465 param.out_flag= 0;
466- param.sort_buffer_length= (size_t)sort_buffer_size;
467+ param.sort_buffer_length= static_cast<size_t>(sort_buffer_size);
468 strcpy(fixed_name,file->filename);
469
470 // Don't lock tables if we have used LOCK Table
471@@ -910,7 +911,7 @@
472 param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
473 T_CREATE_MISSING_KEYS);
474 param.myf_rw&= ~MY_WAIT_IF_FULL;
475- param.sort_buffer_length= (size_t)sort_buffer_size;
476+ param.sort_buffer_length= static_cast<size_t>(sort_buffer_size);
477 param.stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
478 if ((error= (repair(session,param,0) != HA_ADMIN_OK)) && param.retry_repair)
479 {
480@@ -1483,63 +1484,30 @@
481 return (uint)file->state->checksum;
482 }
483
484-static MyisamEngine *engine= NULL;
485-
486 static int myisam_init(module::Context &context)
487 {
488- const module::option_map &vm= context.getOptions();
489-
490- if (vm.count("max-sort-file-size"))
491- {
492- if (max_sort_file_size > UINT64_MAX)
493- {
494- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-sort-file-size\n"));
495- exit(-1);
496- }
497- }
498-
499- if (vm.count("sort-buffer-size"))
500- {
501- if (sort_buffer_size < 1024 || sort_buffer_size > SIZE_MAX)
502- {
503- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for sort-buffer-size\n"));
504- exit(-1);
505- }
506- }
507-
508- engine= new MyisamEngine(engine_name);
509- context.add(engine);
510+ context.add(new MyisamEngine(engine_name));
511+ context.registerVariable(new sys_var_constrained_value<size_t>("sort-buffer-size",
512+ sort_buffer_size,
513+ 8196*1024));
514+ context.registerVariable(new sys_var_uint64_t_ptr("max_sort_file_size",
515+ &max_sort_file_size,
516+ context.getOptions()["max-sort-file-size"].as<uint64_t>()));
517
518 return 0;
519 }
520
521
522-static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
523- PLUGIN_VAR_RQCMDARG,
524- N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
525- NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
526-
527-static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
528- PLUGIN_VAR_RQCMDARG,
529- N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
530- NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
531-
532 static void init_options(drizzled::module::option_context &context)
533 {
534 context("max-sort-file-size",
535 po::value<uint64_t>(&max_sort_file_size)->default_value(INT32_MAX),
536 N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."));
537 context("sort-buffer-size",
538- po::value<uint64_t>(&sort_buffer_size)->default_value(8192*1024),
539+ po::value<sort_buffer_constraint>(&sort_buffer_size)->default_value(8192*1024),
540 N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."));
541 }
542
543-static drizzle_sys_var* sys_variables[]= {
544- DRIZZLE_SYSVAR(max_sort_file_size),
545- DRIZZLE_SYSVAR(sort_buffer_size),
546- NULL
547-};
548-
549
550 DRIZZLE_DECLARE_PLUGIN
551 {
552@@ -1550,7 +1518,7 @@
553 "Default engine as of MySQL 3.23 with great performance",
554 PLUGIN_LICENSE_GPL,
555 myisam_init, /* Plugin Init */
556- sys_variables, /* system variables */
557+ NULL, /* system variables */
558 init_options /* config options */
559 }
560 DRIZZLE_DECLARE_PLUGIN_END;
561
562=== modified file 'plugin/transaction_log/module.cc'
563--- plugin/transaction_log/module.cc 2010-10-25 20:36:07 +0000
564+++ plugin/transaction_log/module.cc 2010-11-11 01:16:06 +0000
565@@ -63,7 +63,7 @@
566 static bool sysvar_transaction_log_enabled= false;
567
568 /** Transaction Log plugin system variable - The path to the log file used */
569-static char* sysvar_transaction_log_file= (char *)DEFAULT_LOG_FILE_PATH;
570+static string sysvar_transaction_log_file;
571
572 /**
573 * Transaction Log plugin system variable - A debugging variable to assist
574@@ -83,18 +83,20 @@
575 * TransactionLog::FLUSH_FREQUENCY_EVERY_WRITE == 1 ... sync on every write
576 * TransactionLog::FLUSH_FREQUENCY_EVERY_SECOND == 2 ... sync at most once a second
577 */
578-static uint32_t sysvar_transaction_log_flush_frequency= 0;
579+typedef constrained_check<int, 2, 0> flush_constraint;
580+static flush_constraint sysvar_transaction_log_flush_frequency;
581 /**
582 * Transaction Log plugin system variable - Number of slots to create
583 * for managing write buffers
584 */
585-static uint32_t sysvar_transaction_log_num_write_buffers= 8;
586+typedef constrained_check<uint32_t, 8192, 4> write_buffers_constraint;
587+static write_buffers_constraint sysvar_transaction_log_num_write_buffers;
588 /**
589 * Transaction Log plugin system variable - The name of the replicator plugin
590 * to pair the transaction log's applier with. Defaults to "default"
591 */
592 static const char DEFAULT_USE_REPLICATOR[]= "default";
593-static char *sysvar_transaction_log_use_replicator= (char *)DEFAULT_USE_REPLICATOR;
594+static string sysvar_transaction_log_use_replicator;
595
596 /** DATA_DICTIONARY views */
597 static TransactionLogTool *transaction_log_tool;
598@@ -119,57 +121,47 @@
599 {
600 (void) close(log_file);
601 }
602+}
603
604- /* These get strdup'd below */
605- free(sysvar_transaction_log_file);
606- free(sysvar_transaction_log_use_replicator);
607+static void set_truncate_debug(Session *, sql_var_t)
608+{
609+ if (transaction_log)
610+ {
611+ if (sysvar_transaction_log_truncate_debug)
612+ {
613+ transaction_log->truncate();
614+ transaction_log_index->clear();
615+ sysvar_transaction_log_truncate_debug= false;
616+ }
617+ }
618 }
619
620 static int init(drizzled::module::Context &context)
621 {
622- const module::option_map &vm= context.getOptions();
623-
624- if (vm.count("flush-frequency"))
625- {
626- if (sysvar_transaction_log_flush_frequency > 2)
627- {
628- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for sync-method\n"));
629- exit(-1);
630- }
631- }
632-
633- if (vm.count("num-write-buffers"))
634- {
635- if (sysvar_transaction_log_num_write_buffers < 4 || sysvar_transaction_log_num_write_buffers > 8192)
636- {
637- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for num-write-buffers\n"));
638- exit(-1);
639- }
640- }
641+ context.registerVariable(new sys_var_bool_ptr_readonly("enable",
642+ &sysvar_transaction_log_enabled));
643+ context.registerVariable(new sys_var_bool_ptr("truncate-debug",
644+ &sysvar_transaction_log_truncate_debug,
645+ set_truncate_debug));
646+
647+ context.registerVariable(new sys_var_const_string("file",
648+ sysvar_transaction_log_file));
649+ context.registerVariable(new sys_var_const_string("use-replicator",
650+ sysvar_transaction_log_use_replicator));
651+ context.registerVariable(new sys_var_bool_ptr_readonly("enable-checksum",
652+ &sysvar_transaction_log_checksum_enabled));
653+ context.registerVariable(new sys_var_constrained_value_readonly<int>("flush-frequency", sysvar_transaction_log_flush_frequency));
654+
655+ context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("num-write-buffers",
656+ sysvar_transaction_log_num_write_buffers));
657
658
659 /* Create and initialize the transaction log itself */
660 if (sysvar_transaction_log_enabled)
661 {
662- if (vm.count("file"))
663- {
664- sysvar_transaction_log_file= strdup(vm["file"].as<string>().c_str());
665- }
666- else
667- {
668- sysvar_transaction_log_file= strdup(DEFAULT_LOG_FILE_PATH);
669- }
670
671- if (vm.count("use-replicator"))
672- {
673- sysvar_transaction_log_use_replicator= strdup(vm["use-replicator"].as<string>().c_str());
674- }
675- else
676- {
677- sysvar_transaction_log_use_replicator= strdup(DEFAULT_USE_REPLICATOR);
678- }
679- transaction_log= new (nothrow) TransactionLog(string(sysvar_transaction_log_file),
680- sysvar_transaction_log_flush_frequency,
681+ transaction_log= new (nothrow) TransactionLog(sysvar_transaction_log_file,
682+ static_cast<int>(sysvar_transaction_log_flush_frequency),
683 sysvar_transaction_log_checksum_enabled);
684
685 if (transaction_log == NULL)
686@@ -216,7 +208,7 @@
687 transaction_log_applier= new (nothrow) TransactionLogApplier("transaction_log_applier",
688 transaction_log,
689 transaction_log_index,
690- sysvar_transaction_log_num_write_buffers);
691+ static_cast<uint32_t>(sysvar_transaction_log_num_write_buffers));
692 if (transaction_log_applier == NULL)
693 {
694 char errmsg[STRERROR_MAX];
695@@ -227,8 +219,8 @@
696 }
697 context.add(transaction_log_applier);
698 ReplicationServices &replication_services= ReplicationServices::singleton();
699- string replicator_name(sysvar_transaction_log_use_replicator);
700- replication_services.attachApplier(transaction_log_applier, replicator_name);
701+ replication_services.attachApplier(transaction_log_applier,
702+ sysvar_transaction_log_use_replicator);
703
704 /* Setup DATA_DICTIONARY views */
705
706@@ -259,89 +251,6 @@
707 }
708
709
710-static void set_truncate_debug(Session *,
711- drizzle_sys_var *,
712- void *,
713- const void *save)
714-{
715- /*
716- * The const void * save comes directly from the check function,
717- * which should simply return the result from the set statement.
718- */
719- if (transaction_log)
720- {
721- if (*(bool *)save != false)
722- {
723- transaction_log->truncate();
724- transaction_log_index->clear();
725- }
726- }
727-}
728-
729-static DRIZZLE_SYSVAR_BOOL(enable,
730- sysvar_transaction_log_enabled,
731- PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
732- N_("Enable transaction log"),
733- NULL, /* check func */
734- NULL, /* update func */
735- false /* default */);
736-
737-static DRIZZLE_SYSVAR_BOOL(truncate_debug,
738- sysvar_transaction_log_truncate_debug,
739- PLUGIN_VAR_NOCMDARG,
740- N_("DEBUGGING - Truncate transaction log"),
741- NULL, /* check func */
742- set_truncate_debug, /* update func */
743- false /* default */);
744-
745-static DRIZZLE_SYSVAR_STR(file,
746- sysvar_transaction_log_file,
747- PLUGIN_VAR_READONLY,
748- N_("Path to the file to use for transaction log"),
749- NULL, /* check func */
750- NULL, /* update func*/
751- DEFAULT_LOG_FILE_PATH /* default */);
752-
753-static DRIZZLE_SYSVAR_STR(use_replicator,
754- sysvar_transaction_log_use_replicator,
755- PLUGIN_VAR_READONLY,
756- N_("Name of the replicator plugin to use (default='default_replicator')"),
757- NULL, /* check func */
758- NULL, /* update func*/
759- DEFAULT_USE_REPLICATOR /* default */);
760-
761-static DRIZZLE_SYSVAR_BOOL(enable_checksum,
762- sysvar_transaction_log_checksum_enabled,
763- PLUGIN_VAR_NOCMDARG,
764- N_("Enable CRC32 Checksumming of each written transaction log entry"),
765- NULL, /* check func */
766- NULL, /* update func */
767- false /* default */);
768-
769-static DRIZZLE_SYSVAR_UINT(flush_frequency,
770- sysvar_transaction_log_flush_frequency,
771- PLUGIN_VAR_OPCMDARG,
772- N_("0 == rely on operating system to sync log file (default), "
773- "1 == sync file at each transaction write, "
774- "2 == sync log file once per second"),
775- NULL, /* check func */
776- NULL, /* update func */
777- 0, /* default */
778- 0,
779- 2,
780- 0);
781-
782-static DRIZZLE_SYSVAR_UINT(num_write_buffers,
783- sysvar_transaction_log_num_write_buffers,
784- PLUGIN_VAR_OPCMDARG,
785- N_("Number of slots for in-memory write buffers (default=8)."),
786- NULL, /* check func */
787- NULL, /* update func */
788- 8, /* default */
789- 4,
790- 8192,
791- 0);
792-
793 static void init_options(drizzled::module::option_context &context)
794 {
795 context("truncate-debug",
796@@ -354,28 +263,17 @@
797 po::value<bool>(&sysvar_transaction_log_enabled)->default_value(false)->zero_tokens(),
798 N_("Enable transaction log"));
799 context("file",
800- po::value<string>(),
801+ po::value<string>(&sysvar_transaction_log_file)->default_value(DEFAULT_LOG_FILE_PATH),
802 N_("Path to the file to use for transaction log"));
803 context("use-replicator",
804- po::value<string>(),
805+ po::value<string>(&sysvar_transaction_log_use_replicator)->default_value(DEFAULT_USE_REPLICATOR),
806 N_("Name of the replicator plugin to use (default='default_replicator')"));
807 context("flush-frequency",
808- po::value<uint32_t>(&sysvar_transaction_log_flush_frequency)->default_value(0),
809+ po::value<flush_constraint>(&sysvar_transaction_log_flush_frequency)->default_value(0),
810 N_("0 == rely on operating system to sync log file (default), 1 == sync file at each transaction write, 2 == sync log file once per second"));
811 context("num-write-buffers",
812- po::value<uint32_t>(&sysvar_transaction_log_num_write_buffers)->default_value(8),
813+ po::value<write_buffers_constraint>(&sysvar_transaction_log_num_write_buffers)->default_value(8),
814 N_("Number of slots for in-memory write buffers (default=8)."));
815 }
816
817-static drizzle_sys_var* sys_variables[]= {
818- DRIZZLE_SYSVAR(enable),
819- DRIZZLE_SYSVAR(truncate_debug),
820- DRIZZLE_SYSVAR(file),
821- DRIZZLE_SYSVAR(enable_checksum),
822- DRIZZLE_SYSVAR(flush_frequency),
823- DRIZZLE_SYSVAR(num_write_buffers),
824- DRIZZLE_SYSVAR(use_replicator),
825- NULL
826-};
827-
828-DRIZZLE_PLUGIN(init, sys_variables, init_options);
829+DRIZZLE_PLUGIN(init, NULL, init_options);
830
831=== modified file 'po/POTFILES.in'
832--- po/POTFILES.in 2010-11-07 06:50:21 +0000
833+++ po/POTFILES.in 2010-11-11 01:16:06 +0000
834@@ -57,6 +57,7 @@
835 plugin/auth_http/auth_http.cc
836 plugin/auth_ldap/auth_ldap.cc
837 plugin/blitzdb/ha_blitz.h
838+plugin/blitzdb/ha_blitz.cc
839 plugin/console/console.cc
840 plugin/default_replicator/default_replicator.cc
841 plugin/drizzle_protocol/drizzle_protocol.cc
842
843=== modified file 'tests/r/variables.result'
844--- tests/r/variables.result 2010-09-02 18:35:05 +0000
845+++ tests/r/variables.result 2010-11-11 01:16:06 +0000
846@@ -295,7 +295,7 @@
847 set global max_write_lock_count=100;
848 set global myisam_sort_buffer_size=100;
849 Warnings:
850-Error 1292 Truncated incorrect sort_buffer_size value: '100'
851+Error 1292 Truncated incorrect myisam_sort_buffer_size value: '100'
852 set global mysql_protocol_buffer_length=100;
853 Warnings:
854 Error 1292 Truncated incorrect buffer_length value: '100'

Subscribers

People subscribed via source and target branches