~drizzle-trunk/drizzle/development

520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
2154.2.5 by Brian Aker
Fix the include list in drizzled.cc (just sorted, and included correctly).
21
22
#include <drizzled/configmake.h>
23
#include <drizzled/atomics.h>
24
#include <drizzled/data_home.h>
520.6.2 by Monty Taylor
Removed netdb.h from common_includes. Check it out - it was only used in ***2*** files. _Definitely_ a common include.
25
26
#include <netdb.h>
1241.9.47 by Monty Taylor
Add sys/types.cc to drizzled to fix freebsd.
27
#include <sys/types.h>
520.6.2 by Monty Taylor
Removed netdb.h from common_includes. Check it out - it was only used in ***2*** files. _Definitely_ a common include.
28
#include <netinet/tcp.h>
1208.1.1 by Monty Taylor
Fixed FreeBSD build issues.
29
#include <netinet/in.h>
520.6.5 by Monty Taylor
Removed signal.h from common_includes.
30
#include <signal.h>
1241.9.59 by Monty Taylor
Removed the first mystrings header.
31
#include <limits.h>
1666.4.18 by Monty Taylor
Added parsing of size suffixes.
32
#include <stdexcept>
520.6.2 by Monty Taylor
Removed netdb.h from common_includes. Check it out - it was only used in ***2*** files. _Definitely_ a common include.
33
1633.1.1 by Monty Taylor
Added in support for program_options output in --help output.
34
#include <boost/program_options.hpp>
2154.2.5 by Brian Aker
Fix the include list in drizzled.cc (just sorted, and included correctly).
35
#include <drizzled/program_options/config_file.h>
1689.2.1 by Brian Aker
Convert LOCK_global_system_variables to boost.
36
#include <boost/thread/recursive_mutex.hpp>
37
#include <boost/thread/mutex.hpp>
1812.3.7 by Brian Aker
Typdef our lock type.
38
#include <boost/thread/shared_mutex.hpp>
1689.2.3 by Brian Aker
Convert COND_refresh.
39
#include <boost/thread/condition_variable.hpp>
1794.3.5 by Monty Taylor
Fixed temporoary dir sequencing.
40
#include <boost/filesystem.hpp>
2039.3.5 by Brian Aker
Switched connection_count to use boost atomic.
41
#include <boost/detail/atomic_count.hpp>
1633.1.1 by Monty Taylor
Added in support for program_options output in --help output.
42
2154.2.5 by Brian Aker
Fix the include list in drizzled.cc (just sorted, and included correctly).
43
#include <drizzled/cached_directory.h>
44
#include <drizzled/charset.h>
45
#include <drizzled/data_home.h>
46
#include <drizzled/debug.h>
47
#include <drizzled/definition/cache.h>
48
#include <drizzled/drizzled.h>
49
#include <drizzled/errmsg_print.h>
50
#include <drizzled/error.h>
51
#include <drizzled/global_buffer.h>
52
#include <drizzled/internal/my_bit.h>
53
#include <drizzled/internal/my_sys.h>
54
#include <drizzled/item/cmpfunc.h>
55
#include <drizzled/item/create.h>
56
#include <drizzled/message/cache.h>
57
#include <drizzled/module/load_list.h>
58
#include <drizzled/module/registry.h>
59
#include <drizzled/plugin/client.h>
60
#include <drizzled/plugin/error_message.h>
61
#include <drizzled/plugin/event_observer.h>
62
#include <drizzled/plugin/listen.h>
63
#include <drizzled/plugin/monitored_in_transaction.h>
64
#include <drizzled/plugin/scheduler.h>
65
#include <drizzled/plugin/storage_engine.h>
66
#include <drizzled/plugin/xa_resource_manager.h>
67
#include <drizzled/probes.h>
68
#include <drizzled/replication_services.h> /* For ReplicationServices::evaluateRegisteredPlugins() */
69
#include <drizzled/session.h>
70
#include <drizzled/session/cache.h>
71
#include <drizzled/show.h>
575.4.7 by Monty Taylor
More header cleanup.
72
#include <drizzled/sql_base.h>
73
#include <drizzled/sql_parse.h>
2241.3.1 by Olaf van der Spek
Refactor Session::status_var
74
#include <drizzled/statistics_variables.h>
2272.1.1 by Olaf van der Spek
Refactor includes
75
#include <drizzled/table/cache.h>
2154.2.5 by Brian Aker
Fix the include list in drizzled.cc (just sorted, and included correctly).
76
#include <drizzled/temporal_format.h> /* For init_temporal_formats() */
670.2.4 by Monty Taylor
Removed more stuff from the headers.
77
#include <drizzled/unireg.h>
2154.2.5 by Brian Aker
Fix the include list in drizzled.cc (just sorted, and included correctly).
78
#include <plugin/myisam/myisam.h>
2151.5.9 by Olaf van der Spek
merge trunk
79
#include <drizzled/typelib.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
80
#include <drizzled/visibility.h>
2241.3.2 by Olaf van der Spek
Refactor Session::variables
81
#include <drizzled/system_variables.h>
2263.3.11 by Olaf van der Spek
Open Tables
82
#include <drizzled/open_tables_state.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
83
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
84
#include <google/protobuf/stubs/common.h>
85
481.1.15 by Monty Taylor
Removed time.h and sys/time.h from global.h.
86
#if TIME_WITH_SYS_TIME
87
# include <sys/time.h>
88
# include <time.h>
89
#else
90
# if HAVE_SYS_TIME_H
91
#  include <sys/time.h>
92
# else
93
#  include <time.h>
94
# endif
95
#endif
96
1 by brian
clean slate
97
#ifdef HAVE_SYS_PRCTL_H
98
#include <sys/prctl.h>
99
#endif
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
100
#include <sys/socket.h>
1 by brian
clean slate
101
102
103
#include <errno.h>
104
#include <sys/stat.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
105
#include <drizzled/option.h>
1 by brian
clean slate
106
#ifdef HAVE_SYSENT_H
107
#include <sysent.h>
108
#endif
109
#include <pwd.h>				// For getpwent
110
#include <grp.h>
111
112
#ifdef HAVE_SELECT_H
113
#  include <select.h>
114
#endif
115
116
#ifdef HAVE_SYS_SELECT_H
117
#include <sys/select.h>
118
#endif
119
120
#include <sys/utsname.h>
121
122
#ifdef HAVE_SYS_MMAN_H
123
#include <sys/mman.h>
124
#endif
125
126
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
127
#include <ieeefp.h>
128
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
129
130
#ifdef HAVE_FPU_CONTROL_H
131
#include <fpu_control.h>
132
#endif
133
134
#ifdef HAVE_SYS_FPU_H
135
/* for IRIX to use set_fpc_csr() */
136
#include <sys/fpu.h>
137
#endif
138
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
139
#include <drizzled/internal/my_pthread.h>			// For thr_setconcurency()
140
#include <drizzled/constrained_value.h>
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
141
142
#include <drizzled/gettext.h>
143
144
1859.2.14 by Brian Aker
Add support for --with-valgrind
145
#ifdef HAVE_VALGRIND
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
146
#define IF_PURIFY(A,B) (A)
147
#else
148
#define IF_PURIFY(A,B) (B)
149
#endif
150
151
#define MAX_MEM_TABLE_SIZE SIZE_MAX
1757.2.4 by Monty Taylor
Next step.
152
#include <iostream>
153
#include <fstream>
154
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
155
156
using namespace std;
1794.3.5 by Monty Taylor
Fixed temporoary dir sequencing.
157
namespace fs=boost::filesystem;
1633.1.1 by Monty Taylor
Added in support for program_options output in --help output.
158
namespace po=boost::program_options;
1815.1.1 by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs
159
namespace dpo=drizzled::program_options;
1633.1.1 by Monty Taylor
Added in support for program_options output in --help output.
160
2131.10.1 by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon.
161
bool opt_daemon= false;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
162
2318.2.3 by Olaf van der Spek
Refactor
163
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
164
1 by brian
clean slate
165
inline void setup_fpu()
166
{
167
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
168
  /*
169
     We can't handle floating point exceptions with threads, so disable
170
     this on freebsd.
171
     Don't fall for overflow, underflow,divide-by-zero or loss of precision
172
  */
173
#if defined(__i386__)
174
  fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ |
175
	      FP_X_IMP));
176
#else
177
  fpsetmask(~(FP_X_INV |             FP_X_OFL | FP_X_UFL | FP_X_DZ |
178
              FP_X_IMP));
179
#endif /* __i386__ */
180
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
181
182
  /*
183
    x86 (32-bit) requires FPU precision to be explicitly set to 64 bit for
184
    portable results of floating point operations
185
  */
186
#if defined(__i386__) && defined(HAVE_FPU_CONTROL_H) && defined(_FPU_DOUBLE)
187
  fpu_control_t cw;
188
  _FPU_GETCW(cw);
189
  cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
190
  _FPU_SETCW(cw);
