651
711
DRIZZLE_CONFIG_NAME, "server", 0, 0
654
static void find_plugin_dir(string progname)
656
if (progname[0] != FN_LIBCHAR)
658
/* We have a relative path and need to find the absolute */
659
char working_dir[FN_REFLEN];
660
char *working_dir_ptr= working_dir;
661
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
662
string new_path(working_dir);
663
if (*(new_path.end()-1) != '/')
664
new_path.push_back('/');
665
if (progname[0] == '.' && progname[1] == '/')
666
new_path.append(progname.substr(2));
668
new_path.append(progname);
669
progname.swap(new_path);
672
/* Now, trim off the exe name */
673
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
674
if (progdir.rfind(".libs/") != string::npos)
676
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
678
string testlofile(progdir);
679
testlofile.append("drizzled.lo");
680
string testofile(progdir);
681
testofile.append("drizzled.o");
682
struct stat testfile_stat;
683
if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
685
/* We are in a source dir! Plugin dir is ../plugin/.libs */
686
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
687
base_plugin_dir= progdir.substr(0,last_libchar_pos);
688
base_plugin_dir /= "plugin";
689
base_plugin_dir /= ".libs";
692
if (plugin_dir.root_directory() == "")
694
fs::path full_plugin_dir(fs::system_complete(base_plugin_dir));
695
full_plugin_dir /= plugin_dir;
696
plugin_dir= full_plugin_dir;
700
static void notify_plugin_dir(fs::path in_plugin_dir)
702
plugin_dir= in_plugin_dir;
703
if (plugin_dir.root_directory() == "")
705
fs::path full_plugin_dir(fs::system_complete(basedir));
706
full_plugin_dir /= plugin_dir;
707
plugin_dir= full_plugin_dir;
711
static void expand_secure_file_priv(fs::path in_secure_file_priv)
713
secure_file_priv= fs::system_complete(in_secure_file_priv);
716
static void check_limits_aii(uint64_t in_auto_increment_increment)
718
global_system_variables.auto_increment_increment= 1;
719
if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
721
cout << _("Error: Invalid Value for auto_increment_increment");
724
global_system_variables.auto_increment_increment= in_auto_increment_increment;
727
static void check_limits_aio(uint64_t in_auto_increment_offset)
729
global_system_variables.auto_increment_offset= 1;
730
if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
732
cout << _("Error: Invalid Value for auto_increment_offset");
735
global_system_variables.auto_increment_offset= in_auto_increment_offset;
738
static void check_limits_completion_type(uint32_t in_completion_type)
740
global_system_variables.completion_type= 0;
741
if (in_completion_type > 2)
743
cout << _("Error: Invalid Value for completion_type");
746
global_system_variables.completion_type= in_completion_type;
750
static void check_limits_dpi(uint32_t in_div_precincrement)
752
global_system_variables.div_precincrement= 4;
753
if (in_div_precincrement > DECIMAL_MAX_SCALE)
755
cout << _("Error: Invalid Value for div-precision-increment");
758
global_system_variables.div_precincrement= in_div_precincrement;
761
static void check_limits_gcml(uint64_t in_group_concat_max_len)
763
global_system_variables.group_concat_max_len= 1024;
764
if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
766
cout << _("Error: Invalid Value for group_concat_max_len");
769
global_system_variables.group_concat_max_len= in_group_concat_max_len;
772
static void check_limits_join_buffer_size(uint64_t in_join_buffer_size)
774
global_system_variables.join_buff_size= (128*1024L);
775
if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
777
cout << _("Error: Invalid Value for join_buffer_size");
780
in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
781
global_system_variables.join_buff_size= in_join_buffer_size;
784
static void check_limits_map(uint32_t in_max_allowed_packet)
786
global_system_variables.max_allowed_packet= (64*1024*1024L);
787
if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
789
cout << _("Error: Invalid Value for max_allowed_packet");
792
in_max_allowed_packet-= in_max_allowed_packet % 1024;
793
global_system_variables.max_allowed_packet= in_max_allowed_packet;
796
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
798
global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
799
if (in_max_error_count > 65535)
801
cout << _("Error: Invalid Value for max_error_count");
804
global_system_variables.max_error_count= in_max_error_count;
807
static void check_limits_mhts(uint64_t in_max_heap_table_size)
809
global_system_variables.max_heap_table_size= (16*1024*1024L);
810
if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
812
cout << _("Error: Invalid Value for max_heap_table_size");
815
in_max_heap_table_size-= in_max_heap_table_size % 1024;
816
global_system_variables.max_heap_table_size= in_max_heap_table_size;
819
static void check_limits_merl(uint64_t in_min_examined_row_limit)
821
global_system_variables.min_examined_row_limit= 0;
822
if (in_min_examined_row_limit > ULONG_MAX)
824
cout << _("Error: Invalid Value for min_examined_row_limit");
827
global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
830
static void check_limits_max_join_size(drizzled::ha_rows in_max_join_size)
832
global_system_variables.max_join_size= INT32_MAX;
833
if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
835
cout << _("Error: Invalid Value for max_join_size");
838
global_system_variables.max_join_size= in_max_join_size;
841
static void check_limits_mlfsd(int64_t in_max_length_for_sort_data)
843
global_system_variables.max_length_for_sort_data= 1024;
844
if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
846
cout << _("Error: Invalid Value for max_length_for_sort_data");
849
global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
852
static void check_limits_msfk(uint64_t in_max_seeks_for_key)
854
global_system_variables.max_seeks_for_key= ULONG_MAX;
855
if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
857
cout << _("Error: Invalid Value for max_seeks_for_key");
860
global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
863
static void check_limits_max_sort_length(size_t in_max_sort_length)
865
global_system_variables.max_sort_length= 1024;
866
if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
868
cout << _("Error: Invalid Value for max_sort_length");
871
global_system_variables.max_sort_length= in_max_sort_length;
874
static void check_limits_osd(uint32_t in_optimizer_search_depth)
876
global_system_variables.optimizer_search_depth= 0;
877
if (in_optimizer_search_depth > MAX_TABLES + 2)
879
cout << _("Error: Invalid Value for optimizer_search_depth");
882
global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
885
static void check_limits_pbs(uint64_t in_preload_buff_size)
887
global_system_variables.preload_buff_size= (32*1024L);
888
if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
890
cout << _("Error: Invalid Value for preload_buff_size");
893
global_system_variables.preload_buff_size= in_preload_buff_size;
896
static void check_limits_qabs(uint32_t in_query_alloc_block_size)
898
global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
899
if (in_query_alloc_block_size < 1024)
901
cout << _("Error: Invalid Value for query_alloc_block_size");
904
in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
905
global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
908
static void check_limits_qps(uint32_t in_query_prealloc_size)
910
global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
911
if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
913
cout << _("Error: Invalid Value for query_prealloc_size");
916
in_query_prealloc_size-= in_query_prealloc_size % 1024;
917
global_system_variables.query_prealloc_size= in_query_prealloc_size;
920
static void check_limits_rabs(size_t in_range_alloc_block_size)
922
global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
923
if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
925
cout << _("Error: Invalid Value for range_alloc_block_size");
928
in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
929
global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
932
static void check_limits_read_buffer_size(int32_t in_read_buff_size)
934
global_system_variables.read_buff_size= (128*1024L);
935
if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
937
cout << _("Error: Invalid Value for read_buff_size");
940
in_read_buff_size-= in_read_buff_size % IO_SIZE;
941
global_system_variables.read_buff_size= in_read_buff_size;
944
static void check_limits_read_rnd_buffer_size(uint32_t in_read_rnd_buff_size)
946
global_system_variables.read_rnd_buff_size= (256*1024L);
947
if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
949
cout << _("Error: Invalid Value for read_rnd_buff_size");
952
global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
955
static void check_limits_sort_buffer_size(size_t in_sortbuff_size)
957
global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
958
if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
960
cout << _("Error: Invalid Value for sort_buff_size");
963
global_system_variables.sortbuff_size= in_sortbuff_size;
966
static void check_limits_tdc(uint32_t in_table_def_size)
969
if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
971
cout << _("Error: Invalid Value for table_def_size");
974
table_def_size= in_table_def_size;
977
static void check_limits_toc(uint32_t in_table_cache_size)
979
table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
980
if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
982
cout << _("Error: Invalid Value for table_cache_size");
985
table_cache_size= in_table_cache_size;
988
static void check_limits_tlwt(uint64_t in_table_lock_wait_timeout)
990
table_lock_wait_timeout= 50;
991
if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
993
cout << _("Error: Invalid Value for table_lock_wait_timeout");
996
table_lock_wait_timeout= in_table_lock_wait_timeout;
999
static void check_limits_thread_stack(uint32_t in_my_thread_stack_size)
1001
my_thread_stack_size= in_my_thread_stack_size - (in_my_thread_stack_size % 1024);
1004
static void check_limits_tmp_table_size(uint64_t in_tmp_table_size)
1006
global_system_variables.tmp_table_size= 16*1024*1024L;
1007
if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1009
cout << _("Error: Invalid Value for table_lock_wait_timeout");
1012
global_system_variables.tmp_table_size= in_tmp_table_size;
1015
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1017
transaction_message_threshold= 1024*1024;
1018
if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1020
cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1023
transaction_message_threshold= in_transaction_message_threshold;
1026
static void process_defaults_files()
1028
for (vector<string>::iterator iter= defaults_file_list.begin();
1029
iter != defaults_file_list.end();
1032
fs::path file_location= *iter;
1034
ifstream input_defaults_file(file_location.file_string().c_str());
1036
po::parsed_options file_parsed=
1037
dpo::parse_config_file(input_defaults_file, full_options, true);
1038
vector<string> file_unknown=
1039
po::collect_unrecognized(file_parsed.options, po::include_positional);
1041
for (vector<string>::iterator it= file_unknown.begin();
1042
it != file_unknown.end();
1045
string new_unknown_opt("--");
1046
new_unknown_opt.append(*it);
1048
if (it != file_unknown.end())
1050
if ((*it) != "true")
1052
new_unknown_opt.push_back('=');
1053
new_unknown_opt.append(*it);
1060
unknown_options.push_back(new_unknown_opt);
1062
store(file_parsed, vm);
1066
static void compose_defaults_file_list(vector<string> in_options)
1068
for (vector<string>::iterator it= in_options.begin();
1069
it != in_options.end();
1073
if (fs::is_regular_file(p))
1074
defaults_file_list.push_back(*it);
1077
errmsg_printf(error::ERROR,
1078
_("Defaults file '%s' not found\n"), (*it).c_str());
1085
int init_basic_variables(int argc, char **argv)
714
static int show_starttime(drizzle_show_var *var, char *buff)
716
var->type= SHOW_LONG;
718
*((long *)buff)= (long) (time(NULL) - server_start_time);
722
static int show_flushstatustime(drizzle_show_var *var, char *buff)
724
var->type= SHOW_LONG;
726
*((long *)buff)= (long) (time(NULL) - flush_status_time);
730
static st_show_var_func_container show_starttime_cont= { &show_starttime };
732
static st_show_var_func_container show_flushstatustime_cont= { &show_flushstatustime };
735
Variables shown by SHOW STATUS in alphabetical order
737
static drizzle_show_var com_status_vars[]= {
738
{"admin_commands", (char*) offsetof(system_status_var, com_other), SHOW_LONG_STATUS},
739
{"alter_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
740
{"alter_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
741
{"analyze", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
742
{"begin", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
743
{"change_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
744
{"check", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECK]), SHOW_LONG_STATUS},
745
{"checksum", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
746
{"commit", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
747
{"create_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
748
{"create_index", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
749
{"create_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
750
{"delete", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
751
{"drop_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
752
{"drop_index", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
753
{"drop_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
754
{"empty_query", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
755
{"flush", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
756
{"insert", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT]), SHOW_LONG_STATUS},
757
{"insert_select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
758
{"kill", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_KILL]), SHOW_LONG_STATUS},
759
{"load", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_LOAD]), SHOW_LONG_STATUS},
760
{"release_savepoint", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
761
{"rename_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
762
{"replace", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
763
{"replace_select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
764
{"rollback", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
765
{"rollback_to_savepoint",(char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
766
{"savepoint", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
767
{"select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SELECT]), SHOW_LONG_STATUS},
768
{"set_option", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
769
{"show_create_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
770
{"show_create_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
771
{"show_errors", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
772
{"show_warnings", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
773
{"truncate", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
774
{"unlock_tables", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
775
{"update", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
776
{NULL, NULL, SHOW_LONGLONG}
779
static drizzle_show_var status_vars[]= {
780
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONGLONG},
781
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONGLONG},
782
{"Bytes_received", (char*) offsetof(system_status_var, bytes_received), SHOW_LONGLONG_STATUS},
783
{"Bytes_sent", (char*) offsetof(system_status_var, bytes_sent), SHOW_LONGLONG_STATUS},
784
{"Connections", (char*) &global_thread_id, SHOW_INT_NOFLUSH},
785
{"Created_tmp_disk_tables", (char*) offsetof(system_status_var, created_tmp_disk_tables), SHOW_LONG_STATUS},
786
{"Created_tmp_tables", (char*) offsetof(system_status_var, created_tmp_tables), SHOW_LONG_STATUS},
787
{"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
788
{"Handler_commit", (char*) offsetof(system_status_var, ha_commit_count), SHOW_LONG_STATUS},
789
{"Handler_delete", (char*) offsetof(system_status_var, ha_delete_count), SHOW_LONG_STATUS},
790
{"Handler_prepare", (char*) offsetof(system_status_var, ha_prepare_count), SHOW_LONG_STATUS},
791
{"Handler_read_first", (char*) offsetof(system_status_var, ha_read_first_count), SHOW_LONG_STATUS},
792
{"Handler_read_key", (char*) offsetof(system_status_var, ha_read_key_count), SHOW_LONG_STATUS},
793
{"Handler_read_next", (char*) offsetof(system_status_var, ha_read_next_count), SHOW_LONG_STATUS},
794
{"Handler_read_prev", (char*) offsetof(system_status_var, ha_read_prev_count), SHOW_LONG_STATUS},
795
{"Handler_read_rnd", (char*) offsetof(system_status_var, ha_read_rnd_count), SHOW_LONG_STATUS},
796
{"Handler_read_rnd_next", (char*) offsetof(system_status_var, ha_read_rnd_next_count), SHOW_LONG_STATUS},
797
{"Handler_rollback", (char*) offsetof(system_status_var, ha_rollback_count), SHOW_LONG_STATUS},
798
{"Handler_savepoint", (char*) offsetof(system_status_var, ha_savepoint_count), SHOW_LONG_STATUS},
799
{"Handler_savepoint_rollback",(char*) offsetof(system_status_var, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
800
{"Handler_update", (char*) offsetof(system_status_var, ha_update_count), SHOW_LONG_STATUS},
801
{"Handler_write", (char*) offsetof(system_status_var, ha_write_count), SHOW_LONG_STATUS},
802
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
803
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
804
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
805
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
806
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
807
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
808
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
809
{"Last_query_cost", (char*) offsetof(system_status_var, last_query_cost), SHOW_DOUBLE_STATUS},
810
{"Max_used_connections", (char*) &max_used_connections, SHOW_INT},
811
{"Questions", (char*) offsetof(system_status_var, questions), SHOW_LONG_STATUS},
812
{"Select_full_join", (char*) offsetof(system_status_var, select_full_join_count), SHOW_LONG_STATUS},
813
{"Select_full_range_join", (char*) offsetof(system_status_var, select_full_range_join_count), SHOW_LONG_STATUS},
814
{"Select_range", (char*) offsetof(system_status_var, select_range_count), SHOW_LONG_STATUS},
815
{"Select_range_check", (char*) offsetof(system_status_var, select_range_check_count), SHOW_LONG_STATUS},
816
{"Select_scan", (char*) offsetof(system_status_var, select_scan_count), SHOW_LONG_STATUS},
817
{"Slow_queries", (char*) offsetof(system_status_var, long_query_count), SHOW_LONG_STATUS},
818
{"Sort_merge_passes", (char*) offsetof(system_status_var, filesort_merge_passes), SHOW_LONG_STATUS},
819
{"Sort_range", (char*) offsetof(system_status_var, filesort_range_count), SHOW_LONG_STATUS},
820
{"Sort_rows", (char*) offsetof(system_status_var, filesort_rows), SHOW_LONG_STATUS},
821
{"Sort_scan", (char*) offsetof(system_status_var, filesort_scan_count), SHOW_LONG_STATUS},
822
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_INT},
823
{"Table_locks_waited", (char*) &locks_waited, SHOW_INT},
824
{"Threads_connected", (char*) &connection_count, SHOW_INT},
825
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
826
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
827
{NULL, NULL, SHOW_LONGLONG}
830
int init_common_variables(const char *conf_file_name, int argc,
831
char **argv, const char **groups)
1087
833
time_t curr_time;
1088
834
umask(((~internal::my_umask) & 0666));
1089
decimal_zero.set_zero(); // set decimal_zero constant;
835
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1090
836
tzset(); // Set tzname
1092
838
curr_time= time(NULL);
1117
864
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1119
866
strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1120
errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
867
errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1122
pid_file= "drizzle";
869
strncpy(pidfile_name, STRING_WITH_LEN("drizzle"));
1126
pid_file= glob_hostname;
1128
pid_file.replace_extension(".pid");
1130
system_config_dir /= "drizzle";
1132
config_options.add_options()
1133
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1134
_("Display this help and exit."))
1135
("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1136
_("Run as a daemon."))
1137
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1138
_("Configuration file defaults are not used if no-defaults is set"))
1139
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1140
_("Configuration file to use"))
1141
("config-dir", po::value<fs::path>(&system_config_dir),
1142
_("Base location for config files"))
1143
("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(¬ify_plugin_dir),
1144
_("Directory for plugins."))
1147
plugin_load_options.add_options()
1148
("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1149
_("Optional comma separated list of plugins to load at startup in addition "
1150
"to the default list of plugins. "
1151
"[for example: --plugin_add=crc32,logger_gearman]"))
1152
("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1153
_("Optional comma separated list of plugins to not load at startup. Effectively "
1154
"removes a plugin from the list of plugins to be loaded. "
1155
"[for example: --plugin_remove=crc32,logger_gearman]"))
1156
("plugin-load", po::value<string>()->notifier(¬ify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1157
_("Optional comma separated list of plugins to load at starup instead of "
1158
"the default plugin load list. "
1159
"[for example: --plugin_load=crc32,logger_gearman]"))
1162
long_options.add_options()
1163
("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1164
_("Auto-increment columns are incremented by this"))
1165
("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1166
_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1167
("basedir,b", po::value<fs::path>(&basedir),
1168
_("Path to installation directory. All paths are usually resolved "
1169
"relative to this."))
1170
("chroot,r", po::value<string>(),
1171
_("Chroot drizzled daemon during startup."))
1172
("collation-server", po::value<string>(),
1173
_("Set the default collation."))
1174
("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1175
_("Default completion type."))
1176
("core-file", _("Write core on errors."))
1177
("datadir", po::value<fs::path>(&getDataHome()),
1178
_("Path to the database root."))
1179
("default-storage-engine", po::value<string>(),
1180
_("Set the default storage engine for tables."))
1181
("default-time-zone", po::value<string>(),
1182
_("Set the default time zone."))
1183
("exit-info,T", po::value<long>(),
1184
_("Used for debugging; Use at your own risk!"))
1185
("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1186
_("Set up signals usable for debugging"))
1187
("lc-time-name", po::value<string>(),
1188
_("Set the language used for the month names and the days of the week."))
1189
("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
1190
_("Log some not critical warnings to the log file."))
1191
("pid-file", po::value<fs::path>(&pid_file),
1192
_("Pid file used by drizzled."))
1193
("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1194
_("Maximum time in seconds to wait for the port to become free. "))
1195
("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1196
_("Include the SQL query in replicated protobuf messages."))
1197
("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1198
_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1199
"within specified directory"))
1200
("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1201
_("Uniquely identifies the server instance in the community of "
1202
"replication partners."))
1203
("skip-stack-trace",
1204
_("Don't print a stack trace on failure."))
1205
("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1206
_("Enable symbolic link support."))
1207
("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1208
_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1210
("tmpdir,t", po::value<string>(),
1211
_("Path for temporary files."))
1212
("transaction-isolation", po::value<string>(),
1213
_("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),
1215
_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1216
("user,u", po::value<string>(),
1217
_("Run drizzled daemon as user."))
1219
_("Output version information and exit."))
1220
("back-log", po::value<back_log_constraints>(&back_log),
1221
_("The number of outstanding connection requests Drizzle can have. This "
1222
"comes into play when the main Drizzle thread gets very many connection "
1223
"requests in a very short time."))
1224
("bulk-insert-buffer-size",
1225
po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1226
_("Size of tree cache used in bulk insert optimization. Note that this is "
1227
"a limit per thread!"))
1228
("div-precision-increment", po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1229
_("Precision of the result of '/' operator will be increased on that "
1231
("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1232
_("The maximum length of the result of function group_concat."))
1233
("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1234
_("The size of the buffer that is used for full joins."))
1235
("join-heap-threshold",
1236
po::value<uint64_t>()->default_value(0),
1237
_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1238
("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1239
_("Max packetlength to send/receive from to server."))
1240
("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
_("Max number of errors/warnings to store for a statement."))
1242
("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1243
_("Don't allow creation of heap tables bigger than this."))
1244
("max-join-size", po::value<drizzled::ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1245
_("Joins that are probably going to read more than max_join_size records "
1246
"return an error."))
1247
("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1248
_("Max number of bytes in sorted records."))
1249
("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1250
_("Limit assumed max number of seeks when looking up rows based on a key"))
1251
("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
1252
_("The number of bytes to use when sorting BLOB or TEXT values "
1253
"(only the first max_sort_length bytes of each value are used; the "
1254
"rest are ignored)."))
1255
("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1256
_("After this many write locks, allow some read locks to run in between."))
1257
("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1258
_("Don't log queries which examine less than min_examined_row_limit "
1260
("disable-optimizer-prune",
1261
_("Do not apply any heuristic(s) during query optimization to prune, "
1262
"thus perform an exhaustive search from the optimizer search space."))
1263
("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1264
_("Maximum depth of search performed by the query optimizer. Values "
1265
"larger than the number of relations in a query result in better query "
1266
"plans, but take longer to compile a query. Smaller values than the "
1267
"number of tables in a relation result in faster optimization, but may "
1268
"produce very bad query plans. If set to 0, the system will "
1269
"automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1270
"optimizer will switch to the original find_best (used for "
1271
"testing/comparison)."))
1272
("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1273
_("The size of the buffer that is allocated when preloading indexes"))
1274
("query-alloc-block-size",
1275
po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1276
_("Allocation block size for query parsing and execution"))
1277
("query-prealloc-size",
1278
po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1279
_("Persistent buffer for query parsing and execution"))
1280
("range-alloc-block-size",
1281
po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1282
_("Allocation block size for storing ranges during optimization"))
1283
("read-buffer-size",
1284
po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1285
_("Each thread that does a sequential scan allocates a buffer of this "
1286
"size for each table it scans. If you do many sequential scans, you may "
1287
"want to increase this value."))
1288
("read-buffer-threshold",
1289
po::value<uint64_t>()->default_value(0),
1290
_("A global cap on the size of read-buffer-size (0 means unlimited)"))
1291
("read-rnd-buffer-size",
1292
po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1293
_("When reading rows in sorted order after a sort, the rows are read "
1294
"through this buffer to avoid a disk seeks. If not set, then it's set "
1295
"to the value of record_buffer."))
1296
("read-rnd-threshold",
1297
po::value<uint64_t>()->default_value(0),
1298
_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1299
("scheduler", po::value<string>(),
1300
_("Select scheduler to be used (by default multi-thread)."))
1301
("sort-buffer-size",
1302
po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1303
_("Each thread that needs to do a sort allocates a buffer of this size."))
1304
("sort-heap-threshold",
1305
po::value<uint64_t>()->default_value(0),
1306
_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1307
("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1308
_("The number of cached table definitions."))
1309
("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1310
_("The number of cached open tables."))
1311
("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1312
_("Timeout in seconds to wait for a table level lock before returning an "
1313
"error. Used only if the connection has active cursors."))
1314
("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1315
_("The stack size for each thread."))
1317
po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1318
_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1319
" automatically convert it to an on-disk MyISAM table."))
1322
full_options.add(long_options);
1323
full_options.add(plugin_load_options);
1325
initial_options.add(config_options);
1326
initial_options.add(plugin_load_options);
1328
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1329
/* Get options about where config files and the like are */
1330
po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1331
options(initial_options).allow_unregistered().run();
1333
po::collect_unrecognized(parsed.options, po::include_positional);
1337
po::store(parsed, vm);
1339
catch (std::exception&)
1341
errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
1345
if (not vm["no-defaults"].as<bool>())
1347
fs::path system_config_file_drizzle(system_config_dir);
1348
system_config_file_drizzle /= "drizzled.cnf";
1349
defaults_file_list.insert(defaults_file_list.begin(),
1350
system_config_file_drizzle.file_string());
1352
fs::path config_conf_d_location(system_config_dir);
1353
config_conf_d_location /= "conf.d";
1356
CachedDirectory config_conf_d(config_conf_d_location.file_string());
1357
if (not config_conf_d.fail())
1360
for (CachedDirectory::Entries::const_iterator iter= config_conf_d.getEntries().begin();
1361
iter != config_conf_d.getEntries().end();
1364
string file_entry((*iter)->filename);
1366
if (not file_entry.empty()
1367
&& file_entry != "."
1368
&& file_entry != "..")
1370
fs::path the_entry(config_conf_d_location);
1371
the_entry /= file_entry;
1372
defaults_file_list.push_back(the_entry.file_string());
1378
/* TODO: here is where we should add a process_env_vars */
1380
/* We need a notify here so that plugin_init will work properly */
1385
catch (po::validation_error &err)
1387
errmsg_printf(error::ERROR,
1389
"Use --help to get a list of available options\n"),
1390
internal::my_progname, err.what());
1394
process_defaults_files();
1396
/* Process with notify a second time because a config file may contain
1397
plugin loader options */
1403
catch (po::validation_error &err)
1405
errmsg_printf(error::ERROR,
1407
"Use --help to get a list of available options\n"),
1408
internal::my_progname, err.what());
1415
int init_remaining_variables(module::Registry &plugins)
1417
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
872
strncpy(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
873
strcpy(internal::fn_ext(pidfile_name),".pid"); // Add proper extension
876
Add server status variables to the dynamic list of
877
status variables that is shown by SHOW STATUS.
878
Later, in plugin_init, new entries could be added to that list.
880
if (add_com_status_vars(com_status_vars))
881
return 1; // an error was already reported
883
if (add_status_vars(status_vars))
884
return 1; // an error was already reported
886
internal::load_defaults(conf_file_name, groups, &argc, &argv);
889
get_options(&defaults_argc, defaults_argv);
1419
891
current_pid= getpid(); /* Save for later ref */
1421
/* At this point, we've read all the options we need to read from files and
1422
collected most of them into unknown options - now let's load everything
1425
if (plugin_init(plugins, plugin_options))
1427
errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1431
full_options.add(plugin_options);
1433
vector<string> final_unknown_options;
1436
po::parsed_options final_parsed=
1437
po::command_line_parser(unknown_options).style(style).
1438
options(full_options).extra_parser(dpo::parse_size_arg).run();
1440
final_unknown_options=
1441
po::collect_unrecognized(final_parsed.options, po::include_positional);
1443
po::store(final_parsed, vm);
1446
catch (po::validation_error &err)
1448
errmsg_printf(error::ERROR,
1450
"Use --help to get a list of available options\n"),
1451
internal::my_progname, err.what());
1454
catch (po::invalid_command_line_syntax &err)
1456
errmsg_printf(error::ERROR,
1458
"Use --help to get a list of available options\n"),
1459
internal::my_progname, err.what());
1462
catch (po::unknown_option &err)
1464
errmsg_printf(error::ERROR,
1465
_("%s\nUse --help to get a list of available options\n"),
1474
catch (po::validation_error &err)
1476
errmsg_printf(error::ERROR,
1478
"Use --help to get a list of available options\n"),
1479
internal::my_progname, err.what());
1485
/* Inverted Booleans */
1487
global_system_variables.optimizer_prune_level=
1488
vm.count("disable-optimizer-prune") ? false : true;
1490
if (vm.count("help") == 0 && vm.count("help-extended") == 0)
1492
if ((user_info= check_user(drizzled_user)))
1494
set_user(drizzled_user, user_info);
1500
892
init_time(); /* Init time-functions (read zone) */
1502
894
if (item_create_init())
1506
898
/* Creates static regex matching for temporal values */
1507
899
if (! init_temporal_formats())
2140
1618
have_symlink=SHOW_OPTION_YES;
1622
if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
1624
(void) strncpy(drizzle_home, tmpenv, sizeof(drizzle_home)-1);
1626
connection_count= 0;
2147
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "drizzled/error.h" and return that code?
2149
static void get_options()
1630
int drizzled_get_one_option(int optid, const struct option *opt,
2152
fs::path &data_home_catalog= getDataHomeCatalog();
2153
data_home_catalog= getDataHome();
2154
data_home_catalog /= "local";
2156
if (vm.count("user"))
2158
if (! drizzled_user || ! strcmp(drizzled_user, vm["user"].as<string>().c_str()))
2159
drizzled_user= (char *)vm["user"].as<string>().c_str();
1635
global_system_variables.tx_isolation= ISO_SERIALIZABLE;
1638
strncpy(drizzle_home,argument,sizeof(drizzle_home)-1);
1641
if (default_collation_name == compiled_default_collation_name)
1642
default_collation_name= 0;
1645
strncpy(data_home_real,argument, sizeof(data_home_real)-1);
1646
/* Correct pointer set by my_getopt (for embedded library) */
1647
data_home= data_home_real;
1648
data_home_len= strlen(data_home);
1651
if (!drizzled_user || !strcmp(drizzled_user, argument))
1652
drizzled_user= argument;
2162
errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
2163
"set to '%s' earlier on the command line\n"),
2164
vm["user"].as<string>().c_str(), drizzled_user);
2167
if (vm.count("version"))
1654
errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
1655
"set to '%s' earlier on the command line\n"),
1656
argument, drizzled_user);
1659
strncpy(language, argument, sizeof(language)-1);
2169
1662
print_version();
2173
if (vm.count("sort-heap-threshold"))
2175
if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2176
(vm["sort-heap-threshold"].as<uint64_t>() <
2177
global_system_variables.sortbuff_size))
2179
cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2183
global_sort_buffer.setMaxSize(vm["sort-heap-threshold"].as<uint64_t>());
2186
if (vm.count("join-heap-threshold"))
2188
if ((vm["join-heap-threshold"].as<uint64_t>() > 0) and
2189
(vm["join-heap-threshold"].as<uint64_t>() <
2190
global_system_variables.join_buff_size))
2192
cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2196
global_join_buffer.setMaxSize(vm["join-heap-threshold"].as<uint64_t>());
2199
if (vm.count("read-rnd-threshold"))
2201
if ((vm["read-rnd-threshold"].as<uint64_t>() > 0) and
2202
(vm["read-rnd-threshold"].as<uint64_t>() <
2203
global_system_variables.read_rnd_buff_size))
2205
cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2209
global_read_rnd_buffer.setMaxSize(vm["read-rnd-threshold"].as<uint64_t>());
2212
if (vm.count("read-buffer-threshold"))
2214
if ((vm["read-buffer-threshold"].as<uint64_t>() > 0) and
2215
(vm["read-buffer-threshold"].as<uint64_t>() <
2216
global_system_variables.read_buff_size))
2218
cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2222
global_read_buffer.setMaxSize(vm["read-buffer-threshold"].as<uint64_t>());
2225
if (vm.count("exit-info"))
2227
if (vm["exit-info"].as<long>())
2229
getDebug().set((uint32_t) vm["exit-info"].as<long>());
2233
if (vm.count("want-core"))
2235
getDebug().set(debug::CORE_ON_SIGNAL);
2238
if (vm.count("skip-stack-trace"))
2240
getDebug().set(debug::NO_STACKTRACE);
2243
if (vm.count("skip-symlinks"))
1666
global_system_variables.log_warnings++;
1667
else if (argument == disabled_my_option)
1668
global_system_variables.log_warnings= 0L;
1670
global_system_variables.log_warnings= atoi(argument);
1675
test_flags.set((uint32_t) atoi(argument));
1678
case (int) OPT_WANT_CORE:
1679
test_flags.set(TEST_CORE_ON_SIGNAL);
1681
case (int) OPT_SKIP_STACK_TRACE:
1682
test_flags.set(TEST_NO_STACKTRACE);
1684
case (int) OPT_SKIP_SYMLINKS:
2245
1685
internal::my_use_symdir=0;
2248
if (vm.count("transaction-isolation"))
2250
int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
2251
global_system_variables.tx_isolation= type - 1;
2254
/* @TODO Make this all strings */
2255
if (vm.count("default-storage-engine"))
2257
default_storage_engine_str= (char *)vm["default-storage-engine"].as<string>().c_str();
1687
case (int) OPT_BIND_ADDRESS:
1689
struct addrinfo *res_lst, hints;
1691
memset(&hints, 0, sizeof(struct addrinfo));
1692
hints.ai_socktype= SOCK_STREAM;
1693
hints.ai_protocol= IPPROTO_TCP;
1695
if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
1697
errmsg_printf(ERRMSG_LVL_ERROR, _("Can't start server: cannot resolve hostname!"));
1698
return EXIT_ARGUMENT_INVALID;
1701
if (res_lst->ai_next)
1703
errmsg_printf(ERRMSG_LVL_ERROR, _("Can't start server: bind-address refers to "
1704
"multiple interfaces!"));
1705
return EXIT_ARGUMENT_INVALID;
1707
freeaddrinfo(res_lst);
1710
case (int) OPT_PID_FILE:
1711
strncpy(pidfile_name, argument, sizeof(pidfile_name)-1);
1715
case OPT_TX_ISOLATION:
1718
type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
1719
global_system_variables.tx_isolation= (type-1);
1722
case OPT_TC_HEURISTIC_RECOVER:
1723
tc_heuristic_recover= find_type_or_exit(argument,
1724
&tc_heuristic_recover_typelib,
1732
static void option_error_reporter(enum loglevel level, const char *format, ...)
1735
va_start(args, format);
1737
/* Don't print warnings for --loose options during bootstrap */
1738
if (level == ERROR_LEVEL || global_system_variables.log_warnings)
1740
plugin::ErrorMessage::vprintf(current_session, ERROR_LEVEL, format, args);
1748
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "drizzled/error.h" and return that code?
1750
static void get_options(int *argc,char **argv)
1754
my_getopt_error_reporter= option_error_reporter;
1756
string progname(argv[0]);
2260
1758
/* Skip unknown options so that they may be processed later by plugins */
2261
1759
my_getopt_skip_unknown= true;
1761
if ((ho_error= handle_options(argc, &argv, my_long_options,
1762
drizzled_get_one_option)))
1764
(*argc)++; /* add back one for the progname handle_options removes */
1765
/* no need to do this for argv as we are discarding it. */
2264
1767
#if defined(HAVE_BROKEN_REALPATH)
2265
1768
internal::my_use_symdir=0;
2294
static void fix_paths()
2296
fs::path pid_file_path(pid_file);
2297
if (pid_file_path.root_path().string() == "")
2299
pid_file_path= getDataHome();
2300
pid_file_path /= pid_file;
2302
pid_file= fs::system_complete(pid_file_path);
2306
const char *tmp_string= getenv("TMPDIR") ? getenv("TMPDIR") : NULL;
1798
static const char *get_relative_path(const char *path)
1800
if (internal::test_if_hard_path(path) &&
1801
(strncmp(path, PREFIX, strlen(PREFIX)) == 0) &&
1802
strcmp(PREFIX,FN_ROOTDIR))
1804
if (strlen(PREFIX) < strlen(path))
1805
path+=(size_t) strlen(PREFIX);
1806
while (*path == FN_LIBCHAR)
1813
static void fix_paths(string &progname)
1815
char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX];
1816
internal::convert_dirname(drizzle_home,drizzle_home,NULL);
1817
/* Resolve symlinks to allow 'drizzle_home' to be a relative symlink */
1818
#if defined(HAVE_BROKEN_REALPATH)
1819
internal::my_load_path(drizzle_home, drizzle_home, NULL);
1821
if (!realpath(drizzle_home,rp_buff))
1822
internal::my_load_path(rp_buff, drizzle_home, NULL);
1823
rp_buff[FN_REFLEN-1]= '\0';
1824
strcpy(drizzle_home,rp_buff);
1825
/* Ensure that drizzle_home ends in FN_LIBCHAR */
1826
pos= strchr(drizzle_home, '\0');
1828
if (pos[-1] != FN_LIBCHAR)
1833
internal::convert_dirname(data_home_real,data_home_real,NULL);
1834
(void) internal::fn_format(buff, data_home_real, "", "",
1835
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
1836
(void) internal::unpack_dirname(data_home_real_unpacked, buff);
1837
internal::convert_dirname(language,language,NULL);
1838
(void) internal::my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
1839
(void) internal::my_load_path(data_home_real, data_home_real,drizzle_home);
1840
(void) internal::my_load_path(pidfile_name, pidfile_name,data_home_real);
1842
if (opt_plugin_dir_ptr == NULL)
1844
/* No plugin dir has been specified. Figure out where the plugins are */
1845
if (progname[0] != FN_LIBCHAR)
1847
/* We have a relative path and need to find the absolute */
1848
char working_dir[FN_REFLEN];
1849
char *working_dir_ptr= working_dir;
1850
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
1851
string new_path(working_dir);
1852
if (*(new_path.end()-1) != '/')
1853
new_path.push_back('/');
1854
if (progname[0] == '.' && progname[1] == '/')
1855
new_path.append(progname.substr(2));
1857
new_path.append(progname);
1858
progname.swap(new_path);
1861
/* Now, trim off the exe name */
1862
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
1863
if (progdir.rfind(".libs/") != string::npos)
1865
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
1867
string testfile(progdir);
1868
testfile.append("drizzled.lo");
1869
struct stat testfile_stat;
1870
if (stat(testfile.c_str(), &testfile_stat))
1872
/* drizzled.lo doesn't exist - we are not in a source dir.
1875
(void) internal::my_load_path(opt_plugin_dir, get_relative_path(PKGPLUGINDIR),
1880
/* We are in a source dir! Plugin dir is ../plugin/.libs */
1881
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
1882
string source_plugindir(progdir.substr(0,last_libchar_pos));
1883
source_plugindir.append("plugin/.libs");
1884
(void) internal::my_load_path(opt_plugin_dir, source_plugindir.c_str(), "");
1889
(void) internal::my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, drizzle_home);
1891
opt_plugin_dir_ptr= opt_plugin_dir;
1893
const char *sharedir= get_relative_path(PKGDATADIR);
1894
if (internal::test_if_hard_path(sharedir))
1895
strncpy(buff,sharedir,sizeof(buff)-1);
1898
strcpy(buff, drizzle_home);
1899
strncat(buff, sharedir, sizeof(buff)-strlen(drizzle_home)-1);
1901
internal::convert_dirname(buff,buff,NULL);
1902
(void) internal::my_load_path(language,language,buff);
2307
1906
struct stat buf;
2308
drizzle_tmpdir.clear();
2310
if (vm.count("tmpdir"))
2312
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
1908
tmp_string= getenv("TMPDIR");
1910
if (opt_drizzle_tmpdir)
1911
drizzle_tmpdir= strdup(opt_drizzle_tmpdir);
2314
1912
else if (tmp_string == NULL)
2316
drizzle_tmpdir.append(getDataHome().file_string());
2317
drizzle_tmpdir.push_back(FN_LIBCHAR);
2318
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
1913
drizzle_tmpdir= strdup(P_tmpdir);
2322
drizzle_tmpdir.append(tmp_string);
2325
drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).file_string();
2326
assert(drizzle_tmpdir.size());
2328
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2330
if (errno != EEXIST)
2332
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());
2337
if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2339
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());
1915
drizzle_tmpdir= strdup(tmp_string);
1917
assert(drizzle_tmpdir);
1919
if (stat(drizzle_tmpdir, &buf) || (S_ISDIR(buf.st_mode) == false))
1926
Convert the secure-file-priv option to system format, allowing
1927
a quick strcmp to check if read or write is in an allowed dir
1929
if (opt_secure_file_priv)
1931
internal::convert_dirname(buff, opt_secure_file_priv, NULL);
1932
free(opt_secure_file_priv);
1933
opt_secure_file_priv= strdup(buff);
1934
if (opt_secure_file_priv == NULL)
2346
1939
} /* namespace drizzled */