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},
356
351
static void get_options();
357
352
static void fix_paths();
360
354
void close_connections();
362
356
fs::path base_plugin_dir(PKGPLUGINDIR);
358
po::options_description general_options(_("General Options"));
364
359
po::options_description config_options(_("Config File Options"));
365
360
po::options_description long_options(_("Kernel Options"));
366
361
po::options_description plugin_load_options(_("Plugin Loading Options"));
383
378
return g_hostname;
381
static void print_version()
384
Note: the instance manager keys off the string 'Ver' so it can find the
385
version from the output of 'drizzled --version', so don't change it!
387
printf("%s Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
388
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
386
391
/****************************************************************************
387
392
** Code to end drizzled
388
393
****************************************************************************/
458
void unireg_abort(int exit_code)
462
errmsg_printf(error::ERROR, _("Aborting"));
469
clean_up(!opt_help && exit_code);
462
static bool unireg_startup_completed= false;
463
void unireg_startup_finished()
465
unireg_startup_completed= true;
471
assert(unireg_startup_completed == false);
475
void unireg_actual_abort(const char *file, int line, const char *func, const std::string& message)
477
std::stringstream temp;
478
temp << _("Aborting:") << "\"" << message << "\"" << ". Abort was called from " << file << ":" << line << " in " << func << "()";
479
errmsg_printf(error::ERROR, temp.str().c_str());
481
clean_up(vm.count("help") == 0);
484
assert(unireg_startup_completed == false);
518
532
tmp_user_info= getpwnam(user);
519
533
if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
520
534
global_system_variables.log_warnings)
521
errmsg_printf(error::WARN, _("One can only use the --user switch "
522
"if running as root\n"));
536
errmsg_printf(error::WARN, _("One can only use the --user switch if running as root"));
528
errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
529
"the manual to find out how to run drizzled as root"));
543
unireg_abort << _("drizzled cannot be run as root, use --user to start drizzled up as another user");
533
546
if (not strcmp(user, "root"))
534
548
return NULL; // Avoid problem with dynamic libraries
536
if (!(tmp_user_info= getpwnam(user)))
551
if ((tmp_user_info= getpwnam(user)) == NULL)
538
553
// Allow a numeric uid to be used
540
555
for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
541
556
if (*pos) // Not numeric id
543
if (!(tmp_user_info= getpwuid(atoi(user))))
559
if ((tmp_user_info= getpwuid(atoi(user))) == NULL)
546
562
return tmp_user_info;
549
errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ; "
550
"Please check that the user exists!\n"),user);
565
unireg_abort << "Fatal error: Can't change to run as user '" << user << "' ; Please check that the user exists!";
553
567
#ifdef PR_SET_DUMPABLE
554
568
if (getDebug().test(debug::CORE_ON_SIGNAL))
571
581
initgroups(user, user_info_arg->pw_gid);
572
582
if (setgid(user_info_arg->pw_gid) == -1)
574
sql_perror(_("Set process group ID failed"));
584
unireg_abort << _("Set process group ID failed ") << strerror(errno);
577
586
if (setuid(user_info_arg->pw_uid) == -1)
579
sql_perror(_("Set process user ID failed"));
588
unireg_abort << _("Set process user ID failed") << strerror(errno);
586
594
/** Change root user if started with @c --chroot . */
587
595
static void set_root(const char *path)
589
if ((chroot(path) == -1) || !chdir("/"))
597
if ((chroot(path) == -1) or chdir("/") == 0)
591
sql_perror(_("Process chroot failed"));
599
unireg_abort << _("Process chroot failed");
688
695
global_system_variables.auto_increment_increment= 1;
689
696
if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
691
cout << _("Error: Invalid Value for auto_increment_increment");
698
unireg_abort << _("Invalid Value for auto_increment_increment");
694
700
global_system_variables.auto_increment_increment= in_auto_increment_increment;
699
705
global_system_variables.auto_increment_offset= 1;
700
706
if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
702
cout << _("Error: Invalid Value for auto_increment_offset");
708
unireg_abort << _("Invalid Value for auto_increment_offset");
705
710
global_system_variables.auto_increment_offset= in_auto_increment_offset;
710
715
global_system_variables.completion_type= 0;
711
716
if (in_completion_type > 2)
713
cout << _("Error: Invalid Value for completion_type");
718
unireg_abort << _("Invalid Value for completion_type");
716
720
global_system_variables.completion_type= in_completion_type;
722
726
global_system_variables.div_precincrement= 4;
723
727
if (in_div_precincrement > DECIMAL_MAX_SCALE)
725
cout << _("Error: Invalid Value for div-precision-increment");
729
unireg_abort << _("Invalid Value for div-precision-increment");
728
731
global_system_variables.div_precincrement= in_div_precincrement;
733
736
global_system_variables.group_concat_max_len= 1024;
734
737
if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
736
cout << _("Error: Invalid Value for group_concat_max_len");
739
unireg_abort << _("Invalid Value for group_concat_max_len");
739
741
global_system_variables.group_concat_max_len= in_group_concat_max_len;
744
746
global_system_variables.join_buff_size= (128*1024L);
745
747
if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
747
cout << _("Error: Invalid Value for join_buffer_size");
749
unireg_abort << _("Invalid Value for join_buffer_size");
750
751
in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
751
752
global_system_variables.join_buff_size= in_join_buffer_size;
756
757
global_system_variables.max_allowed_packet= (64*1024*1024L);
757
758
if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
759
cout << _("Error: Invalid Value for max_allowed_packet");
760
unireg_abort << _("Invalid Value for max_allowed_packet");
762
762
in_max_allowed_packet-= in_max_allowed_packet % 1024;
763
763
global_system_variables.max_allowed_packet= in_max_allowed_packet;
768
768
global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
769
769
if (in_max_error_count > 65535)
771
cout << _("Error: Invalid Value for max_error_count");
771
unireg_abort << _("Invalid Value for max_error_count");
774
773
global_system_variables.max_error_count= in_max_error_count;
779
778
global_system_variables.max_heap_table_size= (16*1024*1024L);
780
779
if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
782
cout << _("Error: Invalid Value for max_heap_table_size");
781
unireg_abort << _("Invalid Value for max_heap_table_size");
785
783
in_max_heap_table_size-= in_max_heap_table_size % 1024;
786
784
global_system_variables.max_heap_table_size= in_max_heap_table_size;
791
789
global_system_variables.min_examined_row_limit= 0;
792
790
if (in_min_examined_row_limit > ULONG_MAX)
794
cout << _("Error: Invalid Value for min_examined_row_limit");
792
unireg_abort << _("Invalid Value for min_examined_row_limit");
797
794
global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
802
799
global_system_variables.max_join_size= INT32_MAX;
803
800
if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
805
cout << _("Error: Invalid Value for max_join_size");
802
unireg_abort << _("Invalid Value for max_join_size");
808
804
global_system_variables.max_join_size= in_max_join_size;
813
809
global_system_variables.max_length_for_sort_data= 1024;
814
810
if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
816
cout << _("Error: Invalid Value for max_length_for_sort_data");
812
unireg_abort << _("Invalid Value for max_length_for_sort_data");
819
814
global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
824
819
global_system_variables.max_seeks_for_key= ULONG_MAX;
825
820
if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
827
cout << _("Error: Invalid Value for max_seeks_for_key");
822
unireg_abort << _("Invalid Value for max_seeks_for_key");
830
824
global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
835
829
global_system_variables.max_sort_length= 1024;
836
830
if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
838
cout << _("Error: Invalid Value for max_sort_length");
832
unireg_abort << _("Invalid Value for max_sort_length");
841
834
global_system_variables.max_sort_length= in_max_sort_length;
846
839
global_system_variables.optimizer_search_depth= 0;
847
840
if (in_optimizer_search_depth > MAX_TABLES + 2)
849
cout << _("Error: Invalid Value for optimizer_search_depth");
842
unireg_abort << _("Invalid Value for optimizer_search_depth");
852
844
global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
857
849
global_system_variables.preload_buff_size= (32*1024L);
858
850
if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
860
cout << _("Error: Invalid Value for preload_buff_size");
852
unireg_abort << _("Invalid Value for preload_buff_size");
863
854
global_system_variables.preload_buff_size= in_preload_buff_size;
868
859
global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
869
860
if (in_query_alloc_block_size < 1024)
871
cout << _("Error: Invalid Value for query_alloc_block_size");
862
unireg_abort << _("Invalid Value for query_alloc_block_size");
874
864
in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
875
865
global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
880
870
global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
881
871
if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
883
cout << _("Error: Invalid Value for query_prealloc_size");
873
unireg_abort << _("Invalid Value for query_prealloc_size");
886
875
in_query_prealloc_size-= in_query_prealloc_size % 1024;
887
876
global_system_variables.query_prealloc_size= in_query_prealloc_size;
892
881
global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
893
882
if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
895
cout << _("Error: Invalid Value for range_alloc_block_size");
884
unireg_abort << _("Invalid Value for range_alloc_block_size");
898
886
in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
899
887
global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
904
892
global_system_variables.read_buff_size= (128*1024L);
905
893
if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
907
cout << _("Error: Invalid Value for read_buff_size");
895
unireg_abort << _("Invalid Value for read_buff_size");
910
897
in_read_buff_size-= in_read_buff_size % IO_SIZE;
911
898
global_system_variables.read_buff_size= in_read_buff_size;
916
903
global_system_variables.read_rnd_buff_size= (256*1024L);
917
904
if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
919
cout << _("Error: Invalid Value for read_rnd_buff_size");
906
unireg_abort << _("Invalid Value for read_rnd_buff_size");
922
908
global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
927
913
global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
928
914
if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
930
cout << _("Error: Invalid Value for sort_buff_size");
916
unireg_abort << _("Invalid Value for sort_buff_size");
933
918
global_system_variables.sortbuff_size= in_sortbuff_size;
949
933
table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
950
934
if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
952
cout << _("Error: Invalid Value for table_cache_size");
936
unireg_abort << _("Invalid Value for table_cache_size");
955
938
table_cache_size= in_table_cache_size;
960
943
table_lock_wait_timeout= 50;
961
944
if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
963
cout << _("Error: Invalid Value for table_lock_wait_timeout");
946
unireg_abort << _("Invalid Value for table_lock_wait_timeout");
966
948
table_lock_wait_timeout= in_table_lock_wait_timeout;
976
958
global_system_variables.tmp_table_size= 16*1024*1024L;
977
959
if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
979
cout << _("Error: Invalid Value for table_lock_wait_timeout");
961
unireg_abort << _("Invalid Value for table_lock_wait_timeout");
982
963
global_system_variables.tmp_table_size= in_tmp_table_size;
987
968
transaction_message_threshold= 1024*1024;
988
969
if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
990
cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
971
unireg_abort << _("Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
993
973
transaction_message_threshold= in_transaction_message_threshold;
1025
1005
fs::path p(it);
1026
1006
if (fs::is_regular_file(p))
1027
1008
defaults_file_list.push_back(it);
1030
errmsg_printf(error::ERROR, _("Defaults file '%s' not found\n"), it.c_str());
1012
unireg_abort << "Defaults file '" << it << "' not found";
1036
int init_basic_variables(int argc, char **argv)
1017
bool init_variables_before_daemonizing(int argc, char **argv)
1038
1019
umask(((~internal::my_umask) & 0666));
1039
1020
decimal_zero.set_zero(); // set decimal_zero constant;
1066
1049
system_config_dir /= "drizzle";
1068
config_options.add_options()
1069
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1070
_("Display this help and exit."))
1051
general_options.add_options()
1053
_("Display help and exit."))
1071
1054
("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1072
1055
_("Run as a daemon."))
1056
("user,u", po::value<string>(),
1057
_("Run drizzled daemon as user."))
1059
_("Print version information and exit."))
1062
config_options.add_options()
1073
1063
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1074
1064
_("Configuration file defaults are not used if no-defaults is set"))
1075
1065
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1149
1139
_("Default transaction isolation level."))
1150
1140
("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1151
1141
_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1152
("user,u", po::value<string>(),
1153
_("Run drizzled daemon as user."))
1155
_("Output version information and exit."))
1156
1142
("back-log", po::value<back_log_constraints>(&back_log),
1157
1143
_("The number of outstanding connection requests Drizzle can have. This "
1158
1144
"comes into play when the main Drizzle thread gets very many connection "
1260
1246
full_options.add(long_options);
1261
1247
full_options.add(plugin_load_options);
1249
initial_options.add(general_options);
1263
1250
initial_options.add(config_options);
1264
1251
initial_options.add(plugin_load_options);
1266
1253
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1267
1255
/* Get options about where config files and the like are */
1268
1256
po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1269
1257
options(initial_options).allow_unregistered().run();
1271
po::collect_unrecognized(parsed.options, po::include_positional);
1259
unknown_options= po::collect_unrecognized(parsed.options, po::include_positional);
1277
1265
catch (std::exception&)
1279
errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
1283
if (not vm["no-defaults"].as<bool>())
1267
unireg_abort << _("Duplicate entry for command line option");
1270
/* TODO: here is where we should add a process_env_vars */
1272
/* We need a notify here so that plugin_init will work properly */
1277
catch (po::validation_error &err)
1279
unireg_abort << "Use --help to get a list of available options. " << err.what();
1282
if (vm.count("version"))
1288
if (vm.count("no-defaults"))
1285
1290
fs::path system_config_file_drizzle(system_config_dir);
1286
1291
system_config_file_drizzle /= "drizzled.cnf";
1304
/* TODO: here is where we should add a process_env_vars */
1306
/* We need a notify here so that plugin_init will work properly */
1311
catch (po::validation_error &err)
1313
errmsg_printf(error::ERROR, _("%s: %s.\nUse --help to get a list of available options\n"), internal::my_progname, err.what());
1317
1309
process_defaults_files();
1319
1311
/* Process with notify a second time because a config file may contain
1326
1318
catch (po::validation_error &err)
1328
errmsg_printf(error::ERROR, _("%s: %s.\nUse --help to get a list of available options\n"), internal::my_progname, err.what());
1320
unireg_abort << "Use --help to get a list of available options. " << err.what();
1335
int init_remaining_variables(module::Registry &plugins)
1326
// Return failure if we can't pass this, unireg_abort() will then be called
1328
bool init_variables_after_daemonizing(module::Registry &plugins)
1337
1330
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1345
1338
if (plugin_init(plugins, plugin_options))
1347
errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1340
unireg_abort << _("Failed to initialize plugins");
1351
1343
full_options.add(plugin_options);
1366
1358
catch (po::validation_error &err)
1368
errmsg_printf(error::ERROR,
1370
"Use --help to get a list of available options\n"),
1371
internal::my_progname, err.what());
1360
unireg_abort << "Use --help to get a list of available options. " << err.what();
1374
1362
catch (po::invalid_command_line_syntax &err)
1376
errmsg_printf(error::ERROR,
1378
"Use --help to get a list of available options\n"),
1379
internal::my_progname, err.what());
1364
unireg_abort << "Use --help to get a list of available options. " << err.what();
1382
1366
catch (po::unknown_option &err)
1384
errmsg_printf(error::ERROR,
1385
_("%s\nUse --help to get a list of available options\n"),
1368
unireg_abort << "Use --help to get a list of available options. " << err.what();
1394
1375
catch (po::validation_error &err)
1396
errmsg_printf(error::ERROR,
1398
"Use --help to get a list of available options\n"),
1399
internal::my_progname, err.what());
1377
unireg_abort << "Use --help to get a list of available options. " << err.what();
1407
1384
global_system_variables.optimizer_prune_level= not vm.count("disable-optimizer-prune");
1409
if (! vm["help"].as<bool>())
1386
if ((user_info= check_user(drizzled_user)))
1411
if ((user_info= check_user(drizzled_user)))
1413
set_user(drizzled_user, user_info);
1388
set_user(drizzled_user, user_info);
1421
1395
item_create_init();
1422
1396
if (sys_var_init())
1424
1401
/* Creates static regex matching for temporal values */
1425
1402
if (not init_temporal_formats())
1428
if (!(default_charset_info=
1429
get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1407
if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1431
1409
errmsg_printf(error::ERROR, _("Error getting default charset"));
1432
return 1; // Eof of the list
1410
return false; // Eof of the list
1435
1413
if (vm.count("scheduler"))
1436
1415
opt_scheduler= vm["scheduler"].as<string>().c_str();
1438
if (default_collation_name)
1440
const charset_info_st * const default_collation= get_charset_by_name(default_collation_name);
1441
if (not default_collation)
1443
errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1446
if (not my_charset_same(default_charset_info, default_collation))
1448
errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1449
default_collation_name,
1450
default_charset_info->csname);
1453
default_charset_info= default_collation;
1455
1418
/* Set collactions that depends on the default collation */
1456
1419
global_system_variables.collation_server= default_charset_info;
1459
1422
get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1461
1424
errmsg_printf(error::ERROR, _("Error setting collation"));
1464
1427
global_system_variables.character_set_filesystem= character_set_filesystem;
1466
if (!(my_default_lc_time_names=
1467
my_locale_by_name(lc_time_names_name)))
1429
if ((my_default_lc_time_names= my_locale_by_name(lc_time_names_name)) == NULL)
1469
1431
errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1472
1434
global_system_variables.lc_time_names= my_default_lc_time_names;
1474
1436
/* Reset table_alias_charset */
1475
1437
table_alias_charset= files_charset_info;
1442
bool was_help_requested()
1444
if (vm.count("help") == 0)
1481
1454
void init_server_components(module::Registry &plugins)
1456
if (was_help_requested())
1484
1462
We need to call each of these following functions to ensure that
1485
1463
all things are initialized so that unireg_abort() doesn't fail
1495
1473
/* Allow storage engine to give real error messages */
1496
1474
ha_init_errors();
1501
1476
if (plugin_finalize(plugins))
1478
unireg_abort << "plugin_finalize() failed";
1506
1481
if (plugin::Scheduler::setPlugin(opt_scheduler))
1508
errmsg_printf(error::ERROR, _("No scheduler found, cannot continue!\n"));
1483
unireg_abort << _("No scheduler found");
1524
1498
plugin::StorageEngine *engine= plugin::StorageEngine::findByName(default_storage_engine_str);
1525
1499
if (engine == NULL)
1527
errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"), default_storage_engine_str);
1501
unireg_abort << _("Unknown/unsupported storage engine: ") << default_storage_engine_str;
1530
1503
global_system_variables.storage_engine= engine;
1612
1585
struct option my_long_options[] =
1615
{"help", '?', N_("Display this help and exit."),
1616
(char**) &opt_help, NULL, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1618
{"daemon", 'd', N_("Run as daemon."),
1619
(char**) &opt_daemon, NULL, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1621
1587
{"auto-increment-increment", OPT_AUTO_INCREMENT,
1622
1588
N_("Auto-increment columns are incremented by this"),
1623
1589
(char**) &global_system_variables.auto_increment_increment,
1638
1604
N_("Chroot drizzled daemon during startup."),
1639
1605
(char**) &drizzled_chroot, NULL, 0, GET_STR, REQUIRED_ARG,
1640
1606
0, 0, 0, 0, 0, 0},
1641
{"collation-server", OPT_DEFAULT_COLLATION,
1642
N_("Set the default collation."),
1643
(char**) &default_collation_name, NULL,
1644
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1645
1607
{"completion-type", OPT_COMPLETION_TYPE,
1646
1608
N_("Default completion type."),
1647
1609
(char**) &global_system_variables.completion_type,
1897
1859
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1900
static void print_version()
1903
Note: the instance manager keys off the string 'Ver' so it can find the
1904
version from the output of 'drizzled --version', so don't change it!
1906
printf("%s Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
1907
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
1864
if ((default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)) == NULL)
1866
unireg_abort << "Failed to load default_charset_info:" << default_character_set_name;
1912
if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1914
if (!default_collation_name)
1869
if (default_collation_name == NULL)
1915
1871
default_collation_name= default_charset_info->name;
1916
1874
print_version();
1917
puts(_("Copyright (C) 2008 Sun Microsystems\n"
1875
puts(_("Copyright (C) 2010-2011 Drizzle Developers, Copyright (C) 2008 Sun Microsystems\n"
1918
1876
"This software comes with ABSOLUTELY NO WARRANTY. "
1919
1877
"This is free software,\n"
1920
1878
"and you are welcome to modify and redistribute it under the GPL "
1924
1882
printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
1926
1884
po::options_description all_options("Drizzled Options");
1885
all_options.add(general_options);
1927
1886
all_options.add(config_options);
1928
1887
all_options.add(plugin_load_options);
1929
1888
all_options.add(long_options);
1930
1889
all_options.add(plugin_options);
1931
1890
cout << all_options << endl;
2027
1987
if (vm.count("user"))
2029
if (! drizzled_user || ! strcmp(drizzled_user, vm["user"].as<string>().c_str()))
1989
if (drizzled_user == NULL or strcmp(drizzled_user, vm["user"].as<string>().c_str()) == 0)
2030
1991
drizzled_user= (char *)vm["user"].as<string>().c_str();
2033
errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
2034
"set to '%s' earlier on the command line\n"),
1995
errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line"),
2035
1996
vm["user"].as<string>().c_str(), drizzled_user);
2038
if (vm.count("version"))
2044
2000
if (vm.count("sort-heap-threshold"))
2046
2002
if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2047
(vm["sort-heap-threshold"].as<uint64_t>() <
2048
global_system_variables.sortbuff_size))
2003
(vm["sort-heap-threshold"].as<uint64_t>() < global_system_variables.sortbuff_size))
2050
cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2005
unireg_abort << _("sort-heap-threshold cannot be less than sort-buffer-size");
2054
2008
global_sort_buffer.setMaxSize(vm["sort-heap-threshold"].as<uint64_t>());
2057
2011
if (vm.count("join-heap-threshold"))
2059
2013
if ((vm["join-heap-threshold"].as<uint64_t>() > 0) and
2060
(vm["join-heap-threshold"].as<uint64_t>() <
2061
global_system_variables.join_buff_size))
2014
(vm["join-heap-threshold"].as<uint64_t>() < global_system_variables.join_buff_size))
2063
cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2016
unireg_abort << _("join-heap-threshold cannot be less than join-buffer-size");
2067
2019
global_join_buffer.setMaxSize(vm["join-heap-threshold"].as<uint64_t>());
2070
2022
if (vm.count("read-rnd-threshold"))
2072
2024
if ((vm["read-rnd-threshold"].as<uint64_t>() > 0) and
2073
(vm["read-rnd-threshold"].as<uint64_t>() <
2074
global_system_variables.read_rnd_buff_size))
2025
(vm["read-rnd-threshold"].as<uint64_t>() < global_system_variables.read_rnd_buff_size))
2076
cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2027
unireg_abort << _("read-rnd-threshold cannot be less than read-rnd-buffer-size");
2080
2030
global_read_rnd_buffer.setMaxSize(vm["read-rnd-threshold"].as<uint64_t>());
2083
2033
if (vm.count("read-buffer-threshold"))
2085
2035
if ((vm["read-buffer-threshold"].as<uint64_t>() > 0) and
2086
(vm["read-buffer-threshold"].as<uint64_t>() <
2087
global_system_variables.read_buff_size))
2036
(vm["read-buffer-threshold"].as<uint64_t>() < global_system_variables.read_buff_size))
2089
cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2038
unireg_abort << _("read-buffer-threshold cannot be less than read-buffer-size");
2093
2041
global_read_buffer.setMaxSize(vm["read-buffer-threshold"].as<uint64_t>());
2114
2062
if (vm.count("skip-symlinks"))
2116
internal::my_use_symdir=0;
2064
internal::my_use_symdir= 0;
2067
if (vm.count("collation-server"))
2069
const charset_info_st * const default_collation= get_charset_by_name(vm["collation-server"].as<string>().c_str());
2070
if (not default_collation)
2072
unireg_abort << "Unknown collation: " << default_collation_name;
2075
if (not my_charset_same(default_charset_info, default_collation))
2077
unireg_abort << "COLLATION '" << default_collation_name << "' is not valid for CHARACTER SET '" << default_charset_info->csname << "'";
2079
default_charset_info= default_collation;
2119
2082
if (vm.count("transaction-isolation"))
2170
2138
pid_file= fs::system_complete(pid_file_path);
2174
const char *tmp_string= getenv("TMPDIR");
2176
drizzle_tmpdir.clear();
2178
if (vm.count("tmpdir"))
2180
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2182
else if (tmp_string == NULL)
2184
drizzle_tmpdir.append(getDataHome().file_string());
2185
drizzle_tmpdir.push_back(FN_LIBCHAR);
2186
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2190
drizzle_tmpdir.append(tmp_string);
2193
drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2194
assert(drizzle_tmpdir.size());
2196
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2198
if (errno != EEXIST)
2200
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());
2205
if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2207
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());
2140
const char *tmp_string= getenv("TMPDIR");
2142
drizzle_tmpdir.clear();
2144
if (vm.count("tmpdir"))
2146
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2148
else if (tmp_string == NULL)
2150
drizzle_tmpdir.append(getDataHome().file_string());
2151
drizzle_tmpdir.push_back(FN_LIBCHAR);
2152
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2156
drizzle_tmpdir.append(tmp_string);
2159
drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2160
assert(drizzle_tmpdir.size());
2162
assert(getuid() != 0 and geteuid() != 0);
2163
if (getuid() == 0 or geteuid() == 0)
2165
unireg_abort << "Drizzle cannot be run as root, please see the Security piece of the manual for more information.";
2168
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2170
if (errno != EEXIST)
2172
unireg_abort << "There was an error creating the '"
2173
<< fs::path(drizzle_tmpdir).leaf()
2174
<< "' part of the path '"
2176
<< "'. Please check the path exists and is writable.";
2180
if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2182
unireg_abort << "There was an error opening the path '" << drizzle_tmpdir << "', please check the path exists and is writable.";
2214
2186
} /* namespace drizzled */