184
193
static const char *tc_heuristic_recover_names[]=
186
"COMMIT", "ROLLBACK", NullS
195
"COMMIT", "ROLLBACK", NULL
188
197
static TYPELIB tc_heuristic_recover_typelib=
211
220
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
212
221
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
214
const char *log_output_names[] = { "NONE", "FILE", NullS};
223
const char *log_output_names[] = { "NONE", "FILE", NULL};
215
224
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
216
225
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
217
226
log_output_names,
223
232
static bool volatile select_thread_in_use, signal_thread_in_use;
224
233
static bool volatile ready_to_exit;
225
234
static bool opt_debugging= 0, opt_console= 0;
226
static uint kill_cached_threads, wake_thread;
235
static uint32_t kill_cached_threads, wake_thread;
227
236
static uint32_t killed_threads, thread_created;
228
237
static uint32_t max_used_connections;
229
238
static volatile uint32_t cached_thread_count= 0;
293
300
ulong opt_binlog_rows_event_max_size;
294
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
301
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NULL};
295
302
TYPELIB binlog_format_typelib=
296
303
{ array_elements(binlog_format_names) - 1, "",
297
304
binlog_format_names, NULL };
300
307
#ifdef HAVE_INITGROUPS
301
308
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
303
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
304
uint mysqld_port_timeout;
305
uint delay_key_write_options, protocol_version;
306
uint lower_case_table_names= 1;
307
uint tc_heuristic_recover= 0;
308
uint volatile thread_count, thread_running;
310
uint32_t mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
311
uint32_t mysqld_port_timeout;
312
uint32_t delay_key_write_options, protocol_version;
313
uint32_t lower_case_table_names= 1;
314
uint32_t tc_heuristic_recover= 0;
315
uint32_t volatile thread_count, thread_running;
309
316
uint64_t thd_startup_options;
310
317
ulong back_log, connect_timeout, server_id;
311
318
ulong table_cache_size, table_def_size;
384
391
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
385
392
*opt_init_file, *opt_tc_log_file;
386
393
char mysql_unpacked_real_data_home[FN_REFLEN];
394
uint32_t reg_ext_length;
388
395
const key_map key_map_empty(0);
389
396
key_map key_map_full(0); // Will be initialized later
391
398
const char *opt_date_time_formats[3];
393
uint mysql_data_home_len;
400
uint32_t mysql_data_home_len;
394
401
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
395
402
char server_version[SERVER_VERSION_LENGTH];
396
403
char *opt_mysql_tmpdir;
454
461
pthread_cond_t COND_server_started;
456
463
/* replication parameters, if master_host is not NULL, we are a slave */
457
uint report_port= DRIZZLE_PORT;
464
uint32_t report_port= DRIZZLE_PORT;
458
465
uint32_t master_retry_count= 0;
459
466
char *master_info_file;
460
467
char *relay_log_info_file, *report_user, *report_password, *report_host;
461
468
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
462
char *opt_logname, *opt_slow_logname;
464
471
/* Static variables */
763
extern "C" sig_handler print_signal_warning(int sig)
770
extern "C" RETSIGTYPE print_signal_warning(int sig)
765
772
if (global_system_variables.log_warnings)
766
sql_print_warning(_("Got signal %d from thread %ld"), sig,my_thread_id());
767
#ifdef DONT_REMEMBER_SIGNAL
773
sql_print_warning(_("Got signal %d from thread %lud"), sig,my_thread_id());
774
#ifndef HAVE_BSD_SIGNALS
768
775
my_sigset(sig,print_signal_warning); /* int. thread system calls */
770
777
if (sig == SIGALRM)
846
847
xid_cache_free();
847
delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
848
delete_elements(&key_caches, (void (*)(const char*, unsigned char*)) free_key_cache);
848
849
multi_keycache_free();
849
850
free_status_vars();
850
851
end_thr_alarm(1); /* Free allocated memory */
851
852
my_free_open_file_info();
852
my_free((char*) global_system_variables.date_format,
853
MYF(MY_ALLOW_ZERO_PTR));
854
my_free((char*) global_system_variables.time_format,
855
MYF(MY_ALLOW_ZERO_PTR));
856
my_free((char*) global_system_variables.datetime_format,
857
MYF(MY_ALLOW_ZERO_PTR));
853
free((char*) global_system_variables.date_format);
854
free((char*) global_system_variables.time_format);
855
free((char*) global_system_variables.datetime_format);
858
856
if (defaults_argv)
859
857
free_defaults(defaults_argv);
860
my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR));
861
my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR));
862
my_free(sys_var_general_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
863
my_free(sys_var_slow_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
858
free(sys_init_connect.value);
859
free(sys_init_slave.value);
864
860
free_tmpdir(&mysql_tmpdir_list);
865
my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
866
x_free(opt_bin_logname);
867
x_free(opt_relay_logname);
868
x_free(opt_secure_file_priv);
861
free(slave_load_tmpdir);
863
free(opt_bin_logname);
864
if (opt_relay_logname)
865
free(opt_relay_logname);
866
if (opt_secure_file_priv)
867
free(opt_secure_file_priv);
869
868
bitmap_free(&temp_pool);
871
869
delete binlog_filter;
872
870
delete rpl_filter;
875
872
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
882
879
(void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
883
880
// TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
884
881
/* if (freeme != NULL)
885
my_free(freeme, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); */
886
883
/* Tell main we are ready */
887
884
logger.cleanup_end();
888
885
(void) pthread_mutex_lock(&LOCK_thread_count);
928
925
(void) pthread_mutex_destroy(&LOCK_error_log);
929
926
(void) pthread_mutex_destroy(&LOCK_user_conn);
930
927
(void) pthread_mutex_destroy(&LOCK_connection_count);
931
(void) pthread_mutex_destroy(&LOCK_rpl_status);
932
(void) pthread_cond_destroy(&COND_rpl_status);
933
928
(void) pthread_mutex_destroy(&LOCK_active_mi);
934
929
(void) rwlock_destroy(&LOCK_sys_init_connect);
935
930
(void) rwlock_destroy(&LOCK_sys_init_slave);
1198
1193
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1200
1195
if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1201
(socket_errno != SOCKET_EADDRINUSE) ||
1196
(errno != EADDRINUSE) ||
1202
1197
(waited >= mysqld_port_timeout))
1204
1199
sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
1769
1764
sql_print_information(_("Got signal %d to shutdown mysqld"),sig);
1771
1766
/* switch to the old log message processing */
1772
logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
1773
opt_log ? LOG_FILE:LOG_NONE);
1774
1767
if (!abort_loop)
1776
1769
abort_loop=1; // mark abort for threads
1801
1794
REFRESH_THREADS | REFRESH_HOSTS),
1802
1795
(TableList*) 0, ¬_used); // Flush logs
1804
logger.set_handlers(LOG_FILE,
1805
opt_slow_log ? log_output_options : LOG_NONE,
1806
opt_log ? log_output_options : LOG_NONE);
1808
1798
#ifdef USE_ONE_SIGNAL_HAND
1809
1799
case THR_SERVER_ALARM:
1831
1821
for the client.
1834
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
1824
extern "C" void my_message_sql(uint32_t error, const char *str, myf MyFlags);
1836
void my_message_sql(uint error, const char *str, myf MyFlags)
1826
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
1845
1835
if (MyFlags & ME_FATALERROR)
1846
1836
thd->is_fatal_error= 1;
1848
#ifdef BUG_36098_FIXED
1849
mysql_audit_general(thd,DRIZZLE_AUDIT_GENERAL_ERROR,error,my_time(0),
1850
0,0,str,str ? strlen(str) : 0,
1851
thd->query,thd->query_length,
1852
thd->variables.character_set_client,
1858
1839
TODO: There are two exceptions mechanism (THD and sp_rcontext),
1859
1840
this could be improved by having a common stack of handlers.
2014
1995
{"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
2015
1996
{"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
2016
1997
{"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
2017
{"show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
2018
1998
{"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
2019
1999
{"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
2020
2000
{"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
2027
2007
{"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
2028
2008
{"update", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
2029
2009
{"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
2030
{NullS, NullS, SHOW_LONG}
2010
{NULL, NULL, SHOW_LONG}
2033
2013
static int init_common_variables(const char *conf_file_name, int argc,
2034
2014
char **argv, const char **groups)
2036
char buff[FN_REFLEN], *s;
2037
2016
umask(((~my_umask) & 0666));
2038
2017
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
2039
2018
tzset(); // Set tzname
2088
2067
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
2089
stpcpy(fn_ext(pidfile_name),".pid"); // Add proper extension
2068
my_stpcpy(fn_ext(pidfile_name),".pid"); // Add proper extension
2092
2071
Add server status variables to the dynamic list of
2107
2086
/* connections and databases needs lots of files */
2109
uint files, wanted_files, max_open_files;
2088
uint32_t files, wanted_files, max_open_files;
2111
2090
/* MyISAM requires two file handles per table. */
2112
2091
wanted_files= 10+max_connections+table_cache_size*2;
2120
2099
can't get max_connections*5 but still got no less than was
2121
2100
requested (value of wanted_files).
2123
max_open_files= max(max((uint32_t)wanted_files, max_connections*5),
2102
max_open_files= cmax(cmax((uint32_t)wanted_files, max_connections*5),
2125
2104
files= my_set_max_open_files(max_open_files);
2127
2106
if (files < wanted_files)
2132
2111
If we have requested too much file handles than we bring
2133
2112
max_connections in supported bounds.
2135
max_connections= (uint32_t) min((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
2114
max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
2136
2115
max_connections);
2138
2117
Decrease table_cache_size according to max_connections, but
2139
not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
2118
not below TABLE_OPEN_CACHE_MIN. Outer cmin() ensures that we
2140
2119
never increase table_cache_size automatically (that could
2141
2120
happen if max_connections is decreased above).
2143
table_cache_size= (uint32_t) min(max((files-10-max_connections)/2,
2122
table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
2144
2123
(uint32_t)TABLE_OPEN_CACHE_MIN),
2145
2124
table_cache_size);
2146
2125
if (global_system_variables.log_warnings)
2248
2227
sys_init_slave.value=my_strdup("",MYF(0));
2250
/* check log options and issue warnings if needed */
2251
if (opt_log && opt_logname && !(log_output_options & LOG_FILE) &&
2252
!(log_output_options & LOG_NONE))
2253
sql_print_warning(_("Although a path was specified for the "
2254
"--log option, log tables are used. "
2255
"To enable logging to files use the "
2256
"--log-output option."));
2258
if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE)
2259
&& !(log_output_options & LOG_NONE))
2260
sql_print_warning(_("Although a path was specified for the "
2261
"--log-slow-queries option, log tables are used. "
2262
"To enable logging to files use the "
2263
"--log-output=file option."));
2265
s= opt_logname ? opt_logname : make_default_log_name(buff, ".log");
2266
sys_var_general_log_path.value= my_strdup(s, MYF(0));
2267
sys_var_general_log_path.value_length= strlen(s);
2269
s= opt_slow_logname ? opt_slow_logname : make_default_log_name(buff, "-slow.log");
2270
sys_var_slow_log_path.value= my_strdup(s, MYF(0));
2271
sys_var_slow_log_path.value_length= strlen(s);
2273
2229
if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2275
2231
if (my_database_names_init())
2306
2262
(void) pthread_cond_init(&COND_global_read_lock,NULL);
2307
2263
(void) pthread_cond_init(&COND_thread_cache,NULL);
2308
2264
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
2309
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2310
(void) pthread_cond_init(&COND_rpl_status, NULL);
2312
2266
/* Parameter for threads created for connections */
2313
2267
(void) pthread_attr_init(&connection_attrib);
2648
2597
if (global_system_variables.log_warnings)
2650
2599
/* %zu is not yet in C++ */
2651
unsigned long long size_tmp= (uint64_t)stack_size;
2652
sql_print_warning(_("Asked for %u thread stack, but got %llu"),
2600
uint64_t size_tmp= (uint64_t)stack_size;
2601
sql_print_warning(_("Asked for %u thread stack, but got %"PRIu64),
2653
2602
my_thread_stack_size, size_tmp);
2655
2604
my_thread_stack_size= stack_size;
2857
2805
if ((number_of= poll(fds, pollfd_count, -1)) == -1)
2859
if (socket_errno != SOCKET_EINTR)
2861
2809
if (!select_errors++ && !abort_loop) /* purecov: inspected */
2862
2810
sql_print_error(_("drizzled: Got error %d from select"),
2863
socket_errno); /* purecov: inspected */
2811
errno); /* purecov: inspected */
2865
2813
MAYBE_BROKEN_SYSCALL
2889
2837
assert(sock != -1);
2891
for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2839
for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2893
size_socket length= sizeof(struct sockaddr_storage);
2841
SOCKET_SIZE_TYPE length= sizeof(struct sockaddr_storage);
2894
2842
new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2896
if (new_sock != -1 || (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
2844
if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
2903
2851
if ((error_count++ & 255) == 0) // This can happen often
2904
2852
sql_perror("Error in accept");
2905
2853
MAYBE_BROKEN_SYSCALL;
2906
if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
2854
if (errno == ENFILE || errno == EMFILE)
2907
2855
sleep(1); // Give other threads some time
2912
size_socket dummyLen;
2860
SOCKET_SIZE_TYPE dummyLen;
2913
2861
struct sockaddr_storage dummy;
2914
2862
dummyLen = sizeof(dummy);
2915
2863
if ( getsockname(new_sock,(struct sockaddr *)&dummy,
2938
2886
if (!(thd= new THD))
2940
2888
(void) shutdown(new_sock, SHUT_RDWR);
2941
VOID(close(new_sock));
2944
if (!(vio_tmp=vio_new(new_sock, VIO_TYPE_TCPIP, sock == 0)) ||
2945
my_net_init(&thd->net,vio_tmp))
2892
if (net_init_sock(&thd->net, new_sock, sock == 0))
2948
Only delete the temporary vio if we didn't already attach it to the
2949
NET object. The destructor in THD will delete any initialized net
2952
if (vio_tmp && thd->net.vio != vio_tmp)
2953
vio_delete(vio_tmp);
2956
(void) shutdown(new_sock, SHUT_RDWR);
2957
(void) close(new_sock);
2984
2919
OPT_SHORT_LOG_FORMAT,
2985
2920
OPT_FLUSH, OPT_SAFE,
2986
2921
OPT_STORAGE_ENGINE, OPT_INIT_FILE,
2987
OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG,
2922
OPT_DELAY_KEY_WRITE_ALL,
2988
2923
OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR,
2989
2924
OPT_MASTER_INFO_FILE,
2990
2925
OPT_MASTER_RETRY_COUNT, OPT_LOG_TC, OPT_LOG_TC_SIZE,
3002
2937
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
3003
2938
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
3004
2939
OPT_ABORT_SLAVE_EVENT_COUNT,
3005
OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
3006
2940
OPT_ENGINE_CONDITION_PUSHDOWN,
3007
2941
OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
3008
2942
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
3085
3018
OPT_ENABLE_LARGE_PAGES,
3086
3019
OPT_TIMED_MUTEXES,
3087
3020
OPT_OLD_STYLE_USER_LIMITS,
3088
OPT_LOG_SLOW_ADMIN_STATEMENTS,
3089
3021
OPT_TABLE_LOCK_WAIT_TIMEOUT,
3090
3022
OPT_PLUGIN_LOAD,
3091
3023
OPT_PLUGIN_DIR,
3093
3024
OPT_PORT_OPEN_TIMEOUT,
3095
3026
OPT_KEEP_FILES_ON_CREATE,
3096
3027
OPT_GENERAL_LOG,
3098
3028
OPT_THREAD_HANDLING,
3099
3029
OPT_INNODB_ROLLBACK_ON_TIMEOUT,
3100
3030
OPT_SECURE_FILE_PRIV,
3101
3031
OPT_MIN_EXAMINED_ROW_LIMIT,
3102
OPT_LOG_SLOW_SLAVE_STATEMENTS,
3104
3033
OPT_POOL_OF_THREADS,
3105
3034
OPT_SLAVE_EXEC_MODE
3207
3136
N_("Path to the database root."),
3208
3137
(char**) &mysql_data_home,
3209
3138
(char**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3210
{"default-character-set", 'C',
3211
N_("Set the default character set (deprecated option, use "
3212
"--character-set-server instead)."),
3213
(char**) &default_character_set_name, (char**) &default_character_set_name,
3214
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3215
{"default-collation", OPT_DEFAULT_COLLATION,
3216
N_("Set the default collation (deprecated option, use --collation-server "
3218
(char**) &default_collation_name, (char**) &default_collation_name,
3219
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3220
3139
{"default-storage-engine", OPT_STORAGE_ENGINE,
3221
3140
N_("Set the default storage engine (table type) for tables."),
3222
3141
(char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
3228
3147
{"delay-key-write", OPT_DELAY_KEY_WRITE,
3229
3148
N_("Type of DELAY_KEY_WRITE."),
3230
3149
0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3231
{"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
3232
N_("Don't flush key buffers between writes for any MyISAM table "
3233
"(Deprecated option, use --delay-key-write=all instead)."),
3234
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3235
3150
{"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
3236
3151
N_("Option used by mysql-test for debugging and testing of replication."),
3237
3152
(char**) &disconnect_slave_event_count,
3262
3177
N_("Set up signals usable for debugging"),
3263
3178
(char**) &opt_debugging, (char**) &opt_debugging,
3264
3179
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3265
{"general-log", OPT_GENERAL_LOG,
3266
N_("Enable general query log"),
3268
(char**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3269
3180
{"init-connect", OPT_INIT_CONNECT,
3270
3181
N_("Command(s) that are executed for each new connection"),
3271
3182
(char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
3307
3218
N_("File that holds the names for last binary log files."),
3308
3219
(char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
3309
3220
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3311
This option starts with "log-bin" to emphasize that it is specific of
3314
{"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
3315
N_("If equal to 0 (the default), then when --log-bin is used, creation of "
3316
"a stored function (or trigger) is allowed only to users having the "
3317
"SUPER privilege and only if this stored function (trigger) may not "
3318
"break binary logging. Note that if ALL connections to this server "
3319
"ALWAYS use row-based binary logging, the security issues do not exist "
3320
"and the binary logging cannot break, so you can safely set this to 1.")
3321
,(char**) &trust_function_creators, (char**) &trust_function_creators, 0,
3322
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3323
3221
{"log-error", OPT_ERROR_LOG_FILE,
3324
3222
N_("Error log file."),
3325
3223
(char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
3328
3226
N_("Log all MyISAM changes to file."),
3329
3227
(char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3330
3228
OPT_ARG, 0, 0, 0, 0, 0, 0},
3331
{"log-long-format", '0',
3332
N_("Log some extra information to update log. Please note that this option "
3333
"is deprecated; see --log-queries-not-using-indexes option."),
3334
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3335
#ifdef WITH_CSV_STORAGE_ENGINE
3336
{"log-output", OPT_LOG_OUTPUT,
3337
N_("Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
3339
(char**) &log_output_str, (char**) &log_output_str, 0,
3340
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3342
{"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
3343
N_("Log queries that are executed without benefit of any index to the "
3344
"slow log if it is open."),
3345
(char**) &opt_log_queries_not_using_indexes,
3346
(char**) &opt_log_queries_not_using_indexes,
3347
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3348
3229
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
3349
3230
N_("Tells the slave to log the updates from the slave thread to the binary "
3350
3231
"log. You will need to turn it on if you plan to "
3352
3233
(char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3354
3235
NO_ARG, 0, 0, 0, 0, 0, 0},
3355
{"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
3356
N_("Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements "
3357
"to the slow log if it is open."),
3358
(char**) &opt_log_slow_admin_statements,
3359
(char**) &opt_log_slow_admin_statements,
3360
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3361
{"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
3362
N_("Log slow statements executed by slave thread to the slow log if it is "
3364
(char**) &opt_log_slow_slave_statements,
3365
(char**) &opt_log_slow_slave_statements,
3366
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3367
{"log-slow-queries", OPT_SLOW_QUERY_LOG,
3368
N_("Log slow queries to a table or log file. Defaults logging to table "
3369
"mysql.slow_log or hostname-slow.log if --log-output=file is used. "
3370
"Must be enabled to activate other slow log options."),
3371
(char**) &opt_slow_logname, (char**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
3373
3236
{"log-tc", OPT_LOG_TC,
3374
3237
N_("Path to transaction coordinator log (used for transactions that affect "
3375
3238
"more than one storage engine, when binary log is disabled)"),
3548
3411
"replication partners."),
3549
3412
(char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
3551
{"set-variable", 'O',
3552
N_("Change the value of a variable. Please note that this option is "
3553
"deprecated;you can set variables directly with --variable-name=value."),
3554
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3555
3414
{"skip-new", OPT_SKIP_NEW,
3556
3415
N_("Don't use new, possible wrong routines."),
3557
3416
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3563
3422
N_("Don't print a stack trace on failure."),
3564
3423
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
3566
{"skip-symlink", OPT_SKIP_SYMLINKS,
3567
N_("Don't allow symlinking of tables. Deprecated option. Use "
3568
"--skip-symbolic-links instead."),
3569
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3570
3425
{"skip-thread-priority", OPT_SKIP_PRIOR,
3571
3426
N_("Don't give threads different priorities."),
3572
3427
0, 0, 0, GET_NO_ARG, NO_ARG,
3588
3443
"and the slave."),
3589
3444
(char**) &slave_exec_mode_str, (char**) &slave_exec_mode_str,
3590
3445
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3591
{"slow-query-log", OPT_SLOW_LOG,
3592
N_("Enable|disable slow query log"),
3593
(char**) &opt_slow_log,
3594
(char**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3595
3446
{"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
3596
3447
N_("(INGORED)"),
3597
3448
0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
3634
3485
N_("Default transaction isolation level."),
3635
3486
0, 0, 0, GET_STR, REQUIRED_ARG, 0,
3636
3487
0, 0, 0, 0, 0},
3637
{"use-symbolic-links", 's',
3638
N_("Enable symbolic link support. Deprecated option; use --symbolic-links "
3640
(char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
3641
IF_PURIFY(0,1), 0, 0, 0, 0, 0},
3643
3489
N_("Run mysqld daemon as user."),
3644
3490
0, 0, 0, GET_STR, REQUIRED_ARG,
3647
3493
N_("Output version information and exit."),
3648
3494
0, 0, 0, GET_NO_ARG,
3649
3495
NO_ARG, 0, 0, 0, 0, 0, 0},
3651
N_("Deprecated; use --log-warnings instead."),
3652
(char**) &global_system_variables.log_warnings,
3653
(char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
3654
1, 0, ULONG_MAX, 0, 0, 0},
3655
3496
{"back_log", OPT_BACK_LOG,
3656
3497
N_("The number of outstanding connection requests MySQL can have. This "
3657
3498
"comes into play when the main MySQL thread gets very many connection "
3855
3696
(char**) &myisam_data_pointer_size,
3856
3697
(char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
3857
3698
6, 2, 7, 0, 1, 0},
3858
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
3859
N_("(Deprecated option)"),
3860
(char**) &global_system_variables.myisam_max_extra_sort_file_size,
3861
(char**) &max_system_variables.myisam_max_extra_sort_file_size,
3862
0, GET_ULL, REQUIRED_ARG, (uint64_t) MI_MAX_TEMP_LENGTH,
3863
0, (uint64_t) MAX_FILE_SIZE, 0, 1, 0},
3864
3699
{"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
3865
3700
N_("Don't use the fast sort index method to created index if the "
3866
3701
"temporary file would get bigger than this."),
4049
3884
"Use 0 (default) to disable synchronous flushing."),
4050
3885
(char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
4051
3886
REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
4052
{"table_cache", OPT_TABLE_OPEN_CACHE,
4053
N_("Deprecated; use --table_open_cache instead."),
4054
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
4055
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
4056
3887
{"table_definition_cache", OPT_TABLE_DEF_CACHE,
4057
3888
N_("The number of cached table definitions."),
4058
3889
(char**) &table_def_size, (char**) &table_def_size,
4328
4159
{"Threads_running", (char*) &thread_running, SHOW_INT},
4329
4160
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
4330
4161
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
4331
{NullS, NullS, SHOW_LONG}
4162
{NULL, NULL, SHOW_LONG}
4334
4165
static void print_version(void)
4396
4227
/* Things reset to zero */
4397
4228
opt_skip_slave_start= opt_reckless_slave = 0;
4398
4229
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
4399
opt_log= opt_slow_log= 0;
4400
4230
log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4401
4231
opt_bin_log= 0;
4402
4232
opt_skip_show_db=0;
4403
opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
4233
opt_logname= opt_binlog_index_name= 0;
4404
4234
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
4405
4235
opt_secure_auth= 0;
4406
4236
opt_secure_file_priv= 0;
4422
4252
binlog_cache_use= binlog_cache_disk_use= 0;
4423
4253
max_used_connections= slow_launch_threads = 0;
4424
4254
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4425
opt_mysql_tmpdir= my_bind_addr_str= NullS;
4255
opt_mysql_tmpdir= my_bind_addr_str= NULL;
4426
4256
memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4427
4257
memset(&global_status_var, 0, sizeof(global_status_var));
4428
4258
key_map_full.set_all();
4452
4282
what_to_log= ~ (1L << (uint) COM_TIME);
4453
4283
refresh_version= 1L; /* Increments on each reload */
4454
4284
global_query_id= thread_id= 1L;
4455
stpcpy(server_version, DRIZZLE_SERVER_VERSION);
4285
my_stpcpy(server_version, DRIZZLE_SERVER_VERSION);
4456
4286
myisam_recover_options_str= "OFF";
4457
4287
myisam_stats_method_str= "nulls_unequal";
4458
4288
threads.empty();
4688
case (int) OPT_SLOW_QUERY_LOG:
4691
#ifdef WITH_CSV_STORAGE_ENGINE
4692
case OPT_LOG_OUTPUT:
4694
if (!argument || !argument[0])
4696
log_output_options= LOG_FILE;
4697
log_output_str= log_output_typelib.type_names[1];
4701
log_output_str= argument;
4703
find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
4708
4515
case (int) OPT_WANT_CORE:
4709
4516
test_flags |= TEST_CORE_ON_SIGNAL;
4835
4642
/** Handle arguments for multiple key caches. */
4837
extern "C" char **mysql_getopt_value(const char *keyname, uint key_length,
4644
extern "C" char **mysql_getopt_value(const char *keyname, uint32_t key_length,
4838
4645
const struct my_option *option);
4841
mysql_getopt_value(const char *keyname, uint key_length,
4648
mysql_getopt_value(const char *keyname, uint32_t key_length,
4842
4649
const struct my_option *option)
4844
4651
switch (option->id) {
4902
4709
(*argc)++; /* add back one for the progname handle_options removes */
4903
4710
/* no need to do this for argv as we are discarding it. */
4905
if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
4906
opt_log_slow_slave_statements) &&
4908
sql_print_warning(_("options --log-slow-admin-statements, "
4909
"--log-queries-not-using-indexes and "
4910
"--log-slow-slave-statements have no effect if "
4911
"--log-slow-queries is not set"));
4913
4712
#if defined(HAVE_BROKEN_REALPATH)
4914
4713
my_use_symdir=0;
4915
4714
my_disable_symlinks=1;
4970
4769
(DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
4772
#ifdef DRIZZLE_SERVER_SUFFIX
4773
#define DRIZZLE_SERVER_SUFFIX_STR STRINGIFY_ARG(DRIZZLE_SERVER_SUFFIX)
4775
#define DRIZZLE_SERVER_SUFFIX_STR DRIZZLE_SERVER_SUFFIX_DEF
4973
4778
static void set_server_version(void)
4975
4780
char *end= strxmov(server_version, DRIZZLE_SERVER_VERSION,
4976
DRIZZLE_SERVER_SUFFIX_STR, NullS);
4977
if (opt_log || opt_slow_log || opt_bin_log)
4978
stpcpy(end, "-log"); // This may slow down system
4781
DRIZZLE_SERVER_SUFFIX_STR, NULL);
4783
my_stpcpy(end, "-log"); // This may slow down system
5008
4813
if (!test_if_hard_path(dir))
5010
4815
strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home,
5014
4819
return !fn_format(to, name, dir, extension,
5019
4824
static void fix_paths(void)
5021
4826
char buff[FN_REFLEN],*pos;
5022
convert_dirname(mysql_home,mysql_home,NullS);
4827
convert_dirname(mysql_home,mysql_home,NULL);
5023
4828
/* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
5024
4829
my_realpath(mysql_home,mysql_home,MYF(0));
5025
4830
/* Ensure that mysql_home ends in FN_LIBCHAR */
5029
4834
pos[0]= FN_LIBCHAR;
5032
convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
4837
convert_dirname(mysql_real_data_home,mysql_real_data_home,NULL);
5033
4838
(void) fn_format(buff, mysql_real_data_home, "", "",
5034
4839
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
5035
4840
(void) unpack_dirname(mysql_unpacked_real_data_home, buff);
5036
convert_dirname(language,language,NullS);
4841
convert_dirname(language,language,NULL);
5037
4842
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
5038
4843
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
5039
4844
(void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
5045
4850
if (test_if_hard_path(sharedir))
5046
4851
strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
5048
strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
5049
convert_dirname(buff,buff,NullS);
4853
strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NULL);
4854
convert_dirname(buff,buff,NULL);
5050
4855
(void) my_load_path(language,language,buff);
5052
4857
/* If --character-sets-dir isn't given, use shared library dir */
5053
4858
if (charsets_dir != mysql_charsets_dir)
5055
4860
strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
5056
CHARSET_DIR, NullS);
5058
4863
(void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
5059
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
4864
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NULL);
5060
4865
charsets_dir=mysql_charsets_dir;
5062
4867
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
5073
4878
if (opt_secure_file_priv)
5075
convert_dirname(buff, opt_secure_file_priv, NullS);
5076
my_free(opt_secure_file_priv, MYF(0));
4880
convert_dirname(buff, opt_secure_file_priv, NULL);
4881
free(opt_secure_file_priv);
5077
4882
opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
5181
4986
char buff[21], *end;
5182
4987
end= int10_to_str((long) getpid(), buff, 10);
5184
if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
4989
if (!my_write(file, (unsigned char*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
5186
4991
(void) my_close(file, MYF(0));