191
#endif /* __i386__ && HAVE_FPU_CONTROL_H && _FPU_DOUBLE */
192
}
193
194
#ifdef SOLARIS
195
extern "C" int gethostname(char *name, int namelen);
196
#endif
197
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
198
const char *first_keyword= "first";
722.1.3 by Monty Taylor
Cleaned up a few build things.
199
const char * const DRIZZLE_CONFIG_NAME= "drizzled";
1776.4.1 by Monty Taylor
Migrates the creation of the plugin lists to have program_options directly
200
1 by brian
clean slate
201
#define GET_HA_ROWS GET_ULL
202
2318.2.3 by Olaf van der Spek
Refactor
203
const char *tx_isolation_names[] = {"READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE", NULL};
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
204
2318.2.3 by Olaf van der Spek
Refactor
205
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names) - 1, "", tx_isolation_names, NULL};
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
206
1 by brian
clean slate
207
arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
208
{{&Arg_comparator::compare_string,     &Arg_comparator::compare_e_string},
209
 {&Arg_comparator::compare_real,       &Arg_comparator::compare_e_real},
210
 {&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
211
 {&Arg_comparator::compare_row,        &Arg_comparator::compare_e_row},
1122.2.13 by Monty Taylor
Header cleanup.
212
 {&Arg_comparator::compare_decimal,    &Arg_comparator::compare_e_decimal}};
1 by brian
clean slate
213
214
/* static variables */
215
1816.2.3 by Monty Taylor
Fixed some more ICC warnings. How did I get started on this this morning?
216
static bool opt_debugging= false;
566 by Brian Aker
Clean up dead thead code.
217
static uint32_t wake_thread;
2318.2.26 by Olaf van der Spek
Refactor
218
static const char* drizzled_chroot;
2318.2.27 by Olaf van der Spek
Refactor
219
static const char* default_character_set_name= "utf8";
2318.2.28 by Olaf van der Spek
Refactor
220
static const char* lc_time_names_name= "en_US";
221
static const char* default_storage_engine_str= "innodb";
2318.2.26 by Olaf van der Spek
Refactor
222
static const char* const compiled_default_collation_name= "utf8_general_ci";
2318.2.28 by Olaf van der Spek
Refactor
223
static const char* default_collation_name= compiled_default_collation_name;
1 by brian
clean slate
224
225
/* Global variables */
226
2318.2.2 by Olaf van der Spek
Add some const
227
const char *drizzled_user;
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
228
bool volatile select_thread_in_use;
1 by brian
clean slate
229
bool volatile abort_loop;
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
230
DRIZZLED_API bool volatile shutdown_in_progress;
2318.2.16 by Olaf van der Spek
Refactor
231
const char* opt_scheduler= "multi_thread";
994.2.2 by Monty Taylor
Store a Registry of SchedulerFactories and set one of them at startup for better error messages earlier.
232
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
233
DRIZZLED_API size_t my_thread_stack_size= 0;
629.2.7 by Monty Taylor
Fixed a couple of memory buffer size issues.
234
1 by brian
clean slate
235
/*
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
236
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
1 by brian
clean slate
237
*/
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
238
plugin::StorageEngine *heap_engine;
239
plugin::StorageEngine *myisam_engine;
1 by brian
clean slate
240
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
241
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
971.3.53 by Eric Day
Cleaned up error messages and a few other things from Jay's review.
242
971.6.7 by Eric Day
Reworked listen interface to not require binding of TCP ports.
243
uint32_t drizzled_bind_timeout;
1089.6.1 by Padraig O'Sullivan
Converted the test_flags variable from a uint32_t to std::bitset.
244
uint32_t dropping_tables, ha_open_options;
482 by Brian Aker
Remove uint.
245
uint32_t tc_heuristic_recover= 0;
520.1.22 by Brian Aker
Second pass of thd cleanup
246
uint64_t session_startup_options;
2318.2.42 by Olaf van der Spek
Refactor
247
back_log_constraints back_log(SOMAXCONN);
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
248
DRIZZLED_API uint32_t server_id;
2290.1.1 by Joseph Daly
Add server uuid
249
DRIZZLED_API string server_uuid;
622.1.1 by Brian Aker
32bit fixes around vars
250
uint64_t table_cache_size;
1226.1.3 by Brian Aker
Possible solution for hash/rehash.
251
size_t table_def_size;
1093.1.57 by Jay Pipes
Merge and resolved conflicts for Monty's plugins/slots reorganization
252
uint32_t global_thread_id= 1UL;
606 by Brian Aker
Remove dead lex structure and clean up use of pid_t
253
pid_t current_pid;
1 by brian
clean slate
254
1241.9.33 by Monty Taylor
Moved most of the global vars to set_var where they belong.
255
extern const double log_10[309];
256
1 by brian
clean slate
257
const double log_10[] = {
258
  1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
259
  1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
260
  1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029,
261
  1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039,
262
  1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049,
263
  1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059,
264
  1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069,
265
  1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079,
266
  1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089,
267
  1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099,
268
  1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
269
  1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
270
  1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
271
  1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
272
  1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
273
  1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
274
  1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169,
275
  1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179,
276
  1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189,
277
  1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199,
278
  1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209,
279
  1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219,
280
  1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229,
281
  1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239,
282
  1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249,
283
  1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259,
284
  1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269,
285
  1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279,
286
  1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289,
287
  1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299,
288
  1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308
289
};
290
855 by Brian Aker
Refactor reset of status.
291
time_t server_start_time;
292
time_t flush_status_time;
1 by brian
clean slate
293
1813.2.1 by Monty Taylor
Migrated --basedir to feed a path.
294
fs::path basedir(PREFIX);
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
295
fs::path pid_file;
2318.5.31 by Olaf van der Spek
Refactor
296
fs::path secure_file_priv;
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
297
fs::path plugin_dir;
1813.2.15 by Monty Taylor
migrated config-dir.
298
fs::path system_config_dir(SYSCONFDIR);
299
2318.5.31 by Olaf van der Spek
Refactor
300
const char *opt_tc_log_file;
982.1.11 by Padraig O'Sullivan
Reverted my changes for replacing Bitmap<> for the moment. Going to fix up
301
const key_map key_map_empty(0);
2119.4.2 by Monty Taylor
Fixed a sun studio compile issue.
302
key_map key_map_full(0);                        // Will be initialized later
1 by brian
clean slate
303
1556.1.1 by Brian Aker
Updates for moving temporary directory.
304
std::string drizzle_tmpdir;
680 by Brian Aker
Remove locks around temp tables for searching tmp directory path.
305
char *opt_drizzle_tmpdir= NULL;
1 by brian
clean slate
306
307
/** name of reference on left espression in rewritten IN subquery */
308
const char *in_left_expr_name= "<left expr>";
309
/** name of additional condition */
310
const char *in_additional_cond= "<IN COND>";
311
const char *in_having_cond= "<IN HAVING>";
312
313
/* classes for comparation parsing/processing */
314
315
FILE *stderror_file=0;
316
2119.4.2 by Monty Taylor
Fixed a sun studio compile issue.
317
drizzle_system_variables global_system_variables;
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
318
drizzle_system_variables max_system_variables;
319
global_counters current_global_counters;
1 by brian
clean slate
320
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
321
DRIZZLED_API const charset_info_st *system_charset_info;
322
const charset_info_st *files_charset_info;
323
const charset_info_st *table_alias_charset;
324
const charset_info_st *character_set_filesystem;
1 by brian
clean slate
325
326
MY_LOCALE *my_default_lc_time_names;
327
177.3.1 by mark
remove ifdef HAVE_DLOPEN, make configure require dlopen()
328
SHOW_COMP_OPTION have_symlink;
1 by brian
clean slate
329
1812.3.5 by Brian Aker
Move to boost condition_any
330
boost::condition_variable_any COND_refresh;
2119.4.2 by Monty Taylor
Fixed a sun studio compile issue.
331
boost::condition_variable COND_thread_count;
1 by brian
clean slate
332
pthread_t signal_thread;
333
334
/* Static variables */
335
900 by Brian Aker
Creating signal handler plugin.
336
int cleanup_done;
1 by brian
clean slate
337
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
338
passwd *user_info;
1 by brian
clean slate
339
2039.3.5 by Brian Aker
Switched connection_count to use boost atomic.
340
boost::detail::atomic_count connection_count(0);
1 by brian
clean slate
341
1796.4.9 by Andrew Hutchings
Add join cache global constraint
342
global_buffer_constraint<uint64_t> global_sort_buffer(0);
343
global_buffer_constraint<uint64_t> global_join_buffer(0);
1796.4.10 by Andrew Hutchings
Add global constraint for --read-rnd-buffer-size
344
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
1796.4.11 by Andrew Hutchings
Add global constraint on read buffer
345
global_buffer_constraint<uint64_t> global_read_buffer(0);
1796.4.1 by Andrew Hutchings
Add initial template work and test
346
2132.3.17 by Andrew Hutchings
Fix possible visibility issue
347
DRIZZLED_API size_t transaction_message_threshold;
2132.3.1 by Andrew Hutchings
Make transaction_message_threshold a read-only global variable instead of a per-session variable
348
2318.2.28 by Olaf van der Spek
Refactor
349
static void drizzle_init_variables();
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
350
static void get_options();
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
351
static void fix_paths();
1 by brian
clean slate
352
2318.2.28 by Olaf van der Spek
Refactor
353
void close_connections();
1633.1.1 by Monty Taylor
Added in support for program_options output in --help output.
354
1798.2.7 by Monty Taylor
Hopefully fixed more madness with plugin paths.
355
fs::path base_plugin_dir(PKGPLUGINDIR);
356
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
357
po::options_description general_options(_("General Options"));
2183.1.1 by Monty Taylor
Use fs::path instead of string searching.
358
po::options_description config_options(_("Config File Options"));
359
po::options_description long_options(_("Kernel Options"));
360
po::options_description plugin_load_options(_("Plugin Loading Options"));
361
po::options_description plugin_options(_("Plugin Options"));
362
po::options_description initial_options(_("Config and Plugin Loading"));
363
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
364
vector<string> unknown_options;
1776.4.3 by Monty Taylor
Add config-dir option.
365
vector<string> defaults_file_list;
1635.1.1 by Monty Taylor
Moved actual parsing of plugin program_options to drizzled.cc so that we do
366
po::variables_map vm;
1813.2.9 by Monty Taylor
Made data_home be fs::path natively.
367
1635.1.1 by Monty Taylor
Moved actual parsing of plugin program_options to drizzled.cc so that we do
368
po::variables_map &getVariablesMap()
369
{
370
  return vm;
371
}
1786.3.1 by Monty Taylor
Initial working local catalog.
372
2318.5.31 by Olaf van der Spek
Refactor
373
static std::string g_hostname= "localhost";
374
375
const std::string& getServerHostname()
376
{
377
  return g_hostname;
2183.1.2 by Monty Taylor
A slew of tiny meaningless changes.
378
}
2139.3.1 by Brian Aker
Merge in encapsulation so that when laying out catalogs we have folks just
379
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
380
static void print_version()
381
{
382
  /*
383
    Note: the instance manager keys off the string 'Ver' so it can find the
384
    version from the output of 'drizzled --version', so don't change it!
385
  */
386
  printf("%s  Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
387
	 PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
388
}
389
1 by brian
clean slate
390
/****************************************************************************
575.4.4 by Yoshinori Sano
Rename mysql to drizzle.
391
** Code to end drizzled
1 by brian
clean slate
392
****************************************************************************/
393
2318.2.28 by Olaf van der Spek
Refactor
394
void close_connections()
1 by brian
clean slate
395
{
907 by Brian Aker
Shutdown for Linux fixed.
396
  /* Abort listening to new connections */
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
397
  plugin::Listen::shutdown();
1 by brian
clean slate
398
399
  /* kill connection thread */
400
  {
2275.3.2 by Olaf van der Spek
Session Cache
401
    boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
1 by brian
clean slate
402
1755.2.4 by Brian Aker
Modify close connection to use boost conditional instead of native.
403
    while (select_thread_in_use)
1 by brian
clean slate
404
    {
2224.1.1 by Olaf van der Spek
Finish removing XID cache
405
      boost::xtime xt;
406
      xtime_get(&xt, boost::TIME_UTC);
407
      xt.sec += 2;
1755.2.4 by Brian Aker
Modify close connection to use boost conditional instead of native.
408
409
      for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
410
      {
411
        bool success= COND_thread_count.timed_wait(scopedLock, xt);
412
        if (not success)
413
          break;
414
      }
1 by brian
clean slate
415
    }
416
  }
417
418
419
  /*
420
    First signal all threads that it's time to die
421
    This will give the threads some time to gracefully abort their
422
    statements and inform their clients that the server is about to die.
423
  */
424
425
  {
2275.3.2 by Olaf van der Spek
Session Cache
426
    boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
2282.1.2 by Olaf van der Spek
Session Cache
427
    session::Cache::list list= session::Cache::getCache();
1932.3.7 by Brian Aker
Connection count restructure.
428
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
429
    BOOST_FOREACH(session::Cache::list::reference tmp, list)
1843.7.4 by Brian Aker
Scope locks.
430
    {
1910.2.8 by Brian Aker
Enapsulate Kill.
431
      tmp->setKilled(Session::KILL_CONNECTION);
1932.3.5 by Brian Aker
Finish change so that we use a shared_ptr for the session list.
432
      tmp->scheduler->killSession(tmp.get());
1843.7.4 by Brian Aker
Scope locks.
433
      DRIZZLE_CONNECTION_DONE(tmp->thread_id);
1961 by Brian Aker
This extends our coverage of interrupting active threads. With no crash
434
1843.7.4 by Brian Aker
Scope locks.
435
      tmp->lockOnSys();
436
    }
1 by brian
clean slate
437
  }
438
2282.1.2 by Olaf van der Spek
Session Cache
439
  if (session::Cache::count())
948 by Brian Aker
Restoring code Monty deleted.
440
    sleep(2);                                   // Give threads time to die
441
1 by brian
clean slate
442
  /*
443
    Force remaining threads to die by closing the connection to the client
444
    This will ensure that threads that are waiting for a command from the
445
    client on a blocking read call are aborted.
446
  */
934.3.10 by Monty Taylor
Revert std::vector changes. dammit.
447
  for (;;)
1 by brian
clean slate
448
  {
2275.3.2 by Olaf van der Spek
Session Cache
449
    boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
2282.1.2 by Olaf van der Spek
Session Cache
450
    session::Cache::list list= session::Cache::getCache();
1932.3.7 by Brian Aker
Connection count restructure.
451
1932.3.3 by Brian Aker
Pull in code to abstract out the session list a bit.
452
    if (list.empty())
1 by brian
clean slate
453
    {
454
      break;
455
    }
1166.4.1 by Diego Medina
* Fixed LP bug#436685
456
    /* Close before unlock, avoiding crash. See LP bug#436685 */
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
457
    list.front()->getClient()->close();
1 by brian
clean slate
458
  }
459
}
460
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
461
static bool unireg_startup_completed= false;
462
void unireg_startup_finished()
463
{
464
  unireg_startup_completed= true;
465
}
1 by brian
clean slate
466
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
467
void unireg_exit()
1 by brian
clean slate
468
{
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
469
  internal::my_end();
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
470
  assert(unireg_startup_completed == false);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
471
  exit(EXIT_SUCCESS);
472
}
473
474
void unireg_actual_abort(const char *file, int line, const char *func, const std::string& message)
475
{
476
  std::stringstream temp;
2363.1.7 by Brian Aker
This shifts the closing of the socket to after we know that no errors are going to occur.
477
  temp << _("Aborting:") << "\"" << message << "\"" << ". Abort was called from " << file << ":" << line << " in " << func << "()";
2449.4.1 by Brian Aker
Fix OSX Lion compile error.
478
  errmsg_printf(error::ERROR, "%s", temp.str().c_str());
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
479
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
480
  clean_up(vm.count("help") == 0);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
481
  internal::my_end();
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
482
483
  assert(unireg_startup_completed == false);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
484
  exit(EXIT_FAILURE);
1 by brian
clean slate
485
}
486
487
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
488
void clean_up(bool print_message)
1 by brian
clean slate
489
{
490
  if (cleanup_done++)
971.6.11 by Eric Day
Removed purecov messages.
491
    return;
1 by brian
clean slate
492
493
  table_cache_free();
494
  free_charsets();
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
495
  module::Registry &modules= module::Registry::singleton();
496
  modules.shutdownModules();
1 by brian
clean slate
497
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
498
  deinit_temporal_formats();
499
500
#if GOOGLE_PROTOBUF_VERSION >= 2001000
501
  google::protobuf::ShutdownProtobufLibrary();
502
#endif
503
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
504
  (void) unlink(pid_file.file_string().c_str());	// This may not always exist
228 by Brian Aker
First pass on socket cleanup.
505
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
506
  if (print_message && server_start_time)
2126.3.3 by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch.
507
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
1932.3.4 by Brian Aker
Move counter lock so that ownership is held by session_list.
508
2282.1.2 by Olaf van der Spek
Session Cache
509
  session::Cache::shutdownFirst();
1 by brian
clean slate
510
511
  /*
512
    The following lines may never be executed as the main thread may have
513
    killed us
514
  */
515
} /* clean_up */
516
517
518
/* Change to run as another user if started with --user */
519
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
520
passwd *check_user(const char *user)
1 by brian
clean slate
521
{
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
522
  passwd *tmp_user_info;
1 by brian
clean slate
523
  uid_t user_id= geteuid();
524
525
  // Don't bother if we aren't superuser
526
  if (user_id)
527
  {
528
    if (user)
529
    {
530
      /* Don't give a warning, if real user is same as given with --user */
531
      tmp_user_info= getpwnam(user);
532
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
533
          global_system_variables.log_warnings)
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
534
      {
535
        errmsg_printf(error::WARN, _("One can only use the --user switch if running as root"));
536
      }
1 by brian
clean slate
537
    }
538
    return NULL;
539
  }
1910.2.8 by Brian Aker
Enapsulate Kill.
540
  if (not user)
1 by brian
clean slate
541
  {
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
542
    unireg_abort << _("drizzled cannot be run as root, use --user to start drizzled up as another user");
1 by brian
clean slate
543
  }
2132.1.1 by Brian Aker
Merge in additional error control.
544
545
  if (not strcmp(user, "root"))
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
546
  {
1 by brian
clean slate
547
    return NULL;                        // Avoid problem with dynamic libraries
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
548
  }
1 by brian
clean slate
549
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
550
  if ((tmp_user_info= getpwnam(user)) == NULL)
1 by brian
clean slate
551
  {
552
    // Allow a numeric uid to be used
2445.1.3 by Olaf van der Spek
Refactor
553
    const char *pos= user;
554
    for (; my_charset_utf8_general_ci.isdigit(*pos); pos++) 
555
    {
556
    }
1 by brian
clean slate
557
    if (*pos)                                   // Not numeric id
558
      goto err;
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
559
560
    if ((tmp_user_info= getpwuid(atoi(user))) == NULL)
1 by brian
clean slate
561
      goto err;
562
  }
563
  return tmp_user_info;
564
565
err:
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
566
  unireg_abort << "Fatal error: Can't change to run as user '" << user << "' ;  Please check that the user exists!";
1 by brian
clean slate
567
568
#ifdef PR_SET_DUMPABLE
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
569
  if (getDebug().test(debug::CORE_ON_SIGNAL))
1 by brian
clean slate
570
  {
571
    /* inform kernel that process is dumpable */
572
    (void) prctl(PR_SET_DUMPABLE, 1);
573
  }
574
#endif
575
908.1.12 by Monty Taylor
mmm.
576
  return NULL;
1 by brian
clean slate
577
}
578
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
579
void set_user(const char *user, passwd *user_info_arg)
1 by brian
clean slate
580
{
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
581
  assert(user_info_arg != 0);
2318.2.3 by Olaf van der Spek
Refactor
582
  initgroups(user, user_info_arg->pw_gid);
1 by brian
clean slate
583
  if (setgid(user_info_arg->pw_gid) == -1)
584
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
585
    unireg_abort << _("Set process group ID failed ") << strerror(errno); 
1 by brian
clean slate
586
  }
587
  if (setuid(user_info_arg->pw_uid) == -1)
588
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
589
    unireg_abort << _("Set process user ID failed") << strerror(errno);
1 by brian
clean slate
590
  }
591
}
592
593
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
594
1 by brian
clean slate
595
/** Change root user if started with @c --chroot . */
596
static void set_root(const char *path)
597
{
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
598
  if ((chroot(path) == -1) or chdir("/") == 0)
1 by brian
clean slate
599
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
600
    unireg_abort << _("Process chroot failed");
1 by brian
clean slate
601
  }
