205
205
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names) - 1, "", tx_isolation_names, NULL};
208
Used with --help for detailed option
210
bool opt_help= false;
212
207
arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
213
208
{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
214
209
{&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
362
357
fs::path base_plugin_dir(PKGPLUGINDIR);
359
po::options_description general_options(_("General Options"));
364
360
po::options_description config_options(_("Config File Options"));
365
361
po::options_description long_options(_("Kernel Options"));
366
362
po::options_description plugin_load_options(_("Plugin Loading Options"));
383
379
return g_hostname;
382
static void print_version()
385
Note: the instance manager keys off the string 'Ver' so it can find the
386
version from the output of 'drizzled --version', so don't change it!
388
printf("%s Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
389
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
386
392
/****************************************************************************
387
393
** Code to end drizzled
388
394
****************************************************************************/
472
479
temp << _("Aborting:") << "\"" << message << "\"" << ". Abort was called from " << file << ":" << line << " in " << func << "()";
473
480
errmsg_printf(error::ERROR, temp.str().c_str());
475
clean_up(opt_help == false);
482
clean_up(vm.count("help") == 0);
476
483
internal::my_end();
485
assert(unireg_startup_completed == false);
477
486
exit(EXIT_FAILURE);
524
533
tmp_user_info= getpwnam(user);
525
534
if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
526
535
global_system_variables.log_warnings)
527
errmsg_printf(error::WARN, _("One can only use the --user switch "
528
"if running as root\n"));
537
errmsg_printf(error::WARN, _("One can only use the --user switch if running as root"));
534
unireg_abort << _("Fatal error: Please read \"Security\" section of the manual to find out how to run drizzled as root");
544
unireg_abort << _("drizzled cannot be run as root, use --user to start drizzled up as another user");
537
547
if (not strcmp(user, "root"))
1040
1050
system_config_dir /= "drizzle";
1042
config_options.add_options()
1043
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1044
_("Display this help and exit."))
1052
general_options.add_options()
1054
_("Display help and exit."))
1045
1055
("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1046
1056
_("Run as a daemon."))
1057
("user,u", po::value<string>(),
1058
_("Run drizzled daemon as user."))
1060
_("Print version information and exit."))
1063
config_options.add_options()
1047
1064
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1048
1065
_("Configuration file defaults are not used if no-defaults is set"))
1049
1066
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1123
1140
_("Default transaction isolation level."))
1124
1141
("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1125
1142
_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1126
("user,u", po::value<string>(),
1127
_("Run drizzled daemon as user."))
1129
_("Output version information and exit."))
1130
1143
("back-log", po::value<back_log_constraints>(&back_log),
1131
1144
_("The number of outstanding connection requests Drizzle can have. This "
1132
1145
"comes into play when the main Drizzle thread gets very many connection "
1234
1247
full_options.add(long_options);
1235
1248
full_options.add(plugin_load_options);
1250
initial_options.add(general_options);
1237
1251
initial_options.add(config_options);
1238
1252
initial_options.add(plugin_load_options);
1240
1254
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1241
1256
/* Get options about where config files and the like are */
1242
1257
po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1243
1258
options(initial_options).allow_unregistered().run();
1245
po::collect_unrecognized(parsed.options, po::include_positional);
1260
unknown_options= po::collect_unrecognized(parsed.options, po::include_positional);
1253
1268
unireg_abort << _("Duplicate entry for command line option");
1256
if (not vm["no-defaults"].as<bool>())
1271
/* TODO: here is where we should add a process_env_vars */
1273
/* We need a notify here so that plugin_init will work properly */
1278
catch (po::validation_error &err)
1280
unireg_abort << "Use --help to get a list of available options. " << err.what();
1283
if (vm.count("version"))
1289
if (vm.count("no-defaults"))
1258
1291
fs::path system_config_file_drizzle(system_config_dir);
1259
1292
system_config_file_drizzle /= "drizzled.cnf";
1277
/* TODO: here is where we should add a process_env_vars */
1279
/* We need a notify here so that plugin_init will work properly */
1284
catch (po::validation_error &err)
1286
unireg_abort << "Use --help to get a list of available options. " << err.what();
1289
1310
process_defaults_files();
1291
1312
/* Process with notify a second time because a config file may contain
1364
1385
global_system_variables.optimizer_prune_level= not vm.count("disable-optimizer-prune");
1366
if (! vm["help"].as<bool>())
1387
if ((user_info= check_user(drizzled_user)))
1368
if ((user_info= check_user(drizzled_user)))
1370
set_user(drizzled_user, user_info);
1389
set_user(drizzled_user, user_info);
1553
1576
struct option my_long_options[] =
1556
{"help", '?', N_("Display this help and exit."),
1557
(char**) &opt_help, NULL, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1559
{"daemon", 'd', N_("Run as daemon."),
1560
(char**) &opt_daemon, NULL, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1562
1578
{"auto-increment-increment", OPT_AUTO_INCREMENT,
1563
1579
N_("Auto-increment columns are incremented by this"),
1564
1580
(char**) &global_system_variables.auto_increment_increment,
1834
1850
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1837
static void print_version()
1840
Note: the instance manager keys off the string 'Ver' so it can find the
1841
version from the output of 'drizzled --version', so don't change it!
1843
printf("%s Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
1844
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
1847
1853
static void usage()
1849
1855
if ((default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)) == NULL)
1867
1873
printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
1869
1875
po::options_description all_options("Drizzled Options");
1876
all_options.add(general_options);
1870
1877
all_options.add(config_options);
1871
1878
all_options.add(plugin_load_options);
1872
1879
all_options.add(long_options);
1970
1977
if (vm.count("user"))
1972
if (! drizzled_user || ! strcmp(drizzled_user, vm["user"].as<string>().c_str()))
1979
if (drizzled_user == NULL or strcmp(drizzled_user, vm["user"].as<string>().c_str()) == 0)
1973
1981
drizzled_user= (char *)vm["user"].as<string>().c_str();
1976
errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
1977
"set to '%s' earlier on the command line\n"),
1985
errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line"),
1978
1986
vm["user"].as<string>().c_str(), drizzled_user);
1981
if (vm.count("version"))
1987
1990
if (vm.count("sort-heap-threshold"))
2122
2128
pid_file= fs::system_complete(pid_file_path);
2126
const char *tmp_string= getenv("TMPDIR");
2128
drizzle_tmpdir.clear();
2130
if (vm.count("tmpdir"))
2132
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2134
else if (tmp_string == NULL)
2136
drizzle_tmpdir.append(getDataHome().file_string());
2137
drizzle_tmpdir.push_back(FN_LIBCHAR);
2138
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2142
drizzle_tmpdir.append(tmp_string);
2145
drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2146
assert(drizzle_tmpdir.size());
2148
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2150
if (errno != EEXIST)
2152
unireg_abort << "There was an error creating the '"
2153
<< fs::path(drizzle_tmpdir).leaf()
2154
<< "' part of the path '"
2156
<< "'. Please check the path exists and is writable.";
2160
if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2162
unireg_abort << "There was an error opening the path '" << drizzle_tmpdir << "', please check the path exists and is writable.";
2130
const char *tmp_string= getenv("TMPDIR");
2132
drizzle_tmpdir.clear();
2134
if (vm.count("tmpdir"))
2136
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2138
else if (tmp_string == NULL)
2140
drizzle_tmpdir.append(getDataHome().file_string());
2141
drizzle_tmpdir.push_back(FN_LIBCHAR);
2142
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2146
drizzle_tmpdir.append(tmp_string);
2149
drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2150
assert(drizzle_tmpdir.size());
2152
assert(getuid() != 0 and geteuid() != 0);
2153
if (getuid() == 0 or geteuid() == 0)
2155
unireg_abort << "Drizzle cannot be run as root, please see the Security piece of the manual for more information.";
2158
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2160
if (errno != EEXIST)
2162
unireg_abort << "There was an error creating the '"
2163
<< fs::path(drizzle_tmpdir).leaf()
2164
<< "' part of the path '"
2166
<< "'. Please check the path exists and is writable.";
2170
if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2172
unireg_abort << "There was an error opening the path '" << drizzle_tmpdir << "', please check the path exists and is writable.";