40
39
#include <boost/filesystem.hpp>
41
40
#include <boost/detail/atomic_count.hpp>
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>
42
#include "drizzled/internal/my_sys.h"
43
#include "drizzled/internal/my_bit.h"
44
#include <drizzled/my_hash.h>
45
#include <drizzled/error.h>
49
46
#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>
47
#include <drizzled/tztime.h>
48
#include <drizzled/sql_base.h>
49
#include <drizzled/show.h>
50
#include <drizzled/sql_parse.h>
54
51
#include <drizzled/item/cmpfunc.h>
52
#include <drizzled/session.h>
55
53
#include <drizzled/item/create.h>
56
#include <drizzled/message/cache.h>
57
#include <drizzled/module/load_list.h>
58
#include <drizzled/module/registry.h>
59
#include <drizzled/my_hash.h>
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>
73
#include <drizzled/sql_base.h>
74
#include <drizzled/sql_parse.h>
75
#include <drizzled/temporal_format.h> /* For init_temporal_formats() */
76
#include <drizzled/tztime.h>
77
54
#include <drizzled/unireg.h>
78
#include <plugin/myisam/myisam.h>
80
#include "drizzled/visibility.h"
55
#include "drizzled/temporal_format.h" /* For init_temporal_formats() */
56
#include "drizzled/plugin/listen.h"
57
#include "drizzled/plugin/error_message.h"
58
#include "drizzled/plugin/client.h"
59
#include "drizzled/plugin/scheduler.h"
60
#include "drizzled/plugin/xa_resource_manager.h"
61
#include "drizzled/plugin/monitored_in_transaction.h"
62
#include "drizzled/replication_services.h" /* For ReplicationServices::evaluateRegisteredPlugins() */
63
#include "drizzled/probes.h"
64
#include "drizzled/session/cache.h"
65
#include "drizzled/charset.h"
66
#include "plugin/myisam/myisam.h"
67
#include "drizzled/drizzled.h"
68
#include "drizzled/module/registry.h"
69
#include "drizzled/module/load_list.h"
70
#include "drizzled/global_buffer.h"
72
#include "drizzled/definition/cache.h"
74
#include "drizzled/plugin/event_observer.h"
76
#include "drizzled/message/cache.h"
82
78
#include <google/protobuf/stubs/common.h>
84
#include <drizzled/refresh_version.h>
86
80
#if TIME_WITH_SYS_TIME
87
81
# include <sys/time.h>
252
246
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
254
248
uint32_t drizzled_bind_timeout;
249
std::bitset<12> test_flags;
255
250
uint32_t dropping_tables, ha_open_options;
256
251
uint32_t tc_heuristic_recover= 0;
257
252
uint64_t session_startup_options;
258
253
back_log_constraints back_log(50);
259
DRIZZLED_API uint32_t server_id;
260
255
uint64_t table_cache_size;
261
256
size_t table_def_size;
257
uint64_t max_connect_errors;
262
258
uint32_t global_thread_id= 1UL;
263
259
pid_t current_pid;
325
321
const char *in_additional_cond= "<IN COND>";
326
322
const char *in_having_cond= "<IN HAVING>";
324
type::Decimal decimal_zero;
328
325
/* classes for comparation parsing/processing */
330
327
FILE *stderror_file=0;
332
drizzle_system_variables global_system_variables;
333
drizzle_system_variables max_system_variables;
334
global_counters current_global_counters;
329
struct drizzle_system_variables global_system_variables;
330
struct drizzle_system_variables max_system_variables;
331
struct global_counters current_global_counters;
336
DRIZZLED_API const CHARSET_INFO *system_charset_info;
337
const CHARSET_INFO *files_charset_info;
333
const CHARSET_INFO *system_charset_info, *files_charset_info ;
338
334
const CHARSET_INFO *table_alias_charset;
339
335
const CHARSET_INFO *character_set_filesystem;
501
518
(void) unlink(pid_file.file_string().c_str()); // This may not always exist
503
520
if (print_message && server_start_time)
504
errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
521
errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
523
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
506
session::Cache::singleton().shutdownFirst();
526
/* do the broadcast inside the lock to ensure that my_end() is not called */
527
COND_server_end.notify_all();
509
531
The following lines may never be executed as the main thread may have
528
550
tmp_user_info= getpwnam(user);
529
551
if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
530
552
global_system_variables.log_warnings)
531
errmsg_printf(error::WARN, _("One can only use the --user switch "
553
errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
532
554
"if running as root\n"));
538
errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
539
"the manual to find out how to run drizzled as root"));
560
errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
561
"the manual to find out how to run drizzled as root!\n"));
543
if (not strcmp(user, "root"))
564
if (!strcmp(user,"root"))
544
565
return NULL; // Avoid problem with dynamic libraries
546
567
if (!(tmp_user_info= getpwnam(user)))
1132
1164
config_options.add_options()
1133
1165
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1134
1166
_("Display this help and exit."))
1135
("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1136
_("Run as a daemon."))
1137
1167
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1138
1168
_("Configuration file defaults are not used if no-defaults is set"))
1139
1169
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1174
1204
("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1175
1205
_("Default completion type."))
1176
1206
("core-file", _("Write core on errors."))
1177
("datadir", po::value<fs::path>(&getDataHome()),
1207
("datadir", po::value<fs::path>(&data_home),
1178
1208
_("Path to the database root."))
1179
1209
("default-storage-engine", po::value<string>(),
1180
1210
_("Set the default storage engine for tables."))
1211
1241
_("Path for temporary files."))
1212
1242
("transaction-isolation", po::value<string>(),
1213
1243
_("Default transaction isolation level."))
1214
("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1244
("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1215
1245
_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1216
1246
("user,u", po::value<string>(),
1217
1247
_("Run drizzled daemon as user."))
1237
1267
_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1238
1268
("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1239
1269
_("Max packetlength to send/receive from to server."))
1270
("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
1271
_("If there is more than this number of interrupted connections from a "
1272
"host this host will be blocked from further connections."))
1240
1273
("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1241
1274
_("Max number of errors/warnings to store for a statement."))
1242
1275
("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1403
1436
catch (po::validation_error &err)
1405
errmsg_printf(error::ERROR,
1438
errmsg_printf(ERRMSG_LVL_ERROR,
1407
1440
"Use --help to get a list of available options\n"),
1408
1441
internal::my_progname, err.what());
1409
1442
unireg_abort(1);
1415
int init_remaining_variables(module::Registry &plugins)
1417
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1419
current_pid= getpid(); /* Save for later ref */
1421
1445
/* At this point, we've read all the options we need to read from files and
1422
1446
collected most of them into unknown options - now let's load everything
1425
1449
if (plugin_init(plugins, plugin_options))
1427
errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1451
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1428
1452
unireg_abort(1);
1522
1547
const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1523
1548
if (not default_collation)
1525
errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1550
errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1528
1553
if (not my_charset_same(default_charset_info, default_collation))
1530
errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1555
errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1531
1556
default_collation_name,
1532
1557
default_charset_info->csname);
1731
1757
{"help", '?', N_("Display this help and exit."),
1732
1758
(char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1734
{"daemon", 'd', N_("Run as daemon."),
1735
(char**) &opt_daemon, (char**) &opt_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1737
1760
{"auto-increment-increment", OPT_AUTO_INCREMENT,
1738
1761
N_("Auto-increment columns are incremented by this"),
1739
1762
(char**) &global_system_variables.auto_increment_increment,
1859
1882
(char**) &global_system_variables.max_allowed_packet,
1860
1883
(char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1861
1884
REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1885
{"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
1886
N_("If there is more than this number of interrupted connections from a "
1887
"host this host will be blocked from further connections."),
1888
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
1889
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
1862
1890
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1863
1891
N_("Don't allow creation of heap tables bigger than this."),
1864
1892
(char**) &global_system_variables.max_heap_table_size,