602
}
603
604
605
/*
520.1.22 by Brian Aker
Second pass of thd cleanup
606
  Unlink session from global list of available connections and free session
1 by brian
clean slate
607
608
  SYNOPSIS
1241.9.12 by Monty Taylor
Trims more out of server_includes.h.
609
    Session::unlink()
520.1.22 by Brian Aker
Second pass of thd cleanup
610
    session		 Thread handler
1 by brian
clean slate
611
*/
612
2246.4.6 by Olaf van der Spek
Remove some unnecessary drizzled::
613
void Session::unlink(session_id_t &session_id)
2015.3.3 by Brian Aker
Update disconnect code.
614
{
2282.1.2 by Olaf van der Spek
Session Cache
615
  Session::shared_ptr session= session::Cache::find(session_id);
2015.3.3 by Brian Aker
Update disconnect code.
616
617
  if (session)
618
    unlink(session);
619
}
620
2318.6.43 by Olaf van der Spek
Refactor
621
void Session::unlink(const Session::shared_ptr& session)
1932.3.13 by Brian Aker
Cleanup session ownership rules such that we know exactly when session has
622
{
2039.3.5 by Brian Aker
Switched connection_count to use boost atomic.
623
  --connection_count;
1932.3.13 by Brian Aker
Cleanup session ownership rules such that we know exactly when session has
624
625
  session->cleanup();
626
2275.3.2 by Olaf van der Spek
Session Cache
627
  boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
1932.3.13 by Brian Aker
Cleanup session ownership rules such that we know exactly when session has
628
629
  if (unlikely(plugin::EventObserver::disconnectSession(*session)))
630
  {
631
    // We should do something about an error...
632
  }
2282.1.2 by Olaf van der Spek
Session Cache
633
  session::Cache::erase(session);
1 by brian
clean slate
634
}
635
636
637
#ifndef SA_RESETHAND
638
#define SA_RESETHAND 0
639
#endif
640
#ifndef SA_NODEFER
641
#define SA_NODEFER 0
642
#endif
643
644
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
645
646
2224.1.1 by Olaf van der Spek
Finish removing XID cache
647
const char *load_default_groups[]=
1 by brian
clean slate
648
{
1300.5.2 by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then
649
  DRIZZLE_CONFIG_NAME, "server", 0, 0
650
};
1 by brian
clean slate
651
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
652
static void find_plugin_dir(string progname)
653
{
2183.1.1 by Monty Taylor
Use fs::path instead of string searching.
654
  fs::path full_progname(fs::system_complete(progname));
655
656
  fs::path progdir(full_progname.parent_path());
657
  if (progdir.filename() == ".libs")
658
  {
659
    progdir= progdir.parent_path();
660
  }
661
662
  if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
663
  {
664
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
2183.1.1 by Monty Taylor
Use fs::path instead of string searching.
665
    base_plugin_dir= progdir.parent_path();
1798.2.7 by Monty Taylor
Hopefully fixed more madness with plugin paths.
666
    base_plugin_dir /= "plugin";
667
    base_plugin_dir /= ".libs";
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
668
  }
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
669
670
  if (plugin_dir.root_directory() == "")
671
  {
672
    fs::path full_plugin_dir(fs::system_complete(base_plugin_dir));
673
    full_plugin_dir /= plugin_dir;
674
    plugin_dir= full_plugin_dir;
675
  }
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
676
}
677
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
678
static void notify_plugin_dir(fs::path in_plugin_dir)
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
679
{
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
680
  plugin_dir= in_plugin_dir;
681
  if (plugin_dir.root_directory() == "")
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
682
  {
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
683
    fs::path full_plugin_dir(fs::system_complete(basedir));
684
    full_plugin_dir /= plugin_dir;
685
    plugin_dir= full_plugin_dir;
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
686
  }
687
}
688
1813.2.10 by Monty Taylor
Expand secure-file-priv once at startup rather than on each path check.
689
static void expand_secure_file_priv(fs::path in_secure_file_priv)
690
{
691
  secure_file_priv= fs::system_complete(in_secure_file_priv);
692
}
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
693
1757.2.4 by Monty Taylor
Next step.
694
static void check_limits_aii(uint64_t in_auto_increment_increment)
695
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
696
  global_system_variables.auto_increment_increment= 1;
1757.2.4 by Monty Taylor
Next step.
697
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
698
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
699
    unireg_abort << _("Invalid Value for auto_increment_increment");
1757.2.4 by Monty Taylor
Next step.
700
  }
701
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
702
}
703
704
static void check_limits_aio(uint64_t in_auto_increment_offset)
705
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
706
  global_system_variables.auto_increment_offset= 1;
1757.2.4 by Monty Taylor
Next step.
707
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
708
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
709
    unireg_abort << _("Invalid Value for auto_increment_offset");
1757.2.4 by Monty Taylor
Next step.
710
  }
711
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
712
}
713
714
static void check_limits_completion_type(uint32_t in_completion_type)
715
{
716
  global_system_variables.completion_type= 0;
717
  if (in_completion_type > 2)
718
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
719
    unireg_abort << _("Invalid Value for completion_type");
1757.2.4 by Monty Taylor
Next step.
720
  }
721
  global_system_variables.completion_type= in_completion_type;
722
}
723
724
725
static void check_limits_dpi(uint32_t in_div_precincrement)
726
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
727
  global_system_variables.div_precincrement= 4;
1757.2.4 by Monty Taylor
Next step.
728
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
729
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
730
    unireg_abort << _("Invalid Value for div-precision-increment");
1757.2.4 by Monty Taylor
Next step.
731
  }
732
  global_system_variables.div_precincrement= in_div_precincrement;
733
}
734
735
static void check_limits_gcml(uint64_t in_group_concat_max_len)
736
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
737
  global_system_variables.group_concat_max_len= 1024;
1757.2.4 by Monty Taylor
Next step.
738
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
739
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
740
    unireg_abort << _("Invalid Value for group_concat_max_len");
1757.2.4 by Monty Taylor
Next step.
741
  }
742
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
743
}
744
745
static void check_limits_join_buffer_size(uint64_t in_join_buffer_size)
746
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
747
  global_system_variables.join_buff_size= (128*1024L);
1757.2.4 by Monty Taylor
Next step.
748
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
749
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
750
    unireg_abort << _("Invalid Value for join_buffer_size");
1757.2.4 by Monty Taylor
Next step.
751
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
752
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
753
  global_system_variables.join_buff_size= in_join_buffer_size;
1757.2.4 by Monty Taylor
Next step.
754
}
755
756
static void check_limits_map(uint32_t in_max_allowed_packet)
757
{
1877.1.3 by Andrew Hutchings
Make default max_packet_size 64MB as 1MB doesn't seem really sane for text/blob columns
758
  global_system_variables.max_allowed_packet= (64*1024*1024L);
1757.2.4 by Monty Taylor
Next step.
759
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
760
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
761
    unireg_abort << _("Invalid Value for max_allowed_packet");
1757.2.4 by Monty Taylor
Next step.
762
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
763
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
764
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
1757.2.4 by Monty Taylor
Next step.
765
}
766
767
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
768
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
769
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
1757.2.4 by Monty Taylor
Next step.
770
  if (in_max_error_count > 65535)
771
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
772
    unireg_abort << _("Invalid Value for max_error_count");
1757.2.4 by Monty Taylor
Next step.
773
  }
774
  global_system_variables.max_error_count= in_max_error_count;
775
}
776
777
static void check_limits_mhts(uint64_t in_max_heap_table_size)
778
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
779
  global_system_variables.max_heap_table_size= (16*1024*1024L);
1757.2.4 by Monty Taylor
Next step.
780
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
781
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
782
    unireg_abort << _("Invalid Value for max_heap_table_size");
1757.2.4 by Monty Taylor
Next step.
783
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
784
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
785
  global_system_variables.max_heap_table_size= in_max_heap_table_size;
1757.2.4 by Monty Taylor
Next step.
786
}
787
788
static void check_limits_merl(uint64_t in_min_examined_row_limit)
789
{
790
  global_system_variables.min_examined_row_limit= 0;
791
  if (in_min_examined_row_limit > ULONG_MAX)
792
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
793
    unireg_abort << _("Invalid Value for min_examined_row_limit");
1757.2.4 by Monty Taylor
Next step.
794
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
795
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
1757.2.4 by Monty Taylor
Next step.
796
}
797
2246.4.6 by Olaf van der Spek
Remove some unnecessary drizzled::
798
static void check_limits_max_join_size(ha_rows in_max_join_size)
1757.2.4 by Monty Taylor
Next step.
799
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
800
  global_system_variables.max_join_size= INT32_MAX;
1757.2.4 by Monty Taylor
Next step.
801
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
802
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
803
    unireg_abort << _("Invalid Value for max_join_size");
1757.2.4 by Monty Taylor
Next step.
804
  }
805
  global_system_variables.max_join_size= in_max_join_size;
806
}
807
808
static void check_limits_mlfsd(int64_t in_max_length_for_sort_data)
809
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
810
  global_system_variables.max_length_for_sort_data= 1024;
1757.2.4 by Monty Taylor
Next step.
811
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
812
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
813
    unireg_abort << _("Invalid Value for max_length_for_sort_data");
1757.2.4 by Monty Taylor
Next step.
814
  }
815
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
816
}
817
818
static void check_limits_msfk(uint64_t in_max_seeks_for_key)
819
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
820
  global_system_variables.max_seeks_for_key= ULONG_MAX;
1757.2.4 by Monty Taylor
Next step.
821
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
822
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
823
    unireg_abort << _("Invalid Value for max_seeks_for_key");
1757.2.4 by Monty Taylor
Next step.
824
  }
825
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
826
}
827
828
static void check_limits_max_sort_length(size_t in_max_sort_length)
829
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
830
  global_system_variables.max_sort_length= 1024;
1757.2.4 by Monty Taylor
Next step.
831
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
832
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
833
    unireg_abort << _("Invalid Value for max_sort_length");
1757.2.4 by Monty Taylor
Next step.
834
  }
835
  global_system_variables.max_sort_length= in_max_sort_length;
836
}
837
838
static void check_limits_osd(uint32_t in_optimizer_search_depth)
839
{
840
  global_system_variables.optimizer_search_depth= 0;
841
  if (in_optimizer_search_depth > MAX_TABLES + 2)
842
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
843
    unireg_abort << _("Invalid Value for optimizer_search_depth");
1757.2.4 by Monty Taylor
Next step.
844
  }
845
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
846
}
847
848
static void check_limits_pbs(uint64_t in_preload_buff_size)
849
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
850
  global_system_variables.preload_buff_size= (32*1024L);
1757.2.4 by Monty Taylor
Next step.
851
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
852
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
853
    unireg_abort << _("Invalid Value for preload_buff_size");
1757.2.4 by Monty Taylor
Next step.
854
  }
855
  global_system_variables.preload_buff_size= in_preload_buff_size;
856
}
857
858
static void check_limits_qabs(uint32_t in_query_alloc_block_size)
859
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
860
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
1757.2.4 by Monty Taylor
Next step.
861
  if (in_query_alloc_block_size < 1024)
862
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
863
    unireg_abort << _("Invalid Value for query_alloc_block_size");
1757.2.4 by Monty Taylor
Next step.
864
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
865
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
866
  global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
1757.2.4 by Monty Taylor
Next step.
867
}
868
869
static void check_limits_qps(uint32_t in_query_prealloc_size)
870
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
871
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
1757.2.4 by Monty Taylor
Next step.
872
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
873
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
874
    unireg_abort << _("Invalid Value for query_prealloc_size");
1757.2.4 by Monty Taylor
Next step.
875
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
876
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
877
  global_system_variables.query_prealloc_size= in_query_prealloc_size;
1757.2.4 by Monty Taylor
Next step.
878
}
879
880
static void check_limits_rabs(size_t in_range_alloc_block_size)
881
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
882
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
1757.2.4 by Monty Taylor
Next step.
883
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
884
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
885
    unireg_abort << _("Invalid Value for range_alloc_block_size");
1757.2.4 by Monty Taylor
Next step.
886
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
887
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
888
  global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
1757.2.4 by Monty Taylor
Next step.
889
}
890
891
static void check_limits_read_buffer_size(int32_t in_read_buff_size)
892
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
893
  global_system_variables.read_buff_size= (128*1024L);
1757.2.4 by Monty Taylor
Next step.
894
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
895
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
896
    unireg_abort << _("Invalid Value for read_buff_size");
1757.2.4 by Monty Taylor
Next step.
897
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
898
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
899
  global_system_variables.read_buff_size= in_read_buff_size;
1757.2.4 by Monty Taylor
Next step.
900
}
901
902
static void check_limits_read_rnd_buffer_size(uint32_t in_read_rnd_buff_size)
903
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
904
  global_system_variables.read_rnd_buff_size= (256*1024L);
1757.2.4 by Monty Taylor
Next step.
905
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
906
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
907
    unireg_abort << _("Invalid Value for read_rnd_buff_size");
1757.2.4 by Monty Taylor
Next step.
908
  }
1757.2.10 by Monty Taylor
Fix max_heap_table_size setting issue.
909
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
1757.2.4 by Monty Taylor
Next step.
910
}
911
912
static void check_limits_sort_buffer_size(size_t in_sortbuff_size)
913
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
914
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
1757.2.4 by Monty Taylor
Next step.
915
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
916
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
917
    unireg_abort << _("Invalid Value for sort_buff_size");
1757.2.4 by Monty Taylor
Next step.
918
  }
919
  global_system_variables.sortbuff_size= in_sortbuff_size;
920
}
921
922
static void check_limits_tdc(uint32_t in_table_def_size)
923
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
924
  table_def_size= 128;
1757.2.4 by Monty Taylor
Next step.
925
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
926
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
927
    unireg_abort << _("Invalid Value for table_def_size");
1757.2.4 by Monty Taylor
Next step.
928
  }
929
  table_def_size= in_table_def_size;
930
}
931
932
static void check_limits_toc(uint32_t in_table_cache_size)
933
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
934
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
1757.2.4 by Monty Taylor
Next step.
935
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
936
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
937
    unireg_abort << _("Invalid Value for table_cache_size");
1757.2.4 by Monty Taylor
Next step.
938
  }
939
  table_cache_size= in_table_cache_size;
940
}
941
942
static void check_limits_tlwt(uint64_t in_table_lock_wait_timeout)
943
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
944
  table_lock_wait_timeout= 50;
1757.2.4 by Monty Taylor
Next step.
945
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
946
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
947
    unireg_abort <<  _("Invalid Value for table_lock_wait_timeout");
1757.2.4 by Monty Taylor
Next step.
948
  }
949
  table_lock_wait_timeout= in_table_lock_wait_timeout;
950
}
951
952
static void check_limits_thread_stack(uint32_t in_my_thread_stack_size)
953
{
954
  my_thread_stack_size= in_my_thread_stack_size - (in_my_thread_stack_size % 1024);
955
}
956
957
static void check_limits_tmp_table_size(uint64_t in_tmp_table_size)
958
{
1757.3.1 by Andrew Hutchings
Hacky quick fix for mtaylor's problem:
959
  global_system_variables.tmp_table_size= 16*1024*1024L;
1757.2.4 by Monty Taylor
Next step.
960
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
961
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
962
    unireg_abort << _("Invalid Value for table_lock_wait_timeout");
1757.2.4 by Monty Taylor
Next step.
963
  }
964
  global_system_variables.tmp_table_size= in_tmp_table_size;
