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