Merge lp:~mordred/drizzle/bug675670 into lp:drizzle/7.0

Proposed by Monty Taylor
Status: Merged
Approved by: Monty Taylor
Approved revision: no longer in the source branch.
Merged at revision: 1946
Proposed branch: lp:~mordred/drizzle/bug675670
Merge into: lp:drizzle/7.0
Diff against target: 994 lines (+286/-256)
11 files modified
drizzled/constrained_value.h (+52/-1)
drizzled/sys_var.cc (+16/-0)
drizzled/sys_var.h (+57/-0)
plugin/auth_http/auth_http.cc (+22/-39)
plugin/haildb/haildb_engine.cc (+52/-158)
plugin/haildb/tests/r/config_file_format.result (+1/-1)
plugin/haildb/tests/t/config_file_format.test (+1/-1)
plugin/mysql_unix_socket_protocol/protocol.cc (+58/-31)
plugin/mysql_unix_socket_protocol/protocol.h (+8/-2)
tests/lib/dtr_process.pl (+11/-7)
tests/test-run.pl (+8/-16)
To merge this branch: bzr merge lp:~mordred/drizzle/bug675670
Reviewer Review Type Date Requested Status
Lee Bieber (community) Needs Fixing
Review via email: mp+41270@code.launchpad.net

Description of the change

Modifies Brian's branch a bit to add an option for clobbering existing socket files which is off by default.

To post a comment you must log in.
lp:~mordred/drizzle/bug675670 updated
1940. By Brian Aker

Rollup merge for barrier patch

1941. By Brian Aker

Merge in Monty

1942. By Lee Bieber

Merge Billy - removed my_getsysdate, my_micro_time and my_micro_time_and_time and replaced with boost::date_time for compatibility.

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

distcheck targets are failing

review: Needs Fixing
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :
lp:~mordred/drizzle/bug675670 updated
1943. By Lee Bieber

Merge Lee - Run bzr ignore for leftover files
Merge Shrews - Add a --replicate-query option to the server which controls whether or not the SQL query string is included in the GPB Statement messages.
Merge Andrew - fix bug 665119: drizzleslap has -i mapped to two options
Merge Andrew fix bug 674145: Table Names Not Case Matched

1944. By Lee Bieber

Merge Brian - refactor share

1945. By Brian Aker

Merge in simple change such that we use the KEY we already have, instead of
recalculating one.

Revision history for this message
Monty Taylor (mordred) wrote :

This is all working for me in param-build.

lp:~mordred/drizzle/bug675670 updated
1953. By Monty Taylor