965
}
966
1802.14.1 by Joseph Daly
add variable for gpb size
967
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
968
{
2132.3.1 by Andrew Hutchings
Make transaction_message_threshold a read-only global variable instead of a per-session variable
969
  transaction_message_threshold= 1024*1024;
1802.14.1 by Joseph Daly
add variable for gpb size
970
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
971
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
972
    unireg_abort << _("Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1802.14.1 by Joseph Daly
add variable for gpb size
973
  }
2132.3.1 by Andrew Hutchings
Make transaction_message_threshold a read-only global variable instead of a per-session variable
974
  transaction_message_threshold= in_transaction_message_threshold;
1802.14.1 by Joseph Daly
add variable for gpb size
975
}
976
1776.4.3 by Monty Taylor
Add config-dir option.
977
static void process_defaults_files()
978
{
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
979
	BOOST_FOREACH(vector<string>::reference iter, defaults_file_list)
1776.4.3 by Monty Taylor
Add config-dir option.
980
  {
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
981
    fs::path file_location= iter;
1776.4.6 by Monty Taylor
Made config files work with a hack - need to go back in and properly deal
982
1813.2.15 by Monty Taylor
migrated config-dir.
983
    ifstream input_defaults_file(file_location.file_string().c_str());
2224.1.1 by Olaf van der Spek
Finish removing XID cache
984
2318.5.31 by Olaf van der Spek
Refactor
985
    po::parsed_options file_parsed= dpo::parse_config_file(input_defaults_file, full_options, true);
986
    vector<string> file_unknown= po::collect_unrecognized(file_parsed.options, po::include_positional);
1776.4.6 by Monty Taylor
Made config files work with a hack - need to go back in and properly deal
987
2318.5.31 by Olaf van der Spek
Refactor
988
    for (vector<string>::iterator it= file_unknown.begin(); it != file_unknown.end(); ++it)
1776.4.6 by Monty Taylor
Made config files work with a hack - need to go back in and properly deal
989
    {
2318.5.31 by Olaf van der Spek
Refactor
990
      string new_unknown_opt("--" + *it);
1776.4.6 by Monty Taylor
Made config files work with a hack - need to go back in and properly deal
991
      ++it;
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
992
      if (it == file_unknown.end())
993
				break;
2318.5.31 by Olaf van der Spek
Refactor
994
      if (*it != "true")
995
        new_unknown_opt += "=" + *it;
1776.4.6 by Monty Taylor
Made config files work with a hack - need to go back in and properly deal
996
      unknown_options.push_back(new_unknown_opt);
997
    }
998
    store(file_parsed, vm);
1776.4.3 by Monty Taylor
Add config-dir option.
999
  }
1000
}
1001
2318.5.31 by Olaf van der Spek
Refactor
1002
static void compose_defaults_file_list(const vector<string>& in_options)
1776.4.3 by Monty Taylor
Add config-dir option.
1003
{
2318.5.31 by Olaf van der Spek
Refactor
1004
	BOOST_FOREACH(const string& it, in_options)
1776.4.3 by Monty Taylor
Add config-dir option.
1005
  {
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
1006
    fs::path p(it);
1883.2.2 by Andrew Hutchings
Error if a defaults-file is missing
1007
    if (fs::is_regular_file(p))
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1008
    {
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
1009
      defaults_file_list.push_back(it);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1010
    }
1883.2.2 by Andrew Hutchings
Error if a defaults-file is missing
1011
    else
1012
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1013
      unireg_abort << "Defaults file '" << it << "' not found";
1883.2.2 by Andrew Hutchings
Error if a defaults-file is missing
1014
    }
1776.4.3 by Monty Taylor
Add config-dir option.
1015
  }
1016
}
1757.2.4 by Monty Taylor
Next step.
1017
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1018
bool init_variables_before_daemonizing(int argc, char **argv)
1 by brian
clean slate
1019
{
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1020
  umask(((~internal::my_umask) & 0666));
2034.2.4 by Brian Aker
Further encapsulation for DECIMAL.
1021
  decimal_zero.set_zero(); // set decimal_zero constant;
1 by brian
clean slate
1022
  tzset();			// Set tzname
1023
2318.5.31 by Olaf van der Spek
Refactor
1024
  time_t curr_time= time(NULL);
685.3.4 by Toru Maesaka
Fixed the issues pointed out by Jay's code review
1025
  if (curr_time == (time_t)-1)
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1026
  {
1027
    return false;
1028
  }
685.3.2 by Toru Maesaka
Removed my_time() and added error checking
1029
298 by Brian Aker
ulong conversion.
1030
  max_system_variables.pseudo_thread_id= UINT32_MAX;
685.3.4 by Toru Maesaka
Fixed the issues pointed out by Jay's code review
1031
  server_start_time= flush_status_time= curr_time;
1 by brian
clean slate
1032
574.2.1 by ysano
Rename mysql to drizzle.
1033
  drizzle_init_variables();
1 by brian
clean slate
1034
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
1035
  find_plugin_dir(argv[0]);
1 by brian
clean slate
1036
2183.1.2 by Monty Taylor
A slew of tiny meaningless changes.
1037
  char ret_hostname[FN_REFLEN];
1038
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
1 by brian
clean slate
1039
  {
2318.5.31 by Olaf van der Spek
Refactor
1040
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"), getServerHostname().c_str());
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
1041
    pid_file= "drizzle";
1 by brian
clean slate
1042
  }
1043
  else
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
1044
  {
2318.5.31 by Olaf van der Spek
Refactor
1045
    g_hostname= ret_hostname;
2183.1.2 by Monty Taylor
A slew of tiny meaningless changes.
1046
    pid_file= getServerHostname();
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
1047
  }
1048
  pid_file.replace_extension(".pid");
1 by brian
clean slate
1049
1813.2.15 by Monty Taylor
migrated config-dir.
1050
  system_config_dir /= "drizzle";
1757.2.4 by Monty Taylor
Next step.
1051
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1052
  general_options.add_options()
1053
  ("help,?",
1054
  _("Display help and exit."))
2131.10.1 by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon.
1055
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1056
  _("Run as a daemon."))
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1057
  ("user,u", po::value<string>(),
1058
  _("Run drizzled daemon as user."))
1059
  ("version,V",
1060
  _("Print version information and exit."))
1061
    ;
1062
1063
  config_options.add_options()
1794.3.1 by Monty Taylor
Rearranged option processing.
1064
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1065
  _("Configuration file defaults are not used if no-defaults is set"))
1794.3.1 by Monty Taylor
Rearranged option processing.
1066
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
2068.4.1 by Andrew Hutchings
Fix intl domain
1067
  _("Configuration file to use"))
1813.2.15 by Monty Taylor
migrated config-dir.
1068
  ("config-dir", po::value<fs::path>(&system_config_dir),
2068.4.1 by Andrew Hutchings
Fix intl domain
1069
  _("Base location for config files"))
1813.2.7 by Monty Taylor
Migrated plugin_dir to fs::path.
1070
  ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
2068.4.1 by Andrew Hutchings
Fix intl domain
1071
  _("Directory for plugins."))
1794.3.1 by Monty Taylor
Rearranged option processing.
1072
  ;
1073
1074
  plugin_load_options.add_options()
1075
  ("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
2068.4.1 by Andrew Hutchings
Fix intl domain
1076
  _("Optional comma separated list of plugins to load at startup in addition "
1794.3.1 by Monty Taylor
Rearranged option processing.
1077
     "to the default list of plugins. "
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1078
     "[for example: --plugin_add=crc32,logger_gearman]"))
1794.3.1 by Monty Taylor
Rearranged option processing.
1079
  ("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
2068.4.1 by Andrew Hutchings
Fix intl domain
1080
  _("Optional comma separated list of plugins to not load at startup. Effectively "
1794.3.1 by Monty Taylor
Rearranged option processing.
1081
     "removes a plugin from the list of plugins to be loaded. "
1082
     "[for example: --plugin_remove=crc32,logger_gearman]"))
1083
  ("plugin-load", po::value<string>()->notifier(&notify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
2068.4.1 by Andrew Hutchings
Fix intl domain
1084
  _("Optional comma separated list of plugins to load at starup instead of "
1794.3.1 by Monty Taylor
Rearranged option processing.
1085
     "the default plugin load list. "
1086
     "[for example: --plugin_load=crc32,logger_gearman]"))
1087
  ;
1088
1089
  long_options.add_options()
1757.2.4 by Monty Taylor
Next step.
1090
  ("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
2068.4.1 by Andrew Hutchings
Fix intl domain
1091
  _("Auto-increment columns are incremented by this"))
1757.2.4 by Monty Taylor
Next step.
1092
  ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
2068.4.1 by Andrew Hutchings
Fix intl domain
1093
  _("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1813.2.4 by Monty Taylor
Set basedir directly from po.
1094
  ("basedir,b", po::value<fs::path>(&basedir),
2068.4.1 by Andrew Hutchings
Fix intl domain
1095
  _("Path to installation directory. All paths are usually resolved "
1757.2.4 by Monty Taylor
Next step.
1096
     "relative to this."))
1097
  ("chroot,r", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1098
  _("Chroot drizzled daemon during startup."))
1757.2.4 by Monty Taylor
Next step.
1099
  ("collation-server", po::value<string>(),
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1100
  _("Set the default collation."))
1757.2.4 by Monty Taylor
Next step.
1101
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
2068.4.1 by Andrew Hutchings
Fix intl domain
1102
  _("Default completion type."))
1103
  ("core-file",  _("Write core on errors."))
2318.5.30 by Olaf van der Spek
Refactor
1104
  ("datadir", po::value<fs::path>(&getMutableDataHome()),
2068.4.1 by Andrew Hutchings
Fix intl domain
1105
  _("Path to the database root."))
1757.2.4 by Monty Taylor
Next step.
1106
  ("default-storage-engine", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1107
  _("Set the default storage engine for tables."))
1757.2.4 by Monty Taylor
Next step.
1108
  ("default-time-zone", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1109
  _("Set the default time zone."))
1757.2.4 by Monty Taylor
Next step.
1110
  ("exit-info,T", po::value<long>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1111
  _("Used for debugging;  Use at your own risk!"))
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1112
  ("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1113
  _("Set up signals usable for debugging"))
1757.2.4 by Monty Taylor
Next step.
1114
  ("lc-time-name", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1115
  _("Set the language used for the month names and the days of the week."))
1816.2.3 by Monty Taylor
Fixed some more ICC warnings. How did I get started on this this morning?
1116
  ("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1117
  _("Log some not critical warnings to the log file."))
1813.2.5 by Monty Taylor
Use pid-file directly from variables map.
1118
  ("pid-file", po::value<fs::path>(&pid_file),
2068.4.1 by Andrew Hutchings
Fix intl domain
1119
  _("Pid file used by drizzled."))
1757.2.4 by Monty Taylor
Next step.
1120
  ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1121
  _("Maximum time in seconds to wait for the port to become free. "))
1938.3.1 by David Shrewsbury
Add --replicate-query option.
1122
  ("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1123
  _("Include the SQL query in replicated protobuf messages."))
1813.2.10 by Monty Taylor
Expand secure-file-priv once at startup rather than on each path check.
1124
  ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
2068.4.1 by Andrew Hutchings
Fix intl domain
1125
  _("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1757.2.4 by Monty Taylor
Next step.
1126
     "within specified directory"))
1127
  ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1128
  _("Uniquely identifies the server instance in the community of "
1757.2.4 by Monty Taylor
Next step.
1129
     "replication partners."))
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1130
  ("skip-stack-trace",
2068.4.1 by Andrew Hutchings
Fix intl domain
1131
  _("Don't print a stack trace on failure."))
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1132
  ("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1133
  _("Enable symbolic link support."))
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1134
  ("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1135
  _("Specify whether to time mutexes (only InnoDB mutexes are currently "
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1136
     "supported)"))
1757.2.4 by Monty Taylor
Next step.
1137
  ("tmpdir,t", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1138
  _("Path for temporary files."))
1757.2.4 by Monty Taylor
Next step.
1139
  ("transaction-isolation", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1140
  _("Default transaction isolation level."))
2132.3.1 by Andrew Hutchings
Make transaction_message_threshold a read-only global variable instead of a per-session variable
1141
  ("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
2068.4.1 by Andrew Hutchings
Fix intl domain
1142
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1863.1.7 by Monty Taylor
Add a constrained_value class which allows us to set compile-time
1143
  ("back-log", po::value<back_log_constraints>(&back_log),
2068.4.1 by Andrew Hutchings
Fix intl domain
1144
  _("The number of outstanding connection requests Drizzle can have. This "
1757.2.4 by Monty Taylor
Next step.
1145
     "comes into play when the main Drizzle thread gets very many connection "
1146
     "requests in a very short time."))
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1147
  ("bulk-insert-buffer-size",
1757.2.4 by Monty Taylor
Next step.
1148
  po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
2068.4.1 by Andrew Hutchings
Fix intl domain
1149
  _("Size of tree cache used in bulk insert optimization. Note that this is "
1757.2.4 by Monty Taylor
Next step.
1150
     "a limit per thread!"))
1151
  ("div-precision-increment",  po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
2068.4.1 by Andrew Hutchings
Fix intl domain
1152
  _("Precision of the result of '/' operator will be increased on that "
1757.2.4 by Monty Taylor
Next step.
1153
     "value."))
1154
  ("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
2068.4.1 by Andrew Hutchings
Fix intl domain
1155
  _("The maximum length of the result of function  group_concat."))
1757.2.4 by Monty Taylor
Next step.
1156
  ("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1157
  _("The size of the buffer that is used for full joins."))
1796.4.9 by Andrew Hutchings
Add join cache global constraint
1158
  ("join-heap-threshold",
1159
  po::value<uint64_t>()->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1160
  _("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1877.1.3 by Andrew Hutchings
Make default max_packet_size 64MB as 1MB doesn't seem really sane for text/blob columns
1161
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
2068.4.1 by Andrew Hutchings
Fix intl domain
1162
  _("Max packetlength to send/receive from to server."))
1757.2.4 by Monty Taylor
Next step.
1163
  ("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
2068.4.1 by Andrew Hutchings
Fix intl domain
1164
  _("Max number of errors/warnings to store for a statement."))
1757.2.4 by Monty Taylor
Next step.
1165
  ("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
2068.4.1 by Andrew Hutchings
Fix intl domain
1166
  _("Don't allow creation of heap tables bigger than this."))
2246.4.6 by Olaf van der Spek
Remove some unnecessary drizzled::
1167
  ("max-join-size", po::value<ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1168
  _("Joins that are probably going to read more than max_join_size records "
1757.2.4 by Monty Taylor
Next step.
1169
     "return an error."))
1170
  ("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
2068.4.1 by Andrew Hutchings
Fix intl domain
1171
  _("Max number of bytes in sorted records."))
1757.2.4 by Monty Taylor
Next step.
1172
  ("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
2068.4.1 by Andrew Hutchings
Fix intl domain
1173
  _("Limit assumed max number of seeks when looking up rows based on a key"))
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1174
  ("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
2068.4.1 by Andrew Hutchings
Fix intl domain
1175
  _("The number of bytes to use when sorting BLOB or TEXT values "
1757.2.4 by Monty Taylor
Next step.
1176
     "(only the first max_sort_length bytes of each value are used; the "
1177
     "rest are ignored)."))
1813.2.9 by Monty Taylor
Made data_home be fs::path natively.
1178
  ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
2068.4.1 by Andrew Hutchings
Fix intl domain
1179
  _("After this many write locks, allow some read locks to run in between."))
1757.2.4 by Monty Taylor
Next step.
1180
  ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
2068.4.1 by Andrew Hutchings
Fix intl domain
1181
  _("Don't log queries which examine less than min_examined_row_limit "
1757.2.4 by Monty Taylor
Next step.
1182
     "rows to file."))
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1183
  ("disable-optimizer-prune",
2068.4.1 by Andrew Hutchings
Fix intl domain
1184
  _("Do not apply any heuristic(s) during query optimization to prune, "
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1185
     "thus perform an exhaustive search from the optimizer search space."))
