666
1557
#define SA_NODEFER 0
672
const char *load_default_groups[]=
674
DRIZZLE_CONFIG_NAME, "server", 0, 0
1560
static void init_signals(void)
1563
struct sigaction sa;
1565
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
1567
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
1569
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
1570
sigemptyset(&sa.sa_mask);
1571
sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
1574
sa.sa_handler=handle_segfault;
1575
sigaction(SIGSEGV, &sa, NULL);
1576
sigaction(SIGABRT, &sa, NULL);
1578
sigaction(SIGBUS, &sa, NULL);
1580
sigaction(SIGILL, &sa, NULL);
1581
sigaction(SIGFPE, &sa, NULL);
1584
#ifdef HAVE_GETRLIMIT
1585
if (test_flags & TEST_CORE_ON_SIGNAL)
1587
/* Change limits so that we will get a core file */
1589
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
1590
if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
1591
sql_print_warning(_("setrlimit could not change the size of core files "
1592
"to 'infinity'; We may not be able to generate a "
1593
"core file on signals"));
1596
(void) sigemptyset(&set);
1597
my_sigset(SIGPIPE,SIG_IGN);
1598
sigaddset(&set,SIGPIPE);
1599
#ifndef IGNORE_SIGHUP_SIGQUIT
1600
sigaddset(&set,SIGQUIT);
1601
sigaddset(&set,SIGHUP);
1603
sigaddset(&set,SIGTERM);
1605
/* Fix signals if blocked by parents (can happen on Mac OS X) */
1606
sigemptyset(&sa.sa_mask);
1608
sa.sa_handler = print_signal_warning;
1609
sigaction(SIGTERM, &sa, (struct sigaction*) 0);
1611
sa.sa_handler = print_signal_warning;
1612
sigaction(SIGHUP, &sa, (struct sigaction*) 0);
1614
sigaddset(&set,SIGTSTP);
1616
if (thd_lib_detected != THD_LIB_LT)
1617
sigaddset(&set,THR_SERVER_ALARM);
1618
if (test_flags & TEST_SIGINT)
1620
my_sigset(thr_kill_signal, end_thread_signal);
1622
sigdelset(&set, thr_kill_signal);
1625
sigaddset(&set,SIGINT);
1626
sigprocmask(SIG_SETMASK,&set,NULL);
1627
pthread_sigmask(SIG_SETMASK,&set,NULL);
1632
static void start_signal_handler(void)
1635
pthread_attr_t thr_attr;
1637
(void) pthread_attr_init(&thr_attr);
1638
pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
1639
(void) pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
1641
struct sched_param tmp_sched_param;
1643
memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
1644
tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1645
(void)pthread_attr_setschedparam(&thr_attr, &tmp_sched_param);
1647
#if defined(__ia64__) || defined(__ia64)
1649
Peculiar things with ia64 platforms - it seems we only have half the
1650
stack size in reality, so we have to double it here
1652
pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
1654
pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
1656
(void) pthread_mutex_lock(&LOCK_thread_count);
1657
if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0)))
1659
sql_print_error(_("Can't create interrupt-thread (error %d, errno: %d)"),
1663
(void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
1664
pthread_mutex_unlock(&LOCK_thread_count);
1666
(void) pthread_attr_destroy(&thr_attr);
1671
/** This threads handles all signals and alarms. */
1673
pthread_handler_t signal_hand(void *arg __attribute__((unused)))
1677
my_thread_init(); // Init new thread
1678
signal_thread_in_use= 1;
1682
This should actually be '+ max_number_of_slaves' instead of +10,
1683
but the +10 should be quite safe.
1685
init_thr_alarm(thread_scheduler.max_threads + 10);
1686
if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT))
1688
(void) sigemptyset(&set); // Setup up SIGINT for debug
1689
(void) sigaddset(&set,SIGINT); // For debugging
1690
(void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
1692
(void) sigemptyset(&set); // Setup up SIGINT for debug
1693
#ifdef USE_ONE_SIGNAL_HAND
1694
(void) sigaddset(&set,THR_SERVER_ALARM); // For alarms
1696
#ifndef IGNORE_SIGHUP_SIGQUIT
1697
(void) sigaddset(&set,SIGQUIT);
1698
(void) sigaddset(&set,SIGHUP);
1700
(void) sigaddset(&set,SIGTERM);
1701
(void) sigaddset(&set,SIGTSTP);
1703
/* Save pid to this process (or thread on Linux) */
1706
#ifdef HAVE_STACK_TRACE_ON_SEGV
1709
sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (uint32_t)getpid());
1710
pstack_install_segv_action(pstack_file_name);
1712
#endif /* HAVE_STACK_TRACE_ON_SEGV */
1715
signal to start_signal_handler that we are ready
1716
This works by waiting for start_signal_handler to free mutex,
1717
after which we signal it that we are ready.
1718
At this pointer there is no other threads running, so there
1719
should not be any other pthread_cond_signal() calls.
1721
(void) pthread_mutex_lock(&LOCK_thread_count);
1722
(void) pthread_mutex_unlock(&LOCK_thread_count);
1723
(void) pthread_cond_broadcast(&COND_thread_count);
1725
(void) pthread_sigmask(SIG_BLOCK,&set,NULL);
1728
int error; // Used when debugging
1729
if (shutdown_in_progress && !abort_loop)
1735
while ((error=my_sigwait(&set,&sig)) == EINTR) ;
1739
signal_thread_in_use= 0;
1740
pthread_exit(0); // Safety
1747
sql_print_information(_("Got signal %d to shutdown mysqld"),sig);
1749
/* switch to the old log message processing */
1752
abort_loop=1; // mark abort for threads
1753
#ifdef USE_ONE_SIGNAL_HAND
1756
struct sched_param tmp_sched_param;
1758
memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
1759
tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1760
(void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
1762
if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
1764
sql_print_error(_("Can't create thread to kill server"));
1766
kill_server((void*) sig); // MIT THREAD has a alarm thread
1774
reload_cache((Session*) 0,
1775
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
1777
REFRESH_THREADS | REFRESH_HOSTS),
1778
(TableList*) 0, ¬_used); // Flush logs
1781
#ifdef USE_ONE_SIGNAL_HAND
1782
case THR_SERVER_ALARM:
1783
process_alarm(sig); // Trigger alarms.
1788
sql_print_warning(_("Got signal: %d error: %d"),sig,error); /* purecov: tested */
1790
break; /* purecov: tested */
1793
return(0); /* purecov: deadcode */
1796
static void check_data_home(const char *path __attribute__((unused)))
1803
All global error messages are sent here where the first one is stored
1807
extern "C" void my_message_sql(uint32_t error, const char *str, myf MyFlags);
1809
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
1813
Put here following assertion when situation with EE_* error codes
1816
if ((session= current_session))
1818
if (MyFlags & ME_FATALERROR)
1819
session->is_fatal_error= 1;
1822
TODO: There are two exceptions mechanism (Session and sp_rcontext),
1823
this could be improved by having a common stack of handlers.
1825
if (session->handle_error(error, str,
1826
DRIZZLE_ERROR::WARN_LEVEL_ERROR))
1829
session->is_slave_error= 1; // needed to catch query errors during replication
1832
session->lex->current_select == 0 if lex structure is not inited
1833
(not query command (COM_QUERY))
1835
if (! (session->lex->current_select &&
1836
session->lex->current_select->no_error && !session->is_fatal_error))
1838
if (! session->main_da.is_error()) // Return only first message
1841
error= ER_UNKNOWN_ERROR;
1844
session->main_da.set_error_status(session, error, str);
1848
if (!session->no_warnings_for_error && !session->is_fatal_error)
1851
Suppress infinite recursion if there a memory allocation error
1852
inside push_warning.
1854
session->no_warnings_for_error= true;
1855
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
1856
session->no_warnings_for_error= false;
1859
if (!session || MyFlags & ME_NOREFRESH)
1860
sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
1865
extern "C" void *my_str_malloc_mysqld(size_t size);
1866
extern "C" void my_str_free_mysqld(void *ptr);
1868
void *my_str_malloc_mysqld(size_t size)
1870
return my_malloc(size, MYF(MY_FAE));
1874
void my_str_free_mysqld(void *ptr)
1876
free((unsigned char*)ptr);
1880
static const char *load_default_groups[]= {
1881
"mysqld","server", DRIZZLE_BASE_VERSION, 0, 0};
1885
Initialize one of the global date/time format variables.
1887
@param format_type What kind of format should be supported
1888
@param var_ptr Pointer to variable that should be updated
1891
The default value is taken from either opt_date_time_formats[] or
1892
the ISO format (ANSI SQL)
1900
static bool init_global_datetime_format(enum enum_drizzle_timestamp_type format_type,
1901
DATE_TIME_FORMAT **var_ptr)
1903
/* Get command line option */
1904
const char *str= opt_date_time_formats[format_type];
1906
if (!str) // No specified format
1908
str= get_date_time_format_str(&known_date_time_formats[ISO_FORMAT],
1911
Set the "command line" option to point to the generated string so
1912
that we can set global formats back to default
1914
opt_date_time_formats[format_type]= str;
1916
if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str))))
1918
fprintf(stderr, _("Wrong date/time format specifier: %s\n"), str);
1924
SHOW_VAR com_status_vars[]= {
1925
{"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
1926
{"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1927
{"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
1928
{"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1929
{"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1930
{"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
1931
{"binlog", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS},
1932
{"change_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
1933
{"change_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_MASTER]), SHOW_LONG_STATUS},
1934
{"check", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS},
1935
{"checksum", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
1936
{"commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
1937
{"create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
1938
{"create_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
1939
{"create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
1940
{"delete", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE]), SHOW_LONG_STATUS},
1941
{"delete_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS},
1942
{"drop_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
1943
{"drop_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
1944
{"drop_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
1945
{"empty_query", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
1946
{"flush", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
1947
{"insert", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT]), SHOW_LONG_STATUS},
1948
{"insert_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
1949
{"kill", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_KILL]), SHOW_LONG_STATUS},
1950
{"load", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD]), SHOW_LONG_STATUS},
1951
{"lock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS},
1952
{"optimize", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS},
1953
{"purge", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE]), SHOW_LONG_STATUS},
1954
{"purge_before_date", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BEFORE]), SHOW_LONG_STATUS},
1955
{"release_savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
1956
{"rename_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
1957
{"repair", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPAIR]), SHOW_LONG_STATUS},
1958
{"replace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
1959
{"replace_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
1960
{"reset", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESET]), SHOW_LONG_STATUS},
1961
{"rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
1962
{"rollback_to_savepoint",(char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
1963
{"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1964
{"select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1965
{"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
1966
{"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
1967
{"show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1968
{"show_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1969
{"show_databases", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
1970
{"show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS},
1971
{"show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
1972
{"show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
1973
{"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
1974
{"show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
1975
{"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
1976
{"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
1977
{"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
1978
{"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
1979
{"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1980
{"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1981
{"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
1982
{"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
1983
{"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
1984
{"slave_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
1985
{"slave_stop", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS},
1986
{"truncate", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1987
{"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1988
{"update", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1989
{"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1990
{NULL, NULL, SHOW_LONG}
677
static void check_limits_aii(uint64_t in_auto_increment_increment)
679
global_system_variables.auto_increment_increment= 1;
680
if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
682
cout << N_("Error: Invalid Value for auto_increment_increment");
685
global_system_variables.auto_increment_increment= in_auto_increment_increment;
688
static void check_limits_aio(uint64_t in_auto_increment_offset)
690
global_system_variables.auto_increment_offset= 1;
691
if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
693
cout << N_("Error: Invalid Value for auto_increment_offset");
696
global_system_variables.auto_increment_offset= in_auto_increment_offset;
699
static void check_limits_completion_type(uint32_t in_completion_type)
701
global_system_variables.completion_type= 0;
702
if (in_completion_type > 2)
704
cout << N_("Error: Invalid Value for completion_type");
707
global_system_variables.completion_type= in_completion_type;
710
static void check_limits_back_log(uint32_t in_back_log)
713
if (in_back_log < 1 || in_back_log > 65535)
715
cout << N_("Error: Invalid Value for back_log");
718
back_log= in_back_log;
721
static void check_limits_dpi(uint32_t in_div_precincrement)
723
global_system_variables.div_precincrement= 4;
724
if (in_div_precincrement > DECIMAL_MAX_SCALE)
726
cout << N_("Error: Invalid Value for div-precision-increment");
729
global_system_variables.div_precincrement= in_div_precincrement;
732
static void check_limits_gcml(uint64_t in_group_concat_max_len)
734
global_system_variables.group_concat_max_len= 1024;
735
if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
737
cout << N_("Error: Invalid Value for group_concat_max_len");
740
global_system_variables.group_concat_max_len= in_group_concat_max_len;
743
static void check_limits_join_buffer_size(uint64_t in_join_buffer_size)
745
global_system_variables.join_buff_size= (128*1024L);
746
if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
748
cout << N_("Error: Invalid Value for join_buffer_size");
751
in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
752
global_system_variables.join_buff_size= in_join_buffer_size;
755
static void check_limits_map(uint32_t in_max_allowed_packet)
757
global_system_variables.max_allowed_packet= (1024*1024L);
758
if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
760
cout << N_("Error: Invalid Value for max_allowed_packet");
763
in_max_allowed_packet-= in_max_allowed_packet % 1024;
764
global_system_variables.max_allowed_packet= in_max_allowed_packet;
767
static void check_limits_mce(uint64_t in_max_connect_errors)
769
max_connect_errors= MAX_CONNECT_ERRORS;
770
if (in_max_connect_errors < 1 || in_max_connect_errors > ULONG_MAX)
772
cout << N_("Error: Invalid Value for max_connect_errors");
775
max_connect_errors= in_max_connect_errors;
778
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
780
global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
781
if (in_max_error_count > 65535)
783
cout << N_("Error: Invalid Value for max_error_count");
786
global_system_variables.max_error_count= in_max_error_count;
789
static void check_limits_mhts(uint64_t in_max_heap_table_size)
791
global_system_variables.max_heap_table_size= (16*1024*1024L);
792
if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
794
cout << N_("Error: Invalid Value for max_heap_table_size");
797
in_max_heap_table_size-= in_max_heap_table_size % 1024;
798
global_system_variables.max_heap_table_size= in_max_heap_table_size;
801
static void check_limits_merl(uint64_t in_min_examined_row_limit)
803
global_system_variables.min_examined_row_limit= 0;
804
if (in_min_examined_row_limit > ULONG_MAX)
806
cout << N_("Error: Invalid Value for min_examined_row_limit");
809
global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
812
static void check_limits_max_join_size(drizzled::ha_rows in_max_join_size)
814
global_system_variables.max_join_size= INT32_MAX;
815
if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
817
cout << N_("Error: Invalid Value for max_join_size");
820
global_system_variables.max_join_size= in_max_join_size;
823
static void check_limits_mlfsd(int64_t in_max_length_for_sort_data)
825
global_system_variables.max_length_for_sort_data= 1024;
826
if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
828
cout << N_("Error: Invalid Value for max_length_for_sort_data");
831
global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
834
static void check_limits_msfk(uint64_t in_max_seeks_for_key)
836
global_system_variables.max_seeks_for_key= ULONG_MAX;
837
if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
839
cout << N_("Error: Invalid Value for max_seeks_for_key");
842
global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
845
static void check_limits_max_sort_length(size_t in_max_sort_length)
847
global_system_variables.max_sort_length= 1024;
848
if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
850
cout << N_("Error: Invalid Value for max_sort_length");
853
global_system_variables.max_sort_length= in_max_sort_length;
856
static void check_limits_mwlc(uint64_t in_min_examined_row_limit)
858
global_system_variables.min_examined_row_limit= ULONG_MAX;
859
if (in_min_examined_row_limit > ULONG_MAX)
861
cout << N_("Error: Invalid Value for min_examined_row_limit");
864
global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
867
static void check_limits_osd(uint32_t in_optimizer_search_depth)
869
global_system_variables.optimizer_search_depth= 0;
870
if (in_optimizer_search_depth > MAX_TABLES + 2)
872
cout << N_("Error: Invalid Value for optimizer_search_depth");
875
global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
878
static 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
cout << N_("Error: Invalid Value for preload_buff_size");
886
global_system_variables.preload_buff_size= in_preload_buff_size;
889
static void check_limits_qabs(uint32_t in_query_alloc_block_size)
891
global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
892
if (in_query_alloc_block_size < 1024)
894
cout << N_("Error: Invalid Value for query_alloc_block_size");
897
in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
898
global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
901
static void check_limits_qps(uint32_t in_query_prealloc_size)
903
global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
904
if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
906
cout << N_("Error: Invalid Value for query_prealloc_size");
909
in_query_prealloc_size-= in_query_prealloc_size % 1024;
910
global_system_variables.query_prealloc_size= in_query_prealloc_size;
913
static void check_limits_rabs(size_t in_range_alloc_block_size)
915
global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
916
if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
918
cout << N_("Error: Invalid Value for range_alloc_block_size");
921
in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
922
global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
925
static void check_limits_read_buffer_size(int32_t in_read_buff_size)
927
global_system_variables.read_buff_size= (128*1024L);
928
if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
930
cout << N_("Error: Invalid Value for read_buff_size");
933
in_read_buff_size-= in_read_buff_size % IO_SIZE;
934
global_system_variables.read_buff_size= in_read_buff_size;
937
static void check_limits_read_rnd_buffer_size(uint32_t in_read_rnd_buff_size)
939
global_system_variables.read_rnd_buff_size= (256*1024L);
940
if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
942
cout << N_("Error: Invalid Value for read_rnd_buff_size");
945
global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
948
static void check_limits_sort_buffer_size(size_t in_sortbuff_size)
950
global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
951
if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
953
cout << N_("Error: Invalid Value for sort_buff_size");
956
global_system_variables.sortbuff_size= in_sortbuff_size;
959
static void check_limits_tdc(uint32_t in_table_def_size)
962
if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
964
cout << N_("Error: Invalid Value for table_def_size");
967
table_def_size= in_table_def_size;
970
static void check_limits_toc(uint32_t in_table_cache_size)
972
table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
973
if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
975
cout << N_("Error: Invalid Value for table_cache_size");
978
table_cache_size= in_table_cache_size;
981
static void check_limits_tlwt(uint64_t in_table_lock_wait_timeout)
983
table_lock_wait_timeout= 50;
984
if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
986
cout << N_("Error: Invalid Value for table_lock_wait_timeout");
989
table_lock_wait_timeout= in_table_lock_wait_timeout;
992
static void check_limits_thread_stack(uint32_t in_my_thread_stack_size)
994
my_thread_stack_size= in_my_thread_stack_size - (in_my_thread_stack_size % 1024);
997
static void check_limits_tmp_table_size(uint64_t in_tmp_table_size)
999
global_system_variables.tmp_table_size= 16*1024*1024L;
1000
if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1002
cout << N_("Error: Invalid Value for table_lock_wait_timeout");
1005
global_system_variables.tmp_table_size= in_tmp_table_size;
1008
static pair<string, string> parse_size_suffixes(string s)
1010
size_t equal_pos= s.find("=");
1011
if (equal_pos != string::npos)
1013
string arg_key(s.substr(0, equal_pos));
1014
string arg_val(s.substr(equal_pos+1));
1018
size_t size_suffix_pos= arg_val.find_last_of("kmgKMG");
1019
if (size_suffix_pos == arg_val.size()-1)
1021
char suffix= arg_val[size_suffix_pos];
1022
string size_val(arg_val.substr(0, size_suffix_pos));
1024
uint64_t base_size= boost::lexical_cast<uint64_t>(size_val);
1025
uint64_t new_size= 0;
1031
new_size= base_size * 1024;
1035
new_size= base_size * 1024 * 1024;
1039
new_size= base_size * 1024 * 1024 * 1024;
1042
return make_pair(arg_key,
1043
boost::lexical_cast<string>(new_size));
1048
/* Screw it, let the normal parser take over */
1052
return make_pair(string(""), string(""));
1055
static pair<string, string> parse_size_arg(string s)
1057
if (s.find("--") == 0)
1059
return parse_size_suffixes(s.substr(2));
1061
return make_pair(string(""), string(""));
1064
static void process_defaults_files()
1066
for (vector<string>::iterator iter= defaults_file_list.begin();
1067
iter != defaults_file_list.end();
1070
string file_location(vm["config-dir"].as<string>());
1071
if ((*iter)[0] != '/')
1073
/* Relative path - add config dir */
1074
file_location.push_back('/');
1075
file_location.append(*iter);
1079
file_location= *iter;
1082
ifstream input_defaults_file(file_location.c_str());
1084
po::parsed_options file_parsed=
1085
po::parse_config_file(input_defaults_file, long_options, true);
1086
vector<string> file_unknown=
1087
po::collect_unrecognized(file_parsed.options, po::include_positional);
1089
for (vector<string>::iterator it= file_unknown.begin();
1090
it != file_unknown.end();
1093
string new_unknown_opt("--");
1094
new_unknown_opt.append(*it);
1096
if (it != file_unknown.end())
1098
if ((*it) != "true")
1100
new_unknown_opt.push_back('=');
1101
new_unknown_opt.append(*it);
1108
unknown_options.push_back(new_unknown_opt);
1110
store(file_parsed, vm);
1114
static void compose_defaults_file_list(vector<string> in_options)
1116
for (vector<string>::iterator it= in_options.begin();
1117
it != in_options.end();
1120
defaults_file_list.push_back(*it);
1124
int init_common_variables(int argc, char **argv)
1127
umask(((~internal::my_umask) & 0666));
1993
static int init_common_variables(const char *conf_file_name, int argc,
1994
char **argv, const char **groups)
1996
umask(((~my_umask) & 0666));
1128
1997
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1129
1998
tzset(); // Set tzname
1131
curr_time= time(NULL);
1132
if (curr_time == (time_t)-1)
1135
2000
max_system_variables.pseudo_thread_id= UINT32_MAX;
1136
server_start_time= flush_status_time= curr_time;
1138
drizzle_init_variables();
2001
server_start_time= flush_status_time= my_time(0);
2002
rpl_filter= new Rpl_filter;
2003
binlog_filter= new Rpl_filter;
2004
if (!rpl_filter || !binlog_filter)
2006
sql_perror("Could not allocate replication and binlog filters");
2010
if (init_thread_environment())
2012
mysql_init_variables();
1141
2016
struct tm tm_tmp;
1142
2017
localtime_r(&server_start_time,&tm_tmp);
1143
strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
2018
strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
1144
2019
sizeof(system_time_zone)-1);
1148
2024
We set SYSTEM time zone as reasonable default and
1149
2025
also for failure of my_tz_init() and bootstrap mode.
1153
2029
global_system_variables.time_zone= my_tz_SYSTEM;
2032
Init mutexes for the global DRIZZLE_BIN_LOG objects.
2033
As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of
2034
global DRIZZLE_BIN_LOGs in their constructors, because then they would be
2035
inited before MY_INIT(). So we do it here.
2037
mysql_bin_log.init_pthread_objects();
1155
2039
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1157
strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1158
errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1160
strncpy(pidfile_name, STRING_WITH_LEN("drizzle"));
2041
strmake(glob_hostname, STRING_WITH_LEN("localhost"));
2042
sql_print_warning(_("gethostname failed, using '%s' as hostname"),
2044
strmake(pidfile_name, STRING_WITH_LEN("mysql"));
1163
strncpy(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
1164
strcpy(internal::fn_ext(pidfile_name),".pid"); // Add proper extension
1166
std::string system_config_dir_drizzle(SYSCONFDIR);
1167
system_config_dir_drizzle.append("/drizzle");
1169
std::string system_config_file_drizzle("drizzled.cnf");
1171
long_options.add_options()
1172
("help-extended", po::value<bool>(&opt_help_extended)->default_value(false)->zero_tokens(),
1173
N_("Display this help and exit after initializing plugins."))
1174
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1175
N_("Display this help and exit."))
1176
("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1177
N_("Auto-increment columns are incremented by this"))
1178
("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1179
N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1180
("basedir,b", po::value<string>(),
1181
N_("Path to installation directory. All paths are usually resolved "
1182
"relative to this."))
1183
("chroot,r", po::value<string>(),
1184
N_("Chroot drizzled daemon during startup."))
1185
("collation-server", po::value<string>(),
1186
N_("Set the default collation."))
1187
("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1188
N_("Default completion type."))
1189
("core-file", N_("Write core on errors."))
1190
("datadir", po::value<string>(),
1191
N_("Path to the database root."))
1192
("default-storage-engine", po::value<string>(),
1193
N_("Set the default storage engine (table type) for tables."))
1194
("default-time-zone", po::value<string>(),
1195
N_("Set the default time zone."))
1196
("exit-info,T", po::value<long>(),
1197
N_("Used for debugging; Use at your own risk!"))
1198
("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1199
N_("Set up signals usable for debugging"))
1200
("language,L", po::value<string>(),
1202
("lc-time-name", po::value<string>(),
1203
N_("Set the language used for the month names and the days of the week."))
1204
("log-warnings,W", po::value<string>(),
1205
N_("Log some not critical warnings to the log file."))
1206
("pid-file", po::value<string>(),
1207
N_("Pid file used by drizzled."))
1208
("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1209
N_("Maximum time in seconds to wait for the port to become free. "
1210
"(Default: no wait)"))
1211
("secure-file-priv", po::value<string>(),
1212
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1213
"within specified directory"))
1214
("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1215
N_("Uniquely identifies the server instance in the community of "
1216
"replication partners."))
1217
("skip-stack-trace",
1218
N_("Don't print a stack trace on failure."))
1219
("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1220
N_("Enable symbolic link support."))
1221
("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1222
N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1224
("tmpdir,t", po::value<string>(),
1225
N_("Path for temporary files."))
1226
("transaction-isolation", po::value<string>(),
1227
N_("Default transaction isolation level."))
1228
("user,u", po::value<string>(),
1229
N_("Run drizzled daemon as user."))
1231
N_("Output version information and exit."))
1232
("back-log", po::value<uint32_t>(&back_log)->default_value(50)->notifier(&check_limits_back_log),
1233
N_("The number of outstanding connection requests Drizzle can have. This "
1234
"comes into play when the main Drizzle thread gets very many connection "
1235
"requests in a very short time."))
1236
("bulk-insert-buffer-size",
1237
po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1238
N_("Size of tree cache used in bulk insert optimization. Note that this is "
1239
"a limit per thread!"))
1240
("div-precision-increment", po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1241
N_("Precision of the result of '/' operator will be increased on that "
1243
("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1244
N_("The maximum length of the result of function group_concat."))
1245
("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1246
N_("The size of the buffer that is used for full joins."))
1247
("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(1024*1024L)->notifier(&check_limits_map),
1248
N_("Max packetlength to send/receive from to server."))
1249
("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
1250
N_("If there is more than this number of interrupted connections from a "
1251
"host this host will be blocked from further connections."))
1252
("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1253
N_("Max number of errors/warnings to store for a statement."))
1254
("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1255
N_("Don't allow creation of heap tables bigger than this."))
1256
("max-join-size", po::value<drizzled::ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1257
N_("Joins that are probably going to read more than max_join_size records "
1258
"return an error."))
1259
("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1260
N_("Max number of bytes in sorted records."))
1261
("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1262
N_("Limit assumed max number of seeks when looking up rows based on a key"))
1263
("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
1264
N_("The number of bytes to use when sorting BLOB or TEXT values "
1265
"(only the first max_sort_length bytes of each value are used; the "
1266
"rest are ignored)."))
1267
("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(ULONG_MAX)->notifier(&check_limits_mwlc),
1268
N_("After this many write locks, allow some read locks to run in between."))
1269
("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1270
N_("Don't log queries which examine less than min_examined_row_limit "
1272
("disable-optimizer-prune",
1273
N_("Do not apply any heuristic(s) during query optimization to prune, "
1274
"thus perform an exhaustive search from the optimizer search space."))
1275
("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1276
N_("Maximum depth of search performed by the query optimizer. Values "
1277
"larger than the number of relations in a query result in better query "
1278
"plans, but take longer to compile a query. Smaller values than the "
1279
"number of tables in a relation result in faster optimization, but may "
1280
"produce very bad query plans. If set to 0, the system will "
1281
"automatically pick a reasonable value; if set to MAX_TABLES+2, the "
1282
"optimizer will switch to the original find_best (used for "
1283
"testing/comparison)."))
1284
("plugin-dir", po::value<string>(),
1285
N_("Directory for plugins."))
1286
("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1287
N_("Optional comma separated list of plugins to load at startup in addition "
1288
"to the default list of plugins. "
1289
"[for example: --plugin_add=crc32,logger_gearman]"))
1290
("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1291
N_("Optional comma separated list of plugins to not load at startup. Effectively "
1292
"removes a plugin from the list of plugins to be loaded. "
1293
"[for example: --plugin_remove=crc32,logger_gearman]"))
1294
("plugin-load", po::value<string>()->notifier(¬ify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1295
N_("Optional comma separated list of plugins to load at starup instead of "
1296
"the default plugin load list. "
1297
"[for example: --plugin_load=crc32,logger_gearman]"))
1298
("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1299
N_("The size of the buffer that is allocated when preloading indexes"))
1300
("query-alloc-block-size",
1301
po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1302
N_("Allocation block size for query parsing and execution"))
1303
("query-prealloc-size",
1304
po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1305
N_("Persistent buffer for query parsing and execution"))
1306
("range-alloc-block-size",
1307
po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1308
N_("Allocation block size for storing ranges during optimization"))
1309
("read-buffer-size",
1310
po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1311
N_("Each thread that does a sequential scan allocates a buffer of this "
1312
"size for each table it scans. If you do many sequential scans, you may "
1313
"want to increase this value."))
1314
("read-rnd-buffer-size",
1315
po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1316
N_("When reading rows in sorted order after a sort, the rows are read "
1317
"through this buffer to avoid a disk seeks. If not set, then it's set "
1318
"to the value of record_buffer."))
1319
("scheduler", po::value<string>(),
1320
N_("Select scheduler to be used (by default multi-thread)."))
1321
("sort-buffer-size",
1322
po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1323
N_("Each thread that needs to do a sort allocates a buffer of this size."))
1324
("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1325
N_("The number of cached table definitions."))
1326
("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1327
N_("The number of cached open tables."))
1328
("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1329
N_("Timeout in seconds to wait for a table level lock before returning an "
1330
"error. Used only if the connection has active cursors."))
1331
("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1332
N_("The stack size for each thread."))
1334
po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1335
N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1336
" automatically convert it to an on-disk MyISAM table."))
1337
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1338
N_("Configuration file defaults are not used if no-defaults is set"))
1339
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1340
N_("Configuration file to use"))
1341
("config-dir", po::value<string>()->default_value(system_config_dir_drizzle),
1342
N_("Base location for config files"))
1345
// Disable allow_guessing
1346
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1348
po::parsed_options parsed= po::command_line_parser(argc, argv).style(style).
1349
options(long_options).allow_unregistered().extra_parser(parse_size_arg).run();
1351
po::collect_unrecognized(parsed.options, po::include_positional);
1355
po::store(parsed, vm);
1359
errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1363
if (not vm["no-defaults"].as<bool>())
1365
defaults_file_list.insert(defaults_file_list.begin(),
1366
system_config_file_drizzle);
1369
string config_conf_d_location(vm["config-dir"].as<string>());
1370
config_conf_d_location.append("/conf.d");
1371
CachedDirectory config_conf_d(config_conf_d_location);
1372
if (not config_conf_d.fail())
1375
for (CachedDirectory::Entries::const_iterator iter= config_conf_d.getEntries().begin();
1376
iter != config_conf_d.getEntries().end();
2047
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
2048
my_stpcpy(fn_ext(pidfile_name),".pid"); // Add proper extension
2051
Add server status variables to the dynamic list of
2052
status variables that is shown by SHOW STATUS.
2053
Later, in plugin_init, and mysql_install_plugin
2054
new entries could be added to that list.
2056
if (add_status_vars(status_vars))
2057
return 1; // an error was already reported
2059
load_defaults(conf_file_name, groups, &argc, &argv);
2062
get_options(&defaults_argc, defaults_argv);
2063
set_server_version();
2066
/* connections and databases needs lots of files */
2068
uint32_t files, wanted_files, max_open_files;
2070
/* MyISAM requires two file handles per table. */
2071
wanted_files= 10+max_connections+table_cache_size*2;
2073
We are trying to allocate no less than max_connections*5 file
2074
handles (i.e. we are trying to set the limit so that they will
2075
be available). In addition, we allocate no less than how much
2076
was already allocated. However below we report a warning and
2077
recompute values only if we got less file handles than were
2078
explicitly requested. No warning and re-computation occur if we
2079
can't get max_connections*5 but still got no less than was
2080
requested (value of wanted_files).
2082
max_open_files= cmax(cmax((uint32_t)wanted_files, max_connections*5),
2084
files= my_set_max_open_files(max_open_files);
2086
if (files < wanted_files)
1379
string file_entry((*iter)->filename);
1381
if (not file_entry.empty()
1382
&& file_entry != "."
1383
&& file_entry != "..")
2088
if (!open_files_limit)
1385
string the_entry(config_conf_d_location);
1386
the_entry.push_back('/');
1387
the_entry.append(file_entry);
1388
defaults_file_list.push_back(the_entry);
2091
If we have requested too much file handles than we bring
2092
max_connections in supported bounds.
2094
max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
2097
Decrease table_cache_size according to max_connections, but
2098
not below TABLE_OPEN_CACHE_MIN. Outer cmin() ensures that we
2099
never increase table_cache_size automatically (that could
2100
happen if max_connections is decreased above).
2102
table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
2103
(uint32_t)TABLE_OPEN_CACHE_MIN),
2105
if (global_system_variables.log_warnings)
2106
sql_print_warning(_("Changed limits: max_open_files: %u "
2107
"max_connections: %ld table_cache: %ld"),
2108
files, max_connections, table_cache_size);
1394
process_defaults_files();
1399
/* Inverted Booleans */
1401
global_system_variables.optimizer_prune_level=
1402
vm.count("disable-optimizer-prune") ? false : true;
1404
if (vm.count("help") == 0 && vm.count("help-extended") == 0)
1406
if ((user_info= check_user(drizzled_user)))
1408
set_user(drizzled_user, user_info);
1414
current_pid= getpid(); /* Save for later ref */
1415
init_time(); /* Init time-functions (read zone) */
2110
else if (global_system_variables.log_warnings)
2111
sql_print_warning(_("Could not increase number of max_open_files "
2112
"to more than %u (request: %u)"),
2113
files, wanted_files);
2115
open_files_limit= files;
2117
unireg_init(0); /* Set up extern variabels */
2118
if (init_errmessage()) /* Read error messages from file */
1417
2121
if (item_create_init())
1419
2124
if (set_var_init())
1421
/* Creates static regex matching for temporal values */
1422
if (! init_temporal_formats())
2126
if (init_replication_sys_vars())
1425
if (!(default_charset_info=
1426
get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
2129
Process a comma-separated character set list and choose
2130
the first available character set. This is mostly for
2131
test purposes, to be able to start "mysqld" even if
2132
the requested character set is not available (see bug#18743).
1428
errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1429
return 1; // Eof of the list
2136
char *next_character_set_name= strchr(default_character_set_name, ',');
2137
if (next_character_set_name)
2138
*next_character_set_name++= '\0';
2139
if (!(default_charset_info=
2140
get_charset_by_csname(default_character_set_name,
2141
MY_CS_PRIMARY, MYF(MY_WME))))
2143
if (next_character_set_name)
2145
default_character_set_name= next_character_set_name;
2146
default_collation_name= 0; // Ignore collation
2149
return 1; // Eof of the list
1432
2155
if (default_collation_name)
1434
const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1435
if (not default_collation)
2157
const CHARSET_INFO * const default_collation=
2158
get_charset_by_name(default_collation_name, MYF(0));
2159
if (!default_collation)
1437
errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
2161
sql_print_error(_(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1440
if (not my_charset_same(default_charset_info, default_collation))
2164
if (!my_charset_same(default_charset_info, default_collation))
1442
errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1443
default_collation_name,
1444
default_charset_info->csname);
2166
sql_print_error(_(ER(ER_COLLATION_CHARSET_MISMATCH)),
2167
default_collation_name,
2168
default_charset_info->csname);
1447
2171
default_charset_info= default_collation;
1449
2173
/* Set collactions that depends on the default collation */
1450
2174
global_system_variables.collation_server= default_charset_info;
1452
if (not (character_set_filesystem=
1453
get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1455
errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
2175
global_system_variables.collation_database= default_charset_info;
2176
global_system_variables.collation_connection= default_charset_info;
2177
global_system_variables.character_set_results= default_charset_info;
2178
global_system_variables.character_set_client= default_charset_info;
2180
global_system_variables.optimizer_use_mrr= 1;
2181
global_system_variables.optimizer_switch= 0;
2183
if (!(character_set_filesystem=
2184
get_charset_by_csname(character_set_filesystem_name,
2185
MY_CS_PRIMARY, MYF(MY_WME))))
1458
2187
global_system_variables.character_set_filesystem= character_set_filesystem;
1460
2189
if (!(my_default_lc_time_names=
1461
2190
my_locale_by_name(lc_time_names_name)))
1463
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
2192
sql_print_error(_("Unknown locale: '%s'"), lc_time_names_name);
1466
2195
global_system_variables.lc_time_names= my_default_lc_time_names;
1468
/* Reset table_alias_charset */
2197
sys_init_connect.value_length= 0;
2198
if ((sys_init_connect.value= opt_init_connect))
2199
sys_init_connect.value_length= strlen(opt_init_connect);
2201
sys_init_connect.value=my_strdup("",MYF(0));
2203
sys_init_slave.value_length= 0;
2204
if ((sys_init_slave.value= opt_init_slave))
2205
sys_init_slave.value_length= strlen(opt_init_slave);
2207
sys_init_slave.value=my_strdup("",MYF(0));
2209
if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2211
if (my_database_names_init())
2215
/* Reset table_alias_charset, now that lower_case_table_names is set. */
2216
lower_case_table_names= 1; /* This we need to look at */
1469
2217
table_alias_charset= files_charset_info;
1475
int init_server_components(module::Registry &plugins)
2223
static int init_thread_environment()
2225
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
2226
(void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
2227
(void) pthread_mutex_init(&LOCK_open, NULL);
2228
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
2229
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2230
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
2231
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
2232
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2233
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2234
(void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
2235
(void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
2236
(void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
2237
(void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2238
(void) my_rwlock_init(&LOCK_sys_init_connect, NULL);
2239
(void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
2240
(void) pthread_cond_init(&COND_thread_count,NULL);
2241
(void) pthread_cond_init(&COND_refresh,NULL);
2242
(void) pthread_cond_init(&COND_global_read_lock,NULL);
2243
(void) pthread_cond_init(&COND_thread_cache,NULL);
2244
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
2246
/* Parameter for threads created for connections */
2247
(void) pthread_attr_init(&connection_attrib);
2248
(void) pthread_attr_setdetachstate(&connection_attrib,
2249
PTHREAD_CREATE_DETACHED);
2250
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
2252
struct sched_param tmp_sched_param;
2254
memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
2255
tmp_sched_param.sched_priority= WAIT_PRIOR;
2256
(void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
2259
if (pthread_key_create(&THR_Session,NULL) ||
2260
pthread_key_create(&THR_MALLOC,NULL))
2262
sql_print_error(_("Can't create thread-keys"));
2269
static int init_server_components()
1478
2272
We need to call each of these following functions to ensure that
1479
2273
all things are initialized so that unireg_abort() doesn't fail
1481
if (table_cache_init())
1483
errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
2275
if (table_cache_init() | table_def_init())
1484
2276
unireg_abort(1);
1486
TableShare::cacheStart();
2278
randominit(&sql_rand,(uint32_t) server_start_time,(uint32_t) server_start_time/2);
1490
2282
/* Setup logs */
2285
Enable old-fashioned error log, except when the user has requested
2286
help information. Since the implementation of plugin server
2287
variables the help output is now written much later.
2289
if (opt_error_log && !opt_help)
2291
if (!log_error_file_ptr[0])
2292
fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
2293
MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
2295
fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
2296
MY_UNPACK_FILENAME | MY_SAFE_PATH);
2297
if (!log_error_file[0])
2298
opt_error_log= 1; // Too long file name
2301
if (freopen(log_error_file, "a+", stdout)==NULL)
2302
sql_print_error(_("Unable to reopen stdout"));
2304
if(freopen(log_error_file, "a+", stderr)==NULL)
2305
sql_print_error(_("Unable to reopen stderr"));
1492
2309
if (xid_cache_init())
1494
errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
2311
sql_print_error(_("Out of memory"));
2316
if (opt_binlog_format_id != BINLOG_FORMAT_UNSPEC)
2318
sql_print_error(_("You need to use --log-bin to make "
2319
"--binlog-format work."));
2324
global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2327
if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
2328
global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2331
assert(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
2334
/* Check that we have not let the format to unspecified at this point */
2335
assert((uint)global_system_variables.binlog_format <=
2336
array_elements(binlog_format_names)-1);
2338
if (opt_log_slave_updates && replicate_same_server_id)
2340
sql_print_error(_("using --replicate-same-server-id in conjunction with "
2341
"--log-slave-updates is impossible, it would lead to "
2342
"infinite loops in this server."));
2348
char buf[FN_REFLEN];
2350
ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
2351
if (!opt_bin_logname && !opt_binlog_index_name)
2354
User didn't give us info to name the binlog index file.
2355
Picking `hostname`-bin.index like did in 4.x, causes replication to
2356
fail if the hostname is changed later. So, we would like to instead
2357
require a name. But as we don't want to break many existing setups, we
2358
only give warning, not error.
2360
sql_print_warning(_("No argument was provided to --log-bin, and "
2361
"--log-bin-index was not used; so replication "
2362
"may break when this Drizzle server acts as a "
2363
"master and has his hostname changed!! Please "
2364
"use '--log-bin=%s' to avoid this problem."), ln);
2368
free(opt_bin_logname);
2369
opt_bin_logname=my_strdup(buf, MYF(0));
2371
if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
2377
Used to specify which type of lock we need to use for queries of type
2378
INSERT ... SELECT. This will change when we have row level logging.
2383
/* call ha_init_key_cache() on all key caches to init them */
2384
process_key_caches(&ha_init_key_cache);
1498
2386
/* Allow storage engine to give real error messages */
2387
if (ha_init_errors())
1501
if (plugin_init(plugins, plugin_options))
2390
if (plugin_init(&defaults_argc, defaults_argv,
2391
(opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
2392
(opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
1503
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
2394
sql_print_error(_("Failed to initialize plugins."));
1504
2395
unireg_abort(1);
1508
if (opt_help || opt_help_extended)
1509
2399
unireg_abort(0);
1511
vector<string> final_unknown_options;
1514
// Disable allow_guessing
1515
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1516
po::parsed_options parsed=
1517
po::command_line_parser(unknown_options).style(style).
1518
options(plugin_options).extra_parser(parse_size_arg).run();
1520
final_unknown_options=
1521
po::collect_unrecognized(parsed.options, po::include_positional);
1523
po::store(parsed, vm);
1526
catch (po::invalid_command_line_syntax &err)
1528
errmsg_printf(ERRMSG_LVL_ERROR,
1530
"Use --help to get a list of available options\n"),
1531
internal::my_progname, err.what());
1534
catch (po::unknown_option &err)
1536
errmsg_printf(ERRMSG_LVL_ERROR,
1537
_("%s\nUse --help to get a list of available options\n"),
1544
plugin_finalize(plugins);
1546
string scheduler_name;
1549
scheduler_name= opt_scheduler;
1553
scheduler_name= opt_scheduler_default;
1554
opt_scheduler= opt_scheduler_default;
1557
if (plugin::Scheduler::setPlugin(scheduler_name))
1559
errmsg_printf(ERRMSG_LVL_ERROR,
1560
_("No scheduler found, cannot continue!\n"));
2401
/* we do want to exit if there are any other unknown options */
2402
if (defaults_argc > 1)
2405
char **tmp_argv= defaults_argv;
2406
struct my_option no_opts[]=
2408
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2411
We need to eat any 'loose' arguments first before we conclude
2412
that there are unprocessed options.
2413
But we need to preserve defaults_argv pointer intact for
2414
free_defaults() to work. Thus we use a copy here.
2416
my_getopt_skip_unknown= 0;
2418
if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts,
2419
mysqld_get_one_option)))
2420
unireg_abort(ho_error);
2425
_("%s: Too many arguments (first extra is '%s').\n"
2426
"Use --verbose --help to get a list of available options\n"),
2427
my_progname, *tmp_argv);
1561
2428
unireg_abort(1);
1565
This is entirely for legacy. We will create a new "disk based" engine and a
1566
"memory" engine which will be configurable longterm.
1568
const std::string myisam_engine_name("MyISAM");
1569
const std::string heap_engine_name("MEMORY");
1570
myisam_engine= plugin::StorageEngine::findByName(myisam_engine_name);
1571
heap_engine= plugin::StorageEngine::findByName(heap_engine_name);
2432
/* We have to initialize the storage engines before CSV logging */
2435
sql_print_error(_("Can't init databases"));
1574
2440
Check that the default storage engine is actually available.
1576
2442
if (default_storage_engine_str)
1578
const std::string name(default_storage_engine_str);
1579
plugin::StorageEngine *engine;
1581
engine= plugin::StorageEngine::findByName(name);
1584
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1585
default_storage_engine_str);
1588
global_system_variables.storage_engine= engine;
1591
if (plugin::XaResourceManager::recoverAllXids())
1593
/* This function alredy generates error messages */
2444
LEX_STRING name= { default_storage_engine_str,
2445
strlen(default_storage_engine_str) };
2449
if ((plugin= ha_resolve_by_name(0, &name)))
2451
hton= plugin_data(plugin,handlerton *);
2455
sql_print_error(_("Unknown/unsupported table type: %s"),
2456
default_storage_engine_str);
2459
if (!ha_storage_engine_is_enabled(hton))
2461
sql_print_error(_("Default storage engine (%s) is not available"),
2462
default_storage_engine_str);
2464
assert(global_system_variables.table_plugin);
2469
Need to unlock as global_system_variables.table_plugin
2470
was acquired during plugin_init()
2472
plugin_unlock(0, global_system_variables.table_plugin);
2473
global_system_variables.table_plugin= plugin;
2477
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ?
2478
(TC_LOG *) &mysql_bin_log :
2479
(TC_LOG *) &tc_log_mmap) :
2480
(TC_LOG *) &tc_log_dummy);
2482
if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file))
2484
sql_print_error(_("Can't initialize tc_log"));
2493
if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
2494
WRITE_CACHE, 0, max_binlog_size, 0))
2497
if (opt_bin_log && expire_logs_days)
2499
time_t purge_time= server_start_time - expire_logs_days*24*60*60;
2500
if (purge_time >= 0)
2501
mysql_bin_log.purge_logs_before_date(purge_time);
2504
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2505
if (locked_in_memory && !getuid())
2507
if (setreuid((uid_t)-1, 0) == -1)
2508
{ // this should never happen
2509
sql_perror("setreuid");
2512
if (mlockall(MCL_CURRENT))
2514
if (global_system_variables.log_warnings)
2515
sql_print_warning(_("Failed to lock memory. Errno: %d\n"),errno);
2516
locked_in_memory= 0;
2519
set_user(mysqld_user, user_info);
1597
2525
init_update_queries();
2530
int main(int argc, char **argv)
2532
#if defined(ENABLE_NLS)
2533
# if defined(HAVE_LOCALE_H)
2534
setlocale(LC_ALL, "");
2536
bindtextdomain("drizzle", LOCALEDIR);
2537
textdomain("drizzle");
2540
MY_INIT(argv[0]); // init my_sys library & pthreads
2541
/* nothing should come before this line ^^^ */
2543
/* Set signal used to kill MySQL */
2544
#if defined(SIGUSR2)
2545
thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
2547
thr_kill_signal= SIGINT;
2551
Perform basic logger initialization logger. Should be called after
2552
MY_INIT, as it initializes mutexes. Log tables are inited later.
2556
#ifdef _CUSTOMSTARTUPCONFIG_
2557
if (_cust_check_startup())
2559
/ * _cust_check_startup will report startup failure error * /
2564
if (init_common_variables(DRIZZLE_CONFIG_NAME,
2565
argc, argv, load_default_groups))
2566
unireg_abort(1); // Will do exit
2570
pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
2572
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
2574
/* Retrieve used stack size; Needed for checking stack overflows */
2575
size_t stack_size= 0;
2576
pthread_attr_getstacksize(&connection_attrib, &stack_size);
2577
/* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
2578
if (stack_size && stack_size < my_thread_stack_size)
2580
if (global_system_variables.log_warnings)
2582
/* %zu is not yet in C++ */
2583
uint64_t size_tmp= (uint64_t)stack_size;
2584
sql_print_warning(_("Asked for %u thread stack, but got %"PRIu64),
2585
my_thread_stack_size, size_tmp);
2587
my_thread_stack_size= stack_size;
2592
select_thread=pthread_self();
2593
select_thread_in_use=1;
2596
We have enough space for fiddling with the argv, continue
2598
check_data_home(mysql_real_data_home);
2599
if (my_setwd(mysql_real_data_home,MYF(MY_WME)) && !opt_help)
2600
unireg_abort(1); /* purecov: inspected */
2601
mysql_data_home= mysql_data_home_buff;
2602
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
2603
mysql_data_home[1]=0;
2604
mysql_data_home_len= 2;
2606
if ((user_info= check_user(mysqld_user)))
2608
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2609
if (locked_in_memory) // getuid() == 0 here
2610
set_effective_user(user_info);
2613
set_user(mysqld_user, user_info);
2616
if (opt_bin_log && !server_id)
2620
sql_print_warning(_("You have enabled the binary log, but you haven't set "
2621
"server-id to a non-zero value: we force server id to "
2622
"1; updates will be logged to the binary log, but "
2623
"connections from slaves will not be accepted."));
2627
if (init_server_components())
2633
Initialize my_str_malloc() and my_str_free()
2635
my_str_malloc= &my_str_malloc_mysqld;
2636
my_str_free= &my_str_free_mysqld;
2639
init signals & alarm
2640
After this we can't quit by a simple unireg_abort
2642
error_handler_hook= my_message_sql;
2643
start_signal_handler(); // Creates pidfile
2645
if (mysql_rm_tmp_tables() || my_tz_init((Session *)0, default_tz_name))
2648
select_thread_in_use=0;
2649
(void) pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
2651
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
2658
init_slave() must be called after the thread keys are created.
2659
Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other
2660
places) assume that active_mi != 0, so let's fail if it's 0 (out of
2661
memory); a message has already been printed.
2663
if (init_slave() && !active_mi)
2668
sql_print_information(_(ER(ER_STARTUP)),my_progname,server_version,
2669
"", mysqld_port, COMPILATION_COMMENT);
2672
handle_connections_sockets();
2674
/* (void) pthread_attr_destroy(&connection_attrib); */
2678
sql_print_error(_("Before Lock_thread_count"));
2680
(void) pthread_mutex_lock(&LOCK_thread_count);
2681
select_thread_in_use=0; // For close_connections
2682
(void) pthread_mutex_unlock(&LOCK_thread_count);
2683
(void) pthread_cond_broadcast(&COND_thread_count);
2685
sql_print_error(_("After lock_thread_count"));
2688
/* Wait until cleanup is done */
2689
(void) pthread_mutex_lock(&LOCK_thread_count);
2690
while (!ready_to_exit)
2691
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
2692
(void) pthread_mutex_unlock(&LOCK_thread_count);
2700
Create new thread to handle incoming connection.
2702
This function will create new thread to handle the incoming
2703
connection. If there are idle cached threads one will be used.
2704
'session' will be pushed into 'threads'.
2706
In single-threaded mode (\#define ONE_THREAD) connection will be
2707
handled inside this function.
2709
@param[in,out] session Thread handle of future thread.
2712
static void create_new_thread(Session *session)
2716
Don't allow too many connections. We roughly check here that we allow
2717
only (max_connections + 1) connections.
2720
pthread_mutex_lock(&LOCK_connection_count);
2722
if (connection_count >= max_connections + 1 || abort_loop)
2724
pthread_mutex_unlock(&LOCK_connection_count);
2726
close_connection(session, ER_CON_COUNT_ERROR, 1);
2733
if (connection_count > max_used_connections)
2734
max_used_connections= connection_count;
2736
pthread_mutex_unlock(&LOCK_connection_count);
2738
/* Start a new thread to handle connection. */
2740
pthread_mutex_lock(&LOCK_thread_count);
2743
The initialization of thread_id is done in create_embedded_session() for
2744
the embedded library.
2745
TODO: refactor this to avoid code duplication there
2747
session->thread_id= session->variables.pseudo_thread_id= thread_id++;
2751
thread_scheduler.add_connection(session);
2757
#ifdef SIGNALS_DONT_BREAK_READ
2758
inline void kill_broken_server()
2760
/* hack to get around signals ignored in syscalls for problem OS's */
2761
if ((ip_sock == -1))
2763
select_thread_in_use = 0;
2764
/* The following call will never return */
2765
kill_server((void*) DRIZZLE_KILL_SIGNAL);
2768
#define MAYBE_BROKEN_SYSCALL kill_broken_server();
2770
#define MAYBE_BROKEN_SYSCALL
2773
/* Handle new connections and spawn new process to handle them */
2775
void handle_connections_sockets()
2779
uint32_t error_count=0;
2781
struct sockaddr_storage cAddr;
2783
MAYBE_BROKEN_SYSCALL;
2788
if ((number_of= poll(fds, pollfd_count, -1)) == -1)
2792
if (!select_errors++ && !abort_loop) /* purecov: inspected */
2793
sql_print_error(_("drizzled: Got error %d from select"),
2794
errno); /* purecov: inspected */
2796
MAYBE_BROKEN_SYSCALL
2802
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
2803
assert(number_of > 1); /* Not handling this at the moment */
2808
MAYBE_BROKEN_SYSCALL;
2812
for (x= 0, sock= -1; x < pollfd_count; x++)
2814
if (fds[x].revents == POLLIN)
2822
for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2824
SOCKET_SIZE_TYPE length= sizeof(struct sockaddr_storage);
2825
new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2827
if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
2834
if ((error_count++ & 255) == 0) // This can happen often
2835
sql_perror("Error in accept");
2836
MAYBE_BROKEN_SYSCALL;
2837
if (errno == ENFILE || errno == EMFILE)
2838
sleep(1); // Give other threads some time
2843
SOCKET_SIZE_TYPE dummyLen;
2844
struct sockaddr_storage dummy;
2845
dummyLen = sizeof(dummy);
2846
if ( getsockname(new_sock,(struct sockaddr *)&dummy,
2847
(socklen_t *)&dummyLen) < 0 )
2849
sql_perror("Error on new connection socket");
2850
(void) shutdown(new_sock, SHUT_RDWR);
2851
(void) close(new_sock);
2854
dummyLen = sizeof(dummy);
2855
if ( getpeername(new_sock, (struct sockaddr *)&dummy,
2856
(socklen_t *)&dummyLen) < 0)
2858
sql_perror("Error on new connection socket");
2859
(void) shutdown(new_sock, SHUT_RDWR);
2860
(void) close(new_sock);
2866
** Don't allow too many connections
2869
if (!(session= new Session))
2871
(void) shutdown(new_sock, SHUT_RDWR);
2875
if (net_init_sock(&session->net, new_sock, sock == 0))
2881
create_new_thread(session);
1603
2886
/****************************************************************************
1604
2887
Handle start options
1605
2888
******************************************************************************/
1607
enum options_drizzled
2892
OPT_ISAM_LOG=256, OPT_SKIP_NEW,
2894
OPT_ENABLE_LOCK, OPT_USE_LOCKING,
2895
OPT_SOCKET, OPT_UPDATE_LOG,
2898
OPT_BIND_ADDRESS, OPT_PID_FILE,
2901
OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES,
2902
OPT_SHORT_LOG_FORMAT,
2903
OPT_FLUSH, OPT_SAFE,
2904
OPT_STORAGE_ENGINE, OPT_INIT_FILE,
2905
OPT_DELAY_KEY_WRITE_ALL,
2906
OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR,
2907
OPT_MASTER_INFO_FILE,
2908
OPT_MASTER_RETRY_COUNT, OPT_LOG_TC, OPT_LOG_TC_SIZE,
2909
OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB,
2910
OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES,
2911
OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB,
2913
OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
1617
OPT_TC_HEURISTIC_RECOVER,
2915
OPT_MEMLOCK, OPT_MYISAM_RECOVER,
2916
OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID,
2917
OPT_SKIP_SLAVE_START,
2918
OPT_REPLICATE_DO_TABLE,
2919
OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
2920
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
2921
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
2922
OPT_ABORT_SLAVE_EVENT_COUNT,
2923
OPT_ENGINE_CONDITION_PUSHDOWN,
1618
2924
OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
1619
2925
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
1624
OPT_MAX_ALLOWED_PACKET,
1625
OPT_MAX_CONNECT_ERRORS,
2926
OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
2927
OPT_SAFE_USER_CREATE,
2928
OPT_DO_PSTACK, OPT_REPORT_HOST,
2929
OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT,
2930
OPT_SHOW_SLAVE_AUTH_INFO,
2931
OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE,
2932
OPT_RPL_RECOVERY_RANK,
2933
OPT_RELAY_LOG, OPT_RELAY_LOG_INDEX, OPT_RELAY_LOG_INFO_FILE,
2934
OPT_SLAVE_SKIP_ERRORS, OPT_SLAVE_ALLOW_BATCHING, OPT_DES_KEY_FILE, OPT_LOCAL_INFILE,
2935
OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA,
2936
OPT_SSL_CAPATH, OPT_SSL_CIPHER,
2937
OPT_BACK_LOG, OPT_BINLOG_CACHE_SIZE,
2938
OPT_CONNECT_TIMEOUT,
2940
OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
2941
OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
2942
OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
2943
OPT_LONG_QUERY_TIME,
2944
OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
2945
OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
2946
OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
1626
2947
OPT_MAX_HEP_TABLE_SIZE,
1627
2948
OPT_MAX_JOIN_SIZE,
1628
OPT_MAX_SORT_LENGTH,
2949
OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH,
1629
2950
OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
1630
2951
OPT_MAX_LENGTH_FOR_SORT_DATA,
1631
2952
OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
1633
2954
OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
1634
2955
OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
1635
2956
OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
1636
OPT_NET_BUFFER_LENGTH,
2957
OPT_MYISAM_STATS_METHOD,
2958
OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
2959
OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
2960
OPT_OPEN_FILES_LIMIT,
1637
2961
OPT_PRELOAD_BUFFER_SIZE,
1638
2962
OPT_RECORD_BUFFER,
1639
OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT,
2963
OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT,
2964
OPT_RELAY_LOG_PURGE,
2965
OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
2966
OPT_SLAVE_TRANS_RETRIES, OPT_READONLY, OPT_DEBUGGING,
1641
2967
OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE,
2968
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
1642
2969
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
1643
2970
OPT_WAIT_TIMEOUT,
2972
OPT_DEFAULT_WEEK_FORMAT,
1644
2973
OPT_RANGE_ALLOC_BLOCK_SIZE,
1645
2974
OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
1646
2975
OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
2976
OPT_SYNC_FRM, OPT_SYNC_BINLOG,
2977
OPT_SYNC_REPLICATION,
2978
OPT_SYNC_REPLICATION_SLAVE_ID,
2979
OPT_SYNC_REPLICATION_TIMEOUT,
2980
OPT_ENABLE_SHARED_MEMORY,
2981
OPT_SHARED_MEMORY_BASE_NAME,
1647
2982
OPT_OLD_ALTER_TABLE,
2983
OPT_EXPIRE_LOGS_DAYS,
1648
2984
OPT_GROUP_CONCAT_MAX_LEN,
1649
2985
OPT_DEFAULT_COLLATION,
2986
OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
1650
2987
OPT_CHARACTER_SET_FILESYSTEM,
1651
2988
OPT_LC_TIME_NAMES,
1652
2989
OPT_INIT_CONNECT,
2994
OPT_DATETIME_FORMAT,
1653
2995
OPT_DEFAULT_TIME_ZONE,
1654
2997
OPT_OPTIMIZER_SEARCH_DEPTH,
1657
2998
OPT_OPTIMIZER_PRUNE_LEVEL,
2999
OPT_UPDATABLE_VIEWS_WITH_LIMIT,
1658
3000
OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET,
1659
3001
OPT_ENABLE_LARGE_PAGES,
1660
3002
OPT_TIMED_MUTEXES,
3003
OPT_OLD_STYLE_USER_LIMITS,
1661
3004
OPT_TABLE_LOCK_WAIT_TIMEOUT,
1664
3005
OPT_PLUGIN_LOAD,
1665
3006
OPT_PLUGIN_DIR,
1666
3007
OPT_PORT_OPEN_TIMEOUT,
3009
OPT_KEEP_FILES_ON_CREATE,
3011
OPT_THREAD_HANDLING,
3012
OPT_INNODB_ROLLBACK_ON_TIMEOUT,
1667
3013
OPT_SECURE_FILE_PRIV,
1668
3014
OPT_MIN_EXAMINED_ROW_LIMIT,
3016
OPT_POOL_OF_THREADS,
1673
struct option my_long_options[] =
3021
#define LONG_TIMEOUT ((uint32_t) 3600L*24L*365L)
3023
struct my_option my_long_options[] =
1676
3025
{"help", '?', N_("Display this help and exit."),
1677
3026
(char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1679
{"help-extended", '?',
1680
N_("Display this help and exit after initializing plugins."),
1681
(char**) &opt_help_extended, (char**) &opt_help_extended,
1682
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3028
{"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT,
3029
N_("Option used by mysql-test for debugging and testing of replication."),
3030
(char**) &abort_slave_event_count, (char**) &abort_slave_event_count,
3031
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1683
3032
{"auto-increment-increment", OPT_AUTO_INCREMENT,
1684
3033
N_("Auto-increment columns are incremented by this"),
1685
3034
(char**) &global_system_variables.auto_increment_increment,
1686
(char**) &max_system_variables.auto_increment_increment, 0, GET_ULL,
1687
OPT_ARG, 1, 1, UINT64_MAX, 0, 1, 0 },
3035
(char**) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
3036
OPT_ARG, 1, 1, 65535, 0, 1, 0 },
1688
3037
{"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
1689
3038
N_("Offset added to Auto-increment columns. Used when "
1690
3039
"auto-increment-increment != 1"),
1691
3040
(char**) &global_system_variables.auto_increment_offset,
1692
(char**) &max_system_variables.auto_increment_offset, 0, GET_ULL, OPT_ARG,
1693
1, 1, UINT64_MAX, 0, 1, 0 },
3041
(char**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
3042
1, 1, 65535, 0, 1, 0 },
1694
3043
{"basedir", 'b',
1695
3044
N_("Path to installation directory. All paths are usually resolved "
1696
3045
"relative to this."),
1697
(char**) &drizzle_home_ptr, (char**) &drizzle_home_ptr, 0, GET_STR, REQUIRED_ARG,
3046
(char**) &mysql_home_ptr, (char**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
1698
3047
0, 0, 0, 0, 0, 0},
3048
{"bind-address", OPT_BIND_ADDRESS, N_("IP address to bind to."),
3049
(char**) &my_bind_addr_str, (char**) &my_bind_addr_str, 0, GET_STR,
3050
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3051
{"binlog_format", OPT_BINLOG_FORMAT,
3052
N_("Does not have any effect without '--log-bin'. "
3053
"Tell the master the form of binary logging to use: either 'row' for "
3054
"row-based binary logging, or 'statement' for statement-based binary "
3055
"logging, or 'mixed'. 'mixed' is statement-based binary logging except "
3056
"for those statements where only row-based is correct: those which "
3057
"involve user-defined functions (i.e. UDFs) or the UUID() function; for "
3058
"those, row-based binary logging is automatically used. ")
3059
,(char**) &opt_binlog_format, (char**) &opt_binlog_format,
3060
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3061
{"binlog-do-db", OPT_BINLOG_DO_DB,
3062
N_("Tells the master it should log updates for the specified database, and "
3063
"exclude all others not explicitly mentioned."),
3064
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3065
{"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
3066
N_("Tells the master that updates to the given database should not "
3067
"be logged tothe binary log."),
3068
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3069
{"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
3070
N_("The maximum size of a row-based binary log event in bytes. Rows will "
3071
"be grouped into events smaller than this size if possible. "
3072
"The value has to be a multiple of 256."),
3073
(char**) &opt_binlog_rows_event_max_size,
3074
(char**) &opt_binlog_rows_event_max_size, 0,
3075
GET_ULONG, REQUIRED_ARG,
3076
/* def_value */ 1024, /* min_value */ 256, /* max_value */ ULONG_MAX,
3077
/* sub_size */ 0, /* block_size */ 256,
3080
{"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
3081
N_("Don't ignore client side character set value sent during handshake."),
3082
(char**) &opt_character_set_client_handshake,
3083
(char**) &opt_character_set_client_handshake,
3084
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
3085
{"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM,
3086
N_("Set the filesystem character set."),
3087
(char**) &character_set_filesystem_name,
3088
(char**) &character_set_filesystem_name,
3089
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3090
{"character-set-server", 'C',
3091
N_("Set the default character set."),
3092
(char**) &default_character_set_name, (char**) &default_character_set_name,
3093
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3094
{"character-sets-dir", OPT_CHARSETS_DIR,
3095
N_("Directory where character sets are."), (char**) &charsets_dir,
3096
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1699
3097
{"chroot", 'r',
1700
N_("Chroot drizzled daemon during startup."),
1701
(char**) &drizzled_chroot, (char**) &drizzled_chroot, 0, GET_STR, REQUIRED_ARG,
3098
N_("Chroot mysqld daemon during startup."),
3099
(char**) &mysqld_chroot, (char**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
1702
3100
0, 0, 0, 0, 0, 0},
1703
3101
{"collation-server", OPT_DEFAULT_COLLATION,
1704
3102
N_("Set the default collation."),
1743
3181
(char**) &lc_time_names_name,
1744
3182
(char**) &lc_time_names_name,
1745
3183
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3184
{"local-infile", OPT_LOCAL_INFILE,
3185
N_("Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)."),
3186
(char**) &opt_local_infile,
3187
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
3190
N_("Log connections and queries to file."),
3191
(char**) &opt_logname,
3192
(char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3193
{"log-bin", OPT_BIN_LOG,
3194
N_("Log update queries in binary format. Optional argument is the "
3195
"location for the binary log files.(Strongly "
3196
"recommended to avoid replication problems if server's hostname "
3198
(char**) &opt_bin_logname, (char**) &opt_bin_logname, 0, GET_STR_ALLOC,
3199
OPT_ARG, 0, 0, 0, 0, 0, 0},
3200
{"log-bin-index", OPT_BIN_LOG_INDEX,
3201
N_("File that holds the names for last binary log files."),
3202
(char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
3203
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3204
{"log-error", OPT_ERROR_LOG_FILE,
3205
N_("Error log file."),
3206
(char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
3207
OPT_ARG, 0, 0, 0, 0, 0, 0},
3208
{"log-isam", OPT_ISAM_LOG,
3209
N_("Log all MyISAM changes to file."),
3210
(char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3211
OPT_ARG, 0, 0, 0, 0, 0, 0},
3212
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
3213
N_("Tells the slave to log the updates from the slave thread to the binary "
3214
"log. You will need to turn it on if you plan to "
3215
"daisy-chain the slaves."),
3216
(char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3218
NO_ARG, 0, 0, 0, 0, 0, 0},
3219
{"log-tc", OPT_LOG_TC,
3220
N_("Path to transaction coordinator log (used for transactions that affect "
3221
"more than one storage engine, when binary log is disabled)"),
3222
(char**) &opt_tc_log_file, (char**) &opt_tc_log_file, 0, GET_STR,
3223
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3225
{"log-tc-size", OPT_LOG_TC_SIZE,
3226
N_("Size of transaction coordinator log."),
3227
(char**) &opt_tc_log_size, (char**) &opt_tc_log_size, 0, GET_ULONG,
3228
REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
3229
TC_LOG_PAGE_SIZE, 0},
1746
3231
{"log-warnings", 'W',
1747
3232
N_("Log some not critical warnings to the log file."),
1748
3233
(char**) &global_system_variables.log_warnings,
1749
(char**) &max_system_variables.log_warnings, 0, GET_BOOL, OPT_ARG, 1, 0, 0,
3234
(char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
3236
{"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
3237
N_("INSERT/DELETE/UPDATE has lower priority than selects."),
3238
(char**) &global_system_variables.low_priority_updates,
3239
(char**) &max_system_variables.low_priority_updates,
3240
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3241
{"master-info-file", OPT_MASTER_INFO_FILE,
3242
N_("The location and name of the file that remembers the master and "
3243
"where the I/O replication thread is in the master's binlogs."),
3244
(char**) &master_info_file, (char**) &master_info_file, 0, GET_STR,
3245
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3246
{"master-retry-count", OPT_MASTER_RETRY_COUNT,
3247
N_("The number of tries the slave will make to connect to the master "
3248
"before giving up."),
3249
(char**) &master_retry_count, (char**) &master_retry_count, 0, GET_ULONG,
3250
REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
3251
{"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS,
3252
N_("Option used by mysql-test for debugging and testing of replication."),
3253
(char**) &max_binlog_dump_events, (char**) &max_binlog_dump_events, 0,
3254
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3255
{"memlock", OPT_MEMLOCK,
3256
N_("Lock mysqld in memory."),
3257
(char**) &locked_in_memory,
3258
(char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3259
{"myisam-recover", OPT_MYISAM_RECOVER,
3260
N_("Syntax: myisam-recover[=option[,option...]], where option can be "
3261
"DEFAULT, BACKUP, FORCE or QUICK."),
3262
(char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
3263
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3265
N_("Use very new possible 'unsafe' functions."),
3266
(char**) &global_system_variables.new_mode,
3267
(char**) &max_system_variables.new_mode,
3268
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3269
{"old-alter-table", OPT_OLD_ALTER_TABLE,
3270
N_("Use old, non-optimized alter table."),
3271
(char**) &global_system_variables.old_alter_table,
3272
(char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
1751
3274
{"pid-file", OPT_PID_FILE,
1752
N_("Pid file used by drizzled."),
3275
N_("Pid file used by safe_mysqld."),
1753
3276
(char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
1754
3277
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3279
N_("Port number to use for connection or 0 for default to, in "
3280
"order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
3281
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
3282
(char**) &mysqld_port,
3283
(char**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1755
3284
{"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
1756
3285
N_("Maximum time in seconds to wait for the port to become free. "
1757
3286
"(Default: no wait)"),
1758
(char**) &drizzled_bind_timeout,
1759
(char**) &drizzled_bind_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3287
(char**) &mysqld_port_timeout,
3288
(char**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3289
{"relay-log", OPT_RELAY_LOG,
3290
N_("The location and name to use for relay logs."),
3291
(char**) &opt_relay_logname, (char**) &opt_relay_logname, 0,
3292
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3293
{"relay-log-index", OPT_RELAY_LOG_INDEX,
3294
N_("The location and name to use for the file that keeps a list of the "
3295
"last relay logs."),
3296
(char**) &opt_relaylog_index_name, (char**) &opt_relaylog_index_name, 0,
3297
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3298
{"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE,
3299
N_("The location and name of the file that remembers where the SQL "
3300
"replication thread is in the relay logs."),
3301
(char**) &relay_log_info_file, (char**) &relay_log_info_file, 0, GET_STR,
3302
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3303
{"replicate-do-db", OPT_REPLICATE_DO_DB,
3304
N_("Tells the slave thread to restrict replication to the specified "
3305
"database. To specify more than one database, use the directive "
3306
"multiple times, once for each database. Note that this will only work "
3307
"if you do not use cross-database queries such as UPDATE "
3308
"some_db.some_table SET foo='bar' while having selected a different or "
3309
"no database. If you need cross database updates to work, use "
3310
"replicate-wild-do-table=db_name.%."),
3311
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3312
{"replicate-do-table", OPT_REPLICATE_DO_TABLE,
3313
N_("Tells the slave thread to restrict replication to the specified table. "
3314
"To specify more than one table, use the directive multiple times, once "
3315
"for each table. This will work for cross-database updates, in contrast "
3316
"to replicate-do-db."),
3317
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3318
{"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB,
3319
N_("Tells the slave thread to not replicate to the specified database. To "
3320
"specify more than one database to ignore, use the directive multiple "
3321
"times, once for each database. This option will not work if you use "
3322
"cross database updates. If you need cross database updates to work, "
3323
"use replicate-wild-ignore-table=db_name.%. "),
3324
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3325
{"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
3326
N_("Tells the slave thread to not replicate to the specified table. To "
3327
"specify more than one table to ignore, use the directive multiple "
3328
"times, once for each table. This will work for cross-datbase updates, "
3329
"in contrast to replicate-ignore-db."),
3330
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3331
{"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB,
3332
N_("Updates to a database with a different name than the original. "
3333
"Example: replicate-rewrite-db=master_db_name->slave_db_name."),
3334
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3335
{"replicate-same-server-id", OPT_REPLICATE_SAME_SERVER_ID,
3336
N_("In replication, if set to 1, do not skip events having our server id. "
3337
"Default value is 0 (to break infinite loops in circular replication). "
3338
"Can't be set to 1 if --log-slave-updates is used."),
3339
(char**) &replicate_same_server_id,
3340
(char**) &replicate_same_server_id,
3341
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3342
{"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE,
3343
N_("Tells the slave thread to restrict replication to the tables that "
3344
"match the specified wildcard pattern. To specify more than one table, "
3345
"use the directive multiple times, once for each table. This will work "
3346
"for cross-database updates. Example: replicate-wild-do-table=foo%.bar% "
3347
"will replicate only updates to tables in all databases that start with "
3348
"foo and whose table names start with bar."),
3349
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3350
{"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE,
3351
N_("Tells the slave thread to not replicate to the tables that match the "
3352
"given wildcard pattern. To specify more than one table to ignore, use "
3353
"the directive multiple times, once for each table. This will work for "
3354
"cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% "
3355
"will not do updates to tables in databases that start with foo and "
3356
"whose table names start with bar."),
3357
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3358
// In replication, we may need to tell the other servers how to connect
3359
{"report-host", OPT_REPORT_HOST,
3360
N_("Hostname or IP of the slave to be reported to to the master during "
3361
"slave registration. Will appear in the output of SHOW SLAVE HOSTS. "
3362
"Leave unset if you do not want the slave to register itself with the "
3363
"master. Note that it is not sufficient for the master to simply read "
3364
"the IP of the slave off the socket once the slave connects. Due to NAT "
3365
"and other routing issues, that IP may not be valid for connecting to "
3366
"the slave from the master or other hosts."),
3367
(char**) &report_host, (char**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
3369
{"report-password", OPT_REPORT_PASSWORD, "Undocumented.",
3370
(char**) &report_password, (char**) &report_password, 0, GET_STR,
3371
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3372
{"report-port", OPT_REPORT_PORT,
3373
N_("Port for connecting to slave reported to the master during slave "
3374
"registration. Set it only if the slave is listening on a non-default "
3375
"port or if you have a special tunnel from the master or other clients "
3376
"to the slave. If not sure, leave this option unset."),
3377
(char**) &report_port, (char**) &report_port, 0, GET_UINT, REQUIRED_ARG,
3378
DRIZZLE_PORT, 0, 0, 0, 0, 0},
3379
{"safe-mode", OPT_SAFE,
3380
N_("Skip some optimize stages (for testing)."),
3381
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1760
3382
{"secure-file-priv", OPT_SECURE_FILE_PRIV,
1761
3383
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1762
3384
"within specified directory"),
1802
3472
0, 0, 0, GET_NO_ARG,
1803
3473
NO_ARG, 0, 0, 0, 0, 0, 0},
1804
3474
{"back_log", OPT_BACK_LOG,
1805
N_("The number of outstanding connection requests Drizzle can have. This "
1806
"comes into play when the main Drizzle thread gets very many connection "
3475
N_("The number of outstanding connection requests MySQL can have. This "
3476
"comes into play when the main MySQL thread gets very many connection "
1807
3477
"requests in a very short time."),
1808
(char**) &back_log, (char**) &back_log, 0, GET_UINT,
3478
(char**) &back_log, (char**) &back_log, 0, GET_ULONG,
1809
3479
REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
3480
{ "binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
3481
N_("The size of the cache to hold the SQL statements for the binary log "
3482
"during a transaction. If you often use big, multi-statement "
3483
"transactions you can increase this to get more performance."),
3484
(char**) &binlog_cache_size, (char**) &binlog_cache_size, 0, GET_ULONG,
3485
REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
1810
3486
{ "bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
1811
N_("Size of tree cache used in bulk insert optimization. Note that this is "
3487
N_("Size of tree cache used in bulk insert optimisation. Note that this is "
1812
3488
"a limit per thread!"),
1813
3489
(char**) &global_system_variables.bulk_insert_buff_size,
1814
3490
(char**) &max_system_variables.bulk_insert_buff_size,
1815
0, GET_ULL, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
3491
0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
3492
{ "connect_timeout", OPT_CONNECT_TIMEOUT,
3493
N_("The number of seconds the mysqld server is waiting for a connect "
3494
"packet before responding with 'Bad handshake'."),
3495
(char**) &connect_timeout, (char**) &connect_timeout,
3496
0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
3497
{ "date_format", OPT_DATE_FORMAT,
3498
N_("The DATE format (For future)."),
3499
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
3500
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
3501
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3502
{ "datetime_format", OPT_DATETIME_FORMAT,
3503
N_("The DATETIME/TIMESTAMP format (for future)."),
3504
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
3505
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
3506
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3507
{ "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
3508
N_("The default week format used by WEEK() functions."),
3509
(char**) &global_system_variables.default_week_format,
3510
(char**) &max_system_variables.default_week_format,
3511
0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0},
1816
3512
{ "div_precision_increment", OPT_DIV_PRECINCREMENT,
1817
3513
N_("Precision of the result of '/' operator will be increased on that "
1819
3515
(char**) &global_system_variables.div_precincrement,
1820
(char**) &max_system_variables.div_precincrement, 0, GET_UINT,
3516
(char**) &max_system_variables.div_precincrement, 0, GET_ULONG,
1821
3517
REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
3518
{ "expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
3519
N_("If non-zero, binary logs will be purged after expire_logs_days "
3520
"days; possible purges happen at startup and at binary log rotation."),
3521
(char**) &expire_logs_days,
3522
(char**) &expire_logs_days, 0, GET_ULONG,
3523
REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
1822
3524
{ "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
1823
3525
N_("The maximum length of the result of function group_concat."),
1824
3526
(char**) &global_system_variables.group_concat_max_len,
1825
(char**) &max_system_variables.group_concat_max_len, 0, GET_UINT64,
3527
(char**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
1826
3528
REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
3529
{ "interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
3530
N_("The number of seconds the server waits for activity on an interactive "
3531
"connection before closing it."),
3532
(char**) &global_system_variables.net_interactive_timeout,
3533
(char**) &max_system_variables.net_interactive_timeout, 0,
3534
GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
1827
3535
{ "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1828
3536
N_("The size of the buffer that is used for full joins."),
1829
3537
(char**) &global_system_variables.join_buff_size,
1830
(char**) &max_system_variables.join_buff_size, 0, GET_UINT64,
3538
(char**) &max_system_variables.join_buff_size, 0, GET_ULONG,
1831
3539
REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
1832
3540
MALLOC_OVERHEAD, IO_SIZE, 0},
3541
{"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
3542
N_("Don't overwrite stale .MYD and .MYI even if no directory is specified."),
3543
(char**) &global_system_variables.keep_files_on_create,
3544
(char**) &max_system_variables.keep_files_on_create,
3545
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3546
{"key_buffer_size", OPT_KEY_BUFFER_SIZE,
3547
N_("The size of the buffer used for index blocks for MyISAM tables. "
3548
"Increase this to get better index handling (for all reads and multiple "
3549
"writes) to as much as you can afford;"),
3550
(char**) &dflt_key_cache_var.param_buff_size,
3552
0, (GET_ULL | GET_ASK_ADDR),
3553
REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
3555
{"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
3556
N_("This characterizes the number of hits a hot block has to be untouched "
3557
"until it is considered aged enough to be downgraded to a warm block. "
3558
"This specifies the percentage ratio of that number of hits to the "
3559
"total number of blocks in key cache"),
3560
(char**) &dflt_key_cache_var.param_age_threshold,
3562
0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
3563
300, 100, ULONG_MAX, 0, 100, 0},
3564
{"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
3565
N_("The default size of key cache blocks"),
3566
(char**) &dflt_key_cache_var.param_block_size,
3568
0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
3569
KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
3570
{"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
3571
N_("The minimum percentage of warm blocks in key cache"),
3572
(char**) &dflt_key_cache_var.param_division_limit,
3574
0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1833
3576
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1834
3577
N_("Max packetlength to send/receive from to server."),
1835
3578
(char**) &global_system_variables.max_allowed_packet,
1836
(char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
3579
(char**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
1837
3580
REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
3581
{"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
3582
N_("Can be used to restrict the total size used to cache a "
3583
"multi-transaction query."),
3584
(char**) &max_binlog_cache_size, (char**) &max_binlog_cache_size, 0,
3585
GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
3586
{"max_binlog_size", OPT_MAX_BINLOG_SIZE,
3587
N_("Binary log will be rotated automatically when the size exceeds this "
3588
"value. Will also apply to relay logs if max_relay_log_size is 0. "
3589
"The minimum value for this variable is 4096."),
3590
(char**) &max_binlog_size, (char**) &max_binlog_size, 0, GET_ULONG,
3591
REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0},
1838
3592
{"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
1839
3593
N_("If there is more than this number of interrupted connections from a "
1840
3594
"host this host will be blocked from further connections."),
1841
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
3595
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_ULONG,
1842
3596
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
3597
// Default max_connections of 151 is larger than Apache's default max
3598
// children, to avoid "too many connections" error in a common setup
3599
{"max_connections", OPT_MAX_CONNECTIONS,
3600
N_("The number of simultaneous clients allowed."),
3601
(char**) &max_connections,
3602
(char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
1843
3604
{"max_error_count", OPT_MAX_ERROR_COUNT,
1844
3605
N_("Max number of errors/warnings to store for a statement."),
1845
3606
(char**) &global_system_variables.max_error_count,
1846
3607
(char**) &max_system_variables.max_error_count,
1847
0, GET_UINT64, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
3608
0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
1848
3609
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1849
3610
N_("Don't allow creation of heap tables bigger than this."),
1850
3611
(char**) &global_system_variables.max_heap_table_size,
1860
3621
{"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
1861
3622
N_("Max number of bytes in sorted records."),
1862
3623
(char**) &global_system_variables.max_length_for_sort_data,
1863
(char**) &max_system_variables.max_length_for_sort_data, 0, GET_ULL,
3624
(char**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
1864
3625
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
3626
{"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE,
3627
N_("If non-zero: relay log will be rotated automatically when the size "
3628
"exceeds this value; if zero (the default): when the size exceeds "
3629
"max_binlog_size. 0 excepted, the minimum value for this variable "
3631
(char**) &max_relay_log_size, (char**) &max_relay_log_size, 0, GET_ULONG,
3632
REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0},
1865
3633
{ "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
1866
3634
N_("Limit assumed max number of seeks when looking up rows based on a key"),
1867
3635
(char**) &global_system_variables.max_seeks_for_key,
1868
(char**) &max_system_variables.max_seeks_for_key, 0, GET_UINT64,
3636
(char**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
1869
3637
REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
1870
3638
{"max_sort_length", OPT_MAX_SORT_LENGTH,
1871
3639
N_("The number of bytes to use when sorting BLOB or TEXT values "
1872
3640
"(only the first max_sort_length bytes of each value are used; the "
1873
3641
"rest are ignored)."),
1874
3642
(char**) &global_system_variables.max_sort_length,
1875
(char**) &max_system_variables.max_sort_length, 0, GET_SIZE,
3643
(char**) &max_system_variables.max_sort_length, 0, GET_ULONG,
1876
3644
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
3645
{"max_tmp_tables", OPT_MAX_TMP_TABLES,
3646
N_("Maximum number of temporary tables a client can keep open at a time."),
3647
(char**) &global_system_variables.max_tmp_tables,
3648
(char**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
3649
REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
1877
3650
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
1878
3651
N_("After this many write locks, allow some read locks to run in between."),
1879
(char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULL,
3652
(char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULONG,
1880
3653
REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
1881
3654
{"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
1882
3655
N_("Don't log queries which examine less than min_examined_row_limit "
1883
3656
"rows to file."),
1884
3657
(char**) &global_system_variables.min_examined_row_limit,
1885
(char**) &max_system_variables.min_examined_row_limit, 0, GET_ULL,
3658
(char**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
1886
3659
REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
3660
{"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
3661
N_("Block size to be used for MyISAM index pages."),
3662
(char**) &opt_myisam_block_size,
3663
(char**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
3664
MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
3665
0, MI_MIN_KEY_BLOCK_LENGTH, 0},
3666
{"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE,
3667
N_("Default pointer size to be used for MyISAM tables."),
3668
(char**) &myisam_data_pointer_size,
3669
(char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
3671
{"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
3672
N_("Don't use the fast sort index method to created index if the "
3673
"temporary file would get bigger than this."),
3674
(char**) &global_system_variables.myisam_max_sort_file_size,
3675
(char**) &max_system_variables.myisam_max_sort_file_size, 0,
3676
GET_ULL, REQUIRED_ARG, (int64_t) LONG_MAX, 0, (uint64_t) MAX_FILE_SIZE,
3678
{"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS,
3679
N_("Number of threads to use when repairing MyISAM tables. The value of "
3680
"1 disables parallel repair."),
3681
(char**) &global_system_variables.myisam_repair_threads,
3682
(char**) &max_system_variables.myisam_repair_threads, 0,
3683
GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
3684
{"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
3685
N_("The buffer that is allocated when sorting the index when doing a "
3686
"REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
3687
(char**) &global_system_variables.myisam_sort_buff_size,
3688
(char**) &max_system_variables.myisam_sort_buff_size, 0,
3689
GET_ULONG, REQUIRED_ARG, 8192*1024, 4, INT32_MAX, 0, 1, 0},
3690
{"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
3691
N_("Specifies how MyISAM index statistics collection code should threat "
3692
"NULLs. Possible values of name are 'nulls_unequal' "
3693
"(default behavior), "
3694
"'nulls_equal' (emulate MySQL 4.0 behavior), and 'nulls_ignored'."),
3695
(char**) &myisam_stats_method_str, (char**) &myisam_stats_method_str, 0,
3696
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3697
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
3698
N_("Buffer length for TCP/IP and socket communication."),
3699
(char**) &global_system_variables.net_buffer_length,
3700
(char**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
3701
REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
3702
{"net_read_timeout", OPT_NET_READ_TIMEOUT,
3703
N_("Number of seconds to wait for more data from a connection before "
3704
"aborting the read."),
3705
(char**) &global_system_variables.net_read_timeout,
3706
(char**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
3707
REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3708
{"net_retry_count", OPT_NET_RETRY_COUNT,
3709
N_("If a read on a communication port is interrupted, retry this many "
3710
"times before giving up."),
3711
(char**) &global_system_variables.net_retry_count,
3712
(char**) &max_system_variables.net_retry_count,0,
3713
GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
3714
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
3715
N_("Number of seconds to wait for a block to be written to a connection "
3716
"before aborting the write."),
3717
(char**) &global_system_variables.net_write_timeout,
3718
(char**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
3719
REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3720
{ "old", OPT_OLD_MODE,
3721
N_("Use compatible behavior."),
3722
(char**) &global_system_variables.old_mode,
3723
(char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
3725
{"open_files_limit", OPT_OPEN_FILES_LIMIT,
3726
N_("If this is not 0, then mysqld will use this value to reserve file "
3727
"descriptors to use with setrlimit(). If this value is 0 then mysqld "
3728
"will reserve max_connections*5 or max_connections + table_cache*2 "
3729
"(whichever is larger) number of files."),
3730
(char**) &open_files_limit, (char**) &open_files_limit, 0, GET_ULONG,
3731
REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
1887
3732
{"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
1888
N_("Controls the heuristic(s) applied during query optimization to prune "
1889
"less-promising partial plans from the optimizer search space. Meaning: "
1890
"false - do not apply any heuristic, thus perform exhaustive search; "
1891
"true - prune plans based on number of retrieved rows."),
1892
(char**) &global_system_variables.optimizer_prune_level,
1893
(char**) &max_system_variables.optimizer_prune_level,
1894
0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 1, 0},
3733
N_("Controls the heuristic(s) applied during query optimization to prune "
3734
"less-promising partial plans from the optimizer search space. Meaning: "
3735
"0 - do not apply any heuristic, thus perform exhaustive search; "
3736
"1 - prune plans based on number of retrieved rows."),
3737
(char**) &global_system_variables.optimizer_prune_level,
3738
(char**) &max_system_variables.optimizer_prune_level,
3739
0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
1895
3740
{"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
1896
3741
N_("Maximum depth of search performed by the query optimizer. Values "
1897
3742
"larger than the number of relations in a query result in better query "
1903
3748
"testing/comparison)."),
1904
3749
(char**) &global_system_variables.optimizer_search_depth,
1905
3750
(char**) &max_system_variables.optimizer_search_depth,
1906
0, GET_UINT, OPT_ARG, 0, 0, MAX_TABLES+2, 0, 1, 0},
3751
0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
1907
3752
{"plugin_dir", OPT_PLUGIN_DIR,
1908
3753
N_("Directory for plugins."),
1909
3754
(char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
1910
3755
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1911
{"plugin_add", OPT_PLUGIN_ADD,
1912
N_("Optional comma separated list of plugins to load at startup in addition "
1913
"to the default list of plugins. "
1914
"[for example: --plugin_add=crc32,logger_gearman]"),
1916
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1917
{"plugin_remove", OPT_PLUGIN_ADD,
1918
N_("Optional comma separated list of plugins to not load at startup. Effectively "
1919
"removes a plugin from the list of plugins to be loaded. "
1920
"[for example: --plugin_remove=crc32,logger_gearman]"),
1922
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1923
3756
{"plugin_load", OPT_PLUGIN_LOAD,
1924
N_("Optional comma separated list of plugins to load at starup instead of "
1925
"the default plugin load list. "
1926
"[for example: --plugin_load=crc32,logger_gearman]"),
3757
N_("Optional comma separated list of plugins to load, where each plugin is "
3758
"identified by the name of the shared library. "
3759
"[for example: --plugin_load=libmd5udf.so]"),
3760
(char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
1928
3761
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1929
3762
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
1930
3763
N_("The size of the buffer that is allocated when preloading indexes"),
1931
3764
(char**) &global_system_variables.preload_buff_size,
1932
(char**) &max_system_variables.preload_buff_size, 0, GET_ULL,
3765
(char**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
1933
3766
REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
1934
3767
{"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
1935
3768
N_("Allocation block size for query parsing and execution"),
1936
3769
(char**) &global_system_variables.query_alloc_block_size,
1937
(char**) &max_system_variables.query_alloc_block_size, 0, GET_UINT,
3770
(char**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
1938
3771
REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
1939
3772
{"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
1940
3773
N_("Persistent buffer for query parsing and execution"),
1941
3774
(char**) &global_system_variables.query_prealloc_size,
1942
(char**) &max_system_variables.query_prealloc_size, 0, GET_UINT,
3775
(char**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
1943
3776
REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
1944
3777
ULONG_MAX, 0, 1024, 0},
1945
3778
{"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
1946
3779
N_("Allocation block size for storing ranges during optimization"),
1947
3780
(char**) &global_system_variables.range_alloc_block_size,
1948
(char**) &max_system_variables.range_alloc_block_size, 0, GET_SIZE,
1949
REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, SIZE_MAX,
3781
(char**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
3782
REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
1951
3784
{"read_buffer_size", OPT_RECORD_BUFFER,
1952
N_("Each thread that does a sequential scan allocates a buffer of this "
1953
"size for each table it scans. If you do many sequential scans, you may "
1954
"want to increase this value."),
1955
(char**) &global_system_variables.read_buff_size,
1956
(char**) &max_system_variables.read_buff_size,0, GET_UINT, REQUIRED_ARG,
1957
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
3785
N_("Each thread that does a sequential scan allocates a buffer of this "
3786
"size for each table it scans. If you do many sequential scans, you may "
3787
"want to increase this value."),
3788
(char**) &global_system_variables.read_buff_size,
3789
(char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
3790
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
3792
{"read_only", OPT_READONLY,
3793
N_("Make all non-temporary tables read-only, with the exception for "
3794
"replication (slave) threads and users with the SUPER privilege"),
3795
(char**) &opt_readonly,
3796
(char**) &opt_readonly,
3797
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
1959
3798
{"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
1960
3799
N_("When reading rows in sorted order after a sort, the rows are read "
1961
3800
"through this buffer to avoid a disk seeks. If not set, then it's set "
1962
3801
"to the value of record_buffer."),
1963
3802
(char**) &global_system_variables.read_rnd_buff_size,
1964
3803
(char**) &max_system_variables.read_rnd_buff_size, 0,
1965
GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
1966
UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
1967
{"scheduler", OPT_SCHEDULER,
1968
N_("Select scheduler to be used (by default multi-thread)."),
1969
(char**)&opt_scheduler, (char**)&opt_scheduler,
1970
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1971
/* x8 compared to MySQL's x2. We have UTF8 to consider. */
3804
GET_ULONG, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
3805
INT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
3806
{"record_buffer", OPT_RECORD_BUFFER,
3807
"Alias for read_buffer_size",
3808
(char**) &global_system_variables.read_buff_size,
3809
(char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
3810
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
3811
INT32_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
3812
{"relay_log_purge", OPT_RELAY_LOG_PURGE,
3813
N_("0 = do not purge relay logs. "
3814
"1 = purge them as soon as they are no more needed."),
3815
(char**) &relay_log_purge,
3816
(char**) &relay_log_purge, 0, GET_BOOL, NO_ARG,
3818
{"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
3819
N_("Maximum space to use for all relay logs."),
3820
(char**) &relay_log_space_limit,
3821
(char**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
3822
(int64_t) ULONG_MAX, 0, 1, 0},
3823
{"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL,
3824
N_("Use compression on master/slave protocol."),
3825
(char**) &opt_slave_compressed_protocol,
3826
(char**) &opt_slave_compressed_protocol,
3827
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3828
{"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT,
3829
N_("Number of seconds to wait for more data from a master/slave connection "
3830
"before aborting the read."),
3831
(char**) &slave_net_timeout, (char**) &slave_net_timeout, 0,
3832
GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3833
{"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES,
3834
N_("Number of times the slave SQL thread will retry a transaction in case "
3835
"it failed with a deadlock or elapsed lock wait timeout, "
3836
"before giving up and stopping."),
3837
(char**) &slave_trans_retries, (char**) &slave_trans_retries, 0,
3838
GET_ULONG, REQUIRED_ARG, 10L, 0L, (int64_t) ULONG_MAX, 0, 1, 0},
3839
{"slave-allow-batching", OPT_SLAVE_ALLOW_BATCHING,
3840
N_("Allow slave to batch requests."),
3841
(char**) &slave_allow_batching, (char**) &slave_allow_batching,
3842
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3843
{"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
3844
N_("If creating the thread takes longer than this value (in seconds), the "
3845
"Slow_launch_threads counter will be incremented."),
3846
(char**) &slow_launch_time, (char**) &slow_launch_time, 0, GET_ULONG,
3847
REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
1972
3848
{"sort_buffer_size", OPT_SORT_BUFFER,
1973
3849
N_("Each thread that needs to do a sort allocates a buffer of this size."),
1974
3850
(char**) &global_system_variables.sortbuff_size,
1975
(char**) &max_system_variables.sortbuff_size, 0, GET_SIZE, REQUIRED_ARG,
1976
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*8, SIZE_MAX,
3851
(char**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
3852
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ULONG_MAX,
1977
3853
MALLOC_OVERHEAD, 1, 0},
3854
{"sync-binlog", OPT_SYNC_BINLOG,
3855
N_("Synchronously flush binary log to disk after every #th event. "
3856
"Use 0 (default) to disable synchronous flushing."),
3857
(char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
3858
REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
1978
3859
{"table_definition_cache", OPT_TABLE_DEF_CACHE,
1979
3860
N_("The number of cached table definitions."),
1980
3861
(char**) &table_def_size, (char**) &table_def_size,
1981
0, GET_SIZE, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
3862
0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
1982
3863
{"table_open_cache", OPT_TABLE_OPEN_CACHE,
1983
3864
N_("The number of cached open tables."),
1984
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_UINT64,
1985
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, TABLE_OPEN_CACHE_MIN, 512*1024L, 0, 1, 0},
3865
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
3866
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
1986
3867
{"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
1987
3868
N_("Timeout in seconds to wait for a table level lock before returning an "
1988
3869
"error. Used only if the connection has active cursors."),
1989
3870
(char**) &table_lock_wait_timeout, (char**) &table_lock_wait_timeout,
1990
0, GET_ULL, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
3871
0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
3872
{"thread_cache_size", OPT_THREAD_CACHE_SIZE,
3873
N_("How many threads we should keep in a cache for reuse."),
3874
(char**) &thread_cache_size, (char**) &thread_cache_size, 0, GET_ULONG,
3875
REQUIRED_ARG, 0, 0, 16384, 0, 1, 0},
3876
{"thread_pool_size", OPT_THREAD_CACHE_SIZE,
3877
N_("How many threads we should create to handle query requests in case of "
3878
"'thread_handling=pool-of-threads'"),
3879
(char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULONG,
3880
REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
1991
3881
{"thread_stack", OPT_THREAD_STACK,
1992
3882
N_("The stack size for each thread."),
1993
3883
(char**) &my_thread_stack_size,
1994
(char**) &my_thread_stack_size, 0, GET_SIZE,
3884
(char**) &my_thread_stack_size, 0, GET_ULONG,
1995
3885
REQUIRED_ARG,DEFAULT_THREAD_STACK,
1996
UINT32_C(1024*512), SIZE_MAX, 0, 1024, 0},
3886
1024L*128L, ULONG_MAX, 0, 1024, 0},
3887
{ "time_format", OPT_TIME_FORMAT,
3888
N_("The TIME format (for future)."),
3889
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
3890
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
3891
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1997
3892
{"tmp_table_size", OPT_TMP_TABLE_SIZE,
1998
N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
3893
N_("If an internal in-memory temporary table exceeds this size, MySQL will"
1999
3894
" automatically convert it to an on-disk MyISAM table."),
2000
3895
(char**) &global_system_variables.tmp_table_size,
2001
3896
(char**) &max_system_variables.tmp_table_size, 0, GET_ULL,
2002
3897
REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
3898
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
3899
N_("Allocation block size for transactions to be stored in binary log"),
3900
(char**) &global_system_variables.trans_alloc_block_size,
3901
(char**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
3902
REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3903
{"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
3904
N_("Persistent buffer for transactions to be stored in binary log"),
3905
(char**) &global_system_variables.trans_prealloc_size,
3906
(char**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
3907
REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3908
{"wait_timeout", OPT_WAIT_TIMEOUT,
3909
N_("The number of seconds the server waits for activity on a connection "
3910
"before closing it."),
3911
(char**) &global_system_variables.net_wait_timeout,
3912
(char**) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
3913
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
2003
3915
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
3918
static int show_net_compression(Session *session __attribute__((unused)),
3920
char *buff __attribute__((unused)))
3922
var->type= SHOW_MY_BOOL;
3923
var->value= (char *)&session->net.compress;
3927
static st_show_var_func_container
3928
show_net_compression_cont= { &show_net_compression };
3930
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
3932
var->type= SHOW_LONG;
3934
*((long *)buff)= (long) (session->query_start() - server_start_time);
3938
static st_show_var_func_container
3939
show_starttime_cont= { &show_starttime };
3941
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
3943
var->type= SHOW_LONG;
3945
*((long *)buff)= (long) (session->query_start() - flush_status_time);
3949
static st_show_var_func_container
3950
show_flushstatustime_cont= { &show_flushstatustime };
3952
static int show_slave_running(Session *session __attribute__((unused)),
3953
SHOW_VAR *var, char *buff)
3955
var->type= SHOW_MY_BOOL;
3956
pthread_mutex_lock(&LOCK_active_mi);
3958
*((bool *)buff)= (bool) (active_mi && active_mi->slave_running &&
3959
active_mi->rli.slave_running);
3960
pthread_mutex_unlock(&LOCK_active_mi);
3964
static st_show_var_func_container
3965
show_slave_running_cont= { &show_slave_running };
3967
static int show_slave_retried_trans(Session *session __attribute__((unused)),
3968
SHOW_VAR *var, char *buff)
3971
TODO: with multimaster, have one such counter per line in
3972
SHOW SLAVE STATUS, and have the sum over all lines here.
3974
pthread_mutex_lock(&LOCK_active_mi);
3977
var->type= SHOW_LONG;
3979
pthread_mutex_lock(&active_mi->rli.data_lock);
3980
*((long *)buff)= (long)active_mi->rli.retried_trans;
3981
pthread_mutex_unlock(&active_mi->rli.data_lock);
3984
var->type= SHOW_UNDEF;
3985
pthread_mutex_unlock(&LOCK_active_mi);
3989
static st_show_var_func_container
3990
show_slave_retried_trans_cont= { &show_slave_retried_trans };
3992
static int show_slave_received_heartbeats(Session *session __attribute__((unused)),
3993
SHOW_VAR *var, char *buff)
3995
pthread_mutex_lock(&LOCK_active_mi);
3998
var->type= SHOW_LONGLONG;
4000
pthread_mutex_lock(&active_mi->rli.data_lock);
4001
*((int64_t *)buff)= active_mi->received_heartbeats;
4002
pthread_mutex_unlock(&active_mi->rli.data_lock);
4005
var->type= SHOW_UNDEF;
4006
pthread_mutex_unlock(&LOCK_active_mi);
4010
static st_show_var_func_container
4011
show_slave_received_heartbeats_cont= { &show_slave_received_heartbeats };
4013
static int show_heartbeat_period(Session *session __attribute__((unused)),
4014
SHOW_VAR *var, char *buff)
4016
pthread_mutex_lock(&LOCK_active_mi);
4019
var->type= SHOW_CHAR;
4021
sprintf(buff, "%.3f",active_mi->heartbeat_period);
4024
var->type= SHOW_UNDEF;
4025
pthread_mutex_unlock(&LOCK_active_mi);
4029
static st_show_var_func_container
4030
show_heartbeat_period_cont= { &show_heartbeat_period};
4032
static int show_open_tables(Session *session __attribute__((unused)),
4033
SHOW_VAR *var, char *buff)
4035
var->type= SHOW_LONG;
4037
*((long *)buff)= (long)cached_open_tables();
4041
static int show_table_definitions(Session *session __attribute__((unused)),
4042
SHOW_VAR *var, char *buff)
4044
var->type= SHOW_LONG;
4046
*((long *)buff)= (long)cached_table_definitions();
4050
static st_show_var_func_container
4051
show_open_tables_cont= { &show_open_tables };
4052
static st_show_var_func_container
4053
show_table_definitions_cont= { &show_table_definitions };
4056
Variables shown by SHOW STATUS in alphabetical order
4059
SHOW_VAR status_vars[]= {
4060
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
4061
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
4062
{"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG},
4063
{"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG},
4064
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
4065
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
4066
{"Com", (char*) com_status_vars, SHOW_ARRAY},
4067
{"Compression", (char*) &show_net_compression_cont, SHOW_FUNC},
4068
{"Connections", (char*) &thread_id, SHOW_LONG_NOFLUSH},
4069
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
4070
{"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG},
4071
{"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
4072
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_NOFLUSH},
4073
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
4074
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
4075
{"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS},
4076
{"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS},
4077
{"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
4078
{"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
4079
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
4080
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
4081
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
4082
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
4083
{"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
4084
{"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
4085
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
4086
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
4087
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
4088
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
4089
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
4090
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
4091
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
4092
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
4093
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
4094
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
4095
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
4096
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
4097
{"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH},
4098
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH},
4099
{"Open_table_definitions", (char*) &show_table_definitions_cont, SHOW_FUNC},
4100
{"Open_tables", (char*) &show_open_tables_cont, SHOW_FUNC},
4101
{"Opened_files", (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
4102
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
4103
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
4104
{"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
4105
{"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
4106
{"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
4107
{"Select_range", (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
4108
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
4109
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
4110
{"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
4111
{"Slave_retried_transactions",(char*) &show_slave_retried_trans_cont, SHOW_FUNC},
4112
{"Slave_heartbeat_period", (char*) &show_heartbeat_period_cont, SHOW_FUNC},
4113
{"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats_cont, SHOW_FUNC},
4114
{"Slave_running", (char*) &show_slave_running_cont, SHOW_FUNC},
4115
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
4116
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
4117
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
4118
{"Sort_range", (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
4119
{"Sort_rows", (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
4120
{"Sort_scan", (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
4121
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG},
4122
{"Table_locks_waited", (char*) &locks_waited, SHOW_LONG},
4124
{"Tc_log_max_pages_used", (char*) &tc_log_max_pages_used, SHOW_LONG},
4125
{"Tc_log_page_size", (char*) &tc_log_page_size, SHOW_LONG},
4126
{"Tc_log_page_waits", (char*) &tc_log_page_waits, SHOW_LONG},
4128
{"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH},
4129
{"Threads_connected", (char*) &connection_count, SHOW_INT},
4130
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
4131
{"Threads_running", (char*) &thread_running, SHOW_INT},
4132
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
4133
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
4134
{NULL, NULL, SHOW_LONG}
2006
4137
static void print_version(void)
4139
set_server_version();
2009
4141
Note: the instance manager keys off the string 'Ver' so it can find the
2010
version from the output of 'drizzled --version', so don't change it!
4142
version from the output of 'mysqld --version', so don't change it!
2012
printf("%s Ver %s for %s-%s on %s (%s)\n",internal::my_progname,
2013
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU,
2014
COMPILATION_COMMENT);
4144
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
4145
server_version,SYSTEM_TYPE,MACHINE_TYPE, COMPILATION_COMMENT);
2017
4148
static void usage(void)
2019
if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
4150
if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
2021
4154
if (!default_collation_name)
2022
4155
default_collation_name= (char*) default_charset_info->name;
2023
4156
print_version();
2024
puts(_("Copyright (C) 2008 Sun Microsystems\n"
4157
puts(_("Copyright (C) 2000 MySQL AB, by Monty and others\n"
2025
4158
"This software comes with ABSOLUTELY NO WARRANTY. "
2026
4159
"This is free software,\n"
2027
4160
"and you are welcome to modify and redistribute it under the GPL "
2031
printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
2033
po::options_description all_options("Drizzled Options");
2034
all_options.add(long_options);
2035
all_options.add(plugin_options);
2036
cout << all_options << endl;
4162
"Starts the Drizzle database server\n"));
4164
printf(_("Usage: %s [OPTIONS]\n"), my_progname);
4167
print_defaults(DRIZZLE_CONFIG_NAME,load_default_groups);
4172
/* Print out all the options including plugin supplied options */
4173
my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
4175
puts(_("\nTo see what values a running Drizzle server is using, type\n"
4176
"'drizzleadmin variables' instead of 'drizzled --help'."));
2041
Initialize all Drizzle global variables to default values.
4182
Initialize all MySQL global variables to default values.
2043
4184
We don't need to set numeric variables refered to in my_long_options
2044
4185
as these are initialized by my_getopt.
2053
4194
as these are initialized by my_getopt.
2056
static void drizzle_init_variables(void)
4197
static void mysql_init_variables(void)
2058
4199
/* Things reset to zero */
2059
drizzle_home[0]= pidfile_name[0]= 0;
4200
opt_skip_slave_start= opt_reckless_slave = 0;
4201
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
4202
log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4205
opt_logname= opt_binlog_index_name= 0;
2060
4206
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
2061
4207
opt_secure_file_priv= 0;
4208
segfaulted= kill_in_progress= 0;
2062
4209
cleanup_done= 0;
2063
dropping_tables= ha_open_options=0;
2066
abort_loop= select_thread_in_use= false;
4212
server_id_supplied= 0;
4213
test_flags= select_errors= dropping_tables= ha_open_options=0;
4214
thread_count= thread_running= kill_cached_threads= wake_thread=0;
4215
slave_open_temp_tables= 0;
4216
cached_thread_count= 0;
4217
opt_endinfo= using_udf_functions= 0;
4218
opt_using_transactions= using_update_log= 0;
4219
abort_loop= select_thread_in_use= signal_thread_in_use= 0;
2067
4220
ready_to_exit= shutdown_in_progress= 0;
2068
drizzled_user= drizzled_chroot= 0;
2069
memset(¤t_global_counters, 0, sizeof(current_global_counters));
4221
aborted_threads= aborted_connects= 0;
4223
binlog_cache_use= binlog_cache_disk_use= 0;
4224
max_used_connections= slow_launch_threads = 0;
4225
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4226
opt_mysql_tmpdir= my_bind_addr_str= NULL;
4227
memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4228
memset(&global_status_var, 0, sizeof(global_status_var));
4229
key_map_full.set_all();
2072
4231
/* Character sets */
2073
4232
system_charset_info= &my_charset_utf8_general_ci;
2074
4233
files_charset_info= &my_charset_utf8_general_ci;
4234
national_charset_info= &my_charset_utf8_general_ci;
2075
4235
table_alias_charset= &my_charset_bin;
2076
4236
character_set_filesystem= &my_charset_bin;
4238
opt_date_time_formats[0]= opt_date_time_formats[1]= opt_date_time_formats[2]= 0;
2078
4240
/* Things with default values that are not zero */
2079
drizzle_home_ptr= drizzle_home;
4241
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
4242
slave_exec_mode_options= 0;
4243
slave_exec_mode_options= (uint)
4244
find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
4245
mysql_home_ptr= mysql_home;
2080
4246
pidfile_name_ptr= pidfile_name;
4247
log_error_file_ptr= log_error_file;
2081
4248
language_ptr= language;
2082
session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
4249
mysql_data_home= mysql_real_data_home;
4250
session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4251
OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
4252
protocol_version= PROTOCOL_VERSION;
4253
what_to_log= ~ (1L << (uint) COM_TIME);
2083
4254
refresh_version= 1L; /* Increments on each reload */
2084
global_thread_id= 1UL;
2085
getSessionList().clear();
4255
global_query_id= thread_id= 1L;
4256
my_stpcpy(server_version, VERSION);
4257
myisam_recover_options_str= "OFF";
4258
myisam_stats_method_str= "nulls_unequal";
4260
thread_cache.empty();
4262
if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
4263
default_key_cache_base.length)))
4265
/* set key_cache_hash.default_value = dflt_key_cache */
4266
multi_keycache_init();
2087
4268
/* Set directory paths */
2088
strncpy(language, LANGUAGE, sizeof(language)-1);
4269
strmake(language, LANGUAGE, sizeof(language)-1);
4270
strmake(mysql_real_data_home, get_relative_path(DATADIR),
4271
sizeof(mysql_real_data_home)-1);
4272
mysql_data_home_buff[0]=FN_CURLIB; // all paths are relative from here
4273
mysql_data_home_buff[1]=0;
4274
mysql_data_home_len= 2;
4276
/* Replication parameters */
4277
master_info_file= (char*) "master.info",
4278
relay_log_info_file= (char*) "relay-log.info";
4279
report_user= report_password = report_host= 0; /* TO BE DELETED */
4280
opt_relay_logname= opt_relaylog_index_name= 0;
2090
4282
/* Variables in libraries */
2091
default_character_set_name= "utf8";
2092
default_collation_name= (char *)compiled_default_collation_name;
2093
character_set_filesystem_name= "binary";
4284
default_character_set_name= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
4285
default_collation_name= compiled_default_collation_name;
4286
character_set_filesystem_name= (char*) "binary";
2094
4287
lc_time_names_name= (char*) "en_US";
2095
4288
/* Set default values for some option variables */
2096
4289
default_storage_engine_str= (char*) "innodb";
2097
global_system_variables.storage_engine= NULL;
4290
global_system_variables.table_plugin= NULL;
2098
4291
global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
2099
4292
global_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
2100
4293
max_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
2101
4294
global_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
2102
4295
max_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
2103
max_system_variables.auto_increment_increment= UINT64_MAX;
2104
max_system_variables.auto_increment_offset= UINT64_MAX;
2105
max_system_variables.completion_type= 2;
2106
max_system_variables.log_warnings= 1;
2107
max_system_variables.bulk_insert_buff_size= ULONG_MAX;
2108
max_system_variables.div_precincrement= DECIMAL_MAX_SCALE;
2109
max_system_variables.group_concat_max_len= ULONG_MAX;
2110
max_system_variables.join_buff_size= ULONG_MAX;
2111
max_system_variables.max_allowed_packet= 1024L*1024L*1024L;
2112
max_system_variables.max_error_count= 65535;
2113
max_system_variables.max_heap_table_size= MAX_MEM_TABLE_SIZE;
2114
max_system_variables.max_join_size= INT32_MAX;
2115
max_system_variables.max_length_for_sort_data= 8192*1024L;
2116
max_system_variables.max_seeks_for_key= ULONG_MAX;
2117
max_system_variables.max_sort_length= 8192*1024L;
2118
max_system_variables.min_examined_row_limit= ULONG_MAX;
2119
max_system_variables.optimizer_prune_level= 1;
2120
max_system_variables.optimizer_search_depth= MAX_TABLES+2;
2121
max_system_variables.preload_buff_size= 1024*1024*1024L;
2122
max_system_variables.query_alloc_block_size= UINT32_MAX;
2123
max_system_variables.query_prealloc_size= UINT32_MAX;
2124
max_system_variables.range_alloc_block_size= SIZE_MAX;
2125
max_system_variables.read_buff_size= INT32_MAX;
2126
max_system_variables.read_rnd_buff_size= UINT32_MAX;
2127
max_system_variables.sortbuff_size= SIZE_MAX;
2128
max_system_variables.tmp_table_size= MAX_MEM_TABLE_SIZE;
2130
opt_scheduler_default= (char*) "multi_thread";
4296
global_system_variables.old_alter_table= 0;
4297
global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
4299
Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
4300
when collecting index statistics for MyISAM tables.
4302
global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
2132
4304
/* Variables that depends on compile options */
2133
4306
#ifdef HAVE_BROKEN_REALPATH
2134
4307
have_symlink=SHOW_OPTION_NO;
2136
4309
have_symlink=SHOW_OPTION_YES;
4311
#ifdef HAVE_COMPRESS
4312
have_compress= SHOW_OPTION_YES;
4314
have_compress= SHOW_OPTION_NO;
2139
4317
const char *tmpenv;
2140
4318
if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
2142
(void) strncpy(drizzle_home, tmpenv, sizeof(drizzle_home)-1);
2144
connection_count= 0;
4319
tmpenv = DEFAULT_DRIZZLE_HOME;
4320
(void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
2150
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "drizzled/error.h" and return that code?
2152
static void get_options()
4325
mysqld_get_one_option(int optid,
4326
const struct my_option *opt __attribute__((unused)),
2155
if (vm.count("base-dir"))
2157
strncpy(drizzle_home,vm["base-dir"].as<string>().c_str(),sizeof(drizzle_home)-1);
2160
if (vm.count("datadir"))
2162
getDataHome()= vm["datadir"].as<string>();
2164
string &data_home_catalog= getDataHomeCatalog();
2165
data_home_catalog= getDataHome();
2166
data_home_catalog.push_back('/');
2167
data_home_catalog.append("local");
2169
if (vm.count("user"))
2171
if (! drizzled_user || ! strcmp(drizzled_user, vm["user"].as<string>().c_str()))
2172
drizzled_user= (char *)vm["user"].as<string>().c_str();
4331
opt_endinfo=1; /* unireg: memory allocation */
4334
global_system_variables.tx_isolation= ISO_SERIALIZABLE;
4337
strmake(mysql_home,argument,sizeof(mysql_home)-1);
4340
if (default_collation_name == compiled_default_collation_name)
4341
default_collation_name= 0;
4344
strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
4345
/* Correct pointer set by my_getopt (for embedded library) */
4346
mysql_data_home= mysql_real_data_home;
4347
mysql_data_home_len= strlen(mysql_data_home);
4350
if (!mysqld_user || !strcmp(mysqld_user, argument))
4351
mysqld_user= argument;
2175
errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2176
"set to '%s' earlier on the command line\n"),
2177
vm["user"].as<string>().c_str(), drizzled_user);
2180
if (vm.count("language"))
2182
strncpy(language, vm["language"].as<string>().c_str(), sizeof(language)-1);
2185
if (vm.count("version"))
4353
sql_print_warning(_("Ignoring user change to '%s' because the user was "
4354
"set to '%s' earlier on the command line\n"),
4355
argument, mysqld_user);
4358
strmake(language, argument, sizeof(language)-1);
4360
case OPT_SLAVE_SKIP_ERRORS:
4361
init_slave_skip_errors(argument);
4363
case OPT_SLAVE_EXEC_MODE:
4364
slave_exec_mode_options= (uint)
4365
find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "");
2187
4368
print_version();
2191
if (vm.count("log-warnings"))
2193
if (vm["log-warnings"].as<string>().empty())
2194
4372
global_system_variables.log_warnings++;
2195
else if (vm["log-warnings"].as<string>().compare("0"))
4373
else if (argument == disabled_my_option)
2196
4374
global_system_variables.log_warnings= 0L;
2198
global_system_variables.log_warnings= atoi(vm["log-warnings"].as<string>().c_str());
2201
if (vm.count("exit-info"))
2203
if (vm["exit-info"].as<long>())
2205
test_flags.set((uint32_t) vm["exit-info"].as<long>());
2209
if (vm.count("want-core"))
2211
test_flags.set(TEST_CORE_ON_SIGNAL);
2214
if (vm.count("skip-stack-trace"))
2216
test_flags.set(TEST_NO_STACKTRACE);
2219
if (vm.count("skip-symlinks"))
2221
internal::my_use_symdir=0;
2224
if (vm.count("pid-file"))
2226
strncpy(pidfile_name, vm["pid-file"].as<string>().c_str(), sizeof(pidfile_name)-1);
2229
if (vm.count("transaction-isolation"))
2232
type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
2233
global_system_variables.tx_isolation= (type-1);
2236
/* @TODO Make this all strings */
2237
if (vm.count("default-storage-engine"))
2239
default_storage_engine_str= (char *)vm["default-storage-engine"].as<string>().c_str();
4376
global_system_variables.log_warnings= atoi(argument);
4379
test_flags= argument ? (uint) atoi(argument) : 0;
4382
case (int) OPT_BIN_LOG:
4383
opt_bin_log= test(argument != disabled_my_option);
4385
case (int) OPT_ERROR_LOG_FILE:
4388
case (int)OPT_REPLICATE_IGNORE_DB:
4390
rpl_filter->add_ignore_db(argument);
4393
case (int)OPT_REPLICATE_DO_DB:
4395
rpl_filter->add_do_db(argument);
4398
case (int)OPT_REPLICATE_REWRITE_DB:
4400
char* key = argument,*p, *val;
4402
if (!(p= strstr(argument, "->")))
4405
_("Bad syntax in replicate-rewrite-db - missing '->'!\n"));
4409
while (my_isspace(mysqld_charset, *p) && p > argument)
4414
_("Bad syntax in replicate-rewrite-db - empty FROM db!\n"));
4419
while (*val && my_isspace(mysqld_charset, *val))
4424
_("Bad syntax in replicate-rewrite-db - empty TO db!\n"));
4428
rpl_filter->add_db_rewrite(key, val);
4432
case (int)OPT_BINLOG_IGNORE_DB:
4434
binlog_filter->add_ignore_db(argument);
4437
case OPT_BINLOG_FORMAT:
4440
id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
4441
global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
4444
case (int)OPT_BINLOG_DO_DB:
4446
binlog_filter->add_do_db(argument);
4449
case (int)OPT_REPLICATE_DO_TABLE:
4451
if (rpl_filter->add_do_table(argument))
4453
fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
4458
case (int)OPT_REPLICATE_WILD_DO_TABLE:
4460
if (rpl_filter->add_wild_do_table(argument))
4462
fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
4467
case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
4469
if (rpl_filter->add_wild_ignore_table(argument))
4471
fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
4476
case (int)OPT_REPLICATE_IGNORE_TABLE:
4478
if (rpl_filter->add_ignore_table(argument))
4480
fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
4485
case (int) OPT_WANT_CORE:
4486
test_flags |= TEST_CORE_ON_SIGNAL;
4488
case (int) OPT_SKIP_STACK_TRACE:
4489
test_flags|=TEST_NO_STACKTRACE;
4491
case (int) OPT_SKIP_SYMLINKS:
4494
case (int) OPT_BIND_ADDRESS:
4496
struct addrinfo *res_lst, hints;
4498
memset(&hints, 0, sizeof(struct addrinfo));
4499
hints.ai_socktype= SOCK_STREAM;
4500
hints.ai_protocol= IPPROTO_TCP;
4502
if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
4504
sql_print_error(_("Can't start server: cannot resolve hostname!"));
4508
if (res_lst->ai_next)
4510
sql_print_error(_("Can't start server: bind-address refers to "
4511
"multiple interfaces!"));
4514
freeaddrinfo(res_lst);
4517
case (int) OPT_PID_FILE:
4518
strmake(pidfile_name, argument, sizeof(pidfile_name)-1);
4522
opt_error_log= 0; // Force logs to stdout
4524
case OPT_LOW_PRIORITY_UPDATES:
4525
thr_upgraded_concurrent_insert_lock= TL_WRITE_LOW_PRIORITY;
4526
global_system_variables.low_priority_updates=1;
4529
server_id_supplied = 1;
4531
case OPT_DELAY_KEY_WRITE_ALL:
4532
if (argument != disabled_my_option)
4533
argument= (char*) "ALL";
4535
case OPT_DELAY_KEY_WRITE:
4536
if (argument == disabled_my_option)
4537
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
4538
else if (! argument)
4539
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
4543
type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name);
4544
delay_key_write_options= (uint) type-1;
4547
case OPT_CHARSETS_DIR:
4548
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1);
4549
charsets_dir = mysql_charsets_dir;
4551
case OPT_TX_ISOLATION:
4554
type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
4555
global_system_variables.tx_isolation= (type-1);
4558
case OPT_MYISAM_RECOVER:
4562
myisam_recover_options= HA_RECOVER_DEFAULT;
4563
myisam_recover_options_str= myisam_recover_typelib.type_names[0];
4565
else if (!argument[0])
4567
myisam_recover_options= HA_RECOVER_NONE;
4568
myisam_recover_options_str= "OFF";
4572
myisam_recover_options_str=argument;
4573
myisam_recover_options=
4574
find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
4576
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
4579
case OPT_TC_HEURISTIC_RECOVER:
4580
tc_heuristic_recover= find_type_or_exit(argument,
4581
&tc_heuristic_recover_typelib,
4584
case OPT_MYISAM_STATS_METHOD:
4586
uint32_t method_conv;
4589
myisam_stats_method_str= argument;
4590
method= find_type_or_exit(argument, &myisam_stats_method_typelib,
4594
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
4597
method_conv= MI_STATS_METHOD_NULLS_EQUAL;
4601
method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4604
global_system_variables.myisam_stats_method= method_conv;
4612
/** Handle arguments for multiple key caches. */
4614
extern "C" char **mysql_getopt_value(const char *keyname, uint32_t key_length,
4615
const struct my_option *option);
4618
mysql_getopt_value(const char *keyname, uint32_t key_length,
4619
const struct my_option *option)
4621
switch (option->id) {
4622
case OPT_KEY_BUFFER_SIZE:
4623
case OPT_KEY_CACHE_BLOCK_SIZE:
4624
case OPT_KEY_CACHE_DIVISION_LIMIT:
4625
case OPT_KEY_CACHE_AGE_THRESHOLD:
4627
KEY_CACHE *key_cache;
4628
if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
4630
switch (option->id) {
4631
case OPT_KEY_BUFFER_SIZE:
4632
return (char**) &key_cache->param_buff_size;
4633
case OPT_KEY_CACHE_BLOCK_SIZE:
4634
return (char**) &key_cache->param_block_size;
4635
case OPT_KEY_CACHE_DIVISION_LIMIT:
4636
return (char**) &key_cache->param_division_limit;
4637
case OPT_KEY_CACHE_AGE_THRESHOLD:
4638
return (char**) &key_cache->param_age_threshold;
4642
return (char **)option->value;
4646
extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
4648
void option_error_reporter(enum loglevel level, const char *format, ...)
4651
va_start(args, format);
4653
/* Don't print warnings for --loose options during bootstrap */
4654
if (level == ERROR_LEVEL || global_system_variables.log_warnings)
4656
vprint_msg_to_log(level, format, args);
4664
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code?
4666
static void get_options(int *argc,char **argv)
4670
my_getopt_register_get_addr(mysql_getopt_value);
4671
my_getopt_error_reporter= option_error_reporter;
2242
4673
/* Skip unknown options so that they may be processed later by plugins */
2243
4674
my_getopt_skip_unknown= true;
4676
if ((ho_error= handle_options(argc, &argv, my_long_options,
4677
mysqld_get_one_option)))
4679
(*argc)++; /* add back one for the progname handle_options removes */
4680
/* no need to do this for argv as we are discarding it. */
2246
4682
#if defined(HAVE_BROKEN_REALPATH)
2247
internal::my_use_symdir=0;
2248
internal::my_disable_symlinks=1;
4684
my_disable_symlinks=1;
2249
4685
have_symlink=SHOW_OPTION_NO;
2251
if (!internal::my_use_symdir)
2253
internal::my_disable_symlinks=1;
4689
my_disable_symlinks=1;
2254
4690
have_symlink=SHOW_OPTION_DISABLED;
2257
4693
if (opt_debugging)
2259
4695
/* Allow break with SIGINT, no core or stack trace */
2260
test_flags.set(TEST_SIGINT);
2261
test_flags.set(TEST_NO_STACKTRACE);
2262
test_flags.reset(TEST_CORE_ON_SIGNAL);
4696
test_flags|= TEST_SIGINT | TEST_NO_STACKTRACE;
4697
test_flags&= ~TEST_CORE_ON_SIGNAL;
4699
/* Set global MyISAM variables from delay_key_write_options */
4700
fix_delay_key_write((Session*) 0, OPT_GLOBAL);
4701
/* Set global slave_exec_mode from its option */
4702
fix_slave_exec_mode(OPT_GLOBAL);
2265
if (drizzled_chroot)
2266
set_root(drizzled_chroot);
4705
set_root(mysqld_chroot);
2269
4709
Set some global variables from the global_system_variables
2270
4710
In most cases the global variables will not be used
2272
internal::my_default_record_cache_size=global_system_variables.read_buff_size;
2276
static const char *get_relative_path(const char *path)
2278
if (internal::test_if_hard_path(path) &&
2279
(strncmp(path, PREFIX, strlen(PREFIX)) == 0) &&
2280
strcmp(PREFIX,FN_ROOTDIR))
4712
my_default_record_cache_size=global_system_variables.read_buff_size;
4713
myisam_max_temp_length=
4714
(my_off_t) global_system_variables.myisam_max_sort_file_size;
4716
/* Set global variables based on startup options */
4717
myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
4719
if (init_global_datetime_format(DRIZZLE_TIMESTAMP_DATE,
4720
&global_system_variables.date_format) ||
4721
init_global_datetime_format(DRIZZLE_TIMESTAMP_TIME,
4722
&global_system_variables.time_format) ||
4723
init_global_datetime_format(DRIZZLE_TIMESTAMP_DATETIME,
4724
&global_system_variables.datetime_format))
4727
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
4732
Create version name for running mysqld version
4733
We automaticly add suffixes -debug, -embedded and -log to the version
4734
name to make the version more descriptive.
4735
(DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
4738
#ifdef DRIZZLE_SERVER_SUFFIX
4739
#define DRIZZLE_SERVER_SUFFIX_STR STRINGIFY_ARG(DRIZZLE_SERVER_SUFFIX)
4741
#define DRIZZLE_SERVER_SUFFIX_STR ""
4744
static void set_server_version(void)
4746
char *end= strxmov(server_version, VERSION,
4747
DRIZZLE_SERVER_SUFFIX_STR, NULL);
4749
my_stpcpy(end, "-log"); // This may slow down system
4753
static char *get_relative_path(const char *path)
4755
if (test_if_hard_path(path) &&
4756
is_prefix(path,DEFAULT_DRIZZLE_HOME) &&
4757
strcmp(DEFAULT_DRIZZLE_HOME,FN_ROOTDIR))
2282
if (strlen(PREFIX) < strlen(path))
2283
path+=(size_t) strlen(PREFIX);
4759
path+=(uint) strlen(DEFAULT_DRIZZLE_HOME);
2284
4760
while (*path == FN_LIBCHAR)
2291
static void fix_paths(string progname)
2293
char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX];
2294
internal::convert_dirname(drizzle_home,drizzle_home,NULL);
2295
/* Resolve symlinks to allow 'drizzle_home' to be a relative symlink */
2296
#if defined(HAVE_BROKEN_REALPATH)
2297
internal::my_load_path(drizzle_home, drizzle_home, NULL);
2299
if (!realpath(drizzle_home,rp_buff))
2300
internal::my_load_path(rp_buff, drizzle_home, NULL);
2301
rp_buff[FN_REFLEN-1]= '\0';
2302
strcpy(drizzle_home,rp_buff);
2303
/* Ensure that drizzle_home ends in FN_LIBCHAR */
2304
pos= strchr(drizzle_home, '\0');
4763
return (char*) path;
4768
Fix filename and replace extension where 'dir' is relative to
4769
mysql_real_data_home.
4771
1 if len(path) > FN_REFLEN
4775
fn_format_relative_to_data_home(char * to, const char *name,
4776
const char *dir, const char *extension)
4778
char tmp_path[FN_REFLEN];
4779
if (!test_if_hard_path(dir))
4781
strcpy(tmp_path, mysql_real_data_home);
4782
strncat(tmp_path, dir, sizeof(tmp_path)-strlen(mysql_real_data_home)-1);
4785
return !fn_format(to, name, dir, extension,
4786
MY_APPEND_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH);
4790
static void fix_paths(void)
4792
char buff[FN_REFLEN],*pos;
4793
convert_dirname(mysql_home,mysql_home,NULL);
4794
/* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
4795
my_realpath(mysql_home,mysql_home,MYF(0));
4796
/* Ensure that mysql_home ends in FN_LIBCHAR */
4797
pos= strchr(mysql_home, '\0');
2306
4798
if (pos[-1] != FN_LIBCHAR)
2308
4800
pos[0]= FN_LIBCHAR;
2311
internal::convert_dirname(language,language,NULL);
2312
(void) internal::my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
2313
(void) internal::my_load_path(pidfile_name, pidfile_name,
2314
getDataHome().c_str());
2316
if (opt_plugin_dir_ptr == NULL)
2318
/* No plugin dir has been specified. Figure out where the plugins are */
2319
if (progname[0] != FN_LIBCHAR)
2321
/* We have a relative path and need to find the absolute */
2322
char working_dir[FN_REFLEN];
2323
char *working_dir_ptr= working_dir;
2324
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
2325
string new_path(working_dir);
2326
if (*(new_path.end()-1) != '/')
2327
new_path.push_back('/');
2328
if (progname[0] == '.' && progname[1] == '/')
2329
new_path.append(progname.substr(2));
2331
new_path.append(progname);
2332
progname.swap(new_path);
2335
/* Now, trim off the exe name */
2336
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
2337
if (progdir.rfind(".libs/") != string::npos)
2339
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
2341
string testlofile(progdir);
2342
testlofile.append("drizzled.lo");
2343
string testofile(progdir);
2344
testofile.append("drizzled.o");
2345
struct stat testfile_stat;
2346
if (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat))
2348
/* neither drizzled.lo or drizzled.o exist - we are not in a source dir.
2351
(void) internal::my_load_path(opt_plugin_dir, get_relative_path(PKGPLUGINDIR),
2356
/* We are in a source dir! Plugin dir is ../plugin/.libs */
2357
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
2358
string source_plugindir(progdir.substr(0,last_libchar_pos));
2359
source_plugindir.append("plugin/.libs");
2360
(void) internal::my_load_path(opt_plugin_dir, source_plugindir.c_str(), "");
2365
(void) internal::my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, drizzle_home);
4803
convert_dirname(mysql_real_data_home,mysql_real_data_home,NULL);
4804
(void) fn_format(buff, mysql_real_data_home, "", "",
4805
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
4806
(void) unpack_dirname(mysql_unpacked_real_data_home, buff);
4807
convert_dirname(language,language,NULL);
4808
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
4809
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
4810
(void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
4811
(void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr ? opt_plugin_dir_ptr :
4812
get_relative_path(PLUGINDIR), mysql_home);
2367
4813
opt_plugin_dir_ptr= opt_plugin_dir;
2369
const char *sharedir= get_relative_path(PKGDATADIR);
2370
if (internal::test_if_hard_path(sharedir))
2371
strncpy(buff,sharedir,sizeof(buff)-1);
4815
char *sharedir=get_relative_path(SHAREDIR);
4816
if (test_if_hard_path(sharedir))
4817
strncpy(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
2374
strcpy(buff, drizzle_home);
2375
strncat(buff, sharedir, sizeof(buff)-strlen(drizzle_home)-1);
2377
internal::convert_dirname(buff,buff,NULL);
2378
(void) internal::my_load_path(language,language,buff);
2380
if (not opt_help and not opt_help_extended)
2382
const char *tmp_string= getenv("TMPDIR") ? getenv("TMPDIR") : NULL;
2384
drizzle_tmpdir.clear();
2386
if (vm.count("tmpdir"))
2388
drizzle_tmpdir.append(vm["tmpdir"].as<string>());
2390
else if (tmp_string == NULL)
2392
drizzle_tmpdir.append(getDataHome());
2393
drizzle_tmpdir.push_back(FN_LIBCHAR);
2394
drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2398
drizzle_tmpdir.append(tmp_string);
2401
assert(drizzle_tmpdir.size());
2403
if (mkdir(drizzle_tmpdir.c_str(), 0777) == -1)
2405
if (errno != EEXIST)
2407
perror(drizzle_tmpdir.c_str());
2412
if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2414
perror(drizzle_tmpdir.c_str());
4820
strcpy(buff, mysql_home);
4821
strncat(buff, sharedir, sizeof(buff)-strlen(mysql_home)-1);
4823
convert_dirname(buff,buff,NULL);
4824
(void) my_load_path(language,language,buff);
4826
/* If --character-sets-dir isn't given, use shared library dir */
4827
if (charsets_dir != mysql_charsets_dir)
4829
strcpy(mysql_charsets_dir, buff);
4830
strncat(mysql_charsets_dir, CHARSET_DIR,
4831
sizeof(mysql_charsets_dir)-strlen(buff)-1);
4833
(void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
4834
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NULL);
4835
charsets_dir=mysql_charsets_dir;
4837
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
4839
if (!slave_load_tmpdir)
4841
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
2420
4845
Convert the secure-file-priv option to system format, allowing
2421
4846
a quick strcmp to check if read or write is in an allowed dir
2423
if (vm.count("secure-file-priv"))
4848
if (opt_secure_file_priv)
2425
internal::convert_dirname(buff, vm["secure-file-priv"].as<string>().c_str(), NULL);
4850
convert_dirname(buff, opt_secure_file_priv, NULL);
2426
4851
free(opt_secure_file_priv);
2427
opt_secure_file_priv= strdup(buff);
2428
if (opt_secure_file_priv == NULL)
2433
} /* namespace drizzled */
4852
opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
4857
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
4864
if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
4866
ptr= bit_lib->type_names;
4868
fprintf(stderr, _("No option given to %s\n"), option);
4870
fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
4872
fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
4874
fprintf(stderr, ",'%s'", *ptr);
4875
fprintf(stderr, "\n");
4884
a bitfield from a string of substrings separated by ','
4886
~(uint32_t) 0 on error.
4889
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
4893
const char *end,*i,*j;
4894
const char **array, *pos;
4895
uint32_t found,found_int,bit;
4900
while (*pos == ' ') pos++;
4901
found_end= *pos == 0;
4904
if ((end=strrchr(pos,',')) != NULL) /* Let end point at fieldend */
4906
while (end > pos && end[-1] == ' ')
4907
end--; /* Skip end-space */
4912
end=pos+strlen(pos);
4915
found_int=0; found_count=0;
4916
for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
4921
if (my_toupper(mysqld_charset,*i++) !=
4922
my_toupper(mysqld_charset,*j++))
4931
else if (j != pos) // Half field found
4933
found_count++; // Could be one of two values
4937
if (found_count != 1)
4938
return(~(uint32_t) 0); // No unique value
4944
} /* find_bit_type */
4948
Create file to store pid number.
4950
static void create_pid_file()
4953
if ((file = my_create(pidfile_name,0664,
4954
O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
4956
char buff[21], *end;
4957
end= int10_to_str((long) getpid(), buff, 10);
4959
if (!my_write(file, (unsigned char*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
4961
(void) my_close(file, MYF(0));
4964
(void) my_close(file, MYF(0));
4966
sql_perror("Can't start server: can't create PID file");
4970
/** Clear most status variables. */
4971
void refresh_status(Session *session)
4973
pthread_mutex_lock(&LOCK_status);
4975
/* Add thread's status variabes to global status */
4976
add_to_status(&global_status_var, &session->status_var);
4978
/* Reset thread's status variables */
4979
memset(&session->status_var, 0, sizeof(session->status_var));
4981
/* Reset some global variables */
4982
reset_status_vars();
4984
/* Reset the counters of all key caches (default and named). */
4985
process_key_caches(reset_key_cache_counters);
4986
flush_status_time= time((time_t*) 0);
4987
pthread_mutex_unlock(&LOCK_status);
4990
Set max_used_connections to the number of currently open
4991
connections. Lock LOCK_thread_count out of LOCK_status to avoid
4992
deadlocks. Status reset becomes not atomic, but status data is
4995
pthread_mutex_lock(&LOCK_thread_count);
4996
max_used_connections= thread_count;
4997
pthread_mutex_unlock(&LOCK_thread_count);
5001
/*****************************************************************************
5002
Instantiate templates
5003
*****************************************************************************/
5005
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
5006
/* Used templates */
5007
template class I_List<Session>;
5008
template class I_List_iterator<Session>;
5009
template class I_List<i_string>;
5010
template class I_List<i_string_pair>;
5011
template class I_List<NAMED_LIST>;
5012
template class I_List<Statement>;
5013
template class I_List_iterator<Statement>;