22#include <drizzled/vc_version.h>
23#include <drizzled/configmake.h>
24#include <drizzled/atomics.h>
25#include <drizzled/data_home.h>
30#include <netinet/in.h>
31#include <netinet/tcp.h>
38#include <boost/program_options.hpp>
39#include <drizzled/program_options/config_file.h>
40#include <boost/thread/recursive_mutex.hpp>
41#include <boost/thread/mutex.hpp>
42#include <boost/thread/shared_mutex.hpp>
43#include <boost/thread/condition_variable.hpp>
44#include <boost/filesystem.hpp>
45#include <boost/smart_ptr/detail/atomic_count.hpp>
48#include <drizzled/charset.h>
49#include <drizzled/data_home.h>
50#include <drizzled/debug.h>
51#include <drizzled/definition/cache.h>
52#include <drizzled/drizzled.h>
53#include <drizzled/errmsg_print.h>
54#include <drizzled/error.h>
55#include <drizzled/global_buffer.h>
56#include <drizzled/internal/my_bit.h>
57#include <drizzled/internal/my_sys.h>
58#include <drizzled/item/cmpfunc.h>
59#include <drizzled/item/create.h>
60#include <drizzled/message/cache.h>
61#include <drizzled/module/load_list.h>
62#include <drizzled/module/registry.h>
63#include <drizzled/plugin/client.h>
64#include <drizzled/plugin/error_message.h>
65#include <drizzled/plugin/event_observer.h>
66#include <drizzled/plugin/listen.h>
67#include <drizzled/plugin/monitored_in_transaction.h>
68#include <drizzled/plugin/scheduler.h>
69#include <drizzled/plugin/storage_engine.h>
70#include <drizzled/plugin/xa_resource_manager.h>
71#include <drizzled/probes.h>
72#include <drizzled/replication_services.h>
73#include <drizzled/session.h>
74#include <drizzled/session/cache.h>
76#include <drizzled/sql_base.h>
77#include <drizzled/sql_parse.h>
78#include <drizzled/statistics_variables.h>
79#include <drizzled/table/cache.h>
81#include <drizzled/drizzled_abort.h>
82#include <plugin/myisam/myisam.h>
83#include <drizzled/typelib.h>
85#include <drizzled/system_variables.h>
86#include <drizzled/open_tables_state.h>
88#include <google/protobuf/stubs/common.h>
94#include <sys/socket.h>
99#include <drizzled/option.h>
107#include <sys/select.h>
109#include <sys/utsname.h>
114#include <fpu_control.h>
117#include <drizzled/internal/my_pthread.h>
118#include <drizzled/constrained_value.h>
120#include <drizzled/gettext.h>
124#define IF_PURIFY(A,B) (A)
126#define IF_PURIFY(A,B) (B)
129#define MAX_MEM_TABLE_SIZE SIZE_MAX
135namespace fs=boost::filesystem;
136namespace po=boost::program_options;
137namespace dpo=drizzled::program_options;
141inline void setup_fpu()
148#if defined(__i386__) && defined(_FPU_DOUBLE)
151 cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
157const char *first_keyword=
"first";
158const char *
const DRIZZLE_CONFIG_NAME=
"drizzled";
160#define GET_HA_ROWS GET_ULL
162const char *tx_isolation_names[] = {
"READ-UNCOMMITTED",
"READ-COMMITTED",
"REPEATABLE-READ",
"SERIALIZABLE", NULL};
164TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names) - 1,
"", tx_isolation_names, NULL};
166arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
168 {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
169 {&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
170 {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
171 {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
175static bool opt_debugging=
false;
176static uint32_t wake_thread;
177static const char* drizzled_chroot;
178static const char* default_character_set_name=
"utf8";
179static const char* lc_time_names_name=
"en_US";
180static const char* default_storage_engine_str=
"innodb";
181static const char*
const compiled_default_collation_name=
"utf8_general_ci";
182static const char* default_collation_name= compiled_default_collation_name;
186const char *drizzled_user;
187bool volatile select_thread_in_use;
188bool volatile abort_loop;
190const char* opt_scheduler=
"multi_thread";
202uint32_t drizzled_bind_timeout;
203uint32_t dropping_tables, ha_open_options;
204uint32_t tc_heuristic_recover= 0;
205uint64_t session_startup_options;
206back_log_constraints back_log(SOMAXCONN);
209uint64_t table_cache_size;
210size_t table_def_size;
211uint32_t global_thread_id= 1UL;
214extern const double log_10[309];
216const double log_10[] = {
217 1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
218 1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
219 1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029,
220 1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039,
221 1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049,
222 1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059,
223 1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069,
224 1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079,
225 1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089,
226 1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099,
227 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
228 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
229 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
230 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
231 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
232 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
233 1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169,
234 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179,
235 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189,
236 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199,
237 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209,
238 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219,
239 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229,
240 1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239,
241 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249,
242 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259,
243 1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269,
244 1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279,
245 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289,
246 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299,
247 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308
250time_t server_start_time;
253fs::path basedir(PREFIX);
255fs::path secure_file_priv;
257fs::path system_config_dir(SYSCONFDIR);
259const key_map key_map_empty(0);
260key_map key_map_full(0);
262std::string drizzle_tmpdir;
263char *opt_drizzle_tmpdir= NULL;
269const char *in_having_cond=
"<IN HAVING>";
273FILE *stderror_file=0;
284MY_LOCALE *my_default_lc_time_names;
286SHOW_COMP_OPTION have_symlink;
288boost::condition_variable_any COND_refresh;
289boost::condition_variable COND_thread_count;
290pthread_t signal_thread;
298boost::detail::atomic_count connection_count(0);
309static void fix_paths();
311void close_connections();
313fs::path base_plugin_dir(PKGPLUGINDIR);
315po::options_description general_options(_(
"General Options"));
316po::options_description config_options(_(
"Config File Options"));
317po::options_description long_options(_(
"Kernel Options"));
318po::options_description plugin_load_options(_(
"Plugin Loading Options"));
319po::options_description plugin_options(_(
"Plugin Options"));
320po::options_description initial_options(_(
"Config and Plugin Loading"));
321po::options_description full_options(_(
"Kernel and Plugin Loading and Plugin"));
322vector<string> unknown_options;
323vector<string> defaults_file_list;
326po::variables_map &getVariablesMap()
331static std::string g_hostname=
"localhost";
333const std::string& getServerHostname()
338static void print_version()
344 printf(
"%s Ver %s for %s-%s on %s (%s)\n", internal::my_progname,
345 DRIZZLE_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
350 char at_exit_pid_file[1024 * 4]= { 0 };
352 static void remove_pidfile(
void)
354 if (at_exit_pid_file[0])
356 if (unlink(at_exit_pid_file) == -1)
358 std::cerr <<
"Could not remove pidfile: " << at_exit_pid_file <<
"(" << strerror(errno) <<
")" << std::endl;
361 at_exit_pid_file[0]= 0;
372#define DEFINED_O_CLOEXEC
375static void create_pid_file()
379 if ((file = open(pid_file.string().c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_CLOEXEC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
382 int length= snprintf(buff,
sizeof(buff),
"%ld\n", (
long) getpid());
384 if ((write(file, buff, length)) == length)
386 if (close(file) != -1)
388 snprintf(at_exit_pid_file,
sizeof(at_exit_pid_file),
"%s", pid_file.string().c_str());
389 atexit(remove_pidfile);
396 drizzled_abort <<
"Can't start server, was unable to create PID file: " << pid_file.string();
399#ifdef DEFINED_O_CLOEXEC
407void close_connections()
414 boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
416 while (select_thread_in_use)
419#if BOOST_VERSION >= 105000
420 xtime_get(&xt, boost::TIME_UTC_);
422 xtime_get(&xt, boost::TIME_UTC);
426 for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
428 bool success= COND_thread_count.timed_wait(scopedLock, xt);
443 boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
444 session::Cache::list list= session::Cache::getCache();
446 for (session::Cache::list::reference tmp : list)
448 tmp->setKilled(Session::KILL_CONNECTION);
449 tmp->scheduler->killSession(tmp.get());
450 DRIZZLE_CONNECTION_DONE(tmp->thread_id);
456 if (session::Cache::count())
458 struct timespec requested;
460 requested.tv_nsec= 0;
461 nanosleep(&requested, NULL);
471 boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
472 session::Cache::list list= session::Cache::getCache();
479 list.front()->getClient()->close();
483static bool drizzled_startup_completed=
false;
484void drizzled_startup_finished()
486 drizzled_startup_completed=
true;
492 assert(drizzled_startup_completed ==
false);
496void drizzled_actual_abort(
const char *file,
int line,
const char *func,
const std::string& message)
498 std::stringstream temp;
499 temp << _(
"Aborting:") <<
"\"" << message <<
"\"" <<
". Abort was called from " << file <<
":" << line <<
" in " << func <<
"()";
500 errmsg_printf(error::ERROR,
"%s", temp.str().c_str());
502 clean_up(vm.count(
"help") == 0);
505 assert(drizzled_startup_completed ==
false);
510void clean_up(
bool print_message)
520 modules.shutdownModules();
524#if GOOGLE_PROTOBUF_VERSION >= 2001000
525 google::protobuf::ShutdownProtobufLibrary();
528 if (print_message && server_start_time)
530 errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
533 session::Cache::shutdownFirst();
544passwd *check_user(
const char *user)
546 passwd *tmp_user_info;
547 uid_t user_id= geteuid();
555 tmp_user_info= getpwnam(user);
556 if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
557 global_system_variables.log_warnings)
559 errmsg_printf(error::WARN, _(
"One can only use the --user switch if running as root"));
565 if (user == NULL || strcmp(user,
"root") == 0)
574 if ((tmp_user_info= getpwnam(user)) == NULL)
577 const char *pos= user;
578 for (; my_charset_utf8_general_ci.isdigit(*pos); pos++)
585 if ((tmp_user_info= getpwuid(atoi(user))) == NULL)
593 drizzled_abort <<
"Fatal error: Can't change to run as user '" << user <<
"' ; Please check that the user exists!";
595#ifdef PR_SET_DUMPABLE
596 if (getDebug().test(debug::CORE_ON_SIGNAL))
599 (void) prctl(PR_SET_DUMPABLE, 1);
606 return tmp_user_info;
609void set_user(
const char *user, passwd *user_info_arg)
611 assert(user_info_arg != 0);
612 initgroups(user, user_info_arg->pw_gid);
613 if (setgid(user_info_arg->pw_gid) == -1)
615 drizzled_abort << _(
"Set process group ID failed ") << strerror(errno);
617 if (setuid(user_info_arg->pw_uid) == -1)
619 drizzled_abort << _(
"Set process user ID failed") << strerror(errno);
628 if ((chroot(path) == -1) or chdir(
"/") == 0)
630 drizzled_abort << _(
"Process chroot failed");
643void Session::unlink(session_id_t &session_id)
645 Session::shared_ptr session= session::Cache::find(session_id);
651void Session::unlink(
const Session::shared_ptr& session)
657 boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
659 if (DRIZZLE_UNLIKELY(plugin::EventObserver::disconnectSession(*session)))
663 session::Cache::erase(session);
668#define SA_RESETHAND 0
677const char *load_default_groups[]=
679 DRIZZLE_CONFIG_NAME,
"server", 0, 0
682static void find_plugin_dir(
string progname)
684 fs::path full_progname(fs::system_complete(progname));
686 fs::path progdir(full_progname.parent_path());
687 if (progdir.filename() ==
".libs")
689 progdir= progdir.parent_path();
692 if (fs::exists(progdir /
"drizzled.lo") || fs::exists(progdir /
"drizzled.o"))
695 base_plugin_dir= progdir.parent_path();
696 base_plugin_dir /=
"plugin";
697 base_plugin_dir /=
".libs";
700 if (plugin_dir.root_directory() ==
"")
702 fs::path full_plugin_dir(fs::system_complete(base_plugin_dir));
703 full_plugin_dir /= plugin_dir;
704 plugin_dir= full_plugin_dir;
708static void notify_plugin_dir(fs::path in_plugin_dir)
710 plugin_dir= in_plugin_dir;
711 if (plugin_dir.root_directory() ==
"")
713 fs::path full_plugin_dir(fs::system_complete(basedir));
714 full_plugin_dir /= plugin_dir;
715 plugin_dir= full_plugin_dir;
719static void expand_secure_file_priv(fs::path in_secure_file_priv)
721 secure_file_priv= fs::system_complete(in_secure_file_priv);
724static void check_limits_aii(uint64_t in_auto_increment_increment)
726 global_system_variables.auto_increment_increment= 1;
727 if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
729 drizzled_abort << _(
"Invalid Value for auto_increment_increment");
731 global_system_variables.auto_increment_increment= in_auto_increment_increment;
734static void check_limits_aio(uint64_t in_auto_increment_offset)
736 global_system_variables.auto_increment_offset= 1;
737 if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
739 drizzled_abort << _(
"Invalid Value for auto_increment_offset");
741 global_system_variables.auto_increment_offset= in_auto_increment_offset;
744static void check_limits_completion_type(uint32_t in_completion_type)
746 global_system_variables.completion_type= 0;
747 if (in_completion_type > 2)
749 drizzled_abort << _(
"Invalid Value for completion_type");
751 global_system_variables.completion_type= in_completion_type;
755static void check_limits_dpi(uint32_t in_div_precincrement)
757 global_system_variables.div_precincrement= 4;
758 if (in_div_precincrement > DECIMAL_MAX_SCALE)
760 drizzled_abort << _(
"Invalid Value for div-precision-increment");
762 global_system_variables.div_precincrement= in_div_precincrement;
765static void check_limits_gcml(uint64_t in_group_concat_max_len)
767 global_system_variables.group_concat_max_len= 1024;
768 if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
770 drizzled_abort << _(
"Invalid Value for group_concat_max_len");
772 global_system_variables.group_concat_max_len= in_group_concat_max_len;
775static void check_limits_join_buffer_size(uint64_t in_join_buffer_size)
777 global_system_variables.join_buff_size= (128*1024L);
778 if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
780 drizzled_abort << _(
"Invalid Value for join_buffer_size");
782 in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
783 global_system_variables.join_buff_size= in_join_buffer_size;
786static void check_limits_map(uint32_t in_max_allowed_packet)
788 global_system_variables.max_allowed_packet= (64*1024*1024L);
789 if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
791 drizzled_abort << _(
"Invalid Value for max_allowed_packet");
793 in_max_allowed_packet-= in_max_allowed_packet % 1024;
794 global_system_variables.max_allowed_packet= in_max_allowed_packet;
797static void check_limits_max_err_cnt(uint64_t in_max_error_count)
799 global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
800 if (in_max_error_count > 65535)
802 drizzled_abort << _(
"Invalid Value for max_error_count");
804 global_system_variables.max_error_count= in_max_error_count;
807static 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 drizzled_abort << _(
"Invalid Value for max_heap_table_size");
814 in_max_heap_table_size-= in_max_heap_table_size % 1024;
815 global_system_variables.max_heap_table_size= in_max_heap_table_size;
818static void check_limits_merl(uint64_t in_min_examined_row_limit)
820 global_system_variables.min_examined_row_limit= 0;
821 if (in_min_examined_row_limit > ULONG_MAX)
823 drizzled_abort << _(
"Invalid Value for min_examined_row_limit");
825 global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
828static void check_limits_max_join_size(ha_rows in_max_join_size)
830 global_system_variables.max_join_size= INT32_MAX;
831 if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
833 drizzled_abort << _(
"Invalid Value for max_join_size");
835 global_system_variables.max_join_size= in_max_join_size;
838static void check_limits_mlfsd(int64_t in_max_length_for_sort_data)
840 global_system_variables.max_length_for_sort_data= 1024;
841 if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
843 drizzled_abort << _(
"Invalid Value for max_length_for_sort_data");
845 global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
848static void check_limits_msfk(uint64_t in_max_seeks_for_key)
850 global_system_variables.max_seeks_for_key= ULONG_MAX;
851 if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
853 drizzled_abort << _(
"Invalid Value for max_seeks_for_key");
855 global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
858static void check_limits_max_sort_length(
size_t in_max_sort_length)
860 global_system_variables.max_sort_length= 1024;
861 if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
863 drizzled_abort << _(
"Invalid Value for max_sort_length");
865 global_system_variables.max_sort_length= in_max_sort_length;
868static void check_limits_osd(uint32_t in_optimizer_search_depth)
870 global_system_variables.optimizer_search_depth= 0;
871 if (in_optimizer_search_depth > MAX_TABLES + 2)
873 drizzled_abort << _(
"Invalid Value for optimizer_search_depth");
875 global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
878static void check_limits_pbs(uint64_t in_preload_buff_size)
880 global_system_variables.preload_buff_size= (32*1024L);
881 if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
883 drizzled_abort << _(
"Invalid Value for preload_buff_size");
885 global_system_variables.preload_buff_size= in_preload_buff_size;
888static void check_limits_qabs(uint32_t in_query_alloc_block_size)
890 global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
891 if (in_query_alloc_block_size < 1024)
893 drizzled_abort << _(
"Invalid Value for query_alloc_block_size");
895 in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
896 global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
899static void check_limits_qps(uint32_t in_query_prealloc_size)
901 global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
902 if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
904 drizzled_abort << _(
"Invalid Value for query_prealloc_size");
906 in_query_prealloc_size-= in_query_prealloc_size % 1024;
907 global_system_variables.query_prealloc_size= in_query_prealloc_size;
910static void check_limits_rabs(
size_t in_range_alloc_block_size)
912 global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
913 if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
915 drizzled_abort << _(
"Invalid Value for range_alloc_block_size");
917 in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
918 global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
921static void check_limits_read_buffer_size(int32_t in_read_buff_size)
923 global_system_variables.read_buff_size= (128*1024L);
924 if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
926 drizzled_abort << _(
"Invalid Value for read_buff_size");
928 in_read_buff_size-= in_read_buff_size % IO_SIZE;
929 global_system_variables.read_buff_size= in_read_buff_size;
932static void check_limits_read_rnd_buffer_size(uint32_t in_read_rnd_buff_size)
934 global_system_variables.read_rnd_buff_size= (256*1024L);
935 if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
937 drizzled_abort << _(
"Invalid Value for read_rnd_buff_size");
939 global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
942static void check_limits_sort_buffer_size(
size_t in_sortbuff_size)
944 global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
945 if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
947 drizzled_abort << _(
"Invalid Value for sort_buff_size");
949 global_system_variables.sortbuff_size= in_sortbuff_size;
952static void check_limits_tdc(uint32_t in_table_def_size)
955 if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
957 drizzled_abort << _(
"Invalid Value for table_def_size");
959 table_def_size= in_table_def_size;
962static void check_limits_toc(uint32_t in_table_cache_size)
964 table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
965 if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
967 drizzled_abort << _(
"Invalid Value for table_cache_size");
969 table_cache_size= in_table_cache_size;
972static void check_limits_tlwt(uint64_t in_table_lock_wait_timeout)
974 table_lock_wait_timeout= 50;
975 if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
977 drizzled_abort << _(
"Invalid Value for table_lock_wait_timeout");
979 table_lock_wait_timeout= in_table_lock_wait_timeout;
982static void check_limits_thread_stack(uint32_t in_my_thread_stack_size)
984 my_thread_stack_size= in_my_thread_stack_size - (in_my_thread_stack_size % 1024);
987static void check_limits_tmp_table_size(uint64_t in_tmp_table_size)
989 global_system_variables.tmp_table_size= 16*1024*1024L;
990 if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
992 drizzled_abort << _(
"Invalid Value for table_lock_wait_timeout");
994 global_system_variables.tmp_table_size= in_tmp_table_size;
997static void check_limits_transaction_message_threshold(
size_t in_transaction_message_threshold)
999 transaction_message_threshold= 1024*1024;
1000 if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1002 drizzled_abort << _(
"Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1004 transaction_message_threshold= in_transaction_message_threshold;
1007static void process_defaults_files()
1009 for (vector<string>::reference iter : defaults_file_list)
1011 fs::path file_location= iter;
1013 ifstream input_defaults_file(file_location.string().c_str());
1015 po::parsed_options file_parsed= dpo::parse_config_file(input_defaults_file, full_options,
true);
1016 vector<string> file_unknown= po::collect_unrecognized(file_parsed.options, po::include_positional);
1018 for (vector<string>::iterator it= file_unknown.begin(); it != file_unknown.end(); ++it)
1020 string new_unknown_opt(
"--" + *it);
1023 if (it == file_unknown.end())
1030 new_unknown_opt +=
"=" + *it;
1033 unknown_options.push_back(new_unknown_opt);
1035 store(file_parsed, vm);
1039static void compose_defaults_file_list(
const vector<string>& in_options)
1041 for (
const string& it : in_options)
1044 if (fs::is_regular_file(p))
1046 defaults_file_list.push_back(it);
1050 drizzled_abort <<
"Defaults file '" << it <<
"' not found";
1055bool init_variables_before_daemonizing(
int argc,
char **argv)
1057 umask(((~internal::get_my_umask()) & 0666));
1058 decimal_zero.set_zero();
1061 time_t curr_time= time(NULL);
1062 if (curr_time == (time_t)-1)
1067 max_system_variables.pseudo_thread_id= UINT32_MAX;
1072 find_plugin_dir(argv[0]);
1074 char ret_hostname[FN_REFLEN];
1075 if (gethostname(ret_hostname,
sizeof(ret_hostname)) < 0)
1077 errmsg_printf(error::WARN, _(
"gethostname failed, using '%s' as hostname"), getServerHostname().c_str());
1078 pid_file=
"drizzle";
1082 g_hostname= ret_hostname;
1083 pid_file= getServerHostname();
1085 pid_file.replace_extension(
".pid");
1087 system_config_dir /=
"drizzle";
1089 general_options.add_options()
1091 _(
"Display help and exit."))
1092 (
"user,u", po::value<string>(),
1093 _(
"Run drizzled daemon as user."))
1095 _(
"Print version information and exit."))
1098 config_options.add_options()
1099 (
"no-defaults", po::value<bool>()->default_value(
false)->zero_tokens(),
1100 _(
"Configuration file defaults are not used if no-defaults is set"))
1101 (
"defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1102 _(
"Configuration file to use"))
1103 (
"config-dir", po::value<fs::path>(&system_config_dir),
1104 _(
"Base location for config files"))
1105 (
"plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(¬ify_plugin_dir),
1106 _(
"Directory for plugins."))
1109 plugin_load_options.add_options()
1110 (
"plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1111 _(
"Optional comma separated list of plugins to load at startup in addition "
1112 "to the default list of plugins. "
1113 "[for example: --plugin_add=crc32,logger_gearman]"))
1114 (
"plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1115 _(
"Optional comma separated list of plugins to not load at startup. Effectively "
1116 "removes a plugin from the list of plugins to be loaded. "
1117 "[for example: --plugin_remove=crc32,logger_gearman]"))
1118 (
"plugin-load", po::value<string>()->notifier(¬ify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1119 _(
"Optional comma separated list of plugins to load at starup instead of "
1120 "the default plugin load list. "
1121 "[for example: --plugin_load=crc32,logger_gearman]"))
1124 long_options.add_options()
1125 (
"auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1126 _(
"Auto-increment columns are incremented by this"))
1127 (
"auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1128 _(
"Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1129 (
"basedir,b", po::value<fs::path>(&basedir),
1130 _(
"Path to installation directory. All paths are usually resolved "
1131 "relative to this."))
1132 (
"chroot,r", po::value<string>(),
1133 _(
"Chroot drizzled daemon during startup."))
1134 (
"collation-server", po::value<string>(),
1135 _(
"Set the default collation."))
1136 (
"completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1137 _(
"Default completion type."))
1138 (
"core-file", _(
"Write core on errors."))
1139 (
"datadir", po::value<fs::path>(&getMutableDataHome()),
1140 _(
"Path to the database root."))
1141 (
"default-storage-engine", po::value<string>(),
1142 _(
"Set the default storage engine for tables."))
1143 (
"exit-info,T", po::value<long>(),
1144 _(
"Used for debugging; Use at your own risk!"))
1145 (
"gdb", po::value<bool>(&opt_debugging)->default_value(
false)->zero_tokens(),
1146 _(
"Set up signals usable for debugging"))
1147 (
"lc-time-name", po::value<string>(),
1148 _(
"Set the language used for the month names and the days of the week."))
1149 (
"log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(
false)->zero_tokens(),
1150 _(
"Log some not critical warnings to the log file."))
1151 (
"pid-file", po::value<fs::path>(&pid_file),
1152 _(
"Pid file used by drizzled."))
1153 (
"port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1154 _(
"Maximum time in seconds to wait for the port to become free. "))
1155 (
"replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(
false)->zero_tokens(),
1156 _(
"Include the SQL query in replicated protobuf messages."))
1157 (
"secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1158 _(
"Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1159 "within specified directory"))
1160 (
"server-id", po::value<uint32_t>(&server_id)->default_value(0),
1161 _(
"Uniquely identifies the server instance in the community of "
1162 "replication partners."))
1163 (
"skip-stack-trace",
1164 _(
"Don't print a stack trace on failure."))
1165 (
"symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(
false,
true))->zero_tokens(),
1166 _(
"Enable symbolic link support."))
1167 (
"tmpdir,t", po::value<string>(),
1168 _(
"Path for temporary files."))
1169 (
"transaction-isolation", po::value<string>(),
1170 _(
"Default transaction isolation level."))
1171 (
"transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1172 _(
"Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1173 (
"back-log", po::value<back_log_constraints>(&back_log),
1174 _(
"The number of outstanding connection requests Drizzle can have. This "
1175 "comes into play when the main Drizzle thread gets very many connection "
1176 "requests in a very short time."))
1177 (
"bulk-insert-buffer-size",
1178 po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1179 _(
"Size of tree cache used in bulk insert optimization. Note that this is "
1180 "a limit per thread!"))
1181 (
"div-precision-increment", po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1182 _(
"Precision of the result of '/' operator will be increased on that "
1184 (
"group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1185 _(
"The maximum length of the result of function group_concat."))
1186 (
"join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1187 _(
"The size of the buffer that is used for full joins."))
1188 (
"join-heap-threshold",
1189 po::value<uint64_t>()->default_value(0),
1190 _(
"A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1191 (
"max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1192 _(
"Max packetlength to send/receive from to server."))
1193 (
"max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1194 _(
"Max number of errors/warnings to store for a statement."))
1195 (
"max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1196 _(
"Don't allow creation of heap tables bigger than this."))
1197 (
"max-join-size", po::value<ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1198 _(
"Joins that are probably going to read more than max_join_size records "
1199 "return an error."))
1200 (
"max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1201 _(
"Max number of bytes in sorted records."))
1202 (
"max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1203 _(
"Limit assumed max number of seeks when looking up rows based on a key"))
1204 (
"max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
1205 _(
"The number of bytes to use when sorting BLOB or TEXT values "
1206 "(only the first max_sort_length bytes of each value are used; the "
1207 "rest are ignored)."))
1208 (
"max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1209 _(
"After this many write locks, allow some read locks to run in between."))
1210 (
"min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1211 _(
"Don't log queries which examine less than min_examined_row_limit "
1213 (
"disable-optimizer-prune",
1214 _(
"Do not apply any heuristic(s) during query optimization to prune, "
1215 "thus perform an exhaustive search from the optimizer search space."))
1216 (
"optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1217 _(
"Maximum depth of search performed by the query optimizer. Values "
1218 "larger than the number of relations in a query result in better query "
1219 "plans, but take longer to compile a query. Smaller values than the "
1220 "number of tables in a relation result in faster optimization, but may "
1221 "produce very bad query plans. If set to 0, the system will "
1222 "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1223 "optimizer will switch to the original find_best (used for "
1224 "testing/comparison)."))
1225 (
"preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1226 _(
"The size of the buffer that is allocated when preloading indexes"))
1227 (
"query-alloc-block-size",
1228 po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1229 _(
"Allocation block size for query parsing and execution"))
1230 (
"query-prealloc-size",
1231 po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1232 _(
"Persistent buffer for query parsing and execution"))
1233 (
"range-alloc-block-size",
1234 po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1235 _(
"Allocation block size for storing ranges during optimization"))
1236 (
"read-buffer-size",
1237 po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1238 _(
"Each thread that does a sequential scan allocates a buffer of this "
1239 "size for each table it scans. If you do many sequential scans, you may "
1240 "want to increase this value."))
1241 (
"read-buffer-threshold",
1242 po::value<uint64_t>()->default_value(0),
1243 _(
"A global cap on the size of read-buffer-size (0 means unlimited)"))
1244 (
"read-rnd-buffer-size",
1245 po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1246 _(
"When reading rows in sorted order after a sort, the rows are read "
1247 "through this buffer to avoid a disk seeks. If not set, then it's set "
1248 "to the value of record_buffer."))
1249 (
"read-rnd-threshold",
1250 po::value<uint64_t>()->default_value(0),
1251 _(
"A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1252 (
"scheduler", po::value<string>(),
1253 _(
"Select scheduler to be used (by default multi-thread)."))
1254 (
"sort-buffer-size",
1255 po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1256 _(
"Each thread that needs to do a sort allocates a buffer of this size."))
1257 (
"sort-heap-threshold",
1258 po::value<uint64_t>()->default_value(0),
1259 _(
"A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1260 (
"table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1261 _(
"The number of cached table definitions."))
1262 (
"table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1263 _(
"The number of cached open tables."))
1264 (
"table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1265 _(
"Timeout in seconds to wait for a table level lock before returning an "
1266 "error. Used only if the connection has active cursors."))
1267 (
"thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(0)->notifier(&check_limits_thread_stack),
1268 _(
"The stack size for each thread."))
1270 po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1271 _(
"If an internal in-memory temporary table exceeds this size, Drizzle will"
1272 " automatically convert it to an on-disk MyISAM table."))
1273 (
"verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
1274 _(
"The verbosity of messages from drizzled. Possible values are INSPECT, INFO, WARN or ERROR"))
1277 full_options.add(long_options);
1278 full_options.add(plugin_load_options);
1280 initial_options.add(general_options);
1281 initial_options.add(config_options);
1282 initial_options.add(plugin_load_options);
1284 int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1287 po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1288 options(initial_options).allow_unregistered().run();
1290 unknown_options= po::collect_unrecognized(parsed.options, po::include_positional);
1294 po::store(parsed, vm);
1296 catch (std::exception&)
1298 drizzled_abort << _(
"Duplicate entry for command line option");
1312 catch (po::validation_error &err)
1314 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1317 if (vm.count(
"version"))
1323 if (!vm[
"no-defaults"].as<bool>())
1325 fs::path system_config_file_drizzle(system_config_dir);
1326 system_config_file_drizzle /=
"drizzled.cnf";
1327 defaults_file_list.insert(defaults_file_list.begin(), system_config_file_drizzle.string());
1329 fs::path config_conf_d_location(system_config_dir);
1330 config_conf_d_location /=
"conf.d";
1333 if (not config_conf_d.fail())
1335 for (CachedDirectory::Entries::const_reference iter : config_conf_d.getEntries())
1337 string file_entry(iter->filename);
1338 if (not file_entry.empty() && file_entry !=
"." && file_entry !=
"..")
1339 defaults_file_list.push_back((config_conf_d_location / file_entry).
string());
1344 process_defaults_files();
1353 catch (po::validation_error &err)
1355 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1367 int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1369 current_pid= getpid();
1375 if (plugin_init(plugins, plugin_options))
1377 drizzled_abort << _(
"Failed to initialize plugins");
1380 full_options.add(plugin_options);
1382 if ( was_help_requested())
1387 vector<string> final_unknown_options;
1390 po::parsed_options final_parsed=
1391 po::command_line_parser(unknown_options).style(style).
1392 options(full_options).extra_parser(dpo::parse_size_arg).run();
1394 final_unknown_options=
1395 po::collect_unrecognized(final_parsed.options, po::include_positional);
1397 po::store(final_parsed, vm);
1400 catch (po::validation_error &err)
1402 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1404 catch (po::invalid_command_line_syntax &err)
1406 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1408 catch (po::unknown_option &err)
1410 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1417 catch (po::validation_error &err)
1419 drizzled_abort << err.what() <<
". " <<
"Use --help to get a list of available options. ";
1426 global_system_variables.optimizer_prune_level= not vm.count(
"disable-optimizer-prune");
1428 if ((user_info= check_user(drizzled_user)))
1430 set_user(drizzled_user, user_info);
1452 if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1454 errmsg_printf(error::ERROR, _(
"Error getting default charset"));
1458 if (vm.count(
"scheduler"))
1460 opt_scheduler= vm[
"scheduler"].as<
string>().c_str();
1464 global_system_variables.collation_server= default_charset_info;
1466 if (not (character_set_filesystem= get_charset_by_csname(
"binary", MY_CS_PRIMARY)))
1468 errmsg_printf(error::ERROR, _(
"Error setting collation"));
1471 global_system_variables.character_set_filesystem= character_set_filesystem;
1473 if ((my_default_lc_time_names= my_locale_by_name(lc_time_names_name)) == NULL)
1475 errmsg_printf(error::ERROR, _(
"Unknown locale: '%s'"), lc_time_names_name);
1478 global_system_variables.lc_time_names= my_default_lc_time_names;
1481 table_alias_charset= files_charset_info;
1486bool was_help_requested()
1488 return bool(vm.count(
"help"));
1493 if (was_help_requested())
1504 table::Cache::rehash(table_def_size);
1505 definition::Cache::rehash(table_def_size);
1506 message::Cache::singleton().rehash(table_def_size);
1513 if (plugin_finalize(plugins))
1515 drizzled_abort <<
"plugin_finalize() failed";
1518 if (plugin::Scheduler::setPlugin(opt_scheduler))
1520 drizzled_abort << _(
"No scheduler found");
1527 myisam_engine= plugin::StorageEngine::findByName(
"MyISAM");
1528 heap_engine= plugin::StorageEngine::findByName(
"MEMORY");
1533 if (default_storage_engine_str)
1538 drizzled_abort << _(
"Unknown/unsupported storage engine: ") << default_storage_engine_str;
1540 global_system_variables.storage_engine= engine;
1543 if (plugin::XaResourceManager::recoverAllXids())
1546 drizzled_abort <<
"plugin::XaResourceManager::recoverAllXids() failed";
1549 init_update_queries();
1557enum options_drizzled
1567 OPT_TC_HEURISTIC_RECOVER,
1568 OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
1569 OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
1574 OPT_MAX_ALLOWED_PACKET,
1575 OPT_MAX_HEP_TABLE_SIZE,
1577 OPT_MAX_SORT_LENGTH,
1578 OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
1579 OPT_MAX_LENGTH_FOR_SORT_DATA,
1580 OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
1581 OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE,
1582 OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
1583 OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
1584 OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
1585 OPT_NET_BUFFER_LENGTH,
1586 OPT_PRELOAD_BUFFER_SIZE,
1588 OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT,
1590 OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE,
1591 OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
1593 OPT_RANGE_ALLOC_BLOCK_SIZE,
1594 OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
1595 OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
1596 OPT_OLD_ALTER_TABLE,
1597 OPT_GROUP_CONCAT_MAX_LEN,
1598 OPT_DEFAULT_COLLATION,
1599 OPT_CHARACTER_SET_FILESYSTEM,
1602 OPT_DEFAULT_TIME_ZONE,
1603 OPT_OPTIMIZER_SEARCH_DEPTH,
1606 OPT_OPTIMIZER_PRUNE_LEVEL,
1607 OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET,
1608 OPT_ENABLE_LARGE_PAGES,
1609 OPT_TABLE_LOCK_WAIT_TIMEOUT,
1614 OPT_PORT_OPEN_TIMEOUT,
1615 OPT_SECURE_FILE_PRIV,
1616 OPT_MIN_EXAMINED_ROW_LIMIT,
1621struct option my_long_options[] =
1623 {
"auto-increment-increment", OPT_AUTO_INCREMENT,
1624 N_(
"Auto-increment columns are incremented by this"),
1625 (
char**) &global_system_variables.auto_increment_increment,
1627 OPT_ARG, 1, 1, INT64_MAX, 0, 1, 0 },
1628 {
"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
1629 N_(
"Offset added to Auto-increment columns. Used when "
1630 "auto-increment-increment != 1"),
1631 (
char**) &global_system_variables.auto_increment_offset,
1632 NULL, 0, GET_ULL, OPT_ARG,
1633 1, 1, INT64_MAX, 0, 1, 0 },
1635 N_(
"Path to installation directory. All paths are usually resolved "
1636 "relative to this."),
1637 NULL, NULL, 0, GET_STR, REQUIRED_ARG,
1640 N_(
"Chroot drizzled daemon during startup."),
1641 (
char**) &drizzled_chroot, NULL, 0, GET_STR, REQUIRED_ARG,
1643 {
"completion-type", OPT_COMPLETION_TYPE,
1644 N_(
"Default completion type."),
1645 (
char**) &global_system_variables.completion_type,
1647 REQUIRED_ARG, 0, 0, 2, 0, 1, 0},
1648 {
"core-file", OPT_WANT_CORE,
1649 N_(
"Write core on errors."),
1650 0, 0, 0, GET_NO_ARG,
1651 NO_ARG, 0, 0, 0, 0, 0, 0},
1653 N_(
"Path to the database root."),
1654 NULL, NULL, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1657 N_(
"Used for debugging; Use at your own risk!"),
1658 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
1661 {
"gdb", OPT_DEBUGGING,
1662 N_(
"Set up signals usable for debugging"),
1663 (
char**) &opt_debugging, NULL,
1664 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1665 {
"log-warnings",
'W',
1666 N_(
"Log some not critical warnings to the log file."),
1667 (
char**) &global_system_variables.log_warnings,
1668 NULL, 0, GET_BOOL, OPT_ARG, 1, 0, 0,
1670 {
"pid-file", OPT_PID_FILE,
1671 N_(
"Pid file used by drizzled."),
1672 NULL, NULL, 0, GET_STR,
1673 REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1674 {
"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
1675 N_(
"Maximum time in seconds to wait for the port to become free. "
1676 "(Default: no wait)"),
1677 (
char**) &drizzled_bind_timeout,
1678 NULL, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1679 {
"secure-file-priv", OPT_SECURE_FILE_PRIV,
1680 N_(
"Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1681 "within specified directory"),
1683 GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1684 {
"server-id", OPT_SERVER_ID,
1685 N_(
"Uniquely identifies the server instance in the community of "
1686 "replication partners."),
1687 (
char**) &server_id, NULL, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 0,
1689 {
"skip-stack-trace", OPT_SKIP_STACK_TRACE,
1690 N_(
"Don't print a stack trace on failure."),
1691 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
1693 {
"symbolic-links",
's',
1694 N_(
"Enable symbolic link support."),
1695 (
char**) &internal::my_use_symdir, NULL, 0, GET_BOOL, NO_ARG,
1701 IF_PURIFY(0,1), 0, 0, 0, 0, 0},
1702 {
"transaction-isolation", OPT_TX_ISOLATION,
1703 N_(
"Default transaction isolation level."),
1704 0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1707 N_(
"Run drizzled daemon as user."),
1708 0, 0, 0, GET_STR, REQUIRED_ARG,
1710 {
"back_log", OPT_BACK_LOG,
1711 N_(
"The number of outstanding connection requests Drizzle can have. This "
1712 "comes into play when the main Drizzle thread gets very many connection "
1713 "requests in a very short time."),
1714 (
char**) &back_log, NULL, 0, GET_UINT,
1715 REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
1716 {
"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
1717 N_(
"Size of tree cache used in bulk insert optimization. Note that this is "
1718 "a limit per thread!"),
1719 (
char**) &global_system_variables.bulk_insert_buff_size,
1721 0, GET_ULL, REQUIRED_ARG, 8192*1024, 0, (int64_t)ULONG_MAX, 0, 1, 0},
1722 {
"div_precision_increment", OPT_DIV_PRECINCREMENT,
1723 N_(
"Precision of the result of '/' operator will be increased on that "
1725 (
char**) &global_system_variables.div_precincrement,
1727 REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
1728 {
"join_buffer_size", OPT_JOIN_BUFF_SIZE,
1729 N_(
"The size of the buffer that is used for full joins."),
1730 (
char**) &global_system_variables.join_buff_size,
1731 NULL, 0, GET_UINT64,
1732 REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, (int64_t)ULONG_MAX,
1733 MALLOC_OVERHEAD, IO_SIZE, 0},
1734 {
"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1735 N_(
"Max packetlength to send/receive from to server."),
1736 (
char**) &global_system_variables.max_allowed_packet,
1737 NULL, 0, GET_UINT32,
1738 REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1739 {
"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1740 N_(
"Don't allow creation of heap tables bigger than this."),
1741 (
char**) &global_system_variables.max_heap_table_size,
1743 REQUIRED_ARG, 16*1024*1024L, 16384, (int64_t)MAX_MEM_TABLE_SIZE,
1744 MALLOC_OVERHEAD, 1024, 0},
1745 {
"max_join_size", OPT_MAX_JOIN_SIZE,
1746 N_(
"Joins that are probably going to read more than max_join_size records "
1747 "return an error."),
1748 (
char**) &global_system_variables.max_join_size,
1749 NULL, 0, GET_HA_ROWS, REQUIRED_ARG,
1750 INT32_MAX, 1, INT32_MAX, 0, 1, 0},
1751 {
"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
1752 N_(
"Max number of bytes in sorted records."),
1753 (
char**) &global_system_variables.max_length_for_sort_data,
1755 REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
1756 {
"max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
1757 N_(
"Limit assumed max number of seeks when looking up rows based on a key"),
1758 (
char**) &global_system_variables.max_seeks_for_key,
1759 NULL, 0, GET_UINT64,
1760 REQUIRED_ARG, (int64_t)ULONG_MAX, 1, (int64_t)ULONG_MAX, 0, 1, 0 },
1761 {
"max_sort_length", OPT_MAX_SORT_LENGTH,
1762 N_(
"The number of bytes to use when sorting BLOB or TEXT values "
1763 "(only the first max_sort_length bytes of each value are used; the "
1764 "rest are ignored)."),
1765 (
char**) &global_system_variables.max_sort_length,
1767 REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
1768 {
"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
1769 N_(
"After this many write locks, allow some read locks to run in between."),
1770 (
char**) &max_write_lock_count, NULL, 0, GET_ULL,
1771 REQUIRED_ARG, (int64_t)ULONG_MAX, 1, (int64_t)ULONG_MAX, 0, 1, 0},
1772 {
"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
1773 N_(
"Don't log queries which examine less than min_examined_row_limit "
1775 (
char**) &global_system_variables.min_examined_row_limit,
1777 REQUIRED_ARG, 0, 0, (int64_t)ULONG_MAX, 0, 1L, 0},
1778 {
"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
1779 N_(
"Controls the heuristic(s) applied during query optimization to prune "
1780 "less-promising partial plans from the optimizer search space. Meaning: "
1781 "false - do not apply any heuristic, thus perform exhaustive search; "
1782 "true - prune plans based on number of retrieved rows."),
1783 (
char**) &global_system_variables.optimizer_prune_level,
1785 0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 1, 0},
1786 {
"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
1787 N_(
"Maximum depth of search performed by the query optimizer. Values "
1788 "larger than the number of relations in a query result in better query "
1789 "plans, but take longer to compile a query. Smaller values than the "
1790 "number of tables in a relation result in faster optimization, but may "
1791 "produce very bad query plans. If set to 0, the system will "
1792 "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1793 "optimizer will switch to the original find_best (used for "
1794 "testing/comparison)."),
1795 (
char**) &global_system_variables.optimizer_search_depth,
1797 0, GET_UINT, OPT_ARG, 0, 0, MAX_TABLES+2, 0, 1, 0},
1798 {
"plugin_dir", OPT_PLUGIN_DIR,
1799 N_(
"Directory for plugins."),
1801 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1802 {
"plugin_add", OPT_PLUGIN_ADD,
1803 N_(
"Optional comma separated list of plugins to load at startup in addition "
1804 "to the default list of plugins. "
1805 "[for example: --plugin_add=crc32,logger_gearman]"),
1807 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1808 {
"plugin_remove", OPT_PLUGIN_ADD,
1809 N_(
"Optional comma separated list of plugins to not load at startup. Effectively "
1810 "removes a plugin from the list of plugins to be loaded. "
1811 "[for example: --plugin_remove=crc32,logger_gearman]"),
1813 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1814 {
"plugin_load", OPT_PLUGIN_LOAD,
1815 N_(
"Optional comma separated list of plugins to load at starup instead of "
1816 "the default plugin load list. "
1817 "[for example: --plugin_load=crc32,logger_gearman]"),
1819 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1820 {
"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
1821 N_(
"The size of the buffer that is allocated when preloading indexes"),
1822 (
char**) &global_system_variables.preload_buff_size,
1824 REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
1825 {
"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
1826 N_(
"Allocation block size for query parsing and execution"),
1827 (
char**) &global_system_variables.query_alloc_block_size,
1829 REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, (int64_t)ULONG_MAX, 0, 1024, 0},
1830 {
"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
1831 N_(
"Persistent buffer for query parsing and execution"),
1832 (
char**) &global_system_variables.query_prealloc_size,
1834 REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
1835 (int64_t)ULONG_MAX, 0, 1024, 0},
1836 {
"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
1837 N_(
"Allocation block size for storing ranges during optimization"),
1838 (
char**) &global_system_variables.range_alloc_block_size,
1840 REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, (int64_t)SIZE_MAX,
1842 {
"read_buffer_size", OPT_RECORD_BUFFER,
1843 N_(
"Each thread that does a sequential scan allocates a buffer of this "
1844 "size for each table it scans. If you do many sequential scans, you may "
1845 "want to increase this value."),
1846 (
char**) &global_system_variables.read_buff_size,
1847 NULL,0, GET_UINT, REQUIRED_ARG,
1848 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
1850 {
"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
1851 N_(
"When reading rows in sorted order after a sort, the rows are read "
1852 "through this buffer to avoid a disk seeks. If not set, then it's set "
1853 "to the value of record_buffer."),
1854 (
char**) &global_system_variables.read_rnd_buff_size,
1856 GET_UINT, REQUIRED_ARG, 256*1024L, 64 ,
1857 UINT32_MAX, MALLOC_OVERHEAD, 1 , 0},
1859 {
"sort_buffer_size", OPT_SORT_BUFFER,
1860 N_(
"Each thread that needs to do a sort allocates a buffer of this size."),
1861 (
char**) &global_system_variables.sortbuff_size,
1862 NULL, 0, GET_SIZE, REQUIRED_ARG,
1863 MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*8, (int64_t)SIZE_MAX,
1864 MALLOC_OVERHEAD, 1, 0},
1865 {
"table_definition_cache", OPT_TABLE_DEF_CACHE,
1866 N_(
"The number of cached table definitions."),
1867 (
char**) &table_def_size, NULL,
1868 0, GET_SIZE, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
1869 {
"table_open_cache", OPT_TABLE_OPEN_CACHE,
1870 N_(
"The number of cached open tables."),
1871 (
char**) &table_cache_size, NULL, 0, GET_UINT64,
1872 REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, TABLE_OPEN_CACHE_MIN, 512*1024L, 0, 1, 0},
1873 {
"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
1874 N_(
"Timeout in seconds to wait for a table level lock before returning an "
1875 "error. Used only if the connection has active cursors."),
1876 (
char**) &table_lock_wait_timeout, NULL,
1877 0, GET_ULL, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
1878 {
"thread_stack", OPT_THREAD_STACK,
1879 N_(
"The stack size for each thread."),
1880 (
char**) &my_thread_stack_size,
1883 UINT32_C(1024*512), (int64_t)SIZE_MAX, 0, 1024, 0},
1884 {
"tmp_table_size", OPT_TMP_TABLE_SIZE,
1885 N_(
"If an internal in-memory temporary table exceeds this size, Drizzle will"
1886 " automatically convert it to an on-disk MyISAM table."),
1887 (
char**) &global_system_variables.tmp_table_size,
1889 REQUIRED_ARG, 16*1024*1024L, 1024, (int64_t)MAX_MEM_TABLE_SIZE, 0, 1, 0},
1890 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1895 if ((default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)) == NULL)
1897 drizzled_abort <<
"Failed to load default_charset_info:" << default_character_set_name;
1900 if (default_collation_name == NULL)
1902 default_collation_name= default_charset_info->name;
1906 puts(_(
"Copyright (C) 2010-2011 Drizzle Developers, Copyright (C) 2008 Sun Microsystems\n"
1907 "This software comes with ABSOLUTELY NO WARRANTY. "
1908 "This is free software,\n"
1909 "and you are welcome to modify and redistribute it under the GPL "
1913 printf(_(
"Usage: %s [OPTIONS]\n"), internal::my_progname);
1915 po::options_description all_options(
"Drizzled Options");
1916 all_options.add(general_options);
1917 all_options.add(config_options);
1918 all_options.add(plugin_load_options);
1919 all_options.add(long_options);
1920 all_options.add(plugin_options);
1921 cout << all_options << endl;
1946 dropping_tables= ha_open_options=0;
1950 select_thread_in_use=
false;
1951 shutdown_in_progress= 0;
1952 drizzled_user= drizzled_chroot= 0;
1953 memset(¤t_global_counters, 0,
sizeof(current_global_counters));
1957 system_charset_info= &my_charset_utf8_general_ci;
1958 files_charset_info= &my_charset_utf8_general_ci;
1959 table_alias_charset= &my_charset_bin;
1960 character_set_filesystem= &my_charset_bin;
1963 session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
1964 global_thread_id= 1;
1965 session::Cache::getCache().clear();
1968 global_system_variables.storage_engine= NULL;
1969 global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
1970 global_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
1971 max_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
1972 global_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
1973 max_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
1974 max_system_variables.auto_increment_increment= UINT64_MAX;
1975 max_system_variables.auto_increment_offset= UINT64_MAX;
1976 max_system_variables.completion_type= 2;
1977 max_system_variables.log_warnings=
true;
1978 max_system_variables.bulk_insert_buff_size= ULONG_MAX;
1979 max_system_variables.div_precincrement= DECIMAL_MAX_SCALE;
1980 max_system_variables.group_concat_max_len= ULONG_MAX;
1981 max_system_variables.join_buff_size= ULONG_MAX;
1982 max_system_variables.max_allowed_packet= 1024L*1024L*1024L;
1983 max_system_variables.max_error_count= 65535;
1984 max_system_variables.max_heap_table_size= MAX_MEM_TABLE_SIZE;
1985 max_system_variables.max_join_size= INT32_MAX;
1986 max_system_variables.max_length_for_sort_data= 8192*1024L;
1987 max_system_variables.max_seeks_for_key= ULONG_MAX;
1988 max_system_variables.max_sort_length= 8192*1024L;
1989 max_system_variables.min_examined_row_limit= ULONG_MAX;
1990 max_system_variables.optimizer_prune_level= 1;
1991 max_system_variables.optimizer_search_depth= MAX_TABLES+2;
1992 max_system_variables.preload_buff_size= 1024*1024*1024L;
1993 max_system_variables.query_alloc_block_size= UINT32_MAX;
1994 max_system_variables.query_prealloc_size= UINT32_MAX;
1995 max_system_variables.range_alloc_block_size= SIZE_MAX;
1996 max_system_variables.read_buff_size= INT32_MAX;
1997 max_system_variables.read_rnd_buff_size= UINT32_MAX;
1998 max_system_variables.sortbuff_size= SIZE_MAX;
1999 max_system_variables.tmp_table_size= MAX_MEM_TABLE_SIZE;
2002#ifdef HAVE_BROKEN_REALPATH
2003 have_symlink=SHOW_OPTION_NO;
2005 have_symlink=SHOW_OPTION_YES;
2016 catalog::resetPath_for_local_identifier();
2018 if (vm.count(
"user"))
2020 if (drizzled_user == NULL or strcmp(drizzled_user, vm[
"user"].as<string>().c_str()) == 0)
2022 drizzled_user= (
char *)vm[
"user"].as<string>().c_str();
2026 errmsg_printf(error::WARN, _(
"Ignoring user change to '%s' because the user was set to '%s' earlier on the command line"),
2027 vm[
"user"].as<string>().c_str(), drizzled_user);
2031 if (vm.count(
"sort-heap-threshold"))
2033 if ((vm[
"sort-heap-threshold"].as<uint64_t>() > 0) and
2034 (vm[
"sort-heap-threshold"].as<uint64_t>() < global_system_variables.sortbuff_size))
2036 drizzled_abort << _(
"sort-heap-threshold cannot be less than sort-buffer-size");
2039 global_sort_buffer.setMaxSize(vm[
"sort-heap-threshold"].as<uint64_t>());
2042 if (vm.count(
"join-heap-threshold"))
2044 if ((vm[
"join-heap-threshold"].as<uint64_t>() > 0) and
2045 (vm[
"join-heap-threshold"].as<uint64_t>() < global_system_variables.join_buff_size))
2047 drizzled_abort << _(
"join-heap-threshold cannot be less than join-buffer-size");
2050 global_join_buffer.setMaxSize(vm[
"join-heap-threshold"].as<uint64_t>());
2053 if (vm.count(
"read-rnd-threshold"))
2055 if ((vm[
"read-rnd-threshold"].as<uint64_t>() > 0) and
2056 (vm[
"read-rnd-threshold"].as<uint64_t>() < global_system_variables.read_rnd_buff_size))
2058 drizzled_abort << _(
"read-rnd-threshold cannot be less than read-rnd-buffer-size");
2061 global_read_rnd_buffer.setMaxSize(vm[
"read-rnd-threshold"].as<uint64_t>());
2064 if (vm.count(
"read-buffer-threshold"))
2066 if ((vm[
"read-buffer-threshold"].as<uint64_t>() > 0) and
2067 (vm[
"read-buffer-threshold"].as<uint64_t>() < global_system_variables.read_buff_size))
2069 drizzled_abort << _(
"read-buffer-threshold cannot be less than read-buffer-size");
2072 global_read_buffer.setMaxSize(vm[
"read-buffer-threshold"].as<uint64_t>());
2075 if (vm.count(
"exit-info"))
2077 if (vm[
"exit-info"].as<long>())
2079 getDebug().set((uint32_t) vm[
"exit-info"].as<long>());
2083 if (vm.count(
"want-core"))
2085 getDebug().set(debug::CORE_ON_SIGNAL);
2088 if (vm.count(
"skip-stack-trace"))
2090 getDebug().set(debug::NO_STACKTRACE);
2093 if (vm.count(
"skip-symlinks"))
2095 internal::my_use_symdir= 0;
2098 if (vm.count(
"collation-server"))
2100 const charset_info_st *
const default_collation= get_charset_by_name(vm[
"collation-server"].as<string>().c_str());
2101 if (not default_collation)
2103 drizzled_abort <<
"Unknown collation: " << default_collation_name;
2106 if (not my_charset_same(default_charset_info, default_collation))
2108 drizzled_abort <<
"COLLATION '" << default_collation_name <<
"' is not valid for CHARACTER SET '" << default_charset_info->csname <<
"'";
2110 default_charset_info= default_collation;
2113 if (vm.count(
"transaction-isolation"))
2115 int type= tx_isolation_typelib.find_type_or_exit(vm[
"transaction-isolation"].as<string>().c_str(),
"transaction-isolation");
2116 global_system_variables.tx_isolation=
type - 1;
2120 if (vm.count(
"default-storage-engine"))
2122 default_storage_engine_str= vm[
"default-storage-engine"].as<
string>().c_str();
2126#if defined(HAVE_BROKEN_REALPATH)
2127 internal::my_use_symdir=0;
2128 internal::my_disable_symlinks=1;
2129 have_symlink=SHOW_OPTION_NO;
2131 if (!internal::my_use_symdir)
2133 internal::my_disable_symlinks=1;
2134 have_symlink=SHOW_OPTION_DISABLED;
2140 getDebug().set(debug::ALLOW_SIGINT);
2141 getDebug().set(debug::NO_STACKTRACE);
2142 getDebug().reset(debug::CORE_ON_SIGNAL);
2145 if (drizzled_chroot)
2154 internal::my_default_record_cache_size=global_system_variables.read_buff_size;
2158static void fix_paths()
2162 if (pid_file.string().size() and pid_file.string()[0] ==
'/')
2166 fs::path pid_file_path(pid_file);
2167 if (pid_file_path.root_path().string() ==
"")
2169 pid_file_path= getDataHome();
2170 pid_file_path /= pid_file;
2172 pid_file= fs::system_complete(pid_file_path);
2176 const char *tmp_string= getenv(
"TMPDIR");
2178 drizzle_tmpdir.clear();
2180 if (vm.count(
"tmpdir"))
2182 drizzle_tmpdir.append(vm[
"tmpdir"].as<string>());
2184 else if (tmp_string == NULL)
2186 drizzle_tmpdir.append(getDataHome().
string());
2187 drizzle_tmpdir.push_back(FN_LIBCHAR);
2188 drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2192 drizzle_tmpdir.append(tmp_string);
2195 drizzle_tmpdir= fs::path(fs::system_complete(fs::path(drizzle_tmpdir))).string();
2196 assert(drizzle_tmpdir.size());
2198 if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2200 if (errno != EEXIST)
2202 drizzled_abort <<
"There was an error creating the '"
2203 << fs::path(drizzle_tmpdir).filename()
2204 <<
"' part of the path '"
2206 <<
"'. Please check the path exists and is writable.";
2210 if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2212 drizzled_abort <<
"There was an error opening the path '" << drizzle_tmpdir <<
"', please check the path exists and is writable.";
Defines the interface to the CachedDirectory class.
Convert from decimal to binary representation.
TODO: Rename this file - func.h is stupid.
const char * in_additional_cond
static void set_root(const char *path)
void ha_init_errors(void)
static void drizzle_init_variables()
bool init_temporal_formats()
static void get_options()
void deinit_temporal_formats()
const char * in_left_expr_name
Visibility Control Macros.