1757.2.4 by Monty Taylor
Next step.
1186
  ("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
2068.4.1 by Andrew Hutchings
Fix intl domain
1187
  _("Maximum depth of search performed by the query optimizer. Values "
1757.2.4 by Monty Taylor
Next step.
1188
     "larger than the number of relations in a query result in better query "
1189
     "plans, but take longer to compile a query. Smaller values than the "
1190
     "number of tables in a relation result in faster optimization, but may "
1191
     "produce very bad query plans. If set to 0, the system will "
1192
     "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1193
     "optimizer will switch to the original find_best (used for "
1194
     "testing/comparison)."))
1195
  ("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
2068.4.1 by Andrew Hutchings
Fix intl domain
1196
  _("The size of the buffer that is allocated when preloading indexes"))
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1197
  ("query-alloc-block-size",
1757.2.4 by Monty Taylor
Next step.
1198
  po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
2068.4.1 by Andrew Hutchings
Fix intl domain
1199
  _("Allocation block size for query parsing and execution"))
1757.2.4 by Monty Taylor
Next step.
1200
  ("query-prealloc-size",
1201
  po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
2068.4.1 by Andrew Hutchings
Fix intl domain
1202
  _("Persistent buffer for query parsing and execution"))
1757.2.4 by Monty Taylor
Next step.
1203
  ("range-alloc-block-size",
1204
  po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
2068.4.1 by Andrew Hutchings
Fix intl domain
1205
  _("Allocation block size for storing ranges during optimization"))
1757.2.4 by Monty Taylor
Next step.
1206
  ("read-buffer-size",
1207
  po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1208
  _("Each thread that does a sequential scan allocates a buffer of this "
1757.2.4 by Monty Taylor
Next step.
1209
      "size for each table it scans. If you do many sequential scans, you may "
1210
      "want to increase this value."))
1796.4.11 by Andrew Hutchings
Add global constraint on read buffer
1211
  ("read-buffer-threshold",
1212
  po::value<uint64_t>()->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1213
  _("A global cap on the size of read-buffer-size (0 means unlimited)"))
1757.2.4 by Monty Taylor
Next step.
1214
  ("read-rnd-buffer-size",
1215
  po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1216
  _("When reading rows in sorted order after a sort, the rows are read "
1757.2.4 by Monty Taylor
Next step.
1217
     "through this buffer to avoid a disk seeks. If not set, then it's set "
1218
     "to the value of record_buffer."))
1796.4.10 by Andrew Hutchings
Add global constraint for --read-rnd-buffer-size
1219
  ("read-rnd-threshold",
1220
  po::value<uint64_t>()->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1221
  _("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1757.2.4 by Monty Taylor
Next step.
1222
  ("scheduler", po::value<string>(),
2068.4.1 by Andrew Hutchings
Fix intl domain
1223
  _("Select scheduler to be used (by default multi-thread)."))
1757.2.4 by Monty Taylor
Next step.
1224
  ("sort-buffer-size",
1225
  po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1226
  _("Each thread that needs to do a sort allocates a buffer of this size."))
1796.4.1 by Andrew Hutchings
Add initial template work and test
1227
  ("sort-heap-threshold",
1796.4.8 by Andrew Hutchings
Change default setting
1228
  po::value<uint64_t>()->default_value(0),
2068.4.1 by Andrew Hutchings
Fix intl domain
1229
  _("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1757.2.4 by Monty Taylor
Next step.
1230
  ("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
2068.4.1 by Andrew Hutchings
Fix intl domain
1231
  _("The number of cached table definitions."))
1757.2.4 by Monty Taylor
Next step.
1232
  ("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
2068.4.1 by Andrew Hutchings
Fix intl domain
1233
  _("The number of cached open tables."))
1757.2.4 by Monty Taylor
Next step.
1234
  ("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
2068.4.1 by Andrew Hutchings
Fix intl domain
1235
  _("Timeout in seconds to wait for a table level lock before returning an "
1757.2.4 by Monty Taylor
Next step.
1236
     "error. Used only if the connection has active cursors."))
2385.3.8 by Olaf van der Spek
Refactor
1237
  ("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(0)->notifier(&check_limits_thread_stack),
2068.4.1 by Andrew Hutchings
Fix intl domain
1238
  _("The stack size for each thread."))
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1239
  ("tmp-table-size",
1757.2.4 by Monty Taylor
Next step.
1240
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
2068.4.1 by Andrew Hutchings
Fix intl domain
1241
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
1757.2.4 by Monty Taylor
Next step.
1242
     " automatically convert it to an on-disk MyISAM table."))
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
1243
  ("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
2215.3.2 by Andrew Hutchings
Make mysql_protocol Listening message INFO level.
1244
  _("The verbosity of messages from drizzled.  Possible values are INSPECT, INFO, WARN or ERROR"))
1757.2.4 by Monty Taylor
Next step.
1245
  ;
1246
1794.3.1 by Monty Taylor
Rearranged option processing.
1247
  full_options.add(long_options);
1248
  full_options.add(plugin_load_options);
1249
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1250
  initial_options.add(general_options);
1794.3.1 by Monty Taylor
Rearranged option processing.
1251
  initial_options.add(config_options);
1252
  initial_options.add(plugin_load_options);
1253
1798.2.3 by Monty Taylor
Concatenate paths differently for pid-file.
1254
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1255
1794.3.1 by Monty Taylor
Rearranged option processing.
1256
  /* Get options about where config files and the like are */
1793.3.1 by Andrew Hutchings
Disable boost:po allow_guessing which was making some wrong assumptions
1257
  po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1794.3.7 by Monty Taylor
It turns out anything the extra_parser returns a value for gets consumed,
1258
    options(initial_options).allow_unregistered().run();
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1259
1260
  unknown_options= po::collect_unrecognized(parsed.options, po::include_positional);
1757.2.4 by Monty Taylor
Next step.
1261
1757.2.14 by Monty Taylor
Added in exception handling around duplicate options. Should fix for real.
1262
  try
1263
  {
1264
    po::store(parsed, vm);
1265
  }
1966.3.1 by Monty Taylor
Use std::exception instead of catch(...)
1266
  catch (std::exception&)
1757.2.14 by Monty Taylor
Added in exception handling around duplicate options. Should fix for real.
1267
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1268
    unireg_abort << _("Duplicate entry for command line option");
1757.2.14 by Monty Taylor
Added in exception handling around duplicate options. Should fix for real.
1269
  }
1270
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1271
  /* TODO: here is where we should add a process_env_vars */
1272
1273
  /* We need a notify here so that plugin_init will work properly */
1274
  try
1275
  {
1276
    po::notify(vm);
1277
  }
1278
  catch (po::validation_error &err)
1279
  {
1280
    unireg_abort << "Use --help to get a list of available options. " << err.what(); 
1281
  }
1282
1283
  if (vm.count("version"))
1284
  {
1285
    print_version();
1286
    unireg_exit();
1287
  }
1288
1289
  if (vm.count("no-defaults"))
1757.2.4 by Monty Taylor
Next step.
1290
  {
1938.2.1 by Monty Taylor
Actually set default paths appropriately.
1291
    fs::path system_config_file_drizzle(system_config_dir);
1292
    system_config_file_drizzle /= "drizzled.cnf";
2318.5.30 by Olaf van der Spek
Refactor
1293
    defaults_file_list.insert(defaults_file_list.begin(), system_config_file_drizzle.file_string());
1879.3.1 by Monty Taylor
Removed some stupid extra path manipulations.
1294
1295
    fs::path config_conf_d_location(system_config_dir);
1296
    config_conf_d_location /= "conf.d";
1297
1298
    CachedDirectory config_conf_d(config_conf_d_location.file_string());
1299
    if (not config_conf_d.fail())
1776.4.4 by Monty Taylor
Added code to run-parts a conf.d dir.
1300
    {
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
1301
			BOOST_FOREACH(CachedDirectory::Entries::const_reference iter, config_conf_d.getEntries())
1776.4.4 by Monty Taylor
Added code to run-parts a conf.d dir.
1302
      {
2246.4.1 by Olaf van der Spek
Use BOOST_FOREACH
1303
        string file_entry(iter->filename);
2318.5.30 by Olaf van der Spek
Refactor
1304
        if (not file_entry.empty() && file_entry != "." && file_entry != "..")
1305
          defaults_file_list.push_back((config_conf_d_location / file_entry).file_string());
1776.4.4 by Monty Taylor
Added code to run-parts a conf.d dir.
1306
      }
1307
    }
1308
  }
1309
1883.2.1 by Andrew Hutchings
The --defaults-file option was processed after a list of options files was processed, so lets change this
1310
  process_defaults_files();
1311
1312
  /* Process with notify a second time because a config file may contain
1313
     plugin loader options */
1314
1315
  try
1316
  {
1317
    po::notify(vm);
1318
  }
1319
  catch (po::validation_error &err)
1320
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1321
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1883.2.1 by Andrew Hutchings
The --defaults-file option was processed after a list of options files was processed, so lets change this
1322
  }
1323
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1324
  return true;
2131.10.7 by Stewart Smith
partition the initialisation of variables and command line options into two phases: the first being the simple one (that we can get out the --daemon option for) and the second being loading plugins, pidfile setup etc. This makes --daemon do the pidfile correctly.
1325
}
1326
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1327
// Return failure if we can't pass this, unireg_abort() will then be called
1328
// by the caller.
1329
bool init_variables_after_daemonizing(module::Registry &plugins)
2131.10.7 by Stewart Smith
partition the initialisation of variables and command line options into two phases: the first being the simple one (that we can get out the --daemon option for) and the second being loading plugins, pidfile setup etc. This makes --daemon do the pidfile correctly.
1330
{
1331
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1332
1333
  current_pid= getpid();		/* Save for later ref */
1334
1794.3.1 by Monty Taylor
Rearranged option processing.
1335
  /* At this point, we've read all the options we need to read from files and
1336
     collected most of them into unknown options - now let's load everything
1337
  */
1338
1339
  if (plugin_init(plugins, plugin_options))
1340
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1341
    unireg_abort << _("Failed to initialize plugins");
1794.3.1 by Monty Taylor
Rearranged option processing.
1342
  }
1343
1344
  full_options.add(plugin_options);
1345
1346
  vector<string> final_unknown_options;
1347
  try
1348
  {
1349
    po::parsed_options final_parsed=
1798.2.1 by Monty Taylor
Merged in options fixes.
1350
      po::command_line_parser(unknown_options).style(style).
1926.2.1 by Monty Taylor
Add better boolean parsing and size suffix parsing.
1351
      options(full_options).extra_parser(dpo::parse_size_arg).run();
1794.3.1 by Monty Taylor
Rearranged option processing.
1352
1353
    final_unknown_options=
1354
      po::collect_unrecognized(final_parsed.options, po::include_positional);
1355
1356
    po::store(final_parsed, vm);
1357
1358
  }
1863.1.7 by Monty Taylor
Add a constrained_value class which allows us to set compile-time
1359
  catch (po::validation_error &err)
1360
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1361
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1863.1.7 by Monty Taylor
Add a constrained_value class which allows us to set compile-time
1362
  }
1794.3.1 by Monty Taylor
Rearranged option processing.
1363
  catch (po::invalid_command_line_syntax &err)
1364
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1365
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1794.3.1 by Monty Taylor
Rearranged option processing.
1366
  }
1367
  catch (po::unknown_option &err)
1368
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1369
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1794.3.1 by Monty Taylor
Rearranged option processing.
1370
  }
1757.2.4 by Monty Taylor
Next step.
1371
1863.1.7 by Monty Taylor
Add a constrained_value class which allows us to set compile-time
1372
  try
1373
  {
1374
    po::notify(vm);
1375
  }
1376
  catch (po::validation_error &err)
1377
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1378
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1863.1.7 by Monty Taylor
Add a constrained_value class which allows us to set compile-time
1379
  }
1794.3.6 by Monty Taylor
Call po::notify _after_ get_options. Doh.
1380
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1381
  get_options();
1 by brian
clean slate
1382
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1383
  /* Inverted Booleans */
1384
2252.1.28 by Olaf van der Spek
Refactor Program Options usage
1385
  global_system_variables.optimizer_prune_level= not vm.count("disable-optimizer-prune");
1757.5.1 by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option.
1386
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1387
  if ((user_info= check_user(drizzled_user)))
1655.1.1 by Andrew Hutchings
1. Move message handler hook earier so that errors during init_commit_variables do not segfault
1388
  {
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1389
    set_user(drizzled_user, user_info);
1655.1.1 by Andrew Hutchings
1. Move message handler hook earier so that errors during init_commit_variables do not segfault
1390
  }
1391
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
1392
  fix_paths();
1655.1.1 by Andrew Hutchings
1. Move message handler hook earier so that errors during init_commit_variables do not segfault
1393
909 by Brian Aker
Remove the need for unireg init
1394
  init_time();				/* Init time-functions (read zone) */
1395
2318.6.77 by Olaf van der Spek
Refactor
1396
  item_create_init();
1878.3.1 by Monty Taylor
Split set_var.* into sys_var.* and set_var.*
1397
  if (sys_var_init())
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1398
  {
1399
    return false;
1400
  }
1401
813.1.2 by Jay Pipes
First function cleanup for temporal handling: YEAR()
1402
  /* Creates static regex matching for temporal values */
2363.1.1 by Brian Aker
Fix memory leak in temporal and json server.
1403
  if (not init_temporal_formats())
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1404
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1405
    return false;
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1406
  }
1085.3.6 by Monty Taylor
Removed a problematic section that's pointless.
1407
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1408
  if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1 by brian
clean slate
1409
  {
2126.3.3 by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch.
1410
    errmsg_printf(error::ERROR, _("Error getting default charset"));
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1411
    return false;                           // Eof of the list
1 by brian
clean slate
1412
  }
1413
1794.3.2 by Andrew Hutchings
Re-enabled scheduler option.
1414
  if (vm.count("scheduler"))
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1415
  {
1794.3.2 by Andrew Hutchings
Re-enabled scheduler option.
1416
    opt_scheduler= vm["scheduler"].as<string>().c_str();
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1417
  }
