216
235
/* static variables */
237
/* the default log output is log tables */
218
238
static bool volatile select_thread_in_use;
219
239
static bool volatile ready_to_exit;
220
240
static bool opt_debugging= 0;
221
241
static uint32_t wake_thread;
222
static uint32_t killed_threads;
242
static uint32_t killed_threads, thread_created;
223
243
static char *drizzled_user, *drizzled_chroot;
224
static char *language_ptr;
225
static const char *default_character_set_name;
226
static const char *character_set_filesystem_name;
244
static char *language_ptr, *opt_init_connect;
245
static char *default_character_set_name;
246
static char *character_set_filesystem_name;
227
247
static char *lc_time_names_name;
248
static char *my_bind_addr_str;
228
249
static char *default_collation_name;
229
250
static char *default_storage_engine_str;
230
static const char *compiled_default_collation_name= "utf8_general_ci";
251
static char compiled_default_collation_name[]= DRIZZLE_DEFAULT_COLLATION_NAME;
252
static struct pollfd fds[UINT8_MAX];
253
static uint8_t pollfd_count= 0;
232
255
/* Global variables */
258
bool opt_log_queries_not_using_indexes= false;
259
bool opt_skip_show_db= false;
260
bool server_id_supplied = 0;
261
bool opt_endinfo, using_udf_functions;
234
262
bool locked_in_memory;
263
bool opt_using_transactions;
235
264
bool volatile abort_loop;
236
265
bool volatile shutdown_in_progress;
266
bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted
267
bool opt_reckless_slave = 0;
268
bool opt_enable_named_pipe= 0;
269
bool opt_local_infile;
270
bool opt_safe_user_create = 0;
271
bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
272
bool opt_log_slave_updates= 0;
237
273
uint32_t max_used_connections;
238
const string opt_scheduler_default("multi_thread");
239
char *opt_scheduler= NULL;
274
const char *opt_scheduler= "pool_of_threads";
241
276
size_t my_thread_stack_size= 65536;
244
Legacy global plugin::StorageEngine. These will be removed (please do not add more).
279
Legacy global handlerton. These will be removed (please do not add more).
246
plugin::StorageEngine *heap_engine;
247
plugin::StorageEngine *myisam_engine;
281
handlerton *heap_hton;
282
handlerton *myisam_hton;
249
285
char* opt_secure_file_priv= 0;
287
True if there is at least one per-hour limit for some user, so we should
288
check them before each query (and possibly reset counters when hour is
289
changed). False otherwise.
251
293
#ifdef HAVE_INITGROUPS
252
294
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
255
uint32_t drizzled_bind_timeout;
256
std::bitset<12> test_flags;
257
uint32_t dropping_tables, ha_open_options;
296
uint32_t drizzled_port, test_flags, select_errors, dropping_tables, ha_open_options;
297
uint32_t drizzled_port_timeout;
298
uint32_t delay_key_write_options, protocol_version= PROTOCOL_VERSION;
299
uint32_t lower_case_table_names= 1;
258
300
uint32_t tc_heuristic_recover= 0;
301
uint32_t volatile thread_count, thread_running;
259
302
uint64_t session_startup_options;
260
303
uint32_t back_log;
304
uint32_t connect_timeout;
261
305
uint32_t server_id;
262
306
uint64_t table_cache_size;
263
size_t table_def_size;
307
uint64_t table_def_size;
309
uint64_t slow_launch_time;
310
uint64_t slave_open_temp_tables;
311
uint32_t refresh_version; /* Increments on each reload */
264
312
uint64_t aborted_threads;
265
313
uint64_t aborted_connects;
266
314
uint64_t max_connect_errors;
267
uint32_t global_thread_id= 1UL;
268
316
pid_t current_pid;
317
uint64_t slow_launch_threads= 0;
318
uint64_t expire_logs_days= 0;
270
320
const double log_10[] = {
271
321
1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
370
440
static char *drizzle_home_ptr, *pidfile_name_ptr;
371
441
static int defaults_argc;
372
442
static char **defaults_argv;
443
static char *opt_bin_logname;
445
struct rand_struct sql_rand; ///< used by sql_class.cc:Session::Session()
374
447
struct passwd *user_info;
375
448
static pthread_t select_thread;
376
449
static uint32_t thr_kill_signal;
451
extern scheduling_st thread_scheduler;
379
454
Number of currently active user connections. The variable is protected by
380
455
LOCK_thread_count.
382
drizzled::atomic<uint32_t> connection_count;
385
Refresh value. We use to test this to find out if a refresh even has happened recently.
387
uint64_t refresh_version; /* Increments on each reload */
457
uint32_t connection_count= 0;
389
459
/* Function declarations */
390
bool drizzle_rm_tmp_tables();
392
461
extern "C" pthread_handler_t signal_hand(void *arg);
393
462
static void drizzle_init_variables(void);
394
463
static void get_options(int *argc,char **argv);
395
464
extern "C" bool drizzled_get_one_option(int, const struct my_option *, char *);
465
static void set_server_version(void);
396
466
static int init_thread_environment();
397
467
static const char *get_relative_path(const char *path);
398
static void fix_paths(string &progname);
468
static void fix_paths(void);
469
void handle_connections_sockets();
399
470
extern "C" pthread_handler_t handle_slave(void *arg);
471
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib);
472
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
400
474
static void clean_up(bool print_message);
402
476
static void usage(void);
477
static void close_server_sock();
403
478
static void clean_up_mutexes(void);
404
void close_connections(void);
479
static void drizzled_exit(int exit_code) __attribute__((noreturn));
480
extern "C" bool safe_read_error_impl(NET *net);
406
482
/****************************************************************************
407
483
** Code to end drizzled
408
484
****************************************************************************/
410
486
void close_connections(void)
412
/* Abort listening to new connections */
413
plugin::Listen::shutdown();
415
489
/* kill connection thread */
416
490
(void) pthread_mutex_lock(&LOCK_thread_count);
717
extern "C" void end_thread_signal(int );
907
static void network_init(void)
913
char port_buf[NI_MAXSERV];
915
struct addrinfo *next;
916
struct addrinfo hints;
921
memset(fds, 0, sizeof(struct pollfd) * UINT8_MAX);
922
memset(&hints, 0, sizeof (hints));
923
hints.ai_flags= AI_PASSIVE;
924
hints.ai_socktype= SOCK_STREAM;
926
snprintf(port_buf, NI_MAXSERV, "%d", drizzled_port);
927
error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
930
sql_perror(ER(ER_IPSOCK_ERROR)); /* purecov: tested */
931
unireg_abort(1); /* purecov: tested */
934
for (next= ai, pollfd_count= 0; next; next= next->ai_next, pollfd_count++)
938
ip_sock= socket(next->ai_family, next->ai_socktype, next->ai_protocol);
942
sql_perror(ER(ER_IPSOCK_ERROR)); /* purecov: tested */
943
unireg_abort(1); /* purecov: tested */
946
fds[pollfd_count].fd= ip_sock;
947
fds[pollfd_count].events= POLLIN | POLLERR;
949
/* Add options for our listening socket */
951
struct linger ling = {0, 0};
955
if (next->ai_family == AF_INET6)
957
error= setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags));
960
perror("setsockopt");
965
error= setsockopt(ip_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&flags, sizeof(flags));
968
perror("setsockopt");
971
error= setsockopt(ip_sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags));
974
perror("setsockopt");
977
error= setsockopt(ip_sock, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling));
980
perror("setsockopt");
983
error= setsockopt(ip_sock, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags));
986
perror("setsockopt");
993
Sometimes the port is not released fast enough when stopping and
994
restarting the server. This happens quite often with the test suite
995
on busy Linux systems. Retry to bind the address at these intervals:
996
Sleep intervals: 1, 2, 4, 6, 9, 13, 17, 22, ...
997
Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ...
998
Limit the sequence by drizzled_port_timeout (set --port-open-timeout=#).
1000
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1002
if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1003
(errno != EADDRINUSE) ||
1004
(waited >= drizzled_port_timeout))
1006
errmsg_printf(ERRMSG_LVL_INFO, _("Retrying bind on TCP/IP port %u"), drizzled_port);
1007
this_wait= retry * retry / 3 + 1;
1012
sql_perror(_("Can't start server: Bind on TCP/IP port"));
1013
errmsg_printf(ERRMSG_LVL_ERROR, _("Do you already have another drizzled server running "
1014
"on port: %d ?"),drizzled_port);
1017
if (listen(ip_sock,(int) back_log) < 0)
1019
sql_perror(_("Can't start server: listen() on TCP/IP port"));
1020
errmsg_printf(ERRMSG_LVL_ERROR, _("listen() on TCP/IP failed with error %d"),
719
1032
/** Called when a thread is aborted. */
720
1034
extern "C" void end_thread_signal(int )
722
1036
Session *session=current_session;
725
1039
statistic_increment(killed_threads, &LOCK_status);
726
session->scheduler->killSessionNow(session);
727
DRIZZLE_CONNECTION_DONE(session->thread_id);
1040
(void)thread_scheduler.end_thread(session, 0); /* purecov: inspected */
1042
return;; /* purecov: deadcode */
1069
1385
if (!session || MyFlags & ME_NOREFRESH)
1070
errmsg_printf(ERRMSG_LVL_ERROR, "%s: %s",my_progname,str);
1386
errmsg_printf(ERRMSG_LVL_ERROR, "%s: %s",my_progname,str); /* purecov: inspected */
1074
1391
static const char *load_default_groups[]= {
1075
DRIZZLE_CONFIG_NAME, "server", 0, 0};
1077
static int show_starttime(SHOW_VAR *var, char *buff)
1079
var->type= SHOW_LONG;
1081
*((long *)buff)= (long) (time(NULL) - server_start_time);
1085
static int show_flushstatustime(SHOW_VAR *var, char *buff)
1087
var->type= SHOW_LONG;
1089
*((long *)buff)= (long) (time(NULL) - flush_status_time);
1093
static int show_open_tables(SHOW_VAR *var, char *buff)
1095
var->type= SHOW_LONG;
1097
*((long *)buff)= (long)cached_open_tables();
1101
static int show_table_definitions(SHOW_VAR *var, char *buff)
1103
var->type= SHOW_LONG;
1105
*((long *)buff)= (long)cached_table_definitions();
1109
static st_show_var_func_container
1110
show_open_tables_cont= { &show_open_tables };
1111
static st_show_var_func_container
1112
show_table_definitions_cont= { &show_table_definitions };
1113
static st_show_var_func_container
1114
show_starttime_cont= { &show_starttime };
1115
static st_show_var_func_container
1116
show_flushstatustime_cont= { &show_flushstatustime };
1119
Variables shown by SHOW STATUS in alphabetical order
1392
DRIZZLE_CONFIG_NAME,"server", DRIZZLE_BASE_VERSION, 0, 0};
1396
Initialize one of the global date/time format variables.
1398
@param format_type What kind of format should be supported
1399
@param var_ptr Pointer to variable that should be updated
1402
The default value is taken from either opt_date_time_formats[] or
1403
the ISO format (ANSI SQL)
1121
static SHOW_VAR com_status_vars[]= {
1411
static bool init_global_datetime_format(enum enum_drizzle_timestamp_type format_type,
1412
DATE_TIME_FORMAT **var_ptr)
1414
/* Get command line option */
1415
const char *str= opt_date_time_formats[format_type];
1417
if (!str) // No specified format
1419
str= get_date_time_format_str(&known_date_time_formats[ISO_FORMAT],
1422
Set the "command line" option to point to the generated string so
1423
that we can set global formats back to default
1425
opt_date_time_formats[format_type]= str;
1427
if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str))))
1429
fprintf(stderr, _("Wrong date/time format specifier: %s\n"), str);
1435
SHOW_VAR com_status_vars[]= {
1122
1436
{"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
1437
{"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1123
1438
{"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
1124
1439
{"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1125
1440
{"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1167
1487
{"truncate", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1168
1488
{"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1169
1489
{"update", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1170
{NULL, NULL, SHOW_LONGLONG}
1173
static SHOW_VAR status_vars[]= {
1174
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONGLONG},
1175
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONGLONG},
1176
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
1177
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
1178
{"Com", (char*) com_status_vars, SHOW_ARRAY},
1179
{"Connections", (char*) &global_thread_id, SHOW_INT_NOFLUSH},
1180
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
1181
{"Created_tmp_files", (char*) &my_tmp_file_created,SHOW_INT},
1182
{"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
1183
{"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
1184
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
1185
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
1186
{"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS},
1187
{"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
1188
{"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
1189
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
1190
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
1191
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
1192
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
1193
{"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
1194
{"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
1195
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
1196
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
1197
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
1198
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
1199
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
1200
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
1201
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
1202
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
1203
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
1204
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
1205
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
1206
{"Max_used_connections", (char*) &max_used_connections, SHOW_INT},
1207
{"Open_files", (char*) &my_file_opened, SHOW_INT_NOFLUSH},
1208
{"Open_streams", (char*) &my_stream_opened, SHOW_INT_NOFLUSH},
1209
{"Open_table_definitions", (char*) &show_table_definitions_cont, SHOW_FUNC},
1210
{"Open_tables", (char*) &show_open_tables_cont, SHOW_FUNC},
1211
{"Opened_files", (char*) &my_file_total_opened, SHOW_INT_NOFLUSH},
1212
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
1213
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
1214
{"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
1215
{"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
1216
{"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
1217
{"Select_range", (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
1218
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
1219
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
1220
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
1221
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
1222
{"Sort_range", (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
1223
{"Sort_rows", (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
1224
{"Sort_scan", (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
1225
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_INT},
1226
{"Table_locks_waited", (char*) &locks_waited, SHOW_INT},
1227
{"Threads_connected", (char*) &connection_count, SHOW_INT},
1228
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
1229
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
1490
{"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1230
1491
{NULL, NULL, SHOW_LONGLONG}
1649
1968
/* Wait until cleanup is done */
1650
1969
(void) pthread_mutex_lock(&LOCK_thread_count);
1651
1970
while (!ready_to_exit)
1652
pthread_cond_wait(&COND_server_end,&LOCK_thread_count);
1971
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
1653
1972
(void) pthread_mutex_unlock(&LOCK_thread_count);
1656
plugin::Registry::shutdown();
1980
Create new thread to handle incoming connection.
1982
This function will create new thread to handle the incoming
1983
connection. If there are idle cached threads one will be used.
1984
'session' will be pushed into 'threads'.
1986
In single-threaded mode (\#define ONE_THREAD) connection will be
1987
handled inside this function.
1989
@param[in,out] session Thread handle of future thread.
1992
static void create_new_thread(Session *session)
1994
pthread_mutex_lock(&LOCK_thread_count);
1998
if (connection_count > max_used_connections)
1999
max_used_connections= connection_count;
2002
The initialization of thread_id is done in create_embedded_session() for
2003
the embedded library.
2004
TODO: refactor this to avoid code duplication there
2006
session->thread_id= session->variables.pseudo_thread_id= thread_id++;
2011
If we error on creation we drop the connection and delete the session.
2013
if (thread_scheduler.add_connection(session))
2015
char error_message_buff[DRIZZLE_ERRMSG_SIZE];
2017
session->killed= Session::KILL_CONNECTION; // Safety
2019
statistic_increment(aborted_connects, &LOCK_status);
2021
/* Can't use my_error() since store_globals has not been called. */
2022
snprintf(error_message_buff, sizeof(error_message_buff), ER(ER_CANT_CREATE_THREAD), 1); /* TODO replace will better error message */
2023
net_send_error(session, ER_CANT_CREATE_THREAD, error_message_buff);
2024
(void) pthread_mutex_lock(&LOCK_thread_count);
2026
session->close_connection(0, 0);
2028
(void) pthread_mutex_unlock(&LOCK_thread_count);
2033
/* Handle new connections and spawn new process to handle them */
2035
void handle_connections_sockets()
2039
uint32_t error_count=0;
2041
struct sockaddr_storage cAddr;
2047
if ((number_of= poll(fds, pollfd_count, -1)) == -1)
2051
if (!select_errors++ && !abort_loop) /* purecov: inspected */
2052
errmsg_printf(ERRMSG_LVL_ERROR, _("drizzled: Got error %d from select"),
2053
errno); /* purecov: inspected */
2060
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
2061
assert(number_of > 1); /* Not handling this at the moment */
2069
for (x= 0, sock= -1; x < pollfd_count; x++)
2071
if (fds[x].revents == POLLIN)
2079
for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2081
SOCKET_SIZE_TYPE length= sizeof(struct sockaddr_storage);
2082
new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2084
if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
2091
if ((error_count++ & 255) == 0) // This can happen often
2092
sql_perror("Error in accept");
2093
if (errno == ENFILE || errno == EMFILE)
2094
sleep(1); // Give other threads some time
2099
SOCKET_SIZE_TYPE dummyLen;
2100
struct sockaddr_storage dummy;
2101
dummyLen = sizeof(dummy);
2102
if ( getsockname(new_sock,(struct sockaddr *)&dummy,
2103
(socklen_t *)&dummyLen) < 0 )
2105
sql_perror("Error on new connection socket");
2106
(void) shutdown(new_sock, SHUT_RDWR);
2107
(void) close(new_sock);
2110
dummyLen = sizeof(dummy);
2111
if ( getpeername(new_sock, (struct sockaddr *)&dummy,
2112
(socklen_t *)&dummyLen) < 0)
2114
sql_perror("Error on new connection socket");
2115
(void) shutdown(new_sock, SHUT_RDWR);
2116
(void) close(new_sock);
2122
** Don't allow too many connections
2125
if (!(session= new Session))
2127
(void) shutdown(new_sock, SHUT_RDWR);
2131
if (drizzleclient_net_init_sock(&session->net, new_sock, sock == 0))
2137
create_new_thread(session);
1784
2292
N_("Set the default time zone."),
1785
2293
(char**) &default_tz_name, (char**) &default_tz_name,
1786
2294
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
2295
{"delay-key-write", OPT_DELAY_KEY_WRITE,
2296
N_("Type of DELAY_KEY_WRITE."),
2297
0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1787
2298
#ifdef HAVE_STACK_TRACE_ON_SEGV
1788
2299
{"enable-pstack", OPT_DO_PSTACK,
1789
2300
N_("Print a symbolic stack trace on failure."),
1790
2301
(char**) &opt_do_pstack, (char**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
1792
2303
#endif /* HAVE_STACK_TRACE_ON_SEGV */
2304
{"engine-condition-pushdown",
2305
OPT_ENGINE_CONDITION_PUSHDOWN,
2306
N_("Push supported query conditions to the storage engine."),
2307
(char**) &global_system_variables.engine_condition_pushdown,
2308
(char**) &global_system_variables.engine_condition_pushdown,
2309
0, GET_BOOL, NO_ARG, false, 0, 0, 0, 0, 0},
1793
2310
/* See how it's handled in get_one_option() */
1794
2311
{"exit-info", 'T',
1795
2312
N_("Used for debugging; Use at your own risk!"),
1796
2313
0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
2314
{"flush", OPT_FLUSH,
2315
N_("Flush tables to disk between SQL commands."),
2316
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1797
2317
/* We must always support the next option to make scripts like mysqltest
1798
2318
easier to do */
1799
2319
{"gdb", OPT_DEBUGGING,
1800
2320
N_("Set up signals usable for debugging"),
1801
2321
(char**) &opt_debugging, (char**) &opt_debugging,
1802
2322
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
2323
{"init-connect", OPT_INIT_CONNECT,
2324
N_("Command(s) that are executed for each new connection"),
2325
(char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
2326
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2327
{"init-file", OPT_INIT_FILE,
2328
N_("Read SQL commands from this file at startup."),
2329
(char**) &opt_init_file, (char**) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
1803
2331
{"language", 'L',
1804
2332
N_("(IGNORED)"),
1805
2333
(char**) &language_ptr, (char**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
1809
2337
(char**) &lc_time_names_name,
1810
2338
(char**) &lc_time_names_name,
1811
2339
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
2340
{"local-infile", OPT_LOCAL_INFILE,
2341
N_("Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)."),
2342
(char**) &opt_local_infile,
2343
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
2346
N_("Log connections and queries to file."),
2347
(char**) &opt_logname,
2348
(char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2349
{"log-isam", OPT_ISAM_LOG,
2350
N_("Log all MyISAM changes to file."),
2351
(char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
2352
OPT_ARG, 0, 0, 0, 0, 0, 0},
1812
2353
{"log-warnings", 'W',
1813
2354
N_("Log some not critical warnings to the log file."),
1814
2355
(char**) &global_system_variables.log_warnings,
1815
(char**) &max_system_variables.log_warnings, 0, GET_BOOL, OPT_ARG, 1, 0, 0,
2356
(char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
1817
2358
{"memlock", OPT_MEMLOCK,
1818
2359
N_("Lock drizzled in memory."),
1819
2360
(char**) &locked_in_memory,
1820
2361
(char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
2362
{"myisam-recover", OPT_MYISAM_RECOVER,
2363
N_("Syntax: myisam-recover[=option[,option...]], where option can be "
2364
"DEFAULT, BACKUP, FORCE or QUICK."),
2365
(char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
2366
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2368
N_("Use very new possible 'unsafe' functions."),
2369
(char**) &global_system_variables.new_mode,
2370
(char**) &max_system_variables.new_mode,
2371
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
2372
{"old-alter-table", OPT_OLD_ALTER_TABLE,
2373
N_("Use old, non-optimized alter table."),
2374
(char**) &global_system_variables.old_alter_table,
2375
(char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
1821
2377
{"pid-file", OPT_PID_FILE,
1822
2378
N_("Pid file used by safe_mysqld."),
1823
2379
(char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
1824
2380
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2382
N_("Port number to use for connection or 0 for default to, in "
2383
"order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
2384
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
2385
(char**) &drizzled_port,
2386
(char**) &drizzled_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1825
2387
{"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
1826
2388
N_("Maximum time in seconds to wait for the port to become free. "
1827
2389
"(Default: no wait)"),
1828
(char**) &drizzled_bind_timeout,
1829
(char**) &drizzled_bind_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2390
(char**) &drizzled_port_timeout,
2391
(char**) &drizzled_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2392
{"safe-mode", OPT_SAFE,
2393
N_("Skip some optimize stages (for testing)."),
2394
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1830
2395
{"secure-file-priv", OPT_SECURE_FILE_PRIV,
1831
2396
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1832
2397
"within specified directory"),
1835
2400
{"server-id", OPT_SERVER_ID,
1836
2401
N_("Uniquely identifies the server instance in the community of "
1837
2402
"replication partners."),
1838
(char**) &server_id, (char**) &server_id, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 0,
2403
(char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
2405
{"skip-new", OPT_SKIP_NEW,
2406
N_("Don't use new, possible wrong routines."),
2407
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1840
2408
{"skip-stack-trace", OPT_SKIP_STACK_TRACE,
1841
2409
N_("Don't print a stack trace on failure."),
1842
2410
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
2412
{"skip-thread-priority", OPT_SKIP_PRIOR,
2413
N_("Don't give threads different priorities."),
2414
0, 0, 0, GET_NO_ARG, NO_ARG,
2415
DEFAULT_SKIP_THREAD_PRIORITY, 0, 0, 0, 0, 0},
1844
2416
{"symbolic-links", 's',
1845
2417
N_("Enable symbolic link support."),
1846
2418
(char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
1883
2465
(char**) &global_system_variables.bulk_insert_buff_size,
1884
2466
(char**) &max_system_variables.bulk_insert_buff_size,
1885
2467
0, GET_ULL, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
2468
{ "connect_timeout", OPT_CONNECT_TIMEOUT,
2469
N_("The number of seconds the drizzled server is waiting for a connect "
2470
"packet before responding with 'Bad handshake'."),
2471
(char**) &connect_timeout, (char**) &connect_timeout,
2472
0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
2473
{ "date_format", OPT_DATE_FORMAT,
2474
N_("The DATE format (For future)."),
2475
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
2476
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
2477
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2478
{ "datetime_format", OPT_DATETIME_FORMAT,
2479
N_("The DATETIME/TIMESTAMP format (for future)."),
2480
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
2481
(char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
2482
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1886
2483
{ "div_precision_increment", OPT_DIV_PRECINCREMENT,
1887
2484
N_("Precision of the result of '/' operator will be increased on that "
1892
2489
{ "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
1893
2490
N_("The maximum length of the result of function group_concat."),
1894
2491
(char**) &global_system_variables.group_concat_max_len,
1895
(char**) &max_system_variables.group_concat_max_len, 0, GET_UINT64,
2492
(char**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
1896
2493
REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
2494
{ "interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
2495
N_("The number of seconds the server waits for activity on an interactive "
2496
"connection before closing it."),
2497
(char**) &global_system_variables.net_interactive_timeout,
2498
(char**) &max_system_variables.net_interactive_timeout, 0,
2499
GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
1897
2500
{ "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1898
2501
N_("The size of the buffer that is used for full joins."),
1899
2502
(char**) &global_system_variables.join_buff_size,
1900
(char**) &max_system_variables.join_buff_size, 0, GET_UINT64,
2503
(char**) &max_system_variables.join_buff_size, 0, GET_ULONG,
1901
2504
REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
1902
2505
MALLOC_OVERHEAD, IO_SIZE, 0},
2506
{"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
2507
N_("Don't overwrite stale .MYD and .MYI even if no directory is specified."),
2508
(char**) &global_system_variables.keep_files_on_create,
2509
(char**) &max_system_variables.keep_files_on_create,
2510
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1903
2511
{"key_buffer_size", OPT_KEY_BUFFER_SIZE,
1904
2512
N_("The size of the buffer used for index blocks for MyISAM tables. "
1905
2513
"Increase this to get better index handling (for all reads and multiple "
1906
2514
"writes) to as much as you can afford;"),
1907
2515
(char**) &dflt_key_cache_var.param_buff_size,
2517
0, (GET_ULL | GET_ASK_ADDR),
1910
2518
REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
1912
2520
{"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
1916
2524
"total number of blocks in key cache"),
1917
2525
(char**) &dflt_key_cache_var.param_age_threshold,
1919
0, (GET_UINT32), REQUIRED_ARG,
2527
0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
1920
2528
300, 100, ULONG_MAX, 0, 100, 0},
1921
2529
{"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
1922
2530
N_("The default size of key cache blocks"),
1923
2531
(char**) &dflt_key_cache_var.param_block_size,
1925
0, (GET_UINT32), REQUIRED_ARG,
2533
0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
1926
2534
KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
1927
2535
{"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
1928
2536
N_("The minimum percentage of warm blocks in key cache"),
1929
2537
(char**) &dflt_key_cache_var.param_division_limit,
1931
0, (GET_UINT32) , REQUIRED_ARG, 100,
2539
0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1932
2540
1, 100, 0, 1, 0},
1933
2541
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1934
2542
N_("Max packetlength to send/receive from to server."),
1935
2543
(char**) &global_system_variables.max_allowed_packet,
1936
(char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
2544
(char**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
1937
2545
REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1938
2546
{"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
1939
2547
N_("If there is more than this number of interrupted connections from a "
1940
2548
"host this host will be blocked from further connections."),
1941
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
2549
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_ULONG,
1942
2550
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
1943
2551
{"max_error_count", OPT_MAX_ERROR_COUNT,
1944
2552
N_("Max number of errors/warnings to store for a statement."),
1945
2553
(char**) &global_system_variables.max_error_count,
1946
2554
(char**) &max_system_variables.max_error_count,
1947
0, GET_UINT64, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
2555
0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
1948
2556
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1949
2557
N_("Don't allow creation of heap tables bigger than this."),
1950
2558
(char**) &global_system_variables.max_heap_table_size,
1965
2573
{ "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
1966
2574
N_("Limit assumed max number of seeks when looking up rows based on a key"),
1967
2575
(char**) &global_system_variables.max_seeks_for_key,
1968
(char**) &max_system_variables.max_seeks_for_key, 0, GET_UINT64,
2576
(char**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
1969
2577
REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
1970
2578
{"max_sort_length", OPT_MAX_SORT_LENGTH,
1971
2579
N_("The number of bytes to use when sorting BLOB or TEXT values "
1972
2580
"(only the first max_sort_length bytes of each value are used; the "
1973
2581
"rest are ignored)."),
1974
2582
(char**) &global_system_variables.max_sort_length,
1975
(char**) &max_system_variables.max_sort_length, 0, GET_SIZE,
2583
(char**) &max_system_variables.max_sort_length, 0, GET_UINT,
1976
2584
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
2585
{"max_tmp_tables", OPT_MAX_TMP_TABLES,
2586
N_("Maximum number of temporary tables a client can keep open at a time."),
2587
(char**) &global_system_variables.max_tmp_tables,
2588
(char**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
2589
REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
1977
2590
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
1978
2591
N_("After this many write locks, allow some read locks to run in between."),
1979
2592
(char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULL,
1984
2597
(char**) &global_system_variables.min_examined_row_limit,
1985
2598
(char**) &max_system_variables.min_examined_row_limit, 0, GET_ULL,
1986
2599
REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
2600
{"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
2601
N_("Specifies how MyISAM index statistics collection code should threat "
2602
"NULLs. Possible values of name are 'nulls_unequal' "
2603
"(default behavior), "
2604
"'nulls_equal' (emulate MySQL 4.0 behavior), and 'nulls_ignored'."),
2605
(char**) &myisam_stats_method_str, (char**) &myisam_stats_method_str, 0,
2606
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2607
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
2608
N_("Buffer length for TCP/IP and socket communication."),
2609
(char**) &global_system_variables.net_buffer_length,
2610
(char**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
2611
REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
2612
{"net_read_timeout", OPT_NET_READ_TIMEOUT,
2613
N_("Number of seconds to wait for more data from a connection before "
2614
"aborting the read."),
2615
(char**) &global_system_variables.net_read_timeout,
2616
(char**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
2617
REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
2618
{"net_retry_count", OPT_NET_RETRY_COUNT,
2619
N_("If a read on a communication port is interrupted, retry this many "
2620
"times before giving up."),
2621
(char**) &global_system_variables.net_retry_count,
2622
(char**) &max_system_variables.net_retry_count,0,
2623
GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
2624
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
2625
N_("Number of seconds to wait for a block to be written to a connection "
2626
"before aborting the write."),
2627
(char**) &global_system_variables.net_write_timeout,
2628
(char**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
2629
REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
2630
{ "old", OPT_OLD_MODE,
2631
N_("Use compatible behavior."),
2632
(char**) &global_system_variables.old_mode,
2633
(char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
1987
2635
{"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
1988
2636
N_("Controls the heuristic(s) applied during query optimization to prune "
1989
2637
"less-promising partial plans from the optimizer search space. Meaning: "
2003
2651
"testing/comparison)."),
2004
2652
(char**) &global_system_variables.optimizer_search_depth,
2005
2653
(char**) &max_system_variables.optimizer_search_depth,
2006
0, GET_UINT, OPT_ARG, 0, 0, MAX_TABLES+2, 0, 1, 0},
2654
0, GET_UINT, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
2007
2655
{"plugin_dir", OPT_PLUGIN_DIR,
2008
2656
N_("Directory for plugins."),
2009
2657
(char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
2010
2658
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2011
{"plugin_add", OPT_PLUGIN_ADD,
2012
N_("Optional comma separated list of plugins to load at startup in addition "
2013
"to the default list of plugins. "
2014
"[for example: --plugin_add=crc32,logger_gearman]"),
2015
(char**) &opt_plugin_add, (char**) &opt_plugin_add, 0,
2016
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2017
2659
{"plugin_load", OPT_PLUGIN_LOAD,
2018
N_("Optional comma separated list of plugins to load at starup instead of "
2019
"the default plugin load list. "
2020
"[for example: --plugin_load=crc32,logger_gearman]"),
2660
N_("Optional colon (or semicolon) separated list of plugins to load,"
2661
"where each plugin is identified by the name of the shared library. "
2662
"[for example: --plugin_load=libmd5udf.so:libauth_pam.so]"),
2021
2663
(char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
2022
2664
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2023
2665
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
2059
2701
GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
2060
2702
UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
2061
2703
{"scheduler", OPT_SCHEDULER,
2062
N_("Select scheduler to be used (by default multi-thread)."),
2063
(char**)&opt_scheduler, (char**)&opt_scheduler,
2064
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2065
/* x8 compared to MySQL's x2. We have UTF8 to consider. */
2704
N_("Select scheduler to be used (by default pool-of-threads)."),
2705
(char**) &opt_scheduler, (char**) &opt_scheduler, 0,
2706
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2066
2707
{"sort_buffer_size", OPT_SORT_BUFFER,
2067
2708
N_("Each thread that needs to do a sort allocates a buffer of this size."),
2068
2709
(char**) &global_system_variables.sortbuff_size,
2069
(char**) &max_system_variables.sortbuff_size, 0, GET_SIZE, REQUIRED_ARG,
2070
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*8, SIZE_MAX,
2710
(char**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
2711
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, SIZE_MAX,
2071
2712
MALLOC_OVERHEAD, 1, 0},
2072
2713
{"table_definition_cache", OPT_TABLE_DEF_CACHE,
2073
2714
N_("The number of cached table definitions."),
2074
2715
(char**) &table_def_size, (char**) &table_def_size,
2075
0, GET_SIZE, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
2716
0, GET_ULL, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
2076
2717
{"table_open_cache", OPT_TABLE_OPEN_CACHE,
2077
2718
N_("The number of cached open tables."),
2078
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_UINT64,
2719
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
2079
2720
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
2080
2721
{"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
2081
2722
N_("Timeout in seconds to wait for a table level lock before returning an "
2104
2750
(char**) &global_system_variables.trans_prealloc_size,
2105
2751
(char**) &max_system_variables.trans_prealloc_size, 0, GET_UINT,
2106
2752
REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
2753
{"wait_timeout", OPT_WAIT_TIMEOUT,
2754
N_("The number of seconds the server waits for activity on a connection "
2755
"before closing it."),
2756
(char**) &global_system_variables.net_wait_timeout,
2757
(char**) &max_system_variables.net_wait_timeout, 0, GET_UINT,
2758
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
2107
2760
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2763
static int show_net_compression(Session *session,
2767
var->type= SHOW_MY_BOOL;
2768
var->value= (char *)&session->net.compress;
2772
static st_show_var_func_container
2773
show_net_compression_cont= { &show_net_compression };
2775
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
2777
var->type= SHOW_LONG;
2779
*((long *)buff)= (long) (session->query_start() - server_start_time);
2783
static st_show_var_func_container
2784
show_starttime_cont= { &show_starttime };
2786
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
2788
var->type= SHOW_LONG;
2790
*((long *)buff)= (long) (session->query_start() - flush_status_time);
2794
static st_show_var_func_container
2795
show_flushstatustime_cont= { &show_flushstatustime };
2797
static int show_open_tables(Session *, SHOW_VAR *var, char *buff)
2799
var->type= SHOW_LONG;
2801
*((long *)buff)= (long)cached_open_tables();
2805
static int show_table_definitions(Session *,
2806
SHOW_VAR *var, char *buff)
2808
var->type= SHOW_LONG;
2810
*((long *)buff)= (long)cached_table_definitions();
2814
static st_show_var_func_container
2815
show_open_tables_cont= { &show_open_tables };
2816
static st_show_var_func_container
2817
show_table_definitions_cont= { &show_table_definitions };
2820
Variables shown by SHOW STATUS in alphabetical order
2823
SHOW_VAR status_vars[]= {
2824
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONGLONG},
2825
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONGLONG},
2826
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
2827
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
2828
{"Com", (char*) com_status_vars, SHOW_ARRAY},
2829
{"Compression", (char*) &show_net_compression_cont, SHOW_FUNC},
2830
{"Connections", (char*) &thread_id, SHOW_LONG_NOFLUSH},
2831
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
2832
{"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_INT},
2833
{"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
2834
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_NOFLUSH},
2835
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
2836
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
2837
{"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS},
2838
{"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
2839
{"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
2840
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
2841
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
2842
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
2843
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
2844
{"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
2845
{"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
2846
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
2847
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
2848
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
2849
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
2850
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
2851
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
2852
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
2853
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
2854
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
2855
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
2856
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
2857
{"Max_used_connections", (char*) &max_used_connections, SHOW_INT},
2858
{"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH},
2859
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH},
2860
{"Open_table_definitions", (char*) &show_table_definitions_cont, SHOW_FUNC},
2861
{"Open_tables", (char*) &show_open_tables_cont, SHOW_FUNC},
2862
{"Opened_files", (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
2863
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
2864
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
2865
{"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
2866
{"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
2867
{"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
2868
{"Select_range", (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
2869
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
2870
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
2871
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONGLONG},
2872
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
2873
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
2874
{"Sort_range", (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
2875
{"Sort_rows", (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
2876
{"Sort_scan", (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
2877
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_INT},
2878
{"Table_locks_waited", (char*) &locks_waited, SHOW_INT},
2879
{"Threads_connected", (char*) &connection_count, SHOW_INT},
2880
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
2881
{"Threads_running", (char*) &thread_running, SHOW_INT},
2882
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
2883
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
2884
{NULL, NULL, SHOW_LONGLONG}
2110
2887
static void print_version(void)
2889
set_server_version();
2113
2891
Note: the instance manager keys off the string 'Ver' so it can find the
2114
2892
version from the output of 'drizzled --version', so don't change it!
2116
printf("%s Ver %s for %s-%s on %s (%s)\n",my_progname,
2117
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU,
2118
COMPILATION_COMMENT);
2894
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
2895
server_version,SYSTEM_TYPE,MACHINE_TYPE, COMPILATION_COMMENT);
2121
2898
static void usage(void)
2162
2945
static void drizzle_init_variables(void)
2164
2947
/* Things reset to zero */
2948
opt_skip_slave_start= opt_reckless_slave = 0;
2165
2949
drizzle_home[0]= pidfile_name[0]= 0;
2166
2953
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
2167
2954
opt_secure_file_priv= 0;
2169
2956
cleanup_done= 0;
2170
2957
defaults_argc= 0;
2171
2958
defaults_argv= 0;
2172
dropping_tables= ha_open_options=0;
2175
abort_loop= select_thread_in_use= false;
2959
server_id_supplied= 0;
2960
test_flags= select_errors= dropping_tables= ha_open_options=0;
2961
thread_count= thread_running= wake_thread=0;
2962
slave_open_temp_tables= 0;
2963
opt_endinfo= using_udf_functions= 0;
2964
opt_using_transactions= false;
2965
abort_loop= select_thread_in_use= 0;
2176
2966
ready_to_exit= shutdown_in_progress= 0;
2177
2967
aborted_threads= aborted_connects= 0;
2178
2968
max_used_connections= 0;
2179
drizzled_user= drizzled_chroot= 0;
2969
slow_launch_threads= 0;
2970
drizzled_user= drizzled_chroot= opt_init_file= opt_bin_logname = 0;
2971
my_bind_addr_str= NULL;
2180
2972
memset(&global_status_var, 0, sizeof(global_status_var));
2973
key_map_full.set_all();
2183
2975
/* Character sets */
2184
2976
system_charset_info= &my_charset_utf8_general_ci;
2185
2977
files_charset_info= &my_charset_utf8_general_ci;
2978
national_charset_info= &my_charset_utf8_general_ci;
2186
2979
table_alias_charset= &my_charset_bin;
2187
2980
character_set_filesystem= &my_charset_bin;
2982
opt_date_time_formats[0]= opt_date_time_formats[1]= opt_date_time_formats[2]= 0;
2189
2984
/* Things with default values that are not zero */
2985
delay_key_write_options= (uint32_t) DELAY_KEY_WRITE_ON;
2190
2986
drizzle_home_ptr= drizzle_home;
2191
2987
pidfile_name_ptr= pidfile_name;
2192
2988
language_ptr= language;
2193
2989
drizzle_data_home= drizzle_real_data_home;
2194
2990
session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2991
what_to_log= ~ (1L << (uint32_t) COM_TIME);
2195
2992
refresh_version= 1L; /* Increments on each reload */
2196
global_thread_id= 1UL;
2197
session_list.clear();
2994
strcpy(server_version, VERSION);
2995
myisam_recover_options_str= "OFF";
2996
myisam_stats_method_str= "nulls_unequal";
2999
if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
3000
default_key_cache_base.length)))
3002
/* set key_cache_hash.default_value = dflt_key_cache */
3003
multi_keycache_init();
2199
3005
/* Set directory paths */
2200
3006
strncpy(language, LANGUAGE, sizeof(language)-1);
2327
3158
global_system_variables.tx_isolation= (type-1);
3161
case OPT_MYISAM_RECOVER:
3165
myisam_recover_options= HA_RECOVER_DEFAULT;
3166
myisam_recover_options_str= myisam_recover_typelib.type_names[0];
3168
else if (!argument[0])
3170
myisam_recover_options= HA_RECOVER_NONE;
3171
myisam_recover_options_str= "OFF";
3175
myisam_recover_options_str=argument;
3176
myisam_recover_options=
3177
find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
3179
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
2330
3182
case OPT_TC_HEURISTIC_RECOVER:
2331
3183
tc_heuristic_recover= find_type_or_exit(argument,
2332
3184
&tc_heuristic_recover_typelib,
3187
case OPT_MYISAM_STATS_METHOD:
3189
uint32_t method_conv;
3192
myisam_stats_method_str= argument;
3193
method= find_type_or_exit(argument, &myisam_stats_method_typelib,
3197
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
3200
method_conv= MI_STATS_METHOD_NULLS_EQUAL;
3204
method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
3207
global_system_variables.myisam_stats_method= method_conv;
3215
/** Handle arguments for multiple key caches. */
3217
extern "C" char **drizzle_getopt_value(const char *keyname, uint32_t key_length,
3218
const struct my_option *option);
3221
drizzle_getopt_value(const char *keyname, uint32_t key_length,
3222
const struct my_option *option)
3224
switch (option->id) {
3225
case OPT_KEY_BUFFER_SIZE:
3226
case OPT_KEY_CACHE_BLOCK_SIZE:
3227
case OPT_KEY_CACHE_DIVISION_LIMIT:
3228
case OPT_KEY_CACHE_AGE_THRESHOLD:
3230
KEY_CACHE *key_cache;
3231
if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
3233
switch (option->id) {
3234
case OPT_KEY_BUFFER_SIZE:
3235
return (char**) &key_cache->param_buff_size;
3236
case OPT_KEY_CACHE_BLOCK_SIZE:
3237
return (char**) &key_cache->param_block_size;
3238
case OPT_KEY_CACHE_DIVISION_LIMIT:
3239
return (char**) &key_cache->param_division_limit;
3240
case OPT_KEY_CACHE_AGE_THRESHOLD:
3241
return (char**) &key_cache->param_age_threshold;
3245
return (char **)option->value;
2340
3249
extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
2342
extern "C" void option_error_reporter(enum loglevel level, const char *format, ...)
3251
void option_error_reporter(enum loglevel level, const char *format, ...)
2345
3254
va_start(args, format);
2448
3382
(void) my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
2449
3383
(void) my_load_path(drizzle_real_data_home, drizzle_real_data_home,drizzle_home);
2450
3384
(void) my_load_path(pidfile_name, pidfile_name,drizzle_real_data_home);
2452
if (opt_plugin_dir_ptr == NULL)
2454
/* No plugin dir has been specified. Figure out where the plugins are */
2455
if (progname[0] != FN_LIBCHAR)
2457
/* We have a relative path and need to find the absolute */
2458
char working_dir[FN_REFLEN];
2459
char *working_dir_ptr= working_dir;
2460
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
2461
string new_path(working_dir);
2462
if (*(new_path.end()-1) != '/')
2463
new_path.push_back('/');
2464
if (progname[0] == '.' && progname[1] == '/')
2465
new_path.append(progname.substr(2));
2467
new_path.append(progname);
2468
progname.swap(new_path);
2471
/* Now, trim off the exe name */
2472
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
2473
if (progdir.rfind(".libs/") != string::npos)
2475
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
2477
string testfile(progdir);
2478
testfile.append("drizzled.o");
2479
struct stat testfile_stat;
2480
if (stat(testfile.c_str(), &testfile_stat))
2482
/* drizzled.o doesn't exist - we are not in a source dir.
2485
(void) my_load_path(opt_plugin_dir, get_relative_path(PKGPLUGINDIR),
2490
/* We are in a source dir! Plugin dir is ../plugin/.libs */
2491
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
2492
string source_plugindir(progdir.substr(0,last_libchar_pos));
2493
source_plugindir.append("plugin/.libs");
2494
(void) my_load_path(opt_plugin_dir, source_plugindir.c_str(), "");
2499
(void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, drizzle_home);
3385
(void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr ? opt_plugin_dir_ptr :
3386
get_relative_path(PKGPLUGINDIR),
2501
3388
opt_plugin_dir_ptr= opt_plugin_dir;
2503
3390
const char *sharedir= get_relative_path(PKGDATADIR);
2504
3391
if (test_if_hard_path(sharedir))
2505
strncpy(buff,sharedir,sizeof(buff)-1);
3392
strncpy(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
2508
3395
strcpy(buff, drizzle_home);
3437
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
3444
if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
3446
ptr= bit_lib->type_names;
3448
fprintf(stderr, _("No option given to %s\n"), option);
3450
fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
3452
fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
3454
fprintf(stderr, ",'%s'", *ptr);
3455
fprintf(stderr, "\n");
3464
a bitfield from a string of substrings separated by ','
3466
~(uint32_t) 0 on error.
3469
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
3473
const char *end,*i,*j;
3474
const char **array, *pos;
3475
uint32_t found,found_int,bit;
3480
while (*pos == ' ') pos++;
3481
found_end= *pos == 0;
3484
if ((end=strrchr(pos,',')) != NULL) /* Let end point at fieldend */
3486
while (end > pos && end[-1] == ' ')
3487
end--; /* Skip end-space */
3492
end=pos+strlen(pos);
3495
found_int=0; found_count=0;
3496
for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
3501
if (my_toupper(mysqld_charset,*i++) !=
3502
my_toupper(mysqld_charset,*j++))
3511
else if (j != pos) // Half field found
3513
found_count++; // Could be one of two values
3517
if (found_count != 1)
3518
return(~(uint32_t) 0); // No unique value
3524
} /* find_bit_type */
3527
bool safe_read_error_impl(NET *net)
3530
return drizzleclient_vio_was_interrupted(net->vio);
2549
3535
/*****************************************************************************
2550
3536
Instantiate templates
2551
3537
*****************************************************************************/
2553
3539
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
2554
3540
/* Used templates */
3541
template class I_List<Session>;
3542
template class I_List_iterator<Session>;
2555
3543
template class I_List<i_string>;
2556
3544
template class I_List<i_string_pair>;
3545
template class I_List<NAMED_LIST>;
2557
3546
template class I_List<Statement>;
2558
3547
template class I_List_iterator<Statement>;