We were overrunning the buffer everywhere, but glibc on ubuntu was
notificing for us.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/constrained_value.h'
2--- drizzled/constrained_value.h 2010-11-09 21:48:09 +0000
3+++ drizzled/constrained_value.h 2010-11-23 02:58:45 +0000
4@@ -93,6 +93,57 @@
5 }
6 };
7
8+namespace
9+{
10+template<class T, T min_val>
11+bool less_than_min(T val_to_check)
12+{
13+ return val_to_check < min_val;
14+}
15+
16+template<>
17+inline bool less_than_min<uint16_t, 0>(uint16_t)
18+{
19+ return false;
20+}
21+
22+template<>
23+inline bool less_than_min<uint32_t, 0>(uint32_t)
24+{
25+ return false;
26+}
27+
28+template<>
29+inline bool less_than_min<uint64_t, 0>(uint64_t)
30+{
31+ return false;
32+}
33+
34+template<class T, T min_val>
35+bool greater_than_max(T val_to_check)
36+{
37+ return val_to_check > min_val;
38+}
39+
40+template<>
41+inline bool greater_than_max<uint16_t, UINT16_MAX>(uint16_t)
42+{
43+ return false;
44+}
45+
46+template<>
47+inline bool greater_than_max<uint32_t, UINT32_MAX>(uint32_t)
48+{
49+ return false;
50+}
51+
52+template<>
53+inline bool greater_than_max<uint64_t, UINT64_MAX>(uint64_t)
54+{
55+ return false;
56+}
57+}
58+
59 template<class T,
60 T MAXVAL,
61 T MINVAL, unsigned int ALIGN= 1>
62@@ -112,7 +163,7 @@
63
64 constrained_value<T>& set_value(T rhs)
65 {
66- if ((rhs > MAXVAL) || (rhs < MINVAL))
67+ if (greater_than_max<T,MAXVAL>(rhs) || less_than_min<T,MINVAL>(rhs))
68 {
69 boost::throw_exception(boost::program_options::invalid_option_value(boost::lexical_cast<std::string>(rhs)));
70 }
71
72=== modified file 'drizzled/sys_var.cc'
73--- drizzled/sys_var.cc 2010-11-19 15:23:07 +0000
74+++ drizzled/sys_var.cc 2010-11-23 02:58:45 +0000
75@@ -338,6 +338,22 @@
76 return res;
77 }
78
79+bool sys_var_std_string::check(Session *session, set_var *var)
80+{
81+ if (check_func == NULL)
82+ {
83+ return false;
84+ }
85+
86+ int res= (*check_func)(session, var);
87+ if (res != 0)
88+ {
89+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
90+ return true;
91+ }
92+ return false;
93+}
94+
95 /*
96 Functions to check and update variables
97 */
98
99=== modified file 'drizzled/sys_var.h'
100--- drizzled/sys_var.h 2010-11-09 21:50:25 +0000
101+++ drizzled/sys_var.h 2010-11-23 02:58:45 +0000
102@@ -519,6 +519,63 @@
103 }
104 };
105
106+class sys_var_std_string :
107+ public sys_var
108+{
109+ std::string &value;
110+ sys_check_func check_func;
111+ sys_update_func update_func;
112+ sys_set_default_func set_default_func;
113+public:
114+ sys_var_std_string(const std::string &name_arg,
115+ std::string &value_arg,
116+ sys_check_func check_func_arg= NULL,
117+ sys_update_func update_func_arg= NULL) :
118+ sys_var(name_arg),
119+ value(value_arg),
120+ check_func(check_func_arg),
121+ update_func(update_func_arg)
122+ { }
123+
124+ inline void set(char *val_in)
125+ {
126+ value= val_in;
127+ }
128+
129+ void set_check_func(sys_check_func check_func_arg= NULL)
130+ {
131+ check_func= check_func_arg;
132+ }
133+
134+ void set_update_func(sys_update_func update_func_arg= NULL)
135+ {
136+ update_func= update_func_arg;
137+ }
138+
139+ bool check(Session *session, set_var *var);
140+
141+ bool update(Session *session, set_var *var)
142+ {
143+ if (update_func != NULL)
144+ {
145+ return (*update_func)(session, var);
146+ }
147+ return false;
148+ }
149+ SHOW_TYPE show_type() { return SHOW_CHAR; }
150+ unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
151+ {
152+ return (unsigned char*)(value.c_str());
153+ }
154+ bool check_update_type(Item_result type)
155+ {
156+ return type != STRING_RESULT; /* Only accept strings */
157+ }
158+ bool check_default(sql_var_t)
159+ { return true; }
160+ bool is_readonly() const { return false; }
161+};
162+
163 class sys_var_const_string :
164 public sys_var
165 {
166
167=== modified file 'plugin/auth_http/auth_http.cc'
168--- plugin/auth_http/auth_http.cc 2010-07-16 09:26:33 +0000
169+++ plugin/auth_http/auth_http.cc 2010-11-23 02:58:45 +0000
170@@ -32,9 +32,6 @@
171 using namespace drizzled;
172 using namespace std;
173
174-static bool sysvar_auth_http_enable;
175-static char* sysvar_auth_http_url= NULL;
176-
177 static size_t curl_cb_read(void *ptr, size_t size, size_t nmemb, void *stream)
178 {
179 (void) ptr;
180@@ -47,9 +44,11 @@
181 {
182 CURLcode rv;
183 CURL *curl_handle;
184+ const std::string auth_url;
185 public:
186- Auth_http(std::string name_arg)
187- : drizzled::plugin::Authentication(name_arg)
188+ Auth_http(std::string name_arg, const std::string &url_arg) :
189+ drizzled::plugin::Authentication(name_arg),
190+ auth_url(url_arg)
191 {
192 // we are trusting that plugin initializers are called singlethreaded at startup
193 // if something else also calls curl_global_init() in a threadrace while we are here,
194@@ -78,14 +77,10 @@
195 {
196 long http_response_code;
197
198- if (sysvar_auth_http_enable == false)
199- return true;
200-
201 assert(sctx.getUser().c_str());
202
203-
204 // set the parameters: url, username, password
205- rv= curl_easy_setopt(curl_handle, CURLOPT_URL, sysvar_auth_http_url);
206+ rv= curl_easy_setopt(curl_handle, CURLOPT_URL, auth_url.c_str());
207 #if defined(HAVE_CURLOPT_USERNAME)
208
209 rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME,
210@@ -123,6 +118,8 @@
211
212 static int initialize(drizzled::module::Context &context)
213 {
214+ const module::option_map &vm= context.getOptions();
215+
216 /*
217 * Per libcurl manual, in multi-threaded applications, curl_global_init() should
218 * be called *before* curl_easy_init()...which is called in Auto_http's
219@@ -131,43 +128,29 @@
220 if (curl_global_init(CURL_GLOBAL_NOTHING) != 0)
221 return 1;
222
223- auth= new Auth_http("auth_http");
224+ const string auth_url(vm["url"].as<string>());
225+ if (auth_url.size() == 0)
226+ {
227+ errmsg_printf(ERRMSG_LVL_ERROR,
228+ _("auth_http plugin loaded but required option url not "
229+ "specified. Against which URL are you intending on "
230+ "authenticating?\n"));
231+ return 1;
232+ }
233+
234+ auth= new Auth_http("auth_http", auth_url);
235 context.add(auth);
236+ context.registerVariable(new sys_var_const_string_val("url", auth_url));
237
238 return 0;
239 }
240
241 static void init_options(drizzled::module::option_context &context)
242 {
243- context("enable", po::value<bool>(&sysvar_auth_http_enable)->default_value(false)->zero_tokens(),
244- N_("Enable HTTP Auth check"));
245+ context("url", po::value<string>()->default_value(""),
246+ N_("URL for HTTP Auth check"));
247 }
248
249-static DRIZZLE_SYSVAR_BOOL(
250- enable,
251- sysvar_auth_http_enable,
252- PLUGIN_VAR_NOCMDARG,
253- N_("Enable HTTP Auth check"),
254- NULL, /* check func */
255- NULL, /* update func */
256- false /* default */);
257-
258-
259-static DRIZZLE_SYSVAR_STR(
260- url,
261- sysvar_auth_http_url,
262- PLUGIN_VAR_READONLY,
263- N_("URL for HTTP Auth check"),
264- NULL, /* check func */
265- NULL, /* update func*/
266- "http://localhost/" /* default */);
267-
268-static drizzle_sys_var* auth_http_system_variables[]= {
269- DRIZZLE_SYSVAR(enable),
270- DRIZZLE_SYSVAR(url),
271- NULL
272-};
273-
274
275 DRIZZLE_DECLARE_PLUGIN
276 {
277@@ -178,7 +161,7 @@
278 "HTTP based authenication.",
279 PLUGIN_LICENSE_GPL,
280 initialize, /* Plugin Init */
281- auth_http_system_variables,
282+ NULL,
283 init_options /* config options */
284 }
285 DRIZZLE_DECLARE_PLUGIN_END;
286
287=== modified file 'plugin/haildb/haildb_engine.cc'
288--- plugin/haildb/haildb_engine.cc 2010-11-12 01:10:48 +0000
289+++ plugin/haildb/haildb_engine.cc 2010-11-23 02:58:45 +0000
290@@ -2818,9 +2818,7 @@
291 return err;
292 }
293
294-static char* innobase_log_group_home_dir = NULL;
295 static bool innobase_use_doublewrite= true;
296-static unsigned long innobase_fast_shutdown= 1;
297 static bool srv_file_per_table= false;
298 static bool innobase_adaptive_hash_index;
299 static bool srv_adaptive_flushing;
300@@ -2828,9 +2826,7 @@
301 static bool innobase_rollback_on_timeout;
302 static bool innobase_create_status_file;
303 static bool srv_use_sys_malloc;
304-static char* innobase_file_format_name = const_cast<char *>("Barracuda");
305-static char* innobase_unix_file_flush_method = NULL;
306-static unsigned long srv_flush_log_at_trx_commit;
307+static string innobase_file_format_name;
308 static unsigned long srv_max_buf_pool_modified_pct;
309 static unsigned long srv_max_purge_lag;
310 static unsigned long innobase_lru_old_blocks_pct;
311@@ -2847,10 +2843,14 @@
312 static additional_mem_pool_constraint innobase_additional_mem_pool_size;
313 static bool innobase_use_checksums= true;
314 typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
315+typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
316+static trinary_constraint innobase_fast_shutdown;
317+static trinary_constraint srv_flush_log_at_trx_commit;
318+typedef constrained_check<uint16_t, 6, 0> force_recovery_constraint;
319+static force_recovery_constraint innobase_force_recovery;
320 static io_capacity_constraint srv_io_capacity;
321
322 static long innobase_open_files;
323-static long innobase_force_recovery;
324 static long innobase_log_buffer_size;
325 static char default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
326 static char* haildb_data_file_path= NULL;
327@@ -2858,6 +2858,24 @@
328 static int64_t haildb_log_file_size;
329 static int64_t haildb_log_files_in_group;
330
331+static int haildb_file_format_name_validate(Session*, set_var *var)
332+{
333+
334+ const char *format= var->value->str_value.ptr();
335+ if (format == NULL)
336+ return 1;
337+
338+ ib_err_t err= ib_cfg_set_text("file_format", format);
339+
340+ if (err == DB_SUCCESS)
341+ {
342+ innobase_file_format_name= format;
343+ return 0;
344+ }
345+ else
346+ return 1;
347+}
348+
349 static int haildb_init(drizzled::module::Context &context)
350 {
351 haildb_system_table_names.insert(std::string("HAILDB_SYS_TABLES"));
352@@ -2878,33 +2896,6 @@
353 innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
354 srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
355
356- if (vm.count("fast-shutdown"))
357- {
358- if (innobase_fast_shutdown > 2)
359- {
360- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
361- return 1;
362- }
363- }
364-
365- if (vm.count("flush-log-at-trx-commit"))
366- {
367- if (srv_flush_log_at_trx_commit > 2)
368- {
369- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
370- return 1;
371- }
372- }
373-
374- if (vm.count("force-recovery"))
375- {
376- if (innobase_force_recovery > 6)
377- {
378- errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
379- return 1;
380- }
381- }
382-
383 if (vm.count("log-file-size"))
384 {
385 if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
386@@ -3008,21 +2999,6 @@
387 }
388 }
389
390- if (vm.count("file-format"))
391- {
392- innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
393- }
394-
395- if (vm.count("log-group-home-dir"))
396- {
397- innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());
398- }
399-
400- if (vm.count("flush-method"))
401- {
402- innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
403- }
404-
405 if (vm.count("data-file-path"))
406 {
407 haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
408@@ -3042,9 +3018,9 @@
409 goto haildb_error;
410 }
411
412- if (innobase_log_group_home_dir)
413+ if (vm.count("log-group-home-dir"))
414 {
415- err= ib_cfg_set_text("log_group_home_dir", innobase_log_group_home_dir);
416+ err= ib_cfg_set_text("log_group_home_dir", vm["log-group-home-dir"].as<string>().c_str());
417 if (err != DB_SUCCESS)
418 goto haildb_error;
419 }
420@@ -3116,18 +3092,21 @@
421 if (err != DB_SUCCESS)
422 goto haildb_error;
423
424- err= ib_cfg_set_int("flush_log_at_trx_commit", srv_flush_log_at_trx_commit);
425+ err= ib_cfg_set_int("flush_log_at_trx_commit",
426+ static_cast<uint16_t>(srv_flush_log_at_trx_commit));
427 if (err != DB_SUCCESS)
428 goto haildb_error;
429
430- if (innobase_unix_file_flush_method)
431+ if (vm.count("flush-method") != 0)
432 {
433- err= ib_cfg_set_text("flush_method", innobase_unix_file_flush_method);
434+ err= ib_cfg_set_text("flush_method",
435+ vm["flush-method"].as<string>().c_str());
436 if (err != DB_SUCCESS)
437 goto haildb_error;
438 }
439
440- err= ib_cfg_set_int("force_recovery", innobase_force_recovery);
441+ err= ib_cfg_set_int("force_recovery",
442+ static_cast<uint16_t>(innobase_force_recovery));
443 if (err != DB_SUCCESS)
444 goto haildb_error;
445
446@@ -3187,7 +3166,7 @@
447 if (err != DB_SUCCESS)
448 goto haildb_error;
449
450- err= ib_startup(innobase_file_format_name);
451+ err= ib_startup(innobase_file_format_name.c_str());
452 if (err != DB_SUCCESS)
453 goto haildb_error;
454
455@@ -3209,6 +3188,18 @@
456 context.registerVariable(new sys_var_const_string_val("data_home_dir",
457 vm.count("data-home-dir") ? vm["data-home-dir"].as<string>() : ""));
458 context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
459+ context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("fast_shutdown", innobase_fast_shutdown));
460+ context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
461+ &srv_file_per_table));
462+ context.registerVariable(new sys_var_std_string("file-format",
463+ innobase_file_format_name,
464+ haildb_file_format_name_validate));
465+ context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
466+ context.registerVariable(new sys_var_const_string_val("flush_method",
467+ vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
468+ context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("force_recovery", innobase_force_recovery));
469+ context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
470+ vm.count("log-group-home-dir") ? vm["log-group-home-dir"].as<string>() : ""));
471
472 haildb_datadict_dump_func_initialize(context);
473 config_table_function_initialize(context);
474@@ -3227,9 +3218,9 @@
475 ib_err_t err;
476 ib_shutdown_t shutdown_flag= IB_SHUTDOWN_NORMAL;
477
478- if (innobase_fast_shutdown == 1)
479+ if (static_cast<unsigned int>(innobase_fast_shutdown) == 1)
480 shutdown_flag= IB_SHUTDOWN_NO_IBUFMERGE_PURGE;
481- else if (innobase_fast_shutdown == 2)
482+ else if (static_cast<unsigned int>(innobase_fast_shutdown) == 2)
483 shutdown_flag= IB_SHUTDOWN_NO_BUFPOOL_FLUSH;
484
485 err= ib_shutdown(shutdown_flag);
486@@ -3241,54 +3232,6 @@
487
488 }
489
490-static char haildb_file_format_name_storage[100];
491-
492-static int haildb_file_format_name_validate(Session*, drizzle_sys_var*,
493- void *save,
494- drizzle_value *value)
495-{
496- ib_err_t err;
497- char buff[100];
498- int len= sizeof(buff);
499- const char *format= value->val_str(value, buff, &len);
500-
501- *static_cast<const char**>(save)= NULL;
502-
503- if (format == NULL)
504- return 1;
505-
506- err= ib_cfg_set_text("file_format", format);
507-
508- if (err == DB_SUCCESS)
509- {
510- strncpy(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
511- haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
512-
513- *static_cast<const char**>(save)= haildb_file_format_name_storage;
514- return 0;
515- }
516- else
517- return 1;
518-}
519-
520-static void haildb_file_format_name_update(Session*, drizzle_sys_var*,
521- void *var_ptr,
522- const void *save)
523-
524-{
525- const char* format;
526-
527- assert(var_ptr != NULL);
528- assert(save != NULL);
529-
530- format= *static_cast<const char*const*>(save);
531-
532- /* Format is already set in validate */
533- memmove(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
534- haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
535-
536- *static_cast<const char**>(var_ptr)= haildb_file_format_name_storage;
537-}
538
539 static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
540 void *,
541@@ -3339,50 +3282,11 @@
542 innobase_create_status_file= status_file_enabled;
543 }
544
545-static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
546- PLUGIN_VAR_OPCMDARG,
547- "Speeds up the shutdown process of the HailDB storage engine. Possible "
548- "values are 0, 1 (faster)"
549- " or 2 (fastest - crash-like)"
550- ".",
551- NULL, NULL, 1, 0, 2, 0);
552-
553-static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
554- PLUGIN_VAR_NOCMDARG,
555- "Stores each HailDB table to an .ibd file in the database dir.",
556- NULL, NULL, false);
557-
558-static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
559- PLUGIN_VAR_RQCMDARG,
560- "File format to use for new tables in .ibd files.",
561- haildb_file_format_name_validate,
562- haildb_file_format_name_update, "Barracuda");
563-
564-static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
565- PLUGIN_VAR_OPCMDARG,
566- "Set to 0 (write and flush once per second),"
567- " 1 (write and flush at each commit)"
568- " or 2 (write at commit, flush once per second).",
569- NULL, NULL, 1, 0, 2, 0);
570-
571-static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
572- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
573- "With which method to flush data.", NULL, NULL, NULL);
574-
575-static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
576- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
577- "Helps to save your data in case the disk image of the database becomes corrupt.",
578- NULL, NULL, 0, 0, 6, 0);
579-
580 static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
581 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
582 "Path to individual files and their sizes.",
583 NULL, NULL, NULL);
584
585-static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
586- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
587- "Path to HailDB log files.", NULL, NULL, NULL);
588-
589 static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
590 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
591 "Size of each log file in a log group.",
592@@ -3494,31 +3398,28 @@
593 po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
594 N_("Number of IOPs the server can do. Tunes the background IO rate"));
595 context("fast-shutdown",
596- po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
597+ po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
598 N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
599 context("file-per-table",
600 po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
601 N_("Stores each HailDB table to an .ibd file in the database dir."));
602 context("file-format",
603- po::value<string>(),
604+ po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
605 N_("File format to use for new tables in .ibd files."));
606 context("flush-log-at-trx-commit",
607- po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
608+ po::value<trinary_constraint>(&srv_flush_log_at_trx_commit)->default_value(1),
609 N_("Set to 0 (write and flush once per second),1 (write and flush at each commit) or 2 (write at commit, flush once per second)."));
610 context("flush-method",
611 po::value<string>(),
612 N_("With which method to flush data."));
613 context("force-recovery",
614- po::value<long>(&innobase_force_recovery)->default_value(0),
615+ po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
616 N_("Helps to save your data in case the disk image of the database becomes corrupt."));
617 context("data-file-path",
618 po::value<string>(),
619 N_("Path to individual files and their sizes."));
620 context("log-group-home-dir",
621 po::value<string>(),
622- N_("Path to individual files and their sizes."));
623- context("log-group-home-dir",
624- po::value<string>(),
625 N_("Path to HailDB log files."));
626 context("log-file-size",
627 po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
628@@ -3569,13 +3470,6 @@
629 }
630
631 static drizzle_sys_var* innobase_system_variables[]= {
632- DRIZZLE_SYSVAR(fast_shutdown),
633- DRIZZLE_SYSVAR(file_per_table),
634- DRIZZLE_SYSVAR(file_format),
635- DRIZZLE_SYSVAR(flush_log_at_trx_commit),
636- DRIZZLE_SYSVAR(flush_method),
637- DRIZZLE_SYSVAR(force_recovery),
638- DRIZZLE_SYSVAR(log_group_home_dir),
639 DRIZZLE_SYSVAR(data_file_path),
640 DRIZZLE_SYSVAR(lock_wait_timeout),
641 DRIZZLE_SYSVAR(log_file_size),
642
643=== modified file 'plugin/haildb/tests/r/config_file_format.result'
644--- plugin/haildb/tests/r/config_file_format.result 2010-09-23 06:31:07 +0000
645+++ plugin/haildb/tests/r/config_file_format.result 2010-11-23 02:58:45 +0000
646@@ -19,7 +19,7 @@
647 NAME TYPE VALUE
648 file_format TEXT Barracuda
649 SET GLOBAL innodb_file_format='broccolini';
650-ERROR HY000: Incorrect arguments to SET
651+ERROR 42000: Variable 'innodb_file_format' can't be set to the value of 'broccolini'
652 SHOW VARIABLES LIKE 'innodb_file_format';
653 Variable_name Value
654 innodb_file_format barracuda
655
656=== modified file 'plugin/haildb/tests/t/config_file_format.test'
657--- plugin/haildb/tests/t/config_file_format.test 2010-09-23 06:31:07 +0000
658+++ plugin/haildb/tests/t/config_file_format.test 2010-11-23 02:58:45 +0000
659@@ -6,7 +6,7 @@
660 SET GLOBAL innodb_file_format='barracuda';
661 SHOW VARIABLES LIKE 'innodb_file_format';
662 SELECT * FROM DATA_DICTIONARY.HAILDB_CONFIGURATION WHERE NAME='file_format';
663---error ER_WRONG_ARGUMENTS
664+--error ER_WRONG_VALUE_FOR_VAR
665 SET GLOBAL innodb_file_format='broccolini';
666 SHOW VARIABLES LIKE 'innodb_file_format';
667 SELECT * FROM DATA_DICTIONARY.HAILDB_CONFIGURATION WHERE NAME='file_format';
668
669=== modified file 'plugin/mysql_unix_socket_protocol/protocol.cc'
670--- plugin/mysql_unix_socket_protocol/protocol.cc 2010-10-29 18:10:56 +0000
671+++ plugin/mysql_unix_socket_protocol/protocol.cc 2010-11-23 02:58:45 +0000
672@@ -30,6 +30,7 @@
673 #include <algorithm>
674 #include <iostream>
675 #include <boost/program_options.hpp>
676+#include <boost/filesystem.hpp>
677 #include <drizzled/module/option_map.h>
678
679 #include <sys/un.h>
680@@ -38,22 +39,24 @@
681
682 #define DRIZZLE_UNIX_SOCKET_PATH "/tmp/mysql.socket"
683
684-static std::string unix_socket_path(DRIZZLE_UNIX_SOCKET_PATH);
685-
686 namespace po= boost::program_options;
687+namespace fs= boost::filesystem;
688 using namespace drizzled;
689 using namespace std;
690
691 namespace mysql_unix_socket_protocol
692 {
693
694+static bool clobber= false;
695+
696 Protocol::~Protocol()
697 {
698+ fs::remove(unix_socket_path);
699 }
700
701 const char* Protocol::getHost(void) const
702 {
703- return DRIZZLE_UNIX_SOCKET_PATH;
704+ return unix_socket_path.file_string().c_str();
705 }
706
707 in_port_t Protocol::getPort(void) const
708@@ -65,21 +68,28 @@
709 {
710 const module::option_map &vm= context.getOptions();
711
712- if (vm.count("path"))
713- {
714- unix_socket_path.clear();
715- unix_socket_path.append(vm["path"].as<string>());
716- }
717-
718- context.add(new Protocol("mysql_unix_socket_protocol", true));
719+ fs::path uds_path(vm["path"].as<fs::path>());
720+ if (not fs::exists(uds_path))
721+ {
722+ context.add(new Protocol("mysql_unix_socket_protocol",
723+ true,
724+ uds_path));
725+ context.registerVariable(new sys_var_const_string_val("path", fs::system_complete(uds_path).file_string()));
726+ context.registerVariable(new sys_var_bool_ptr_readonly("clobber", &clobber));
727+ }
728+ else
729+ {
730+ cerr << uds_path << _(" exists already. Do you have another Drizzle or "
731+ "MySQL running? Or perhaps the file is stale and "
732+ "should be removed?") << std::endl;
733+ return 0;
734+ }
735
736 return 0;
737 }
738
739 bool Protocol::getFileDescriptors(std::vector<int> &fds)
740 {
741- struct sockaddr_un servAddr;
742- socklen_t addrlen;
743 int unix_sock;
744
745 if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
746@@ -88,34 +98,52 @@
747 return false;
748 }
749
750+ // In case we restart and find something in our way we move it aside and
751+ // then attempt to remove it.
752+ if (clobber)
753+ {
754+ fs::path move_file(unix_socket_path.file_string() + ".old");
755+ fs::rename(unix_socket_path, move_file);
756+ unlink(move_file.file_string().c_str());
757+ }
758+
759+
760+ int arg= 1;
761+
762+ (void) setsockopt(unix_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, sizeof(arg));
763+ unlink(unix_socket_path.file_string().c_str());
764+
765+ struct sockaddr_un servAddr;
766 memset(&servAddr, 0, sizeof(servAddr));
767
768 servAddr.sun_family= AF_UNIX;
769- strcpy(servAddr.sun_path, unix_socket_path.c_str());
770- (void) unlink(unix_socket_path.c_str());
771-
772- int arg= 1;
773-
774- (void) setsockopt(unix_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, sizeof(arg));
775-
776- addrlen= sizeof(servAddr);
777+ if (unix_socket_path.file_string().size() > sizeof(servAddr.sun_path))
778+ {
779+ std::cerr << "Unix Socket Path length too long. Must be under "
780+ << sizeof(servAddr.sun_path) << " bytes." << endl;
781+ return false;
782+ }
783+ memcpy(servAddr.sun_path, unix_socket_path.file_string().c_str(), sizeof(servAddr.sun_path)-1);
784+
785+ socklen_t addrlen= sizeof(servAddr);
786 if (::bind(unix_sock, reinterpret_cast<sockaddr *>(&servAddr), addrlen) < 0)
787 {
788- std::cerr << "Can't start server : Bind on unix socket\n";
789- std::cerr << "Do you already have another of drizzled or mysqld running on socket: " << unix_socket_path << "?\n";
790- std::cerr << "Can't start server : UNIX Socket";
791+ std::cerr << "Can't start server : Bind on unix socket." << std::endl;
792+ std::cerr << "Do you already have another of drizzled or mysqld running on socket: " << unix_socket_path << "?" << std::endl;
793+ std::cerr << "Can't start server : UNIX Socket" << std::endl;
794
795 return false;
796 }
797
798- if (listen(unix_sock,(int) 1000) < 0)
799+ if (listen(unix_sock, (int) 1000) < 0)
800 {
801 std::cerr << "listen() on Unix socket failed with error " << errno << "\n";
802 }
803 else
804 {
805- std::cerr << "Listening on " << unix_socket_path.c_str() << "\n";
806+ std::cerr << "Listening on " << unix_socket_path << "\n";
807 }
808+ (void) unlink(unix_socket_path.file_string().c_str());
809
810 fds.push_back(unix_sock);
811
812@@ -126,14 +154,13 @@
813 static void init_options(drizzled::module::option_context &context)
814 {
815 context("path",
816- po::value<string>()->default_value(unix_socket_path),
817+ po::value<fs::path>()->default_value(DRIZZLE_UNIX_SOCKET_PATH),
818 N_("Path used for MySQL UNIX Socket Protocol."));
819+ context("clobber",
820+ N_("Clobber socket file if one is there already."));
821+
822 }
823
824-static drizzle_sys_var* sys_variables[]= {
825- NULL
826-};
827-
828 } /* namespace mysql_unix_socket_protocol */
829
830-DRIZZLE_PLUGIN(mysql_unix_socket_protocol::init, mysql_unix_socket_protocol::sys_variables, mysql_unix_socket_protocol::init_options);
831+DRIZZLE_PLUGIN(mysql_unix_socket_protocol::init, NULL, mysql_unix_socket_protocol::init_options);
832
833=== modified file 'plugin/mysql_unix_socket_protocol/protocol.h'
834--- plugin/mysql_unix_socket_protocol/protocol.h 2010-10-28 14:56:34 +0000
835+++ plugin/mysql_unix_socket_protocol/protocol.h 2010-11-23 02:58:45 +0000
836@@ -27,6 +27,8 @@
837 #include <drizzled/atomics.h>
838 #include "drizzled/plugin/table_function.h"
839
840+#include <boost/filesystem.hpp>
841+
842 #include "plugin/mysql_protocol/mysql_protocol.h"
843
844 namespace mysql_unix_socket_protocol
845@@ -34,9 +36,13 @@
846
847 class Protocol: public ListenMySQLProtocol
848 {
849+ const boost::filesystem::path unix_socket_path;
850 public:
851- Protocol(std::string name_arg, bool using_mysql41_protocol_arg):
852- ListenMySQLProtocol(name_arg, using_mysql41_protocol_arg)
853+ Protocol(std::string name_arg,
854+ bool using_mysql41_protocol_arg,
855+ const boost::filesystem::path &unix_socket_path_arg) :
856+ ListenMySQLProtocol(name_arg, using_mysql41_protocol_arg),
857+ unix_socket_path(unix_socket_path_arg)
858 { }
859
860 ~Protocol();
861
862=== modified file 'tests/lib/dtr_process.pl'
863--- tests/lib/dtr_process.pl 2010-11-10 15:35:05 +0000
864+++ tests/lib/dtr_process.pl 2010-11-23 02:58:45 +0000
865@@ -356,7 +356,7 @@
866 dtr_debug(" - drizzled " .
867 "(pid: $srv->{pid}; " .
868 "pid file: '$srv->{path_pid}'; " .
869- "socket: '$srv->{path_sock}'; ".
870+ "socket: '$srv->{sockfile}'; ".
871 "port: $srv->{port})");
872
873 my $pid= dtr_server_shutdown($srv);
874@@ -367,7 +367,7 @@
875 push(@kill_pids,{
876 pid => $srv->{'pid'},
877 pidfile => $srv->{'path_pid'},
878- sockfile => $srv->{'path_sock'},
879+ sockfile => $srv->{'sockfile'},
880 port => $srv->{'port'},
881 });
882 $srv->{'pid'}= 0; # Assume we are done with it
883@@ -590,6 +590,11 @@
884 {
885 dtr_error("can't remove $srv->{'pidfile'}");
886 }
887+ if ( -f $srv->{'sockfile'} and ! unlink($srv->{'sockfile'}) and
888+ -f $srv->{'sockfile'} )
889+ {
890+ dtr_error("can't remove $srv->{'sockfile'}");
891+ }
892 }
893 }
894
895@@ -608,6 +613,10 @@
896 my $errors= 0;
897 foreach my $srv ( @$spec )
898 {
899+ if ( $srv->{'sockfile'} )
900+ {
901+ unlink($srv->{'sockfile'});
902+ }
903 if ( $srv->{'pid'} )
904 {
905 # Server has been hard killed, clean it's resources
906@@ -682,11 +691,6 @@
907 dtr_add_arg($args, "--password=");
908 dtr_add_arg($args, "--silent");
909
910- if ( -e $srv->{'path_sock'} )
911- {
912- dtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
913- }
914-
915 if ( $srv->{'port'} )
916 {
917 dtr_add_arg($args, "--port=%s", $srv->{'port'});
918
919=== modified file 'tests/test-run.pl'
920--- tests/test-run.pl 2010-11-07 05:10:46 +0000
921+++ tests/test-run.pl 2010-11-23 02:58:45 +0000
922@@ -942,17 +942,6 @@
923 }
924 }
925
926- # On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
927- # considered different, so avoid the extra slash (/) in the socket
928- # paths.
929- my $sockdir = $opt_tmpdir;
930- $sockdir =~ s|/+$||;
931-
932- # On some operating systems, there is a limit to the length of a
933- # UNIX domain socket's path far below PATH_MAX, so try to avoid long
934- # socket path names.
935- $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
936-
937 $master->[0]=
938 {
939 pid => 0,
940@@ -961,7 +950,7 @@
941 path_myddir => "$opt_vardir/master-data",
942 path_myerr => "$opt_vardir/log/master.err",
943 path_pid => "$opt_vardir/run/master.pid",
944- path_sock => "$sockdir/master.sock",
945+ path_sock => "$opt_vardir/master.sock",
946 port => $opt_master_myport,
947 secondary_port => $opt_master_myport + $secondary_port_offset,
948 start_timeout => 400, # enough time create innodb tables
949@@ -977,7 +966,7 @@
950 path_myddir => "$opt_vardir/master1-data",
951 path_myerr => "$opt_vardir/log/master1.err",
952 path_pid => "$opt_vardir/run/master1.pid",
953- path_sock => "$sockdir/master1.sock",
954+ path_sock => "$opt_vardir/master1.sock",
955 port => $opt_master_myport + 1,
956 secondary_port => $opt_master_myport + 1 + $secondary_port_offset,
957 start_timeout => 400, # enough time create innodb tables
958@@ -993,7 +982,7 @@
959 path_myddir => "$opt_vardir/slave-data",
960 path_myerr => "$opt_vardir/log/slave.err",
961 path_pid => "$opt_vardir/run/slave.pid",
962- path_sock => "$sockdir/slave.sock",
963+ path_sock => "$opt_vardir/slave.sock",
964 port => $opt_slave_myport,
965 secondary_port => $opt_slave_myport + $secondary_port_offset,
966 start_timeout => 400,
967@@ -1009,7 +998,7 @@
968 path_myddir => "$opt_vardir/slave1-data",
969 path_myerr => "$opt_vardir/log/slave1.err",
970 path_pid => "$opt_vardir/run/slave1.pid",
971- path_sock => "$sockdir/slave1.sock",
972+ path_sock => "$opt_vardir/slave1.sock",
973 port => $opt_slave_myport + 1,
974 secondary_port => $opt_slave_myport + 1 + $secondary_port_offset,
975 start_timeout => 300,
976@@ -1025,7 +1014,7 @@
977 path_myddir => "$opt_vardir/slave2-data",
978 path_myerr => "$opt_vardir/log/slave2.err",
979 path_pid => "$opt_vardir/run/slave2.pid",
980- path_sock => "$sockdir/slave2.sock",
981+ path_sock => "$opt_vardir/slave2.sock",
982 port => $opt_slave_myport + 2,
983 secondary_port => $opt_slave_myport + 2 + $secondary_port_offset,
984 start_timeout => 300,
985@@ -2533,6 +2522,9 @@
986 dtr_add_arg($args, "%s--datadir=%s", $prefix,
987 $drizzled->{'path_myddir'});
988
989+ dtr_add_arg($args, "%s--mysql-unix-socket-protocol.path=%s", $prefix,
990+ $drizzled->{'path_sock'});
991+
992 # Check if "extra_opt" contains --skip-log-bin
993 if ( $drizzled->{'type'} eq 'master' )
994 {

Subscribers

People subscribed via source and target branches