1794.3.2 by Andrew Hutchings
Re-enabled scheduler option.
1418
1 by brian
clean slate
1419
  /* Set collactions that depends on the default collation */
1420
  global_system_variables.collation_server=	 default_charset_info;
1421
2462.2.1 by Olaf van der Spek
Refactor
1422
  if (not (character_set_filesystem= get_charset_by_csname("binary", MY_CS_PRIMARY)))
1743.4.1 by LinuxJedi
Make sure unireg_abort shows the reason for the fail.
1423
  {
2126.3.3 by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch.
1424
    errmsg_printf(error::ERROR, _("Error setting collation"));
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1425
    return false;
1743.4.1 by LinuxJedi
Make sure unireg_abort shows the reason for the fail.
1426
  }
1 by brian
clean slate
1427
  global_system_variables.character_set_filesystem= character_set_filesystem;
1428
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1429
  if ((my_default_lc_time_names= my_locale_by_name(lc_time_names_name)) == NULL)
1 by brian
clean slate
1430
  {
2126.3.3 by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch.
1431
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1432
    return false;
1 by brian
clean slate
1433
  }
1434
  global_system_variables.lc_time_names= my_default_lc_time_names;
236.1.40 by Monty Taylor
A few meaningless changes.
1435
1039.1.5 by Brian Aker
Remove lower case filename bits (aka we just lock into the most compatible
1436
  /* Reset table_alias_charset */
224.2.1 by Brian Aker
First pass for table name issue across platforms.
1437
  table_alias_charset= files_charset_info;
1 by brian
clean slate
1438
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1439
  return true;
1 by brian
clean slate
1440
}
1441
2392.1.1 by Brian Aker
Fixes for --help work.
1442
bool was_help_requested()
1443
{
2462.2.1 by Olaf van der Spek
Refactor
1444
  return vm.count("help");
2392.1.1 by Brian Aker
Fixes for --help work.
1445
}
1446
1447
void usage();
1 by brian
clean slate
1448
2318.6.57 by Olaf van der Spek
Refactor
1449
void init_server_components(module::Registry &plugins)
1 by brian
clean slate
1450
{
2392.1.1 by Brian Aker
Fixes for --help work.
1451
  if (was_help_requested())
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1452
  {
1453
    usage();
1454
  }
1455
1 by brian
clean slate
1456
  /*
1457
    We need to call each of these following functions to ensure that
1458
    all things are initialized so that unireg_abort() doesn't fail
1459
  */
1877.2.9 by Brian Aker
Adding cache.h for definition.
1460
1461
  // Resize the definition Cache at startup
2275.3.1 by Olaf van der Spek
Remove table::Cache::singleton()
1462
  table::Cache::rehash(table_def_size);
2275.3.6 by Olaf van der Spek
Definition Cache
1463
  definition::Cache::rehash(table_def_size);
1910.2.14 by Brian Aker
Check simple cache performance hit.
1464
  message::Cache::singleton().rehash(table_def_size);
1 by brian
clean slate
1465
1466
  setup_fpu();
1467
1468
  /* Allow storage engine to give real error messages */
1271.7.9 by Tim Penhey
Almost there.
1469
  ha_init_errors();
1 by brian
clean slate
1470
1794.3.5 by Monty Taylor
Fixed temporoary dir sequencing.
1471
  if (plugin_finalize(plugins))
1472
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1473
    unireg_abort << "plugin_finalize() failed";
1794.3.5 by Monty Taylor
Fixed temporoary dir sequencing.
1474
  }
1672.2.1 by Monty Taylor
Fixed plugin option processing. Now we pre-load the modules registering
1475
2318.2.16 by Olaf van der Spek
Refactor
1476
  if (plugin::Scheduler::setPlugin(opt_scheduler))
1477
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1478
    unireg_abort << _("No scheduler found");
994.2.2 by Monty Taylor
Store a Registry of SchedulerFactories and set one of them at startup for better error messages earlier.
1479
  }
1480
1 by brian
clean slate
1481
  /*
971.1.22 by Monty Taylor
Moved storage engine initialization to init methods.
1482
    This is entirely for legacy. We will create a new "disk based" engine and a
1115.1.3 by Brian Aker
Remove final bits of "myisam" specific from drizzled.cc
1483
    "memory" engine which will be configurable longterm.
971.1.22 by Monty Taylor
Moved storage engine initialization to init methods.
1484
  */
2318.2.16 by Olaf van der Spek
Refactor
1485
  myisam_engine= plugin::StorageEngine::findByName("MyISAM");
1486
  heap_engine= plugin::StorageEngine::findByName("MEMORY");
971.1.22 by Monty Taylor
Moved storage engine initialization to init methods.
1487
1488
  /*
1 by brian
clean slate
1489
    Check that the default storage engine is actually available.
1490
  */
1491
  if (default_storage_engine_str)
1492
  {
2318.2.16 by Olaf van der Spek
Refactor
1493
    plugin::StorageEngine *engine= plugin::StorageEngine::findByName(default_storage_engine_str);
1095.3.32 by Stewart Smith
misc codestyle fixes. usually around if ( and associated conditions
1494
    if (engine == NULL)
971.1.21 by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin.
1495
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1496
      unireg_abort << _("Unknown/unsupported storage engine: ") << default_storage_engine_str;
1273.1.20 by Jay Pipes
Remove StorageEngine::start_consitent_snapshot() and StorageEngine::enable(), disable() and is_enabled(). Unused.
1497
    }
1498
    global_system_variables.storage_engine= engine;
1 by brian
clean slate
1499
  }
1500
1720.5.3 by Monty Taylor
Removed a HASH in xa_resource_manager. It's not actually used, but I left it
1501
  if (plugin::XaResourceManager::recoverAllXids())
1 by brian
clean slate
1502
  {
1743.4.1 by LinuxJedi
Make sure unireg_abort shows the reason for the fail.
1503
    /* This function alredy generates error messages */
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1504
    unireg_abort << "plugin::XaResourceManager::recoverAllXids() failed";
1 by brian
clean slate
1505
  }
1506
1507
  init_update_queries();
1508
}
1509
1510
1511
/****************************************************************************
1512
  Handle start options
1513
******************************************************************************/
1514
575.4.4 by Yoshinori Sano
Rename mysql to drizzle.
1515
enum options_drizzled
1 by brian
clean slate
1516
{
1067.1.4 by Stewart Smith
remove unused log-isam server option
1517
  OPT_SOCKET=256,
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1518
  OPT_BIND_ADDRESS,
1115.1.2 by Brian Aker
Taylor the defaults for MyISAM for its "tmp" behavior.
1519
  OPT_PID_FILE,
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1520
  OPT_STORAGE_ENGINE,
867 by Brian Aker
Remove dead options.
1521
  OPT_INIT_FILE,
1 by brian
clean slate
1522
  OPT_WANT_CORE,
867 by Brian Aker
Remove dead options.
1523
  OPT_MEMLOCK,
614 by Brian Aker
Remove filtering (wrong layer, belongs in plugin).
1524
  OPT_SERVER_ID,
867 by Brian Aker
Remove dead options.
1525
  OPT_TC_HEURISTIC_RECOVER,
1 by brian
clean slate
1526
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
1527
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
867 by Brian Aker
Remove dead options.
1528
  OPT_DO_PSTACK,
1529
  OPT_LOCAL_INFILE,
798.2.18 by Brian Aker
Remove dead COM for BINLOG/REGISTER.
1530
  OPT_BACK_LOG,
956 by Brian Aker
Remove dead options.
1531
  OPT_JOIN_BUFF_SIZE,
1532
  OPT_MAX_ALLOWED_PACKET,
1 by brian
clean slate
1533
  OPT_MAX_HEP_TABLE_SIZE,
245 by Brian Aker
Removed dead variables.
1534
  OPT_MAX_JOIN_SIZE,
956 by Brian Aker
Remove dead options.
1535
  OPT_MAX_SORT_LENGTH,
1 by brian
clean slate
1536
  OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
1537
  OPT_MAX_LENGTH_FOR_SORT_DATA,
1538
  OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
1539
  OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE,
1540
  OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
1541
  OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
1542
  OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
971.3.60 by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin.
1543
  OPT_NET_BUFFER_LENGTH,
1 by brian
clean slate
1544
  OPT_PRELOAD_BUFFER_SIZE,
245 by Brian Aker
Removed dead variables.
1545
  OPT_RECORD_BUFFER,
867 by Brian Aker
Remove dead options.
1546
  OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT,
1547
  OPT_DEBUGGING,
1 by brian
clean slate
1548
  OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE,
1549
  OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
1550
  OPT_WAIT_TIMEOUT,
80.2.1 by mark
remove handling of suspicious UDFs
1551
  OPT_RANGE_ALLOC_BLOCK_SIZE,
1 by brian
clean slate
1552
  OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
1553
  OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
1554
  OPT_OLD_ALTER_TABLE,
1555
  OPT_GROUP_CONCAT_MAX_LEN,
1556
  OPT_DEFAULT_COLLATION,
1557
  OPT_CHARACTER_SET_FILESYSTEM,
1558
  OPT_LC_TIME_NAMES,
1559
  OPT_INIT_CONNECT,
1560
  OPT_DEFAULT_TIME_ZONE,
1561
  OPT_OPTIMIZER_SEARCH_DEPTH,
868 by Brian Aker
Adding Multi-threaded Scheduler into the system.
1562
  OPT_SCHEDULER,
994.2.2 by Monty Taylor
Store a Registry of SchedulerFactories and set one of them at startup for better error messages earlier.
1563
  OPT_PROTOCOL,
1 by brian
clean slate
1564
  OPT_OPTIMIZER_PRUNE_LEVEL,
1565
  OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET,
1566
  OPT_ENABLE_LARGE_PAGES,
1567
  OPT_TIMED_MUTEXES,
1568
  OPT_TABLE_LOCK_WAIT_TIMEOUT,
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
1569
  OPT_PLUGIN_ADD,
1283.1.5 by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins
1570
  OPT_PLUGIN_REMOVE,
1 by brian
clean slate
1571
  OPT_PLUGIN_LOAD,
1572
  OPT_PLUGIN_DIR,
1573
  OPT_PORT_OPEN_TIMEOUT,
1574
  OPT_SECURE_FILE_PRIV,
1743.3.2 by LinuxJedi
Make --print-defaults ack as old behaviour for the defaults list at the end of --help because this is still needed in drizzled for dtr. Killing 2 birds with one stone.
1575
  OPT_MIN_EXAMINED_ROW_LIMIT,
1576
  OPT_PRINT_DEFAULTS
1 by brian
clean slate
1577
};
1578
1579
1410.3.4 by Djellel E. Difallah
update references to old my_'s
1580
struct option my_long_options[] =
1 by brian
clean slate
1581
{
1582
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1583
   N_("Auto-increment columns are incremented by this"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1584
   (char**) &global_system_variables.auto_increment_increment,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1585
   NULL, 0, GET_ULL,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1586
   OPT_ARG, 1, 1, INT64_MAX, 0, 1, 0 },
1 by brian
clean slate
1587
  {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1588
   N_("Offset added to Auto-increment columns. Used when "
1589
      "auto-increment-increment != 1"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1590
   (char**) &global_system_variables.auto_increment_offset,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1591
   NULL, 0, GET_ULL, OPT_ARG,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1592
   1, 1, INT64_MAX, 0, 1, 0 },
1 by brian
clean slate
1593
  {"basedir", 'b',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1594
   N_("Path to installation directory. All paths are usually resolved "
1595
      "relative to this."),
1813.2.1 by Monty Taylor
Migrated --basedir to feed a path.
1596
   NULL, NULL, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
1597
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1598
  {"chroot", 'r',
575.4.4 by Yoshinori Sano
Rename mysql to drizzle.
1599
   N_("Chroot drizzled daemon during startup."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1600
   (char**) &drizzled_chroot, NULL, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
1601
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1602
  {"completion-type", OPT_COMPLETION_TYPE,
1603
   N_("Default completion type."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1604
   (char**) &global_system_variables.completion_type,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1605
   NULL, 0, GET_UINT,
1 by brian
clean slate
1606
   REQUIRED_ARG, 0, 0, 2, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1607
  {"core-file", OPT_WANT_CORE,
1608
   N_("Write core on errors."),
1609
   0, 0, 0, GET_NO_ARG,
1 by brian
clean slate
1610
   NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1611
  {"datadir", 'h',
1612
   N_("Path to the database root."),
1786.3.1 by Monty Taylor
Initial working local catalog.
1613
   NULL, NULL, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
1614
  /* See how it's handled in get_one_option() */
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1615
  {"exit-info", 'T',
1616
   N_("Used for debugging;  Use at your own risk!"),
1617
   0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
1618
  /* We must always support the next option to make scripts like mysqltest
1619
     easier to do */
1620
  {"gdb", OPT_DEBUGGING,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1621
   N_("Set up signals usable for debugging"),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1622
   (char**) &opt_debugging, NULL,
1 by brian
clean slate
1623
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1624
  {"log-warnings", 'W',
1625
   N_("Log some not critical warnings to the log file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1626
   (char**) &global_system_variables.log_warnings,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1627
   NULL, 0, GET_BOOL, OPT_ARG, 1, 0, 0,
1 by brian
clean slate
1628
   0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1629
  {"pid-file", OPT_PID_FILE,
1776.5.1 by Vijay Samuel
Merge removed the -h short form for --datadir and replaced safe_mysqld with drizzled in help message of --pid-file
1630
   N_("Pid file used by drizzled."),
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
1631
   NULL, NULL, 0, GET_STR,
1 by brian
clean slate
1632
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1633
  {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1634
   N_("Maximum time in seconds to wait for the port to become free. "
1635
      "(Default: no wait)"),
971.6.7 by Eric Day
Reworked listen interface to not require binding of TCP ports.
1636
   (char**) &drizzled_bind_timeout,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1637
   NULL, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
1638
  {"secure-file-priv", OPT_SECURE_FILE_PRIV,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1639
   N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1640
      "within specified directory"),
1813.2.6 by Monty Taylor
Made secure_file_priv be an fs::path from the beginning.
1641
   NULL, NULL, 0,
1 by brian
clean slate
1642
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1643
  {"server-id",	OPT_SERVER_ID,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1644
   N_("Uniquely identifies the server instance in the community of "
1645
      "replication partners."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1646
   (char**) &server_id, NULL, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 0,
1 by brian
clean slate
1647
   0, 0, 0},
1648
  {"skip-stack-trace", OPT_SKIP_STACK_TRACE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1649
   N_("Don't print a stack trace on failure."),
1650
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
1 by brian
clean slate
1651
   0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1652
  {"symbolic-links", 's',
1653
   N_("Enable symbolic link support."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1654
   (char**) &internal::my_use_symdir, NULL, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
1655
   /*
1656
     The system call realpath() produces warnings under valgrind and
1657
     purify. These are not suppressed: instead we disable symlinks
1658
     option if compiled with valgrind support.
1659
   */
1660
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
1661
  {"timed_mutexes", OPT_TIMED_MUTEXES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1662
   N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1663
      "supported)"),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1664
   (char**) &internal::timed_mutexes, NULL, 0, GET_BOOL, NO_ARG, 0,
1 by brian
clean slate
1665
    0, 0, 0, 0, 0},
1666
  {"transaction-isolation", OPT_TX_ISOLATION,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1667
   N_("Default transaction isolation level."),
1668
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1 by brian
clean slate
1669
   0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1670
  {"user", 'u',
574.2.1 by ysano
Rename mysql to drizzle.
1671
   N_("Run drizzled daemon as user."),
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1672
   0, 0, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
1673
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1674
  {"back_log", OPT_BACK_LOG,
575.4.4 by Yoshinori Sano
Rename mysql to drizzle.
1675
   N_("The number of outstanding connection requests Drizzle can have. This "
1676
      "comes into play when the main Drizzle thread gets very many connection "
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1677
      "requests in a very short time."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1678
    (char**) &back_log, NULL, 0, GET_UINT,
1 by brian
clean slate
1679
    REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1680
  { "bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
672.1.3 by Andrew Hutchings
Minor string fixes (mainly US English spelling and typos)
1681
    N_("Size of tree cache used in bulk insert optimization. Note that this is "
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1682
       "a limit per thread!"),
1683
    (char**) &global_system_variables.bulk_insert_buff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1684
    NULL,
619 by Brian Aker
Removed ulong methods from vars.
1685
    0, GET_ULL, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1686
  { "div_precision_increment", OPT_DIV_PRECINCREMENT,
1687
   N_("Precision of the result of '/' operator will be increased on that "
1688
      "value."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1689
   (char**) &global_system_variables.div_precincrement,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1690
   NULL, 0, GET_UINT,
1 by brian
clean slate
1691
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1692
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1693
    N_("The size of the buffer that is used for full joins."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1694
   (char**) &global_system_variables.join_buff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1695
   NULL, 0, GET_UINT64,
1 by brian
clean slate
1696
   REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
1697
   MALLOC_OVERHEAD, IO_SIZE, 0},
1698
  {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1699
   N_("Max packetlength to send/receive from to server."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1700
   (char**) &global_system_variables.max_allowed_packet,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1701
   NULL, 0, GET_UINT32,
1877.1.3 by Andrew Hutchings
Make default max_packet_size 64MB as 1MB doesn't seem really sane for text/blob columns
1702
   REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1 by brian
clean slate
1703
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1704
   N_("Don't allow creation of heap tables bigger than this."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1705
   (char**) &global_system_variables.max_heap_table_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1706
   NULL, 0, GET_ULL,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1707
   REQUIRED_ARG, 16*1024*1024L, 16384, (int64_t)MAX_MEM_TABLE_SIZE,
1 by brian
clean slate
1708
   MALLOC_OVERHEAD, 1024, 0},
1709
  {"max_join_size", OPT_MAX_JOIN_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1710
   N_("Joins that are probably going to read more than max_join_size records "
1711
      "return an error."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1712
   (char**) &global_system_variables.max_join_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1713
   NULL, 0, GET_HA_ROWS, REQUIRED_ARG,
365.2.8 by Monty Taylor
More MAX macros.
1714
   INT32_MAX, 1, INT32_MAX, 0, 1, 0},
312.1.12 by Monty Taylor
Fixed a syntax oops.
1715
  {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
1716
   N_("Max number of bytes in sorted records."),
1717
   (char**) &global_system_variables.max_length_for_sort_data,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1718
   NULL, 0, GET_ULL,
312.1.12 by Monty Taylor
Fixed a syntax oops.
1719
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
1 by brian
clean slate
1720
  { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1721
    N_("Limit assumed max number of seeks when looking up rows based on a key"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1722
    (char**) &global_system_variables.max_seeks_for_key,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1723
    NULL, 0, GET_UINT64,
1 by brian
clean slate
1724
    REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
1725
  {"max_sort_length", OPT_MAX_SORT_LENGTH,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1726
   N_("The number of bytes to use when sorting BLOB or TEXT values "
1727
      "(only the first max_sort_length bytes of each value are used; the "
1728
      "rest are ignored)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1729
   (char**) &global_system_variables.max_sort_length,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1730
   NULL, 0, GET_SIZE,
1 by brian
clean slate
1731
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
1732
  {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1733
   N_("After this many write locks, allow some read locks to run in between."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1734
   (char**) &max_write_lock_count, NULL, 0, GET_ULL,
1 by brian
clean slate
1735
   REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
1736
  {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1737
   N_("Don't log queries which examine less than min_examined_row_limit "
1738
      "rows to file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1739
   (char**) &global_system_variables.min_examined_row_limit,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1740
   NULL, 0, GET_ULL,
312.1.12 by Monty Taylor
Fixed a syntax oops.
1741
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
1 by brian
clean slate
1742
  {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
619 by Brian Aker
Removed ulong methods from vars.
1743
    N_("Controls the heuristic(s) applied during query optimization to prune "
1744
       "less-promising partial plans from the optimizer search space. Meaning: "
1745
       "false - do not apply any heuristic, thus perform exhaustive search; "
1746
       "true - prune plans based on number of retrieved rows."),
1747
    (char**) &global_system_variables.optimizer_prune_level,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1748
    NULL,
619 by Brian Aker
Removed ulong methods from vars.
1749
    0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 1, 0},
1 by brian
clean slate
1750
  {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1751
   N_("Maximum depth of search performed by the query optimizer. Values "
1752
      "larger than the number of relations in a query result in better query "
1753
      "plans, but take longer to compile a query. Smaller values than the "
1754
      "number of tables in a relation result in faster optimization, but may "
1755
      "produce very bad query plans. If set to 0, the system will "
1756
      "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1757
      "optimizer will switch to the original find_best (used for "
1758
      "testing/comparison)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1759
   (char**) &global_system_variables.optimizer_search_depth,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1760
   NULL,
1108.6.44 by Padraig O'Sullivan
Set the default value for optimizer_search_depth to 0.
1761
   0, GET_UINT, OPT_ARG, 0, 0, MAX_TABLES+2, 0, 1, 0},
1 by brian
clean slate
1762
  {"plugin_dir", OPT_PLUGIN_DIR,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1763
   N_("Directory for plugins."),
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
1764
   NULL, NULL, 0,
1 by brian
clean slate
1765
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
1766
  {"plugin_add", OPT_PLUGIN_ADD,
1767
   N_("Optional comma separated list of plugins to load at startup in addition "
1768
      "to the default list of plugins. "
1769
      "[for example: --plugin_add=crc32,logger_gearman]"),
1776.4.1 by Monty Taylor
Migrates the creation of the plugin lists to have program_options directly
1770
   NULL, NULL, 0,
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
1771
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1283.1.5 by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins
1772
  {"plugin_remove", OPT_PLUGIN_ADD,
1773
   N_("Optional comma separated list of plugins to not load at startup. Effectively "
1774
      "removes a plugin from the list of plugins to be loaded. "
1775
      "[for example: --plugin_remove=crc32,logger_gearman]"),
1776.4.1 by Monty Taylor
Migrates the creation of the plugin lists to have program_options directly
1776
   NULL, NULL, 0,
1283.1.5 by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins
1777
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
1778
  {"plugin_load", OPT_PLUGIN_LOAD,
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
1779
   N_("Optional comma separated list of plugins to load at starup instead of "
1780
      "the default plugin load list. "
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
1781
      "[for example: --plugin_load=crc32,logger_gearman]"),
1776.4.1 by Monty Taylor
Migrates the creation of the plugin lists to have program_options directly
1782
   NULL, NULL, 0,
1 by brian
clean slate
1783
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1784
  {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1785
   N_("The size of the buffer that is allocated when preloading indexes"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1786
   (char**) &global_system_variables.preload_buff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1787
   NULL, 0, GET_ULL,
1 by brian
clean slate
1788
   REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
1789
  {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1790
   N_("Allocation block size for query parsing and execution"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1791
   (char**) &global_system_variables.query_alloc_block_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1792
   NULL, 0, GET_UINT,
1 by brian
clean slate
1793
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
1794
  {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1795
   N_("Persistent buffer for query parsing and execution"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1796
   (char**) &global_system_variables.query_prealloc_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1797
   NULL, 0, GET_UINT,
1 by brian
clean slate
1798
   REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
1799
   ULONG_MAX, 0, 1024, 0},
1800
  {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1801
   N_("Allocation block size for storing ranges during optimization"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1802
   (char**) &global_system_variables.range_alloc_block_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1803
   NULL, 0, GET_SIZE,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1804
   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, (int64_t)SIZE_MAX,
1 by brian
clean slate
1805
   0, 1024, 0},
1806
  {"read_buffer_size", OPT_RECORD_BUFFER,
619 by Brian Aker
Removed ulong methods from vars.
1807
    N_("Each thread that does a sequential scan allocates a buffer of this "
1808
       "size for each table it scans. If you do many sequential scans, you may "
1809
       "want to increase this value."),
1810
    (char**) &global_system_variables.read_buff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1811
    NULL,0, GET_UINT, REQUIRED_ARG,
619 by Brian Aker
Removed ulong methods from vars.
1812
    128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
1813
    0},
1 by brian
clean slate
1814
  {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1815
   N_("When reading rows in sorted order after a sort, the rows are read "
1816
      "through this buffer to avoid a disk seeks. If not set, then it's set "
1817
      "to the value of record_buffer."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1818
   (char**) &global_system_variables.read_rnd_buff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1819
   NULL, 0,
619 by Brian Aker
Removed ulong methods from vars.
1820
   GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
1821
   UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
1034.1.6 by Brian Aker
Increase the default sort buffer size.
1822
  /* x8 compared to MySQL's x2. We have UTF8 to consider. */
1 by brian
clean slate
1823
  {"sort_buffer_size", OPT_SORT_BUFFER,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1824
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1825
   (char**) &global_system_variables.sortbuff_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1826
   NULL, 0, GET_SIZE, REQUIRED_ARG,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1827
   MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*8, (int64_t)SIZE_MAX,
1 by brian
clean slate
1828
   MALLOC_OVERHEAD, 1, 0},
1829
  {"table_definition_cache", OPT_TABLE_DEF_CACHE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1830
   N_("The number of cached table definitions."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1831
   (char**) &table_def_size, NULL,
1226.1.3 by Brian Aker
Possible solution for hash/rehash.
1832
   0, GET_SIZE, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
1 by brian
clean slate
1833
  {"table_open_cache", OPT_TABLE_OPEN_CACHE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1834
   N_("The number of cached open tables."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1835
   (char**) &table_cache_size, NULL, 0, GET_UINT64,
1313.1.19 by Stewart Smith
TABLE_OPEN_CACHE_MIN should be used instead of unused.
1836
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, TABLE_OPEN_CACHE_MIN, 512*1024L, 0, 1, 0},
1 by brian
clean slate
1837
  {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1838
   N_("Timeout in seconds to wait for a table level lock before returning an "
1839
      "error. Used only if the connection has active cursors."),
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1840
   (char**) &table_lock_wait_timeout, NULL,
622.1.1 by Brian Aker
32bit fixes around vars
1841
   0, GET_ULL, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
1 by brian
clean slate
1842
  {"thread_stack", OPT_THREAD_STACK,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1843
   N_("The stack size for each thread."),
1844
   (char**) &my_thread_stack_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1845
   NULL, 0, GET_SIZE,
2385.3.8 by Olaf van der Spek
Refactor
1846
   REQUIRED_ARG,0,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1847
   UINT32_C(1024*512), (int64_t)SIZE_MAX, 0, 1024, 0},
1 by brian
clean slate
1848
  {"tmp_table_size", OPT_TMP_TABLE_SIZE,
672.1.3 by Andrew Hutchings
Minor string fixes (mainly US English spelling and typos)
1849
   N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1850
      " automatically convert it to an on-disk MyISAM table."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
1851
   (char**) &global_system_variables.tmp_table_size,
2318.2.5 by Olaf van der Spek
Set unused u_max_value to NULL
1852
   NULL, 0, GET_ULL,
1816.2.4 by Monty Taylor
Cleaned up a bunch more warnings.
1853
   REQUIRED_ARG, 16*1024*1024L, 1024, (int64_t)MAX_MEM_TABLE_SIZE, 0, 1, 0},
1 by brian
clean slate
1854
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1855
};
1856
2392.1.1 by Brian Aker
Fixes for --help work.
1857
void usage()
1 by brian
clean slate
1858
{
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1859
  if ((default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)) == NULL)
1860
  {
1861
    unireg_abort << "Failed to load default_charset_info:" << default_character_set_name;
1862
  }
1863
1864
  if (default_collation_name == NULL)
1865
  {
2318.2.28 by Olaf van der Spek
Refactor
1866
    default_collation_name= default_charset_info->name;
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1867
  }
1868
1 by brian
clean slate
1869
  print_version();
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1870
  puts(_("Copyright (C) 2010-2011 Drizzle Developers, Copyright (C) 2008 Sun Microsystems\n"
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
1871
         "This software comes with ABSOLUTELY NO WARRANTY. "
1872
         "This is free software,\n"
1873
         "and you are welcome to modify and redistribute it under the GPL "
1743.3.2 by LinuxJedi
Make --print-defaults ack as old behaviour for the defaults list at the end of --help because this is still needed in drizzled for dtr. Killing 2 birds with one stone.
1874
         "license\n\n"));
1 by brian
clean slate
1875
2224.1.1 by Olaf van der Spek
Finish removing XID cache
1876
1757.2.3 by Monty Taylor
Made printing of --help work via program_options from the core. Removed
1877
  printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
1878
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1879
  po::options_description all_options("Drizzled Options");
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1880
  all_options.add(general_options);
1794.3.1 by Monty Taylor
Rearranged option processing.
1881
  all_options.add(config_options);
1882
  all_options.add(plugin_load_options);
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1883
  all_options.add(long_options);
1884
  all_options.add(plugin_options);
1885
  cout << all_options << endl;
1743.3.2 by LinuxJedi
Make --print-defaults ack as old behaviour for the defaults list at the end of --help because this is still needed in drizzled for dtr. Killing 2 birds with one stone.
1886
2392.1.1 by Brian Aker
Fixes for --help work.
1887
  unireg_exit();
1 by brian
clean slate
1888
}
1889
1890
/**
575.4.4 by Yoshinori Sano
Rename mysql to drizzle.
1891
  Initialize all Drizzle global variables to default values.
1 by brian
clean slate
1892
1893
  We don't need to set numeric variables refered to in my_long_options
1894
  as these are initialized by my_getopt.
1895
1896
  @note
1897
    The reason to set a lot of global variables to zero is to allow one to
1898
    restart the embedded server with a clean environment
1899
    It's also needed on some exotic platforms where global variables are
1900
    not set to 0 when a program starts.
1901
1902
    We don't need to set numeric variables refered to in my_long_options
1903
    as these are initialized by my_getopt.
1904
*/
1905
2318.2.28 by Olaf van der Spek
Refactor
1906
static void drizzle_init_variables()
1 by brian
clean slate
1907
{
1908
  /* Things reset to zero */
1909
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
1910
  cleanup_done= 0;
1089.6.1 by Padraig O'Sullivan
Converted the test_flags variable from a uint32_t to std::bitset.
1911
  dropping_tables= ha_open_options=0;
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
1912
  getDebug().reset();
952 by Brian Aker
Remove bad variables.
1913
  wake_thread=0;
909 by Brian Aker
Remove the need for unireg init
1914
  abort_loop= select_thread_in_use= false;
2114.3.2 by Brian Aker
Encapsulate the condition we use to being a per-session case.
1915
  shutdown_in_progress= 0;
971.3.12 by Eric Day
Started abstracting Protocol, removed init_connect, init_file.
1916
  drizzled_user= drizzled_chroot= 0;
1537.2.1 by Joe Daly
add statistics_variables.h
1917
  memset(&current_global_counters, 0, sizeof(current_global_counters));
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
1918
  key_map_full.set();
1 by brian
clean slate
1919
1920
  /* Character sets */
1921
  system_charset_info= &my_charset_utf8_general_ci;
1922
  files_charset_info= &my_charset_utf8_general_ci;
1923
  table_alias_charset= &my_charset_bin;
1924
  character_set_filesystem= &my_charset_bin;
1925
1926
  /* Things with default values that are not zero */
818 by Brian Aker
Found a few bits to be deleted (around binlog).
1927
  session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2318.2.28 by Olaf van der Spek
Refactor
1928
  global_thread_id= 1;
2282.1.2 by Olaf van der Spek
Session Cache
1929
  session::Cache::getCache().clear();
1 by brian
clean slate
1930
1931
  /* Set default values for some option variables */
971.1.21 by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin.
1932
  global_system_variables.storage_engine= NULL;
1 by brian
clean slate
1933
  global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
151 by Brian Aker
Ulonglong to uint64_t
1934
  global_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
1935
  max_system_variables.select_limit=    (uint64_t) HA_POS_ERROR;
1936
  global_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
1937
  max_system_variables.max_join_size=   (uint64_t) HA_POS_ERROR;
1757.2.9 by Monty Taylor
Set all of the max_system_variables values explicitly.
1938
  max_system_variables.auto_increment_increment= UINT64_MAX;
1939
  max_system_variables.auto_increment_offset= UINT64_MAX;
1940
  max_system_variables.completion_type= 2;
1816.2.3 by Monty Taylor
Fixed some more ICC warnings. How did I get started on this this morning?
1941
  max_system_variables.log_warnings= true;
1757.2.9 by Monty Taylor
Set all of the max_system_variables values explicitly.
1942
  max_system_variables.bulk_insert_buff_size= ULONG_MAX;
1943
  max_system_variables.div_precincrement= DECIMAL_MAX_SCALE;
1944
  max_system_variables.group_concat_max_len= ULONG_MAX;
1945
  max_system_variables.join_buff_size= ULONG_MAX;
1946
  max_system_variables.max_allowed_packet= 1024L*1024L*1024L;
1947
  max_system_variables.max_error_count= 65535;
1948
  max_system_variables.max_heap_table_size= MAX_MEM_TABLE_SIZE;
1949
  max_system_variables.max_join_size= INT32_MAX;
1950
  max_system_variables.max_length_for_sort_data= 8192*1024L;
1951
  max_system_variables.max_seeks_for_key= ULONG_MAX;
1952
  max_system_variables.max_sort_length= 8192*1024L;
1953
  max_system_variables.min_examined_row_limit= ULONG_MAX;
1954
  max_system_variables.optimizer_prune_level= 1;
1955
  max_system_variables.optimizer_search_depth= MAX_TABLES+2;
1956
  max_system_variables.preload_buff_size= 1024*1024*1024L;
1957
  max_system_variables.query_alloc_block_size= UINT32_MAX;
1958
  max_system_variables.query_prealloc_size= UINT32_MAX;
1959
  max_system_variables.range_alloc_block_size= SIZE_MAX;
1960
  max_system_variables.read_buff_size= INT32_MAX;
1961
  max_system_variables.read_rnd_buff_size= UINT32_MAX;
1962
  max_system_variables.sortbuff_size= SIZE_MAX;
1963
  max_system_variables.tmp_table_size= MAX_MEM_TABLE_SIZE;
1964
1 by brian
clean slate
1965
  /* Variables that depends on compile options */
1966
#ifdef HAVE_BROKEN_REALPATH
1967
  have_symlink=SHOW_OPTION_NO;
1968
#else
1969
  have_symlink=SHOW_OPTION_YES;
1970
#endif
1971
}
1972
1973
1974
/**
1975
  @todo
1271.5.3 by Tim Penhey
change the include files
1976
  - FIXME add EXIT_TOO_MANY_ARGUMENTS to "drizzled/error.h" and return that code?
1 by brian
clean slate
1977
*/
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1978
static void get_options()
1 by brian
clean slate
1979
{
2318.5.30 by Olaf van der Spek
Refactor
1980
  setDataHomeCatalog(getDataHome() / "local");
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1981
1982
  if (vm.count("user"))
1983
  {
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1984
    if (drizzled_user == NULL or strcmp(drizzled_user, vm["user"].as<string>().c_str()) == 0)
1985
    {
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1986
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1987
    }
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1988
    else
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1989
    {
1990
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line"),
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1991
                    vm["user"].as<string>().c_str(), drizzled_user);
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
1992
    }
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
1993
  }
1994
1796.4.1 by Andrew Hutchings
Add initial template work and test
1995
  if (vm.count("sort-heap-threshold"))
1996
  {
1796.4.21 by Andrew Hutchings
Fix breakage on 32bit boxes
1997
    if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
1998
      (vm["sort-heap-threshold"].as<uint64_t>() < global_system_variables.sortbuff_size))
1796.4.8 by Andrew Hutchings
Change default setting
1999
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2000
      unireg_abort << _("sort-heap-threshold cannot be less than sort-buffer-size");
1796.4.8 by Andrew Hutchings
Change default setting
2001
    }
2002
1796.4.1 by Andrew Hutchings
Add initial template work and test
2003
    global_sort_buffer.setMaxSize(vm["sort-heap-threshold"].as<uint64_t>());
2004
  }
2005
1796.4.9 by Andrew Hutchings
Add join cache global constraint
2006
  if (vm.count("join-heap-threshold"))
2007
  {
1796.4.21 by Andrew Hutchings
Fix breakage on 32bit boxes
2008
    if ((vm["join-heap-threshold"].as<uint64_t>() > 0) and
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2009
      (vm["join-heap-threshold"].as<uint64_t>() < global_system_variables.join_buff_size))
1796.4.9 by Andrew Hutchings
Add join cache global constraint
2010
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2011
      unireg_abort << _("join-heap-threshold cannot be less than join-buffer-size");
1796.4.9 by Andrew Hutchings
Add join cache global constraint
2012
    }
2013
2014
    global_join_buffer.setMaxSize(vm["join-heap-threshold"].as<uint64_t>());
2015
  }
2016
1796.4.10 by Andrew Hutchings
Add global constraint for --read-rnd-buffer-size
2017
  if (vm.count("read-rnd-threshold"))
2018
  {
1796.4.21 by Andrew Hutchings
Fix breakage on 32bit boxes
2019
    if ((vm["read-rnd-threshold"].as<uint64_t>() > 0) and
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2020
      (vm["read-rnd-threshold"].as<uint64_t>() < global_system_variables.read_rnd_buff_size))
1796.4.10 by Andrew Hutchings
Add global constraint for --read-rnd-buffer-size
2021
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2022
      unireg_abort << _("read-rnd-threshold cannot be less than read-rnd-buffer-size");
1796.4.10 by Andrew Hutchings
Add global constraint for --read-rnd-buffer-size
2023
    }
2024
2025
    global_read_rnd_buffer.setMaxSize(vm["read-rnd-threshold"].as<uint64_t>());
2026
  }
2027
1796.4.11 by Andrew Hutchings
Add global constraint on read buffer
2028
  if (vm.count("read-buffer-threshold"))
2029
  {
1796.4.21 by Andrew Hutchings
Fix breakage on 32bit boxes
2030
    if ((vm["read-buffer-threshold"].as<uint64_t>() > 0) and
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2031
      (vm["read-buffer-threshold"].as<uint64_t>() < global_system_variables.read_buff_size))
1796.4.11 by Andrew Hutchings
Add global constraint on read buffer
2032
    {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2033
      unireg_abort << _("read-buffer-threshold cannot be less than read-buffer-size");
1796.4.11 by Andrew Hutchings
Add global constraint on read buffer
2034
    }
2035
2036
    global_read_buffer.setMaxSize(vm["read-buffer-threshold"].as<uint64_t>());
2037
  }
2038
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2039
  if (vm.count("exit-info"))
2040
  {
2041
    if (vm["exit-info"].as<long>())
2042
    {
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
2043
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2044
    }
2045
  }
2046
2047
  if (vm.count("want-core"))
2048
  {
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
2049
    getDebug().set(debug::CORE_ON_SIGNAL);
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2050
  }
2051
2052
  if (vm.count("skip-stack-trace"))
2053
  {
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
2054
    getDebug().set(debug::NO_STACKTRACE);
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2055
  }
2056
2057
  if (vm.count("skip-symlinks"))
2058
  {
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2059
    internal::my_use_symdir= 0;
2060
  }
2061
2062
  if (vm.count("collation-server"))
2063
  {
2064
    const charset_info_st * const default_collation= get_charset_by_name(vm["collation-server"].as<string>().c_str());
2065
    if (not default_collation)
2066
    {
2067
      unireg_abort << "Unknown collation: " << default_collation_name;
2068
    }
2069
2070
    if (not my_charset_same(default_charset_info, default_collation))
2071
    {
2072
      unireg_abort << "COLLATION '" << default_collation_name << "' is not valid for CHARACTER SET '" << default_charset_info->csname << "'";
2073
    }
2074
    default_charset_info= default_collation;
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2075
  }
2076
2077
  if (vm.count("transaction-isolation"))
2078
  {
2151.5.1 by Olaf van der Spek
Make class of TYPELIB
2079
    int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
2080
    global_system_variables.tx_isolation= type - 1;
1757.2.6 by Monty Taylor
We've gotten further. Now things sometimes work, but some things aren't
2081
  }
2082
1757.2.12 by Monty Taylor
Fixed plugin loading.
2083
  /* @TODO Make this all strings */
1757.2.13 by Monty Taylor
Fixed temp_Table test.
2084
  if (vm.count("default-storage-engine"))
2085
  {
2318.2.3 by Olaf van der Spek
Refactor
2086
    default_storage_engine_str= vm["default-storage-engine"].as<string>().c_str();
1757.2.13 by Monty Taylor
Fixed temp_Table test.
2087
  }
1 by brian
clean slate
2088
2089
2090
#if defined(HAVE_BROKEN_REALPATH)
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2091
  internal::my_use_symdir=0;
2092
  internal::my_disable_symlinks=1;
1 by brian
clean slate
2093
  have_symlink=SHOW_OPTION_NO;
2094
#else
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2095
  if (!internal::my_use_symdir)
1 by brian
clean slate
2096
  {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2097
    internal::my_disable_symlinks=1;
1 by brian
clean slate
2098
    have_symlink=SHOW_OPTION_DISABLED;
2099
  }
2100
#endif
2101
  if (opt_debugging)
2102
  {
2103
    /* Allow break with SIGINT, no core or stack trace */
2104.3.3 by Brian Aker
Cleanup test flags for debug options on server startup
2104
    getDebug().set(debug::ALLOW_SIGINT);
2105
    getDebug().set(debug::NO_STACKTRACE);
2106
    getDebug().reset(debug::CORE_ON_SIGNAL);
1 by brian
clean slate
2107
  }
2108
574.2.1 by ysano
Rename mysql to drizzle.
2109
  if (drizzled_chroot)
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2110
  {
574.2.1 by ysano
Rename mysql to drizzle.
2111
    set_root(drizzled_chroot);
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
2112
  }
1 by brian
clean slate
2113
2114
  /*
2115
    Set some global variables from the global_system_variables
2116
    In most cases the global variables will not be used
2117
  */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2118
  internal::my_default_record_cache_size=global_system_variables.read_buff_size;
1 by brian
clean slate
2119
}
2120
2121
1794.3.4 by Monty Taylor
Fixed plugin dir sequencing
2122
static void fix_paths()
1 by brian
clean slate
2123
{
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
2124
  if (vm.count("help"))
2125
    return;
2126
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
2127
  fs::path pid_file_path(pid_file);
1798.2.3 by Monty Taylor
Concatenate paths differently for pid-file.
2128
  if (pid_file_path.root_path().string() == "")
2129
  {
1813.2.9 by Monty Taylor
Made data_home be fs::path natively.
2130
    pid_file_path= getDataHome();
1813.2.2 by Monty Taylor
Replaced pid-file with fs::path.
2131
    pid_file_path /= pid_file;
1798.2.3 by Monty Taylor
Concatenate paths differently for pid-file.
2132
  }
1926.2.2 by Monty Taylor
Make sure we pop the pid-file path out to an absolute path in fix_paths,
2133
  pid_file= fs::system_complete(pid_file_path);
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
2134
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
2135
  const char *tmp_string= getenv("TMPDIR");
2136
  struct stat buf;
2137
  drizzle_tmpdir.clear();
2138
2139
  if (vm.count("tmpdir"))
2140
  {
2141
    drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2142
  }
2143
  else if (tmp_string == NULL)
2144
  {
2145
    drizzle_tmpdir.append(getDataHome().file_string());
2146
    drizzle_tmpdir.push_back(FN_LIBCHAR);
2147
    drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2148
  }
2149
  else
2150
  {
2151
    drizzle_tmpdir.append(tmp_string);
2152
  }
2153
2154
  drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2155
  assert(drizzle_tmpdir.size());
2156
2157
  assert(getuid() != 0 and geteuid() != 0);
2158
  if (getuid() == 0 or geteuid() == 0)
2159
  {
2160
    unireg_abort << "Drizzle cannot be run as root, please see the Security piece of the manual for more information.";
2161
  }
2162
2163
  if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2164
  {
2165
    if (errno != EEXIST)
2166
    {
2167
      unireg_abort << "There was an error creating the '" 
2168
        << fs::path(drizzle_tmpdir).leaf() 
2169
        << "' part of the path '" 
2170
        << drizzle_tmpdir 
2171
        << "'.  Please check the path exists and is writable.";
2172
    }
2173
  }
2174
2175
  if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2176
  {
2177
    unireg_abort << "There was an error opening the path '" << drizzle_tmpdir << "', please check the path exists and is writable.";
680 by Brian Aker
Remove locks around temp tables for searching tmp directory path.
2178
  }
1 by brian
clean slate
2179
}
2180
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2181
} /* namespace drizzled */
2182