~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/drizzled.cc

Removed/replaced DBUG symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
 
21
 
#include <drizzled/server_includes.h>
22
 
#include <mysys/my_bit.h>
 
1
/* Copyright (C) 2000-2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysql_priv.h"
 
17
#include <m_ctype.h>
 
18
#include <my_dir.h>
 
19
#include <my_bit.h>
23
20
#include "slave.h"
24
21
#include "rpl_mi.h"
25
22
#include "sql_repl.h"
26
23
#include "rpl_filter.h"
 
24
#include "repl_failsafe.h"
27
25
#include "stacktrace.h"
28
 
#include <mysys/mysys_err.h>
29
 
#include <sys/poll.h>
30
 
#include <netinet/tcp.h>
31
 
#include <drizzled/error.h>
32
 
#include <drizzled/tztime.h>
33
 
 
34
 
#if TIME_WITH_SYS_TIME
35
 
# include <sys/time.h>
36
 
# include <time.h>
37
 
#else
38
 
# if HAVE_SYS_TIME_H
39
 
#  include <sys/time.h>
40
 
# else
41
 
#  include <time.h>
42
 
# endif
43
 
#endif
44
 
 
45
 
#include <storage/myisam/ha_myisam.h>
 
26
#include "mysqld_suffix.h"
 
27
#include "mysys_err.h"
 
28
 
 
29
#include "../storage/myisam/ha_myisam.h"
46
30
 
47
31
#ifdef HAVE_SYS_PRCTL_H
48
32
#include <sys/prctl.h>
52
36
#define DEFAULT_SKIP_THREAD_PRIORITY 0
53
37
#endif
54
38
 
55
 
#include <mysys/thr_alarm.h>
56
 
#include <libdrizzle/errmsg.h>
57
 
#include <locale.h>
 
39
#include <thr_alarm.h>
 
40
#include <errmsg.h>
58
41
 
59
 
#define mysqld_charset &my_charset_utf8_general_ci
 
42
#define mysqld_charset &my_charset_latin1
60
43
 
61
44
#ifdef HAVE_purify
62
45
#define IF_PURIFY(A,B) (A)
64
47
#define IF_PURIFY(A,B) (B)
65
48
#endif
66
49
 
67
 
#define MAX_MEM_TABLE_SIZE SIZE_MAX
 
50
#if SIZEOF_CHARP == 4
 
51
#define MAX_MEM_TABLE_SIZE ~(ulong) 0
 
52
#else
 
53
#define MAX_MEM_TABLE_SIZE ~(ulonglong) 0
 
54
#endif
68
55
 
69
56
/* We have HAVE_purify below as this speeds up the shutdown of MySQL */
70
57
 
75
62
extern "C" {                                    // Because of SCO 3.2V4.2
76
63
#include <errno.h>
77
64
#include <sys/stat.h>
78
 
#include <mysys/my_getopt.h>
 
65
#ifndef __GNU_LIBRARY__
 
66
#define __GNU_LIBRARY__                         // Skip warnings in getopt.h
 
67
#endif
 
68
#include <my_getopt.h>
79
69
#ifdef HAVE_SYSENT_H
80
70
#include <sysent.h>
81
71
#endif
85
75
#ifdef HAVE_GRP_H
86
76
#include <grp.h>
87
77
#endif
 
78
#include <my_net.h>
88
79
 
89
80
#include <sys/resource.h>
90
81
 
103
94
#endif
104
95
 
105
96
#define SIGNAL_FMT "signal %d"
106
 
 
 
97
  
107
98
 
108
99
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
109
100
#include <ieeefp.h>
152
143
 
153
144
} /* cplusplus */
154
145
 
155
 
#define DRIZZLE_KILL_SIGNAL SIGTERM
156
 
 
157
 
#include <mysys/my_pthread.h>                   // For thr_setconcurency()
158
 
 
159
 
#include <drizzled/gettext.h>
 
146
#define MYSQL_KILL_SIGNAL SIGTERM
 
147
 
 
148
#include <my_pthread.h>                 // For thr_setconcurency()
160
149
 
161
150
#ifdef SOLARIS
162
151
extern "C" int gethostname(char *name, int namelen);
163
152
#endif
164
153
 
165
 
extern "C" RETSIGTYPE handle_segfault(int sig);
 
154
extern "C" sig_handler handle_segfault(int sig);
166
155
 
167
156
/* Constants */
168
157
 
175
164
static const char *optimizer_switch_names[]=
176
165
{
177
166
  "no_materialization", "no_semijoin",
178
 
  NULL
 
167
  NullS
179
168
};
180
169
 
181
170
/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */
191
180
 
192
181
static const char *tc_heuristic_recover_names[]=
193
182
{
194
 
  "COMMIT", "ROLLBACK", NULL
 
183
  "COMMIT", "ROLLBACK", NullS
195
184
};
196
185
static TYPELIB tc_heuristic_recover_typelib=
197
186
{
201
190
 
202
191
const char *first_keyword= "first", *binary_keyword= "BINARY";
203
192
const char *my_localhost= "localhost";
 
193
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
204
194
#define GET_HA_ROWS GET_ULL
 
195
#else
 
196
#define GET_HA_ROWS GET_ULONG
 
197
#endif
205
198
 
206
199
/*
207
200
  Used with --help for detailed option
208
201
*/
209
 
static bool opt_help= false;
 
202
static my_bool opt_help= 0, opt_verbose= 0;
210
203
 
211
204
arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
212
205
{{&Arg_comparator::compare_string,     &Arg_comparator::compare_e_string},
215
208
 {&Arg_comparator::compare_row,        &Arg_comparator::compare_e_row},
216
209
 {&Arg_comparator::compare_decimal,    &Arg_comparator::compare_e_decimal}};
217
210
 
218
 
const char *log_output_names[] = { "NONE", "FILE", NULL};
219
 
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
 
211
const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS};
 
212
static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 };
220
213
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
221
 
                             log_output_names,
 
214
                             log_output_names, 
222
215
                             (unsigned int *) log_output_names_len};
223
216
 
224
217
/* static variables */
225
218
 
226
219
/* the default log output is log tables */
 
220
static bool lower_case_table_names_used= 0;
227
221
static bool volatile select_thread_in_use, signal_thread_in_use;
228
222
static bool volatile ready_to_exit;
229
 
static bool opt_debugging= 0, opt_console= 0;
230
 
static uint32_t wake_thread;
231
 
static uint32_t killed_threads, thread_created;
232
 
static uint32_t max_used_connections;
 
223
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
 
224
static my_bool opt_short_log_format= 0;
 
225
static uint kill_cached_threads, wake_thread;
 
226
static ulong killed_threads, thread_created;
 
227
static ulong max_used_connections;
 
228
static volatile ulong cached_thread_count= 0;
233
229
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
234
230
static char *opt_init_slave, *language_ptr, *opt_init_connect;
235
231
static char *default_character_set_name;
236
232
static char *character_set_filesystem_name;
237
233
static char *lc_time_names_name;
238
234
static char *my_bind_addr_str;
239
 
static char *default_collation_name;
 
235
static char *default_collation_name; 
240
236
static char *default_storage_engine_str;
241
 
static char compiled_default_collation_name[]= DRIZZLE_DEFAULT_COLLATION_NAME;
242
 
static I_List<Session> thread_cache;
 
237
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
 
238
static I_List<THD> thread_cache;
 
239
static double long_query_time;
243
240
 
244
241
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
245
242
 
246
243
/* Global variables */
247
244
 
248
245
bool opt_bin_log;
 
246
my_bool opt_log, opt_slow_log;
249
247
ulong log_output_options;
250
 
bool opt_log_queries_not_using_indexes= false;
251
 
bool opt_error_log= 0;
252
 
bool opt_skip_show_db= false;
253
 
bool opt_character_set_client_handshake= 1;
 
248
my_bool opt_log_queries_not_using_indexes= 0;
 
249
bool opt_error_log= IF_WIN(1,0);
 
250
bool opt_disable_networking=0, opt_skip_show_db=0;
 
251
my_bool opt_character_set_client_handshake= 1;
254
252
bool server_id_supplied = 0;
255
253
bool opt_endinfo, using_udf_functions;
256
 
bool locked_in_memory;
 
254
my_bool locked_in_memory;
257
255
bool opt_using_transactions, using_update_log;
258
256
bool volatile abort_loop;
259
257
bool volatile shutdown_in_progress;
260
 
bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted
261
 
bool opt_reckless_slave = 0;
262
 
bool opt_enable_named_pipe= 0;
263
 
bool opt_local_infile;
264
 
bool opt_slave_compressed_protocol;
265
 
bool opt_safe_user_create = 0;
266
 
bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
267
 
bool opt_log_slave_updates= 0;
268
 
static struct pollfd fds[UINT8_MAX];
269
 
static uint8_t pollfd_count= 0;
 
258
my_bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted
 
259
my_bool opt_reckless_slave = 0;
 
260
my_bool opt_enable_named_pipe= 0;
 
261
my_bool opt_local_infile, opt_slave_compressed_protocol;
 
262
my_bool opt_safe_user_create = 0;
 
263
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
 
264
my_bool opt_log_slave_updates= 0;
270
265
 
271
266
/*
272
267
  Legacy global handlerton. These will be removed (please do not add more).
274
269
handlerton *heap_hton;
275
270
handlerton *myisam_hton;
276
271
 
277
 
bool opt_readonly;
278
 
bool use_temp_pool;
279
 
bool relay_log_purge;
 
272
my_bool opt_readonly, use_temp_pool, relay_log_purge;
 
273
my_bool opt_sync_frm;
 
274
my_bool opt_secure_auth= 0;
280
275
char* opt_secure_file_priv= 0;
 
276
my_bool opt_log_slow_admin_statements= 0;
 
277
my_bool opt_log_slow_slave_statements= 0;
 
278
my_bool lower_case_file_system= 0;
 
279
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
281
280
/*
282
281
  True if there is at least one per-hour limit for some user, so we should
283
282
  check them before each query (and possibly reset counters when hour is
284
283
  changed). False otherwise.
285
284
*/
286
 
bool opt_noacl;
 
285
volatile bool mqh_used = 0;
 
286
my_bool opt_noacl;
287
287
 
288
288
ulong opt_binlog_rows_event_max_size;
289
 
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NULL};
 
289
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
290
290
TYPELIB binlog_format_typelib=
291
291
  { array_elements(binlog_format_names) - 1, "",
292
292
    binlog_format_names, NULL };
293
 
uint32_t opt_binlog_format_id= (uint32_t) BINLOG_FORMAT_UNSPEC;
 
293
ulong opt_binlog_format_id= (ulong) BINLOG_FORMAT_UNSPEC;
294
294
const char *opt_binlog_format= binlog_format_names[opt_binlog_format_id];
295
295
#ifdef HAVE_INITGROUPS
296
 
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
 
296
static bool calling_initgroups= FALSE; /**< Used in SIGSEGV handler. */
297
297
#endif
298
 
uint32_t mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
299
 
uint32_t mysqld_port_timeout;
300
 
uint32_t delay_key_write_options, protocol_version;
301
 
uint32_t lower_case_table_names= 1;
302
 
uint32_t tc_heuristic_recover= 0;
303
 
uint32_t volatile thread_count, thread_running;
304
 
uint64_t session_startup_options;
305
 
ulong back_log, connect_timeout;
306
 
uint32_t server_id;
 
298
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
 
299
uint mysqld_port_timeout;
 
300
uint delay_key_write_options, protocol_version;
 
301
uint lower_case_table_names;
 
302
uint tc_heuristic_recover= 0;
 
303
uint volatile thread_count, thread_running;
 
304
ulonglong thd_startup_options;
 
305
ulong back_log, connect_timeout, server_id;
307
306
ulong table_cache_size, table_def_size;
308
307
ulong what_to_log;
309
 
ulong slow_launch_time, slave_open_temp_tables;
310
 
ulong open_files_limit;
311
 
ulong max_binlog_size;
312
 
ulong max_relay_log_size;
313
 
ulong slave_net_timeout;
314
 
ulong slave_trans_retries;
315
 
bool slave_allow_batching;
 
308
ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
 
309
ulong open_files_limit, max_binlog_size, max_relay_log_size;
 
310
ulong slave_net_timeout, slave_trans_retries;
 
311
my_bool slave_allow_batching;
316
312
ulong slave_exec_mode_options;
317
313
const char *slave_exec_mode_str= "STRICT";
318
 
ulong thread_cache_size= 0;
319
 
ulong thread_pool_size= 0;
320
 
ulong binlog_cache_size= 0;
321
 
ulong max_binlog_cache_size= 0;
322
 
uint32_t refresh_version;  /* Increments on each reload */
323
 
ulong aborted_threads;
324
 
ulong aborted_connects;
325
 
ulong specialflag= 0;
326
 
ulong binlog_cache_use= 0;
327
 
ulong binlog_cache_disk_use= 0;
328
 
ulong max_connections;
329
 
ulong max_connect_errors;
330
 
uint32_t  max_user_connections= 0;
331
 
ulong thread_id=1L;
332
 
ulong current_pid;
333
 
ulong slow_launch_threads = 0;
334
 
ulong sync_binlog_period;
 
314
ulong thread_cache_size=0, thread_pool_size= 0;
 
315
ulong binlog_cache_size=0, max_binlog_cache_size=0;
 
316
ulong refresh_version;  /* Increments on each reload */
 
317
query_id_t global_query_id;
 
318
ulong aborted_threads, aborted_connects;
 
319
ulong flush_time;
 
320
ulong specialflag=0;
 
321
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
 
322
ulong max_connections, max_connect_errors;
 
323
uint  max_user_connections= 0;
 
324
ulong thread_id=1L,current_pid;
 
325
ulong slow_launch_threads = 0, sync_binlog_period;
335
326
ulong expire_logs_days = 0;
336
327
ulong rpl_recovery_rank=0;
337
328
const char *log_output_str= "FILE";
379
370
     language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
380
371
     *opt_init_file, *opt_tc_log_file;
381
372
char mysql_unpacked_real_data_home[FN_REFLEN];
382
 
uint32_t reg_ext_length;
 
373
uint reg_ext_length;
383
374
const key_map key_map_empty(0);
384
375
key_map key_map_full(0);                        // Will be initialized later
385
376
 
386
377
const char *opt_date_time_formats[3];
387
378
 
388
 
uint32_t mysql_data_home_len;
 
379
uint mysql_data_home_len;
389
380
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
390
381
char server_version[SERVER_VERSION_LENGTH];
391
382
char *opt_mysql_tmpdir;
 
383
const char **errmesg;                   /**< Error messages */
392
384
const char *myisam_recover_options_str="OFF";
393
385
const char *myisam_stats_method_str="nulls_unequal";
394
386
 
407
399
Ge_creator ge_creator;
408
400
Le_creator le_creator;
409
401
 
 
402
FILE *bootstrap_file;
 
403
int bootstrap_error;
410
404
FILE *stderror_file=0;
411
405
 
412
 
I_List<Session> threads;
 
406
I_List<THD> threads;
413
407
I_List<NAMED_LIST> key_caches;
414
408
Rpl_filter* rpl_filter;
415
409
Rpl_filter* binlog_filter;
421
415
MY_TMPDIR mysql_tmpdir_list;
422
416
MY_BITMAP temp_pool;
423
417
 
424
 
const CHARSET_INFO *system_charset_info, *files_charset_info ;
425
 
const CHARSET_INFO *national_charset_info, *table_alias_charset;
426
 
const CHARSET_INFO *character_set_filesystem;
 
418
CHARSET_INFO *system_charset_info, *files_charset_info ;
 
419
CHARSET_INFO *national_charset_info, *table_alias_charset;
 
420
CHARSET_INFO *character_set_filesystem;
427
421
 
428
422
MY_LOCALE *my_default_lc_time_names;
429
423
 
430
 
SHOW_COMP_OPTION have_symlink;
431
 
SHOW_COMP_OPTION have_compress;
 
424
SHOW_COMP_OPTION have_symlink, have_dlopen;
 
425
SHOW_COMP_OPTION have_crypt, have_compress;
432
426
 
433
427
/* Thread specific variables */
434
428
 
435
429
pthread_key(MEM_ROOT**,THR_MALLOC);
436
 
pthread_key(Session*, THR_Session);
 
430
pthread_key(THD*, THR_THD);
437
431
pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
438
 
                LOCK_status,
439
 
                LOCK_global_read_lock,
440
 
                LOCK_error_log,
441
 
                LOCK_global_system_variables,
442
 
                LOCK_slave_list, 
443
 
                LOCK_active_mi,
 
432
                LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
 
433
                LOCK_error_log, LOCK_uuid_generator,
 
434
                LOCK_crypt,
 
435
                LOCK_global_system_variables,
 
436
                LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
444
437
                LOCK_connection_count;
445
438
 
446
439
rw_lock_t       LOCK_sys_init_connect, LOCK_sys_init_slave;
451
444
pthread_cond_t  COND_server_started;
452
445
 
453
446
/* replication parameters, if master_host is not NULL, we are a slave */
454
 
uint32_t report_port= DRIZZLE_PORT;
455
 
uint32_t master_retry_count= 0;
 
447
uint report_port= MYSQL_PORT;
 
448
ulong master_retry_count=0;
456
449
char *master_info_file;
457
450
char *relay_log_info_file, *report_user, *report_password, *report_host;
458
451
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
459
 
char *opt_logname;
 
452
char *opt_logname, *opt_slow_logname;
460
453
 
461
454
/* Static variables */
462
455
 
463
456
static bool kill_in_progress, segfaulted;
464
457
#ifdef HAVE_STACK_TRACE_ON_SEGV
465
 
static bool opt_do_pstack;
 
458
static my_bool opt_do_pstack;
466
459
#endif /* HAVE_STACK_TRACE_ON_SEGV */
 
460
static my_bool opt_bootstrap, opt_myisam_log;
467
461
static int cleanup_done;
468
 
static uint32_t opt_myisam_block_size;
 
462
static ulong opt_specialflag, opt_myisam_block_size;
469
463
static char *opt_binlog_index_name;
470
464
static char *opt_tc_heuristic_recover;
471
465
static char *mysql_home_ptr, *pidfile_name_ptr;
473
467
static char **defaults_argv;
474
468
static char *opt_bin_logname;
475
469
 
476
 
struct rand_struct sql_rand; ///< used by sql_class.cc:Session::Session()
 
470
static my_socket ip_sock;
 
471
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
477
472
 
478
473
struct passwd *user_info;
479
474
static pthread_t select_thread;
480
 
static uint32_t thr_kill_signal;
 
475
static uint thr_kill_signal;
481
476
 
482
477
/* OS specific variables */
483
478
 
484
479
bool mysqld_embedded=0;
485
480
 
 
481
#ifndef DBUG_OFF
 
482
static const char* default_dbug_option;
 
483
#endif
 
484
 
486
485
scheduler_functions thread_scheduler;
487
486
 
488
487
/**
489
488
  Number of currently active user connections. The variable is protected by
490
489
  LOCK_connection_count.
491
490
*/
492
 
uint32_t connection_count= 0;
 
491
uint connection_count= 0;
493
492
 
494
493
/* Function declarations */
495
494
 
496
495
pthread_handler_t signal_hand(void *arg);
497
496
static void mysql_init_variables(void);
498
497
static void get_options(int *argc,char **argv);
499
 
extern "C" bool mysqld_get_one_option(int, const struct my_option *, char *);
 
498
extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *);
500
499
static void set_server_version(void);
501
500
static int init_thread_environment();
502
501
static char *get_relative_path(const char *path);
504
503
void handle_connections_sockets();
505
504
pthread_handler_t kill_server_thread(void *arg);
506
505
pthread_handler_t handle_slave(void *arg);
507
 
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib);
508
 
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
 
506
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
 
507
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
509
508
                                   const char *option);
510
509
static void clean_up(bool print_message);
 
510
static int test_if_case_insensitive(const char *dir_name);
511
511
 
512
512
static void usage(void);
513
513
static void start_signal_handler(void);
527
527
  int count=0;
528
528
#endif
529
529
 
 
530
  /* Clear thread cache */
 
531
  kill_cached_threads++;
 
532
  flush_thread_cache();
 
533
 
 
534
  /* kill flush thread */
 
535
  (void) pthread_mutex_lock(&LOCK_manager);
 
536
  if (manager_thread_in_use)
 
537
  {
 
538
   (void) pthread_cond_signal(&COND_manager);
 
539
  }
 
540
  (void) pthread_mutex_unlock(&LOCK_manager);
 
541
 
530
542
  /* kill connection thread */
531
543
  (void) pthread_mutex_lock(&LOCK_thread_count);
532
544
 
540
552
      break;                                    // allready dead
541
553
#endif
542
554
    set_timespec(abstime, 2);
543
 
    for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
 
555
    for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
544
556
    {
545
557
      error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count,
546
558
                                   &abstime);
549
561
    }
550
562
#ifdef EXTRA_DEBUG
551
563
    if (error != 0 && !count++)
552
 
      sql_print_error(_("Got error %d from pthread_cond_timedwait"),error);
 
564
      sql_print_error("Got error %d from pthread_cond_timedwait",error);
553
565
#endif
554
566
    close_server_sock();
555
567
  }
557
569
 
558
570
 
559
571
  /* Abort listening to new connections */
 
572
  if (!opt_disable_networking )
560
573
  {
561
 
    int x;
562
 
 
563
 
    for (x= 0; x < pollfd_count; x++)
 
574
    if (ip_sock != INVALID_SOCKET)
564
575
    {
565
 
      if (fds[x].fd != -1)
566
 
      {
567
 
        (void) shutdown(fds[x].fd, SHUT_RDWR);
568
 
        (void) close(fds[x].fd);
569
 
        fds[x].fd= -1;
570
 
      }
 
576
      (void) shutdown(ip_sock, SHUT_RDWR);
 
577
      (void) closesocket(ip_sock);
 
578
      ip_sock= INVALID_SOCKET;
571
579
    }
572
580
  }
573
 
 
574
581
  end_thr_alarm(0);                      // Abort old alarms.
575
582
 
576
583
  /*
579
586
    statements and inform their clients that the server is about to die.
580
587
  */
581
588
 
582
 
  Session *tmp;
 
589
  THD *tmp;
583
590
  (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
584
591
 
585
 
  I_List_iterator<Session> it(threads);
 
592
  I_List_iterator<THD> it(threads);
586
593
  while ((tmp=it++))
587
594
  {
588
595
    /* We skip slave threads & scheduler on this first loop through. */
589
596
    if (tmp->slave_thread)
590
597
      continue;
591
598
 
592
 
    tmp->killed= Session::KILL_CONNECTION;
 
599
    tmp->killed= THD::KILL_CONNECTION;
593
600
    thread_scheduler.post_kill_notification(tmp);
594
601
    if (tmp->mysys_var)
595
602
    {
597
604
      pthread_mutex_lock(&tmp->mysys_var->mutex);
598
605
      if (tmp->mysys_var->current_cond)
599
606
      {
600
 
        pthread_mutex_lock(tmp->mysys_var->current_mutex);
601
 
        pthread_cond_broadcast(tmp->mysys_var->current_cond);
602
 
        pthread_mutex_unlock(tmp->mysys_var->current_mutex);
 
607
        pthread_mutex_lock(tmp->mysys_var->current_mutex);
 
608
        pthread_cond_broadcast(tmp->mysys_var->current_cond);
 
609
        pthread_mutex_unlock(tmp->mysys_var->current_mutex);
603
610
      }
604
611
      pthread_mutex_unlock(&tmp->mysys_var->mutex);
605
612
    }
651
658
static void close_server_sock()
652
659
{
653
660
#ifdef HAVE_CLOSE_SERVER_SOCK
 
661
  my_socket tmp_sock;
 
662
  tmp_sock=ip_sock;
 
663
  if (tmp_sock != INVALID_SOCKET)
654
664
  {
655
 
    int x;
656
 
 
657
 
    for (x= 0; x < pollfd_count; x++)
658
 
    {
659
 
      if (fds[x].fd != -1)
660
 
      {
661
 
        (void) shutdown(fds[x].fd, SHUT_RDWR);
662
 
        (void) close(fds[x].fd);
663
 
        fds[x].fd= -1;
664
 
      }
665
 
    }
 
665
    ip_sock=INVALID_SOCKET;
 
666
    VOID(shutdown(tmp_sock, SHUT_RDWR));
666
667
  }
 
668
  return;;
667
669
#endif
668
670
}
669
671
 
677
679
#endif
678
680
 
679
681
#if defined(HAVE_PTHREAD_KILL)
680
 
  pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
 
682
  pthread_kill(signal_thread, MYSQL_KILL_SIGNAL);
681
683
#elif !defined(SIGNALS_DONT_BREAK_READ)
682
 
  kill(current_pid, DRIZZLE_KILL_SIGNAL);
 
684
  kill(current_pid, MYSQL_KILL_SIGNAL);
683
685
#endif
684
686
  shutdown_in_progress=1;                       // Safety if kill didn't work
685
687
#ifdef SIGNALS_DONT_BREAK_READ
689
691
    abort_loop=1;
690
692
    if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
691
693
                           (void*) 0))
692
 
      sql_print_error(_("Can't create thread to kill server"));
 
694
      sql_print_error("Can't create thread to kill server");
693
695
  }
694
696
#endif
695
697
  return;;
713
715
  // if there is a signal during the kill in progress, ignore the other
714
716
  if (kill_in_progress)                         // Safety
715
717
    RETURN_FROM_KILL_SERVER;
716
 
  kill_in_progress=true;
 
718
  kill_in_progress=TRUE;
717
719
  abort_loop=1;                                 // This should be set
718
720
  if (sig != 0) // 0 is not a valid signal number
719
721
    my_sigset(sig, SIG_IGN);                    /* purify inspected */
720
 
  if (sig == DRIZZLE_KILL_SIGNAL || sig == 0)
721
 
    sql_print_information(_(ER(ER_NORMAL_SHUTDOWN)),my_progname);
 
722
  if (sig == MYSQL_KILL_SIGNAL || sig == 0)
 
723
    sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname);
722
724
  else
723
 
    sql_print_error(_(ER(ER_GOT_SIGNAL)),my_progname,sig); /* purecov: inspected */
724
 
 
 
725
    sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
 
726
  
725
727
  close_connections();
726
 
  if (sig != DRIZZLE_KILL_SIGNAL &&
 
728
  if (sig != MYSQL_KILL_SIGNAL &&
727
729
      sig != 0)
728
730
    unireg_abort(1);                            /* purecov: inspected */
729
731
  else
753
755
#endif
754
756
 
755
757
 
756
 
extern "C" RETSIGTYPE print_signal_warning(int sig)
 
758
extern "C" sig_handler print_signal_warning(int sig)
757
759
{
758
760
  if (global_system_variables.log_warnings)
759
 
    sql_print_warning(_("Got signal %d from thread %"PRIu64), sig,my_thread_id());
760
 
#ifndef HAVE_BSD_SIGNALS
 
761
    sql_print_warning("Got signal %d from thread %ld", sig,my_thread_id());
 
762
#ifdef DONT_REMEMBER_SIGNAL
761
763
  my_sigset(sig,print_signal_warning);          /* int. thread system calls */
762
764
#endif
763
765
  if (sig == SIGALRM)
790
792
{
791
793
 
792
794
  if (exit_code)
793
 
    sql_print_error(_("Aborting\n"));
 
795
    sql_print_error("Aborting\n");
794
796
  else if (opt_help)
795
797
    usage();
796
 
  clean_up(!opt_help && (exit_code)); /* purecov: inspected */
 
798
  clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
797
799
  mysqld_exit(exit_code);
798
800
}
799
801
 
812
814
  if (cleanup_done++)
813
815
    return; /* purecov: inspected */
814
816
 
 
817
  /*
 
818
    make sure that handlers finish up
 
819
    what they have that is dependent on the binlog
 
820
  */
 
821
  ha_binlog_end(current_thd);
 
822
 
815
823
  logger.cleanup_base();
816
824
 
817
825
  mysql_bin_log.cleanup();
831
839
  if (tc_log)
832
840
    tc_log->close();
833
841
  xid_cache_free();
834
 
  delete_elements(&key_caches, (void (*)(const char*, unsigned char*)) free_key_cache);
 
842
  delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
835
843
  multi_keycache_free();
836
844
  free_status_vars();
837
845
  end_thr_alarm(1);                     /* Free allocated memory */
838
846
  my_free_open_file_info();
839
 
  free((char*) global_system_variables.date_format);
840
 
  free((char*) global_system_variables.time_format);
841
 
  free((char*) global_system_variables.datetime_format);
 
847
  my_free((char*) global_system_variables.date_format,
 
848
          MYF(MY_ALLOW_ZERO_PTR));
 
849
  my_free((char*) global_system_variables.time_format,
 
850
          MYF(MY_ALLOW_ZERO_PTR));
 
851
  my_free((char*) global_system_variables.datetime_format,
 
852
          MYF(MY_ALLOW_ZERO_PTR));
842
853
  if (defaults_argv)
843
854
    free_defaults(defaults_argv);
844
 
  free(sys_init_connect.value);
845
 
  free(sys_init_slave.value);
 
855
  my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR));
 
856
  my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR));
 
857
  my_free(sys_var_general_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
 
858
  my_free(sys_var_slow_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
846
859
  free_tmpdir(&mysql_tmpdir_list);
847
 
  free(slave_load_tmpdir);
848
 
  if (opt_bin_logname)
849
 
    free(opt_bin_logname);
850
 
  if (opt_relay_logname)
851
 
    free(opt_relay_logname);
852
 
  if (opt_secure_file_priv)
853
 
    free(opt_secure_file_priv);
 
860
  my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
 
861
  x_free(opt_bin_logname);
 
862
  x_free(opt_relay_logname);
 
863
  x_free(opt_secure_file_priv);
854
864
  bitmap_free(&temp_pool);
 
865
  end_slave_list();
855
866
  delete binlog_filter;
856
867
  delete rpl_filter;
857
 
 
858
 
  (void) my_delete(pidfile_name,MYF(0));        // This may not always exist
859
 
 
860
 
  if (print_message && server_start_time)
861
 
    sql_print_information(_(ER(ER_SHUTDOWN_COMPLETE)),my_progname);
 
868
  vio_end();
 
869
 
 
870
  if (!opt_bootstrap)
 
871
    (void) my_delete(pidfile_name,MYF(0));      // This may not always exist
 
872
  if (print_message && errmesg && server_start_time)
 
873
    sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname);
862
874
  thread_scheduler.end();
863
 
  /* Returns NULL on globerrs, we don't want to try to free that */
864
 
  //void *freeme=
865
 
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
866
 
  // TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
867
 
/*  if (freeme != NULL)
868
 
    free(freeme);  */
 
875
  finish_client_errs();
 
876
  my_free((uchar*) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
 
877
          MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
869
878
  /* Tell main we are ready */
870
879
  logger.cleanup_end();
871
880
  (void) pthread_mutex_lock(&LOCK_thread_count);
887
896
*/
888
897
static void wait_for_signal_thread_to_end()
889
898
{
890
 
  uint32_t i;
 
899
  uint i;
891
900
  /*
892
901
    Wait up to 10 seconds for signal thread to die. We use this mainly to
893
902
    avoid getting warnings that my_thread_end has not been called
894
903
  */
895
904
  for (i= 0 ; i < 100 && signal_thread_in_use; i++)
896
905
  {
897
 
    if (pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL) != ESRCH)
 
906
    if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL) != ESRCH)
898
907
      break;
899
908
    my_sleep(100);                              // Give it time to die
900
909
  }
907
916
  (void) pthread_mutex_destroy(&LOCK_lock_db);
908
917
  (void) pthread_mutex_destroy(&LOCK_open);
909
918
  (void) pthread_mutex_destroy(&LOCK_thread_count);
 
919
  (void) pthread_mutex_destroy(&LOCK_mapped_file);
910
920
  (void) pthread_mutex_destroy(&LOCK_status);
911
921
  (void) pthread_mutex_destroy(&LOCK_error_log);
 
922
  (void) pthread_mutex_destroy(&LOCK_manager);
 
923
  (void) pthread_mutex_destroy(&LOCK_crypt);
 
924
  (void) pthread_mutex_destroy(&LOCK_user_conn);
912
925
  (void) pthread_mutex_destroy(&LOCK_connection_count);
 
926
  (void) pthread_mutex_destroy(&LOCK_rpl_status);
 
927
  (void) pthread_cond_destroy(&COND_rpl_status);
913
928
  (void) pthread_mutex_destroy(&LOCK_active_mi);
914
929
  (void) rwlock_destroy(&LOCK_sys_init_connect);
915
930
  (void) rwlock_destroy(&LOCK_sys_init_slave);
916
931
  (void) pthread_mutex_destroy(&LOCK_global_system_variables);
917
932
  (void) rwlock_destroy(&LOCK_system_variables_hash);
918
933
  (void) pthread_mutex_destroy(&LOCK_global_read_lock);
 
934
  (void) pthread_mutex_destroy(&LOCK_uuid_generator);
919
935
  (void) pthread_cond_destroy(&COND_thread_count);
920
936
  (void) pthread_cond_destroy(&COND_refresh);
921
937
  (void) pthread_cond_destroy(&COND_global_read_lock);
922
938
  (void) pthread_cond_destroy(&COND_thread_cache);
923
939
  (void) pthread_cond_destroy(&COND_flush_thread_cache);
 
940
  (void) pthread_cond_destroy(&COND_manager);
924
941
}
925
942
 
926
943
 
931
948
static void set_ports()
932
949
{
933
950
  char  *env;
934
 
  if (!mysqld_port)
 
951
  if (!mysqld_port && !opt_disable_networking)
935
952
  {                                     // Get port if not from commandline
936
 
    mysqld_port= DRIZZLE_PORT;
 
953
    mysqld_port= MYSQL_PORT;
937
954
 
938
955
    /*
939
956
      if builder specifically requested a default port, use that
940
957
      (even if it coincides with our factory default).
941
958
      only if they didn't do we check /etc/services (and, failing
942
 
      on that, fall back to the factory default of 4427).
 
959
      on that, fall back to the factory default of 3306).
943
960
      either default can be overridden by the environment variable
944
 
      DRIZZLE_TCP_PORT, which in turn can be overridden with command
 
961
      MYSQL_TCP_PORT, which in turn can be overridden with command
945
962
      line options.
946
963
    */
947
964
 
 
965
#if MYSQL_PORT_DEFAULT == 0
948
966
    struct  servent *serv_ptr;
949
 
    if ((serv_ptr= getservbyname("drizzle", "tcp")))
 
967
    if ((serv_ptr= getservbyname("mysql", "tcp")))
950
968
      mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
951
 
 
952
 
    if ((env = getenv("DRIZZLE_TCP_PORT")))
 
969
#endif
 
970
    if ((env = getenv("MYSQL_TCP_PORT")))
953
971
      mysqld_port= (uint) atoi(env);            /* purecov: inspected */
954
 
 
955
 
    assert(mysqld_port);
956
972
  }
957
973
}
958
974
 
972
988
      /* purecov: begin tested */
973
989
      tmp_user_info= getpwnam(user);
974
990
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
975
 
          global_system_variables.log_warnings)
976
 
        sql_print_warning(_("One can only use the --user switch "
977
 
                            "if running as root\n"));
 
991
          global_system_variables.log_warnings)
 
992
        sql_print_warning(
 
993
                    "One can only use the --user switch if running as root\n");
978
994
      /* purecov: end */
979
995
    }
980
996
    return NULL;
981
997
  }
982
998
  if (!user)
983
999
  {
984
 
    sql_print_error(_("Fatal error: Please read \"Security\" section of "
985
 
                      "the manual to find out how to run mysqld as root!\n"));
986
 
    unireg_abort(1);
987
 
 
 
1000
    if (!opt_bootstrap)
 
1001
    {
 
1002
      sql_print_error("Fatal error: Please read \"Security\" section of the manual to find out how to run mysqld as root!\n");
 
1003
      unireg_abort(1);
 
1004
    }
988
1005
    return NULL;
989
1006
  }
990
1007
  /* purecov: begin tested */
1005
1022
  /* purecov: end */
1006
1023
 
1007
1024
err:
1008
 
  sql_print_error(_("Fatal error: Can't change to run as user '%s' ;  "
1009
 
                    "Please check that the user exists!\n"),user);
 
1025
  sql_print_error("Fatal error: Can't change to run as user '%s' ;  Please check that the user exists!\n",user);
1010
1026
  unireg_abort(1);
1011
1027
 
1012
1028
#ifdef PR_SET_DUMPABLE
1031
1047
    calling_initgroups as a flag to the SIGSEGV handler that is then used to
1032
1048
    output a specific message to help the user resolve this problem.
1033
1049
  */
1034
 
  calling_initgroups= true;
 
1050
  calling_initgroups= TRUE;
1035
1051
  initgroups((char*) user, user_info_arg->pw_gid);
1036
 
  calling_initgroups= false;
 
1052
  calling_initgroups= FALSE;
1037
1053
#endif
1038
1054
  if (setgid(user_info_arg->pw_gid) == -1)
1039
1055
  {
1079
1095
 
1080
1096
static void network_init(void)
1081
1097
{
 
1098
  int   arg;
1082
1099
  int   ret;
1083
 
  uint32_t  waited;
1084
 
  uint32_t  this_wait;
1085
 
  uint32_t  retry;
 
1100
  uint  waited;
 
1101
  uint  this_wait;
 
1102
  uint  retry;
1086
1103
  char port_buf[NI_MAXSERV];
1087
 
  struct addrinfo *ai;
1088
 
  struct addrinfo *next;
1089
 
  struct addrinfo hints;
1090
 
  int error;
1091
1104
 
1092
1105
  if (thread_scheduler.init())
1093
1106
    unireg_abort(1);                    /* purecov: inspected */
1094
1107
 
1095
1108
  set_ports();
1096
1109
 
1097
 
  memset(fds, 0, sizeof(struct pollfd) * UINT8_MAX);
1098
 
  memset(&hints, 0, sizeof (hints));
1099
 
  hints.ai_flags= AI_PASSIVE;
1100
 
  hints.ai_socktype= SOCK_STREAM;
1101
 
 
1102
 
  snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
1103
 
  error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
1104
 
  if (error != 0)
1105
 
  {
1106
 
    sql_perror(ER(ER_IPSOCK_ERROR));            /* purecov: tested */
1107
 
    unireg_abort(1);                            /* purecov: tested */
1108
 
  }
1109
 
 
1110
 
  for (next= ai, pollfd_count= 0; next; next= next->ai_next, pollfd_count++)
1111
 
  {
1112
 
    int ip_sock;
1113
 
 
1114
 
    ip_sock= socket(next->ai_family, next->ai_socktype, next->ai_protocol);
1115
 
 
1116
 
    if (ip_sock == -1)
1117
 
    {
1118
 
      sql_perror(ER(ER_IPSOCK_ERROR));          /* purecov: tested */
1119
 
      unireg_abort(1);                          /* purecov: tested */
1120
 
    }
1121
 
 
1122
 
    fds[pollfd_count].fd= ip_sock;
1123
 
    fds[pollfd_count].events= POLLIN | POLLERR;
1124
 
 
1125
 
    /* Add options for our listening socket */
1126
 
    {
1127
 
      int error;
1128
 
      struct linger ling = {0, 0};
1129
 
      int flags =1;
 
1110
  if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
 
1111
  {
 
1112
    struct addrinfo *ai;
 
1113
    struct addrinfo hints;
 
1114
    int error;
 
1115
 
 
1116
    bzero(&hints, sizeof (hints));
 
1117
    hints.ai_flags= AI_PASSIVE;
 
1118
    hints.ai_socktype= SOCK_STREAM;
 
1119
    hints.ai_family= AF_UNSPEC;
 
1120
 
 
1121
    snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
 
1122
    error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
 
1123
    if (error != 0)
 
1124
    {
 
1125
      sql_perror(ER(ER_IPSOCK_ERROR));          /* purecov: tested */
 
1126
      unireg_abort(1);                          /* purecov: tested */
 
1127
    }
 
1128
 
 
1129
 
 
1130
    ip_sock= socket(ai->ai_family, ai->ai_socktype,
 
1131
                    ai->ai_protocol);
 
1132
 
 
1133
    if (ip_sock == INVALID_SOCKET)
 
1134
    {
 
1135
      sql_perror(ER(ER_IPSOCK_ERROR));          /* purecov: tested */
 
1136
      unireg_abort(1);                          /* purecov: tested */
 
1137
    }
 
1138
 
 
1139
    /*
 
1140
      We should not use SO_REUSEADDR on windows as this would enable a
 
1141
      user to open two mysqld servers with the same TCP/IP port.
 
1142
    */
 
1143
    arg= 1;
 
1144
    (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg));
1130
1145
 
1131
1146
#ifdef IPV6_V6ONLY
1132
 
      if (next->ai_family == AF_INET6) 
1133
 
      {
1134
 
        error= setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags));
1135
 
        if (error != 0)
1136
 
        {
1137
 
          perror("setsockopt");
1138
 
          assert(error == 0);
1139
 
        }
1140
 
      }
1141
 
#endif   
1142
 
      error= setsockopt(ip_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&flags, sizeof(flags));
1143
 
      if (error != 0)
1144
 
      {
1145
 
        perror("setsockopt");
1146
 
        assert(error == 0);
1147
 
      }
1148
 
      error= setsockopt(ip_sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags));
1149
 
      if (error != 0)
1150
 
      {
1151
 
        perror("setsockopt");
1152
 
        assert(error == 0);
1153
 
      }
1154
 
      error= setsockopt(ip_sock, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling));
1155
 
      if (error != 0)
1156
 
      {
1157
 
        perror("setsockopt");
1158
 
        assert(error == 0);
1159
 
      }
1160
 
      error= setsockopt(ip_sock, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags));
1161
 
      if (error != 0)
1162
 
      {
1163
 
        perror("setsockopt");
1164
 
        assert(error == 0);
1165
 
      }
 
1147
     /*
 
1148
       For interoperability with older clients, IPv6 socket should
 
1149
       listen on both IPv6 and IPv4 wildcard addresses.
 
1150
       Turn off IPV6_V6ONLY option.
 
1151
     */
 
1152
    if (ai->ai_family == AF_INET6)
 
1153
    {
 
1154
      arg= 0;      
 
1155
      (void) setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
 
1156
                sizeof(arg));
1166
1157
    }
1167
 
 
1168
 
 
 
1158
#endif
1169
1159
    /*
1170
1160
      Sometimes the port is not released fast enough when stopping and
1171
1161
      restarting the server. This happens quite often with the test suite
1176
1166
    */
1177
1167
    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1178
1168
    {
1179
 
      if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1180
 
          (errno != EADDRINUSE) ||
 
1169
      if (((ret= bind(ip_sock, ai->ai_addr, ai->ai_addrlen)) >= 0 ) ||
 
1170
          (socket_errno != SOCKET_EADDRINUSE) ||
1181
1171
          (waited >= mysqld_port_timeout))
1182
1172
        break;
1183
 
      sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
 
1173
      sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port);
1184
1174
      this_wait= retry * retry / 3 + 1;
1185
1175
      sleep(this_wait);
1186
1176
    }
 
1177
    freeaddrinfo(ai);
1187
1178
    if (ret < 0)
1188
1179
    {
1189
 
      sql_perror(_("Can't start server: Bind on TCP/IP port"));
1190
 
      sql_print_error(_("Do you already have another drizzled server running "
1191
 
                        "on port: %d ?"),mysqld_port);
 
1180
      sql_perror("Can't start server: Bind on TCP/IP port");
 
1181
      sql_print_error("Do you already have another mysqld server running on port: %d ?",mysqld_port);
1192
1182
      unireg_abort(1);
1193
1183
    }
1194
1184
    if (listen(ip_sock,(int) back_log) < 0)
1195
1185
    {
1196
 
      sql_perror(_("Can't start server: listen() on TCP/IP port"));
1197
 
      sql_print_error(_("listen() on TCP/IP failed with error %d"),
1198
 
                      errno);
 
1186
      sql_perror("Can't start server: listen() on TCP/IP port");
 
1187
      sql_print_error("listen() on TCP/IP failed with error %d",
 
1188
                      socket_errno);
1199
1189
      unireg_abort(1);
1200
1190
    }
1201
1191
  }
1202
1192
 
1203
 
  freeaddrinfo(ai);
1204
 
  return;
 
1193
  return;;
1205
1194
}
1206
1195
 
1207
1196
/**
1208
1197
  Close a connection.
1209
1198
 
1210
 
  @param session                Thread handle
 
1199
  @param thd            Thread handle
1211
1200
  @param errcode        Error code to print to console
1212
1201
  @param lock           1 if we have have to lock LOCK_thread_count
1213
1202
 
1214
1203
  @note
1215
1204
    For the connection that is doing shutdown, this is called twice
1216
1205
*/
1217
 
void close_connection(Session *session, uint32_t errcode, bool lock)
 
1206
void close_connection(THD *thd, uint errcode, bool lock)
1218
1207
{
1219
1208
  st_vio *vio;
1220
1209
  if (lock)
1221
1210
    (void) pthread_mutex_lock(&LOCK_thread_count);
1222
 
  session->killed= Session::KILL_CONNECTION;
1223
 
  if ((vio= session->net.vio) != 0)
 
1211
  thd->killed= THD::KILL_CONNECTION;
 
1212
  if ((vio= thd->net.vio) != 0)
1224
1213
  {
1225
1214
    if (errcode)
1226
 
      net_send_error(session, errcode, ER(errcode)); /* purecov: inspected */
1227
 
    net_close(&(session->net));         /* vio is freed in delete session */
 
1215
      net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
 
1216
    vio_close(vio);                     /* vio is freed in delete thd */
1228
1217
  }
1229
1218
  if (lock)
1230
1219
    (void) pthread_mutex_unlock(&LOCK_thread_count);
1234
1223
 
1235
1224
/** Called when a thread is aborted. */
1236
1225
/* ARGSUSED */
1237
 
extern "C" RETSIGTYPE end_thread_signal(int sig __attribute__((unused)))
 
1226
extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
1238
1227
{
1239
 
  Session *session=current_session;
1240
 
  if (session)
 
1228
  THD *thd=current_thd;
 
1229
  if (thd && ! thd->bootstrap)
1241
1230
  {
1242
1231
    statistic_increment(killed_threads, &LOCK_status);
1243
 
    thread_scheduler.end_thread(session,0);             /* purecov: inspected */
 
1232
    thread_scheduler.end_thread(thd,0);         /* purecov: inspected */
1244
1233
  }
1245
1234
  return;;                              /* purecov: deadcode */
1246
1235
}
1247
1236
 
1248
1237
 
1249
1238
/*
1250
 
  Unlink session from global list of available connections and free session
 
1239
  Unlink thd from global list of available connections and free thd
1251
1240
 
1252
1241
  SYNOPSIS
1253
 
    unlink_session()
1254
 
    session              Thread handler
 
1242
    unlink_thd()
 
1243
    thd          Thread handler
1255
1244
 
1256
1245
  NOTES
1257
1246
    LOCK_thread_count is locked and left locked
1258
1247
*/
1259
1248
 
1260
 
void unlink_session(Session *session)
 
1249
void unlink_thd(THD *thd)
1261
1250
{
1262
 
  session->cleanup();
 
1251
  thd->cleanup();
1263
1252
 
1264
1253
  pthread_mutex_lock(&LOCK_connection_count);
1265
1254
  --connection_count;
1267
1256
 
1268
1257
  (void) pthread_mutex_lock(&LOCK_thread_count);
1269
1258
  thread_count--;
1270
 
  delete session;
 
1259
  delete thd;
1271
1260
  return;;
1272
1261
}
1273
1262
 
1274
1263
 
 
1264
/*
 
1265
  Store thread in cache for reuse by new connections
 
1266
 
 
1267
  SYNOPSIS
 
1268
    cache_thread()
 
1269
 
 
1270
  NOTES
 
1271
    LOCK_thread_count has to be locked
 
1272
 
 
1273
  RETURN
 
1274
    0  Thread was not put in cache
 
1275
    1  Thread is to be reused by new connection.
 
1276
       (ie, caller should return, not abort with pthread_exit())
 
1277
*/
 
1278
 
 
1279
 
 
1280
static bool cache_thread()
 
1281
{
 
1282
  safe_mutex_assert_owner(&LOCK_thread_count);
 
1283
  if (cached_thread_count < thread_cache_size &&
 
1284
      ! abort_loop && !kill_cached_threads)
 
1285
  {
 
1286
    /* Don't kill the thread, just put it in cache for reuse */
 
1287
    cached_thread_count++;
 
1288
    while (!abort_loop && ! wake_thread && ! kill_cached_threads)
 
1289
      (void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
 
1290
    cached_thread_count--;
 
1291
    if (kill_cached_threads)
 
1292
      pthread_cond_signal(&COND_flush_thread_cache);
 
1293
    if (wake_thread)
 
1294
    {
 
1295
      THD *thd;
 
1296
      wake_thread--;
 
1297
      thd= thread_cache.get();
 
1298
      thd->thread_stack= (char*) &thd;          // For store_globals
 
1299
      (void) thd->store_globals();
 
1300
      /*
 
1301
        THD::mysys_var::abort is associated with physical thread rather
 
1302
        than with THD object. So we need to reset this flag before using
 
1303
        this thread for handling of new THD object/connection.
 
1304
      */
 
1305
      thd->mysys_var->abort= 0;
 
1306
      thd->thr_create_utime= my_micro_time();
 
1307
      threads.append(thd);
 
1308
      return(1);
 
1309
    }
 
1310
  }
 
1311
  return(0);
 
1312
}
 
1313
 
 
1314
 
 
1315
/*
 
1316
  End thread for the current connection
 
1317
 
 
1318
  SYNOPSIS
 
1319
    one_thread_per_connection_end()
 
1320
    thd           Thread handler
 
1321
    put_in_cache  Store thread in cache, if there is room in it
 
1322
                  Normally this is true in all cases except when we got
 
1323
                  out of resources initializing the current thread
 
1324
 
 
1325
  NOTES
 
1326
    If thread is cached, we will wait until thread is scheduled to be
 
1327
    reused and then we will return.
 
1328
    If thread is not cached, we end the thread.
 
1329
 
 
1330
  RETURN
 
1331
    0    Signal to handle_one_connection to reuse connection
 
1332
*/
 
1333
 
 
1334
bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
 
1335
{
 
1336
  unlink_thd(thd);
 
1337
  if (put_in_cache)
 
1338
    put_in_cache= cache_thread();
 
1339
  pthread_mutex_unlock(&LOCK_thread_count);
 
1340
  if (put_in_cache)
 
1341
    return(0);                             // Thread is reused
 
1342
 
 
1343
  /* It's safe to broadcast outside a lock (COND... is not deleted here) */
 
1344
  my_thread_end();
 
1345
  (void) pthread_cond_broadcast(&COND_thread_count);
 
1346
 
 
1347
  pthread_exit(0);
 
1348
  return(0);                               // Impossible
 
1349
}
 
1350
 
 
1351
 
 
1352
void flush_thread_cache()
 
1353
{
 
1354
  (void) pthread_mutex_lock(&LOCK_thread_count);
 
1355
  kill_cached_threads++;
 
1356
  while (cached_thread_count)
 
1357
  {
 
1358
    pthread_cond_broadcast(&COND_thread_cache);
 
1359
    pthread_cond_wait(&COND_flush_thread_cache,&LOCK_thread_count);
 
1360
  }
 
1361
  kill_cached_threads--;
 
1362
  (void) pthread_mutex_unlock(&LOCK_thread_count);
 
1363
}
 
1364
 
 
1365
 
1275
1366
#ifdef THREAD_SPECIFIC_SIGPIPE
1276
1367
/**
1277
1368
  Aborts a thread nicely. Comes here on SIGPIPE.
1279
1370
  @todo
1280
1371
    One should have to fix that thr_alarm know about this thread too.
1281
1372
*/
1282
 
extern "C" RETSIGTYPE abort_thread(int sig __attribute__((unused)))
 
1373
extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
1283
1374
{
1284
 
  Session *session=current_session;
1285
 
  if (session)
1286
 
    session->killed= Session::KILL_CONNECTION;
 
1375
  THD *thd=current_thd;
 
1376
  if (thd)
 
1377
    thd->killed= THD::KILL_CONNECTION;
1287
1378
  return;;
1288
1379
}
1289
1380
#endif
1290
1381
 
1291
 
#if defined(BACKTRACE_DEMANGLE)
 
1382
#if BACKTRACE_DEMANGLE
1292
1383
#include <cxxabi.h>
1293
1384
extern "C" char *my_demangle(const char *mangled_name, int *status)
1294
1385
{
1297
1388
#endif
1298
1389
 
1299
1390
 
1300
 
extern "C" RETSIGTYPE handle_segfault(int sig)
 
1391
extern "C" sig_handler handle_segfault(int sig)
1301
1392
{
1302
1393
  time_t curr_time;
1303
1394
  struct tm tm;
 
1395
  THD *thd=current_thd;
1304
1396
 
1305
1397
  /*
1306
1398
    Strictly speaking, one needs a mutex here
1310
1402
  */
1311
1403
  if (segfaulted)
1312
1404
  {
1313
 
    fprintf(stderr, _("Fatal " SIGNAL_FMT " while backtracing\n"), sig);
 
1405
    fprintf(stderr, "Fatal " SIGNAL_FMT " while backtracing\n", sig);
1314
1406
    exit(1);
1315
1407
  }
1316
1408
 
1319
1411
  curr_time= my_time(0);
1320
1412
  localtime_r(&curr_time, &tm);
1321
1413
 
1322
 
  fprintf(stderr,"%02d%02d%02d %2d:%02d:%02d - mysqld got "
1323
 
          SIGNAL_FMT " ;\n"
1324
 
          "This could be because you hit a bug. It is also possible that "
1325
 
          "this binary\n or one of the libraries it was linked against is "
1326
 
          "corrupt, improperly built,\n or misconfigured. This error can "
1327
 
          "also be caused by malfunctioning hardware.\n",
 
1414
  fprintf(stderr,"\
 
1415
%02d%02d%02d %2d:%02d:%02d - mysqld got " SIGNAL_FMT " ;\n\
 
1416
This could be because you hit a bug. It is also possible that this binary\n\
 
1417
or one of the libraries it was linked against is corrupt, improperly built,\n\
 
1418
or misconfigured. This error can also be caused by malfunctioning hardware.\n",
1328
1419
          tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
1329
1420
          tm.tm_hour, tm.tm_min, tm.tm_sec,
1330
 
          sig);
1331
 
  fprintf(stderr, _("We will try our best to scrape up some info that "
1332
 
                    "will hopefully help diagnose\n"
1333
 
                    "the problem, but since we have already crashed, "
1334
 
                    "something is definitely wrong\nand this may fail.\n\n"));
1335
 
  fprintf(stderr, "key_buffer_size=%u\n",
1336
 
          (uint32_t) dflt_key_cache->key_cache_mem_size);
 
1421
          sig);
 
1422
  fprintf(stderr, "\
 
1423
We will try our best to scrape up some info that will hopefully help diagnose\n\
 
1424
the problem, but since we have already crashed, something is definitely wrong\n\
 
1425
and this may fail.\n\n");
 
1426
  fprintf(stderr, "key_buffer_size=%lu\n",
 
1427
          (ulong) dflt_key_cache->key_cache_mem_size);
1337
1428
  fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
1338
 
  fprintf(stderr, "max_used_connections=%u\n", max_used_connections);
 
1429
  fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
1339
1430
  fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
1340
1431
  fprintf(stderr, "thread_count=%u\n", thread_count);
1341
1432
  fprintf(stderr, "connection_count=%u\n", connection_count);
1342
 
  fprintf(stderr, _("It is possible that mysqld could use up to \n"
1343
 
                    "key_buffer_size + (read_buffer_size + "
1344
 
                    "sort_buffer_size)*max_threads = %lu K\n"
1345
 
                    "bytes of memory\n"
1346
 
                    "Hope that's ok; if not, decrease some variables in the "
1347
 
                    "equation.\n\n"),
1348
 
                    ((uint32_t) dflt_key_cache->key_cache_mem_size +
1349
 
                     (global_system_variables.read_buff_size +
1350
 
                      global_system_variables.sortbuff_size) *
1351
 
                     thread_scheduler.max_threads +
1352
 
                     max_connections * sizeof(Session)) / 1024);
 
1433
  fprintf(stderr, "It is possible that mysqld could use up to \n\
 
1434
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
 
1435
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
 
1436
                     (global_system_variables.read_buff_size +
 
1437
                      global_system_variables.sortbuff_size) *
 
1438
                     thread_scheduler.max_threads +
 
1439
                     max_connections * sizeof(THD)) / 1024);
 
1440
  fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
1353
1441
 
1354
1442
#ifdef HAVE_STACKTRACE
1355
 
  Session *session= current_session;
1356
 
 
1357
1443
  if (!(test_flags & TEST_NO_STACKTRACE))
1358
1444
  {
1359
 
    fprintf(stderr,"session: 0x%lx\n",(long) session);
1360
 
    fprintf(stderr,_("Attempting backtrace. You can use the following "
1361
 
                     "information to find out\n"
1362
 
                     "where mysqld died. If you see no messages after this, "
1363
 
                     "something went\n"
1364
 
                     "terribly wrong...\n"));
1365
 
    print_stacktrace(session ? (unsigned char*) session->thread_stack : (unsigned char*) 0,
 
1445
    fprintf(stderr,"thd: 0x%lx\n",(long) thd);
 
1446
    fprintf(stderr,"\
 
1447
Attempting backtrace. You can use the following information to find out\n\
 
1448
where mysqld died. If you see no messages after this, something went\n\
 
1449
terribly wrong...\n");  
 
1450
    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
1366
1451
                     my_thread_stack_size);
1367
1452
  }
1368
 
  if (session)
 
1453
  if (thd)
1369
1454
  {
1370
1455
    const char *kreason= "UNKNOWN";
1371
 
    switch (session->killed) {
1372
 
    case Session::NOT_KILLED:
 
1456
    switch (thd->killed) {
 
1457
    case THD::NOT_KILLED:
1373
1458
      kreason= "NOT_KILLED";
1374
1459
      break;
1375
 
    case Session::KILL_BAD_DATA:
 
1460
    case THD::KILL_BAD_DATA:
1376
1461
      kreason= "KILL_BAD_DATA";
1377
1462
      break;
1378
 
    case Session::KILL_CONNECTION:
 
1463
    case THD::KILL_CONNECTION:
1379
1464
      kreason= "KILL_CONNECTION";
1380
1465
      break;
1381
 
    case Session::KILL_QUERY:
 
1466
    case THD::KILL_QUERY:
1382
1467
      kreason= "KILL_QUERY";
1383
1468
      break;
1384
 
    case Session::KILLED_NO_VALUE:
 
1469
    case THD::KILLED_NO_VALUE:
1385
1470
      kreason= "KILLED_NO_VALUE";
1386
1471
      break;
1387
1472
    }
1388
 
    fprintf(stderr, _("Trying to get some variables.\n"
1389
 
                      "Some pointers may be invalid and cause the "
1390
 
                      "dump to abort...\n"));
1391
 
    safe_print_str("session->query", session->query, 1024);
1392
 
    fprintf(stderr, "session->thread_id=%"PRIu32"\n", (uint32_t) session->thread_id);
1393
 
    fprintf(stderr, "session->killed=%s\n", kreason);
 
1473
    fprintf(stderr, "Trying to get some variables.\n\
 
1474
Some pointers may be invalid and cause the dump to abort...\n");
 
1475
    safe_print_str("thd->query", thd->query, 1024);
 
1476
    fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id);
 
1477
    fprintf(stderr, "thd->killed=%s\n", kreason);
1394
1478
  }
 
1479
  fprintf(stderr, "\
 
1480
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains\n\
 
1481
information that should help you find out what is causing the crash.\n");
1395
1482
  fflush(stderr);
1396
1483
#endif /* HAVE_STACKTRACE */
1397
1484
 
1398
1485
#ifdef HAVE_INITGROUPS
1399
1486
  if (calling_initgroups)
1400
 
    fprintf(stderr, _("\nThis crash occured while the server was calling "
1401
 
                      "initgroups(). This is\n"
1402
 
                      "often due to the use of a drizzled that is statically "
1403
 
                      "linked against glibc\n"
1404
 
                      "and configured to use LDAP in /etc/nsswitch.conf. "
1405
 
                      "You will need to either\n"
1406
 
                      "upgrade to a version of glibc that does not have this "
1407
 
                      "problem (2.3.4 or\n"
1408
 
                      "later when used with nscd), disable LDAP in your "
1409
 
                      "nsswitch.conf, or use a\n"
1410
 
                      "drizzled that is not statically linked.\n"));
 
1487
    fprintf(stderr, "\n\
 
1488
This crash occured while the server was calling initgroups(). This is\n\
 
1489
often due to the use of a mysqld that is statically linked against glibc\n\
 
1490
and configured to use LDAP in /etc/nsswitch.conf. You will need to either\n\
 
1491
upgrade to a version of glibc that does not have this problem (2.3.4 or\n\
 
1492
later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\
 
1493
mysqld that is not statically linked.\n");
1411
1494
#endif
1412
1495
 
1413
1496
  if (thd_lib_detected == THD_LIB_LT && !getenv("LD_ASSUME_KERNEL"))
1414
 
    fprintf(stderr,
1415
 
            _("\nYou are running a statically-linked LinuxThreads binary "
1416
 
              "on an NPTL system.\n"
1417
 
              "This can result in crashes on some distributions due "
1418
 
              "to LT/NPTL conflicts.\n"
1419
 
              "You should either build a dynamically-linked binary, or force "
1420
 
              "LinuxThreads\n"
1421
 
              "to be used with the LD_ASSUME_KERNEL environment variable. "
1422
 
              "Please consult\n"
1423
 
              "the documentation for your distribution on how to do that.\n"));
1424
 
 
 
1497
    fprintf(stderr,"\n\
 
1498
You are running a statically-linked LinuxThreads binary on an NPTL system.\n\
 
1499
This can result in crashes on some distributions due to LT/NPTL conflicts.\n\
 
1500
You should either build a dynamically-linked binary, or force LinuxThreads\n\
 
1501
to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
 
1502
the documentation for your distribution on how to do that.\n");
 
1503
  
1425
1504
  if (locked_in_memory)
1426
1505
  {
1427
 
    fprintf(stderr,
1428
 
            _("\nThe '--memlock' argument, which was enabled, uses system "
1429
 
              "calls that are\n"
1430
 
              "unreliable and unstable on some operating systems and "
1431
 
              "operating-system\n"
1432
 
              "versions (notably, some versions of Linux).  "
1433
 
              "This crash could be due to use\n"
1434
 
              "of those buggy OS calls.  You should consider whether you "
1435
 
              "really need the\n"
1436
 
              "'--memlock' parameter and/or consult the OS "
1437
 
              "distributor about 'mlockall'\n bugs.\n"));
 
1506
    fprintf(stderr, "\n\
 
1507
The \"--memlock\" argument, which was enabled, uses system calls that are\n\
 
1508
unreliable and unstable on some operating systems and operating-system\n\
 
1509
versions (notably, some versions of Linux).  This crash could be due to use\n\
 
1510
of those buggy OS calls.  You should consider whether you really need the\n\
 
1511
\"--memlock\" parameter and/or consult the OS distributer about \"mlockall\"\n\
 
1512
bugs.\n");
1438
1513
  }
1439
1514
 
1440
1515
#ifdef HAVE_WRITE_CORE
1441
1516
  if (test_flags & TEST_CORE_ON_SIGNAL)
1442
1517
  {
1443
 
    fprintf(stderr, _("Writing a core file\n"));
 
1518
    fprintf(stderr, "Writing a core file\n");
1444
1519
    fflush(stderr);
1445
1520
    write_core(sig);
1446
1521
  }
1487
1562
    STRUCT_RLIMIT rl;
1488
1563
    rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
1489
1564
    if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
1490
 
      sql_print_warning(_("setrlimit could not change the size of core files "
1491
 
                          "to 'infinity';  We may not be able to generate a "
1492
 
                          "core file on signals"));
 
1565
      sql_print_warning("setrlimit could not change the size of core files to 'infinity';  We may not be able to generate a core file on signals");
1493
1566
  }
1494
1567
#endif
1495
1568
  (void) sigemptyset(&set);
1536
1609
  (void) pthread_attr_init(&thr_attr);
1537
1610
  pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
1538
1611
  (void) pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
 
1612
  if (!(opt_specialflag & SPECIAL_NO_PRIOR))
1539
1613
  {
1540
1614
    struct sched_param tmp_sched_param;
1541
1615
 
1555
1629
  (void) pthread_mutex_lock(&LOCK_thread_count);
1556
1630
  if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0)))
1557
1631
  {
1558
 
    sql_print_error(_("Can't create interrupt-thread (error %d, errno: %d)"),
1559
 
                    error,errno);
 
1632
    sql_print_error("Can't create interrupt-thread (error %d, errno: %d)",
 
1633
                    error,errno);
1560
1634
    exit(1);
1561
1635
  }
1562
1636
  (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
1600
1674
  (void) sigaddset(&set,SIGTSTP);
1601
1675
 
1602
1676
  /* Save pid to this process (or thread on Linux) */
1603
 
  create_pid_file();
 
1677
  if (!opt_bootstrap)
 
1678
    create_pid_file();
1604
1679
 
1605
1680
#ifdef HAVE_STACK_TRACE_ON_SEGV
1606
1681
  if (opt_do_pstack)
1607
1682
  {
1608
 
    sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (uint32_t)getpid());
 
1683
    sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (ulong)getpid());
1609
1684
    pstack_install_segv_action(pstack_file_name);
1610
1685
  }
1611
1686
#endif /* HAVE_STACK_TRACE_ON_SEGV */
1643
1718
    case SIGQUIT:
1644
1719
    case SIGKILL:
1645
1720
#ifdef EXTRA_DEBUG
1646
 
      sql_print_information(_("Got signal %d to shutdown mysqld"),sig);
 
1721
      sql_print_information("Got signal %d to shutdown mysqld",sig);
1647
1722
#endif
1648
1723
      /* switch to the old log message processing */
 
1724
      logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
 
1725
                          opt_log ? LOG_FILE:LOG_NONE);
1649
1726
      if (!abort_loop)
1650
1727
      {
1651
1728
        abort_loop=1;                           // mark abort for threads
1652
1729
#ifdef USE_ONE_SIGNAL_HAND
1653
1730
        pthread_t tmp;
 
1731
        if (!(opt_specialflag & SPECIAL_NO_PRIOR))
1654
1732
        {
1655
1733
          struct sched_param tmp_sched_param;
1656
1734
 
1660
1738
        }
1661
1739
        if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
1662
1740
                           (void*) &sig))
1663
 
          sql_print_error(_("Can't create thread to kill server"));
 
1741
          sql_print_error("Can't create thread to kill server");
1664
1742
#else
1665
1743
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
1666
1744
#endif
1670
1748
      if (!abort_loop)
1671
1749
      {
1672
1750
        bool not_used;
1673
 
        reload_cache((Session*) 0,
 
1751
        mysql_print_status();           // Print some debug info
 
1752
        reload_cache((THD*) 0,
1674
1753
                     (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
1675
 
                      REFRESH_HOSTS),
1676
 
                     (TableList*) 0, &not_used); // Flush logs
 
1754
                      REFRESH_GRANT |
 
1755
                      REFRESH_THREADS | REFRESH_HOSTS),
 
1756
                     (TABLE_LIST*) 0, &not_used); // Flush logs
 
1757
      }
 
1758
      /* reenable logs after the options were reloaded */
 
1759
      if (log_output_options & LOG_NONE)
 
1760
      {
 
1761
        logger.set_handlers(LOG_FILE,
 
1762
                            opt_slow_log ? LOG_TABLE : LOG_NONE,
 
1763
                            opt_log ? LOG_TABLE : LOG_NONE);
 
1764
      }
 
1765
      else
 
1766
      {
 
1767
        logger.set_handlers(LOG_FILE,
 
1768
                            opt_slow_log ? log_output_options : LOG_NONE,
 
1769
                            opt_log ? log_output_options : LOG_NONE);
1677
1770
      }
1678
1771
      break;
1679
1772
#ifdef USE_ONE_SIGNAL_HAND
1683
1776
#endif
1684
1777
    default:
1685
1778
#ifdef EXTRA_DEBUG
1686
 
      sql_print_warning(_("Got signal: %d  error: %d"),sig,error); /* purecov: tested */
 
1779
      sql_print_warning("Got signal: %d  error: %d",sig,error); /* purecov: tested */
1687
1780
#endif
1688
1781
      break;                                    /* purecov: tested */
1689
1782
    }
1691
1784
  return(0);                                    /* purecov: deadcode */
1692
1785
}
1693
1786
 
1694
 
static void check_data_home(const char *path __attribute__((unused)))
 
1787
static void check_data_home(const char *path)
1695
1788
{}
1696
1789
 
1697
1790
#endif  /* __WIN__*/
1702
1795
  for the client.
1703
1796
*/
1704
1797
/* ARGSUSED */
1705
 
extern "C" void my_message_sql(uint32_t error, const char *str, myf MyFlags);
 
1798
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
1706
1799
 
1707
 
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
 
1800
void my_message_sql(uint error, const char *str, myf MyFlags)
1708
1801
{
1709
 
  Session *session;
 
1802
  THD *thd;
1710
1803
  /*
1711
1804
    Put here following assertion when situation with EE_* error codes
1712
1805
    will be fixed
1713
1806
  */
1714
 
  if ((session= current_session))
 
1807
  if ((thd= current_thd))
1715
1808
  {
1716
1809
    if (MyFlags & ME_FATALERROR)
1717
 
      session->is_fatal_error= 1;
 
1810
      thd->is_fatal_error= 1;
 
1811
 
 
1812
#ifdef BUG_36098_FIXED
 
1813
    mysql_audit_general(thd,MYSQL_AUDIT_GENERAL_ERROR,error,my_time(0),
 
1814
                        0,0,str,str ? strlen(str) : 0,
 
1815
                        thd->query,thd->query_length,
 
1816
                        thd->variables.character_set_client,
 
1817
                        thd->row_count);
 
1818
#endif
 
1819
 
1718
1820
 
1719
1821
    /*
1720
 
      TODO: There are two exceptions mechanism (Session and sp_rcontext),
 
1822
      TODO: There are two exceptions mechanism (THD and sp_rcontext),
1721
1823
      this could be improved by having a common stack of handlers.
1722
1824
    */
1723
 
    if (session->handle_error(error, str,
1724
 
                          DRIZZLE_ERROR::WARN_LEVEL_ERROR))
 
1825
    if (thd->handle_error(error, str,
 
1826
                          MYSQL_ERROR::WARN_LEVEL_ERROR))
1725
1827
      return;;
1726
1828
 
1727
 
    session->is_slave_error=  1; // needed to catch query errors during replication
 
1829
    thd->is_slave_error=  1; // needed to catch query errors during replication
1728
1830
 
1729
1831
    /*
1730
 
      session->lex->current_select == 0 if lex structure is not inited
 
1832
      thd->lex->current_select == 0 if lex structure is not inited
1731
1833
      (not query command (COM_QUERY))
1732
1834
    */
1733
 
    if (! (session->lex->current_select &&
1734
 
        session->lex->current_select->no_error && !session->is_fatal_error))
1735
 
    {
1736
 
      if (! session->main_da.is_error())            // Return only first message
 
1835
    if (thd->lex->current_select &&
 
1836
        thd->lex->current_select->no_error && !thd->is_fatal_error)
 
1837
    {
 
1838
      /* DBUG_WAS_HERE */
 
1839
    }
 
1840
    else
 
1841
    {
 
1842
      if (! thd->main_da.is_error())            // Return only first message
1737
1843
      {
1738
1844
        if (error == 0)
1739
1845
          error= ER_UNKNOWN_ERROR;
1740
1846
        if (str == NULL)
1741
1847
          str= ER(error);
1742
 
        session->main_da.set_error_status(session, error, str);
 
1848
        thd->main_da.set_error_status(thd, error, str);
1743
1849
      }
1744
1850
    }
1745
1851
 
1746
 
    if (!session->no_warnings_for_error && !session->is_fatal_error)
 
1852
    if (!thd->no_warnings_for_error && !thd->is_fatal_error)
1747
1853
    {
1748
1854
      /*
1749
1855
        Suppress infinite recursion if there a memory allocation error
1750
1856
        inside push_warning.
1751
1857
      */
1752
 
      session->no_warnings_for_error= true;
1753
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
1754
 
      session->no_warnings_for_error= false;
 
1858
      thd->no_warnings_for_error= TRUE;
 
1859
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
 
1860
      thd->no_warnings_for_error= FALSE;
1755
1861
    }
1756
1862
  }
1757
 
  if (!session || MyFlags & ME_NOREFRESH)
 
1863
  if (!thd || MyFlags & ME_NOREFRESH)
1758
1864
    sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
1759
1865
  return;;
1760
1866
}
1771
1877
 
1772
1878
void my_str_free_mysqld(void *ptr)
1773
1879
{
1774
 
  free((unsigned char*)ptr);
 
1880
  my_free((uchar*)ptr, MYF(MY_FAE));
1775
1881
}
1776
1882
 
1777
1883
 
1778
1884
static const char *load_default_groups[]= {
1779
 
"mysqld","server", DRIZZLE_BASE_VERSION, 0, 0};
 
1885
"mysqld","server", MYSQL_BASE_VERSION, 0, 0};
1780
1886
 
1781
1887
 
1782
1888
/**
1795
1901
    1 error
1796
1902
*/
1797
1903
 
1798
 
static bool init_global_datetime_format(enum enum_drizzle_timestamp_type format_type,
 
1904
static bool init_global_datetime_format(timestamp_type format_type,
1799
1905
                                        DATE_TIME_FORMAT **var_ptr)
1800
1906
{
1801
1907
  /* Get command line option */
1813
1919
  }
1814
1920
  if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str))))
1815
1921
  {
1816
 
    fprintf(stderr, _("Wrong date/time format specifier: %s\n"), str);
 
1922
    fprintf(stderr, "Wrong date/time format specifier: %s\n", str);
1817
1923
    return 1;
1818
1924
  }
1819
1925
  return 0;
1823
1929
  {"admin_commands",       (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
1824
1930
  {"assign_to_keycache",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1825
1931
  {"alter_db",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
 
1932
  {"alter_db_upgrade",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB_UPGRADE]), SHOW_LONG_STATUS},
1826
1933
  {"alter_table",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1827
1934
  {"analyze",              (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1828
1935
  {"begin",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
1861
1968
  {"savepoint",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1862
1969
  {"select",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1863
1970
  {"set_option",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
 
1971
  {"show_binlog_events",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
1864
1972
  {"show_binlogs",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
 
1973
  {"show_charsets",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS},
 
1974
  {"show_collations",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS},
1865
1975
  {"show_create_db",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1866
1976
  {"show_create_table",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1867
1977
  {"show_databases",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
1873
1983
  {"show_open_tables",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
1874
1984
  {"show_plugins",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
1875
1985
  {"show_processlist",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
 
1986
  {"show_slave_hosts",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
1876
1987
  {"show_slave_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
1877
1988
  {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1878
1989
  {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1885
1996
  {"unlock_tables",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1886
1997
  {"update",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1887
1998
  {"update_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1888
 
  {NULL, NULL, SHOW_LONG}
 
1999
  {NullS, NullS, SHOW_LONG}
1889
2000
};
1890
2001
 
1891
2002
static int init_common_variables(const char *conf_file_name, int argc,
1892
2003
                                 char **argv, const char **groups)
1893
2004
{
 
2005
  char buff[FN_REFLEN], *s;
1894
2006
  umask(((~my_umask) & 0666));
1895
2007
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1896
2008
  tzset();                      // Set tzname
1897
2009
 
1898
 
  max_system_variables.pseudo_thread_id= UINT32_MAX;
 
2010
  max_system_variables.pseudo_thread_id= (ulong)~0;
1899
2011
  server_start_time= flush_status_time= my_time(0);
1900
2012
  rpl_filter= new Rpl_filter;
1901
2013
  binlog_filter= new Rpl_filter;
1902
 
  if (!rpl_filter || !binlog_filter)
 
2014
  if (!rpl_filter || !binlog_filter) 
1903
2015
  {
1904
2016
    sql_perror("Could not allocate replication and binlog filters");
1905
2017
    exit(1);
1927
2039
  global_system_variables.time_zone= my_tz_SYSTEM;
1928
2040
 
1929
2041
  /*
1930
 
    Init mutexes for the global DRIZZLE_BIN_LOG objects.
 
2042
    Init mutexes for the global MYSQL_BIN_LOG objects.
1931
2043
    As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of
1932
 
    global DRIZZLE_BIN_LOGs in their constructors, because then they would be
 
2044
    global MYSQL_BIN_LOGs in their constructors, because then they would be
1933
2045
    inited before MY_INIT(). So we do it here.
1934
2046
  */
1935
2047
  mysql_bin_log.init_pthread_objects();
1937
2049
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1938
2050
  {
1939
2051
    strmake(glob_hostname, STRING_WITH_LEN("localhost"));
1940
 
    sql_print_warning(_("gethostname failed, using '%s' as hostname"),
 
2052
    sql_print_warning("gethostname failed, using '%s' as hostname",
1941
2053
                      glob_hostname);
1942
2054
    strmake(pidfile_name, STRING_WITH_LEN("mysql"));
1943
2055
  }
1944
2056
  else
1945
2057
  strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
1946
 
  my_stpcpy(fn_ext(pidfile_name),".pid");               // Add proper extension
 
2058
  strmov(fn_ext(pidfile_name),".pid");          // Add proper extension
1947
2059
 
1948
2060
  /*
1949
2061
    Add server status variables to the dynamic list of
1954
2066
  if (add_status_vars(status_vars))
1955
2067
    return 1; // an error was already reported
1956
2068
 
 
2069
#ifndef DBUG_OFF
 
2070
  /*
 
2071
    We have few debug-only commands in com_status_vars, only visible in debug
 
2072
    builds. for simplicity we enable the assert only in debug builds
 
2073
 
 
2074
    There are 7 Com_ variables which don't have corresponding SQLCOM_ values:
 
2075
    (TODO strictly speaking they shouldn't be here, should not have Com_ prefix
 
2076
    that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?)
 
2077
 
 
2078
      Com_admin_commands       => com_other
 
2079
      Com_stmt_close           => com_stmt_close
 
2080
      Com_stmt_execute         => com_stmt_execute
 
2081
      Com_stmt_fetch           => com_stmt_fetch
 
2082
      Com_stmt_prepare         => com_stmt_prepare
 
2083
      Com_stmt_reset           => com_stmt_reset
 
2084
      Com_stmt_send_long_data  => com_stmt_send_long_data
 
2085
 
 
2086
    With this correction the number of Com_ variables (number of elements in
 
2087
    the array, excluding the last element - terminator) must match the number
 
2088
    of SQLCOM_ constants.
 
2089
  */
 
2090
  compile_time_assert(sizeof(com_status_vars)/sizeof(com_status_vars[0]) - 1 ==
 
2091
                     SQLCOM_END + 7);
 
2092
#endif
 
2093
 
1957
2094
  load_defaults(conf_file_name, groups, &argc, &argv);
1958
2095
  defaults_argv=argv;
1959
2096
  defaults_argc=argc;
1963
2100
 
1964
2101
  /* connections and databases needs lots of files */
1965
2102
  {
1966
 
    uint32_t files, wanted_files, max_open_files;
 
2103
    uint files, wanted_files, max_open_files;
1967
2104
 
1968
2105
    /* MyISAM requires two file handles per table. */
1969
2106
    wanted_files= 10+max_connections+table_cache_size*2;
1977
2114
      can't get max_connections*5 but still got no less than was
1978
2115
      requested (value of wanted_files).
1979
2116
    */
1980
 
    max_open_files= cmax(cmax((uint32_t)wanted_files, max_connections*5),
1981
 
                         open_files_limit);
 
2117
    max_open_files= max(max(wanted_files, max_connections*5),
 
2118
                        open_files_limit);
1982
2119
    files= my_set_max_open_files(max_open_files);
1983
2120
 
1984
2121
    if (files < wanted_files)
1989
2126
          If we have requested too much file handles than we bring
1990
2127
          max_connections in supported bounds.
1991
2128
        */
1992
 
        max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
 
2129
        max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
1993
2130
                                     max_connections);
1994
2131
        /*
1995
2132
          Decrease table_cache_size according to max_connections, but
1996
 
          not below TABLE_OPEN_CACHE_MIN.  Outer cmin() ensures that we
 
2133
          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
1997
2134
          never increase table_cache_size automatically (that could
1998
2135
          happen if max_connections is decreased above).
1999
2136
        */
2000
 
        table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
2001
 
                                          (uint32_t)TABLE_OPEN_CACHE_MIN),
 
2137
        table_cache_size= (ulong) min(max((files-10-max_connections)/2,
 
2138
                                          TABLE_OPEN_CACHE_MIN),
2002
2139
                                      table_cache_size);
2003
 
        if (global_system_variables.log_warnings)
2004
 
          sql_print_warning(_("Changed limits: max_open_files: %u  "
2005
 
                              "max_connections: %ld  table_cache: %ld"),
2006
 
                            files, max_connections, table_cache_size);
 
2140
        if (global_system_variables.log_warnings)
 
2141
          sql_print_warning("Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
 
2142
                        files, max_connections, table_cache_size);
2007
2143
      }
2008
2144
      else if (global_system_variables.log_warnings)
2009
 
        sql_print_warning(_("Could not increase number of max_open_files "
2010
 
                            "to more than %u (request: %u)"),
2011
 
                          files, wanted_files);
 
2145
        sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files);
2012
2146
    }
2013
2147
    open_files_limit= files;
2014
2148
  }
2015
 
  unireg_init(0); /* Set up extern variabels */
 
2149
  unireg_init(opt_specialflag); /* Set up extern variabels */
2016
2150
  if (init_errmessage())        /* Read error messages from file */
2017
2151
    return 1;
 
2152
  init_client_errs();
2018
2153
  lex_init();
2019
2154
  if (item_create_init())
2020
2155
    return 1;
2023
2158
    return 1;
2024
2159
  if (init_replication_sys_vars())
2025
2160
    return 1;
 
2161
  mysys_uses_curses=0;
2026
2162
  /*
2027
2163
    Process a comma-separated character set list and choose
2028
2164
    the first available character set. This is mostly for
2052
2188
 
2053
2189
  if (default_collation_name)
2054
2190
  {
2055
 
    const CHARSET_INFO * const default_collation=
2056
 
      get_charset_by_name(default_collation_name, MYF(0));
 
2191
    CHARSET_INFO *default_collation;
 
2192
    default_collation= get_charset_by_name(default_collation_name, MYF(0));
2057
2193
    if (!default_collation)
2058
2194
    {
2059
 
      sql_print_error(_(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
2195
      sql_print_error(ER(ER_UNKNOWN_COLLATION), default_collation_name);
2060
2196
      return 1;
2061
2197
    }
2062
2198
    if (!my_charset_same(default_charset_info, default_collation))
2063
2199
    {
2064
 
      sql_print_error(_(ER(ER_COLLATION_CHARSET_MISMATCH)),
2065
 
                      default_collation_name,
2066
 
                      default_charset_info->csname);
 
2200
      sql_print_error(ER(ER_COLLATION_CHARSET_MISMATCH),
 
2201
                      default_collation_name,
 
2202
                      default_charset_info->csname);
2067
2203
      return 1;
2068
2204
    }
2069
2205
    default_charset_info= default_collation;
2078
2214
  global_system_variables.optimizer_use_mrr= 1;
2079
2215
  global_system_variables.optimizer_switch= 0;
2080
2216
 
2081
 
  if (!(character_set_filesystem=
 
2217
  if (!(character_set_filesystem= 
2082
2218
        get_charset_by_csname(character_set_filesystem_name,
2083
2219
                              MY_CS_PRIMARY, MYF(MY_WME))))
2084
2220
    return 1;
2087
2223
  if (!(my_default_lc_time_names=
2088
2224
        my_locale_by_name(lc_time_names_name)))
2089
2225
  {
2090
 
    sql_print_error(_("Unknown locale: '%s'"), lc_time_names_name);
 
2226
    sql_print_error("Unknown locale: '%s'", lc_time_names_name);
2091
2227
    return 1;
2092
2228
  }
2093
2229
  global_system_variables.lc_time_names= my_default_lc_time_names;
2094
 
 
 
2230
  
2095
2231
  sys_init_connect.value_length= 0;
2096
2232
  if ((sys_init_connect.value= opt_init_connect))
2097
2233
    sys_init_connect.value_length= strlen(opt_init_connect);
2104
2240
  else
2105
2241
    sys_init_slave.value=my_strdup("",MYF(0));
2106
2242
 
 
2243
  /* check log options and issue warnings if needed */
 
2244
  if (opt_log && opt_logname && !(log_output_options & LOG_FILE) &&
 
2245
      !(log_output_options & LOG_NONE))
 
2246
    sql_print_warning("Although a path was specified for the "
 
2247
                      "--log option, log tables are used. "
 
2248
                      "To enable logging to files use the --log-output option.");
 
2249
 
 
2250
  if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE)
 
2251
      && !(log_output_options & LOG_NONE))
 
2252
    sql_print_warning("Although a path was specified for the "
 
2253
                      "--log-slow-queries option, log tables are used. "
 
2254
                      "To enable logging to files use the --log-output=file option.");
 
2255
 
 
2256
  s= opt_logname ? opt_logname : make_default_log_name(buff, ".log");
 
2257
  sys_var_general_log_path.value= my_strdup(s, MYF(0));
 
2258
  sys_var_general_log_path.value_length= strlen(s);
 
2259
 
 
2260
  s= opt_slow_logname ? opt_slow_logname : make_default_log_name(buff, "-slow.log");
 
2261
  sys_var_slow_log_path.value= my_strdup(s, MYF(0));
 
2262
  sys_var_slow_log_path.value_length= strlen(s);
 
2263
 
2107
2264
  if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2108
2265
    return 1;
2109
2266
  if (my_database_names_init())
2110
2267
    return 1;
2111
2268
 
 
2269
  /*
 
2270
    Ensure that lower_case_table_names is set on system where we have case
 
2271
    insensitive names.  If this is not done the users MyISAM tables will
 
2272
    get corrupted if accesses with names of different case.
 
2273
  */
 
2274
  lower_case_file_system= test_if_case_insensitive(mysql_real_data_home);
 
2275
  if (!lower_case_table_names && lower_case_file_system == 1)
 
2276
  {
 
2277
    if (lower_case_table_names_used)
 
2278
    {
 
2279
      if (global_system_variables.log_warnings)
 
2280
        sql_print_warning("\
 
2281
You have forced lower_case_table_names to 0 through a command-line \
 
2282
option, even though your file system '%s' is case insensitive.  This means \
 
2283
that you can corrupt a MyISAM table by accessing it with different cases. \
 
2284
You should consider changing lower_case_table_names to 1 or 2",
 
2285
                        mysql_real_data_home);
 
2286
    }
 
2287
    else
 
2288
    {
 
2289
      if (global_system_variables.log_warnings)
 
2290
        sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home);
 
2291
      lower_case_table_names= 2;
 
2292
    }
 
2293
  }
 
2294
  else if (lower_case_table_names == 2 &&
 
2295
           !(lower_case_file_system=
 
2296
             (test_if_case_insensitive(mysql_real_data_home) == 1)))
 
2297
  {
 
2298
    if (global_system_variables.log_warnings)
 
2299
      sql_print_warning("lower_case_table_names was set to 2, even though your "
 
2300
                        "the file system '%s' is case sensitive.  Now setting "
 
2301
                        "lower_case_table_names to 0 to avoid future problems.",
 
2302
                        mysql_real_data_home);
 
2303
    lower_case_table_names= 0;
 
2304
  }
 
2305
  else
 
2306
  {
 
2307
    lower_case_file_system=
 
2308
      (test_if_case_insensitive(mysql_real_data_home) == 1);
 
2309
  }
2112
2310
 
2113
2311
  /* Reset table_alias_charset, now that lower_case_table_names is set. */
2114
 
  lower_case_table_names= 1; /* This we need to look at */
2115
 
  table_alias_charset= files_charset_info;
 
2312
  table_alias_charset= (lower_case_table_names ?
 
2313
                        files_charset_info :
 
2314
                        &my_charset_bin);
2116
2315
 
2117
2316
  return 0;
2118
2317
}
2124
2323
  (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
2125
2324
  (void) pthread_mutex_init(&LOCK_open, NULL);
2126
2325
  (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
 
2326
  (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
2127
2327
  (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2128
2328
  (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
 
2329
  (void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
 
2330
  (void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
 
2331
  (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
2129
2332
  (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2130
2333
  (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2131
2334
  (void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
2132
2335
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
 
2336
  (void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
2133
2337
  (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2134
2338
  (void) my_rwlock_init(&LOCK_sys_init_connect, NULL);
2135
2339
  (void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
2138
2342
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
2139
2343
  (void) pthread_cond_init(&COND_thread_cache,NULL);
2140
2344
  (void) pthread_cond_init(&COND_flush_thread_cache,NULL);
 
2345
  (void) pthread_cond_init(&COND_manager,NULL);
 
2346
  (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
 
2347
  (void) pthread_cond_init(&COND_rpl_status, NULL);
2141
2348
 
2142
2349
  /* Parameter for threads created for connections */
2143
2350
  (void) pthread_attr_init(&connection_attrib);
2144
2351
  (void) pthread_attr_setdetachstate(&connection_attrib,
2145
2352
                                     PTHREAD_CREATE_DETACHED);
2146
2353
  pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
 
2354
  if (!(opt_specialflag & SPECIAL_NO_PRIOR))
2147
2355
  {
2148
2356
    struct sched_param tmp_sched_param;
2149
2357
 
2152
2360
    (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
2153
2361
  }
2154
2362
 
2155
 
  if (pthread_key_create(&THR_Session,NULL) ||
 
2363
  if (pthread_key_create(&THR_THD,NULL) ||
2156
2364
      pthread_key_create(&THR_MALLOC,NULL))
2157
2365
  {
2158
 
    sql_print_error(_("Can't create thread-keys"));
 
2366
    sql_print_error("Can't create thread-keys");
2159
2367
    return 1;
2160
2368
  }
2161
2369
  return 0;
2171
2379
  if (table_cache_init() | table_def_init())
2172
2380
    unireg_abort(1);
2173
2381
 
2174
 
  randominit(&sql_rand,(uint32_t) server_start_time,(uint32_t) server_start_time/2);
 
2382
  randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
2175
2383
  setup_fpu();
2176
2384
  init_thr_lock();
 
2385
  init_slave_list();
2177
2386
 
2178
2387
  /* Setup logs */
2179
2388
 
2194
2403
      opt_error_log= 1;                         // Too long file name
2195
2404
    else
2196
2405
    {
2197
 
      if (freopen(log_error_file, "a+", stdout)==NULL)
2198
 
        sql_print_error(_("Unable to reopen stdout"));
2199
 
      else
2200
 
        if(freopen(log_error_file, "a+", stderr)==NULL)
2201
 
          sql_print_error(_("Unable to reopen stderr"));
 
2406
      if (freopen(log_error_file, "a+", stdout))
 
2407
        freopen(log_error_file, "a+", stderr);
2202
2408
    }
2203
2409
  }
2204
2410
 
2205
2411
  if (xid_cache_init())
2206
2412
  {
2207
 
    sql_print_error(_("Out of memory"));
 
2413
    sql_print_error("Out of memory");
2208
2414
    unireg_abort(1);
2209
2415
  }
2210
2416
 
2211
2417
  if (!opt_bin_log)
2212
2418
    if (opt_binlog_format_id != BINLOG_FORMAT_UNSPEC)
2213
2419
    {
2214
 
      sql_print_error(_("You need to use --log-bin to make "
2215
 
                        "--binlog-format work."));
 
2420
      sql_print_error("You need to use --log-bin to make "
 
2421
                      "--binlog-format work.");
2216
2422
      unireg_abort(1);
2217
2423
    }
2218
2424
    else
2223
2429
    if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
2224
2430
      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2225
2431
    else
2226
 
    {
 
2432
    { 
2227
2433
      assert(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
2228
2434
    }
2229
2435
 
2233
2439
 
2234
2440
  if (opt_log_slave_updates && replicate_same_server_id)
2235
2441
  {
2236
 
    sql_print_error(_("using --replicate-same-server-id in conjunction with "
2237
 
                      "--log-slave-updates is impossible, it would lead to "
2238
 
                      "infinite loops in this server."));
 
2442
    sql_print_error("\
 
2443
using --replicate-same-server-id in conjunction with \
 
2444
--log-slave-updates is impossible, it would lead to infinite loops in this \
 
2445
server.");
2239
2446
    unireg_abort(1);
2240
2447
  }
2241
2448
 
2253
2460
        require a name. But as we don't want to break many existing setups, we
2254
2461
        only give warning, not error.
2255
2462
      */
2256
 
      sql_print_warning(_("No argument was provided to --log-bin, and "
2257
 
                          "--log-bin-index was not used; so replication "
2258
 
                          "may break when this Drizzle server acts as a "
2259
 
                          "master and has his hostname changed!! Please "
2260
 
                          "use '--log-bin=%s' to avoid this problem."), ln);
 
2463
      sql_print_warning("No argument was provided to --log-bin, and "
 
2464
                        "--log-bin-index was not used; so replication "
 
2465
                        "may break when this MySQL server acts as a "
 
2466
                        "master and has his hostname changed!! Please "
 
2467
                        "use '--log-bin=%s' to avoid this problem.", ln);
2261
2468
    }
2262
2469
    if (ln == buf)
2263
2470
    {
2264
 
      free(opt_bin_logname);
 
2471
      my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
2265
2472
      opt_bin_logname=my_strdup(buf, MYF(0));
2266
2473
    }
2267
2474
    if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
2287
2494
                  (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
2288
2495
                  (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
2289
2496
  {
2290
 
    sql_print_error(_("Failed to initialize plugins."));
 
2497
    sql_print_error("Failed to initialize plugins.");
2291
2498
    unireg_abort(1);
2292
2499
  }
2293
2500
 
2317
2524
 
2318
2525
    if (defaults_argc)
2319
2526
    {
2320
 
      fprintf(stderr,
2321
 
              _("%s: Too many arguments (first extra is '%s').\n"
2322
 
                "Use --verbose --help to get a list of available options\n"),
 
2527
      fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n"
 
2528
              "Use --verbose --help to get a list of available options\n",
2323
2529
              my_progname, *tmp_argv);
2324
2530
      unireg_abort(1);
2325
2531
    }
2326
2532
  }
2327
2533
 
 
2534
  /* if the errmsg.sys is not loaded, terminate to maintain behaviour */
 
2535
  if (!errmesg[0][0])
 
2536
    unireg_abort(1);
 
2537
 
2328
2538
  /* We have to initialize the storage engines before CSV logging */
2329
2539
  if (ha_init())
2330
2540
  {
2331
 
    sql_print_error(_("Can't init databases"));
 
2541
    sql_print_error("Can't init databases");
2332
2542
    unireg_abort(1);
2333
2543
  }
2334
2544
 
 
2545
  logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
 
2546
                      opt_log ? LOG_FILE:LOG_NONE);
 
2547
 
2335
2548
  /*
2336
2549
    Check that the default storage engine is actually available.
2337
2550
  */
2341
2554
                       strlen(default_storage_engine_str) };
2342
2555
    plugin_ref plugin;
2343
2556
    handlerton *hton;
2344
 
 
 
2557
    
2345
2558
    if ((plugin= ha_resolve_by_name(0, &name)))
2346
 
    {
2347
 
      hton= plugin_data(plugin,handlerton *);
2348
 
    }
 
2559
      hton= plugin_data(plugin, handlerton*);
2349
2560
    else
2350
2561
    {
2351
 
      sql_print_error(_("Unknown/unsupported table type: %s"),
 
2562
      sql_print_error("Unknown/unsupported table type: %s",
2352
2563
                      default_storage_engine_str);
2353
2564
      unireg_abort(1);
2354
2565
    }
2355
2566
    if (!ha_storage_engine_is_enabled(hton))
2356
2567
    {
2357
 
      sql_print_error(_("Default storage engine (%s) is not available"),
2358
 
                      default_storage_engine_str);
2359
 
      unireg_abort(1);
 
2568
      if (!opt_bootstrap)
 
2569
      {
 
2570
        sql_print_error("Default storage engine (%s) is not available",
 
2571
                        default_storage_engine_str);
 
2572
        unireg_abort(1);
 
2573
      }
2360
2574
      assert(global_system_variables.table_plugin);
2361
2575
    }
2362
2576
    else
2363
2577
    {
2364
2578
      /*
2365
 
        Need to unlock as global_system_variables.table_plugin
 
2579
        Need to unlock as global_system_variables.table_plugin 
2366
2580
        was acquired during plugin_init()
2367
2581
      */
2368
2582
      plugin_unlock(0, global_system_variables.table_plugin);
2377
2591
 
2378
2592
  if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file))
2379
2593
  {
2380
 
    sql_print_error(_("Can't initialize tc_log"));
 
2594
    sql_print_error("Can't init tc log");
2381
2595
    unireg_abort(1);
2382
2596
  }
2383
2597
 
2397
2611
      mysql_bin_log.purge_logs_before_date(purge_time);
2398
2612
  }
2399
2613
 
 
2614
  if (opt_myisam_log)
 
2615
    (void) mi_log(1);
 
2616
 
2400
2617
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2401
2618
  if (locked_in_memory && !getuid())
2402
2619
  {
2408
2625
    if (mlockall(MCL_CURRENT))
2409
2626
    {
2410
2627
      if (global_system_variables.log_warnings)
2411
 
        sql_print_warning(_("Failed to lock memory. Errno: %d\n"),errno);
 
2628
        sql_print_warning("Failed to lock memory. Errno: %d\n",errno);
2412
2629
      locked_in_memory= 0;
2413
2630
    }
2414
2631
    if (user_info)
2423
2640
}
2424
2641
 
2425
2642
 
 
2643
static void create_maintenance_thread()
 
2644
{
 
2645
  if (flush_time && flush_time != ~(ulong) 0L)
 
2646
  {
 
2647
    pthread_t hThread;
 
2648
    if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
 
2649
      sql_print_warning("Can't create thread to manage maintenance");
 
2650
  }
 
2651
}
 
2652
 
 
2653
 
2426
2654
int main(int argc, char **argv)
2427
2655
{
2428
 
#if defined(ENABLE_NLS)
2429
 
# if defined(HAVE_LOCALE_H)
2430
 
  setlocale(LC_ALL, "");
2431
 
# endif
2432
 
  bindtextdomain("drizzle", LOCALEDIR);
2433
 
  textdomain("drizzle");
2434
 
#endif
2435
 
 
2436
2656
  MY_INIT(argv[0]);             // init my_sys library & pthreads
2437
2657
  /* nothing should come before this line ^^^ */
2438
2658
 
2457
2677
  }
2458
2678
#endif
2459
2679
 
2460
 
  if (init_common_variables(DRIZZLE_CONFIG_NAME,
 
2680
  if (init_common_variables(MYSQL_CONFIG_NAME,
2461
2681
                            argc, argv, load_default_groups))
2462
2682
    unireg_abort(1);                            // Will do exit
2463
2683
 
2464
2684
  init_signals();
 
2685
  if (!(opt_specialflag & SPECIAL_NO_PRIOR))
 
2686
  {
 
2687
    struct sched_param tmp_sched_param;
2465
2688
 
 
2689
    memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
 
2690
    tmp_sched_param.sched_priority= my_thread_stack_size*2;
 
2691
    (void)pthread_setschedparam(pthread_self(), SCHED_OTHER, &tmp_sched_param);
 
2692
  }
2466
2693
  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
2467
 
 
2468
2694
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
2469
2695
  {
2470
2696
    /* Retrieve used stack size;  Needed for checking stack overflows */
2474
2700
    if (stack_size && stack_size < my_thread_stack_size)
2475
2701
    {
2476
2702
      if (global_system_variables.log_warnings)
2477
 
      {
2478
 
        /* %zu is not yet in C++ */
2479
 
        uint64_t size_tmp= (uint64_t)stack_size;
2480
 
        sql_print_warning(_("Asked for %u thread stack, but got %"PRIu64),
2481
 
                          my_thread_stack_size, size_tmp);
2482
 
      }
 
2703
        sql_print_warning("Asked for %lu thread stack, but got %ld",
 
2704
                          my_thread_stack_size, (long) stack_size);
2483
2705
      my_thread_stack_size= stack_size;
2484
2706
    }
2485
2707
  }
2513
2735
  {
2514
2736
    server_id= 1;
2515
2737
#ifdef EXTRA_DEBUG
2516
 
    sql_print_warning(_("You have enabled the binary log, but you haven't set "
2517
 
                        "server-id to a non-zero value: we force server id to "
2518
 
                        "1; updates will be logged to the binary log, but "
2519
 
                        "connections from slaves will not be accepted."));
 
2738
    sql_print_warning("You have enabled the binary log, but you haven't set "
 
2739
                      "server-id to a non-zero value: we force server id to 1; "
 
2740
                      "updates will be logged to the binary log, but "
 
2741
                      "connections from slaves will not be accepted.");
2520
2742
#endif
2521
2743
  }
2522
2744
 
2538
2760
  error_handler_hook= my_message_sql;
2539
2761
  start_signal_handler();                               // Creates pidfile
2540
2762
 
2541
 
  if (mysql_rm_tmp_tables() || my_tz_init((Session *)0, default_tz_name))
 
2763
  if (mysql_rm_tmp_tables() || my_tz_init((THD *)0, default_tz_name, opt_bootstrap))
2542
2764
  {
2543
2765
    abort_loop=1;
2544
2766
    select_thread_in_use=0;
2545
 
    (void) pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
 
2767
    (void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL);
2546
2768
 
2547
 
    (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
 
2769
    if (!opt_bootstrap)
 
2770
      (void) my_delete(pidfile_name,MYF(MY_WME));       // Not needed anymore
2548
2771
 
2549
2772
    exit(1);
2550
2773
  }
2551
2774
 
 
2775
  udf_init();
 
2776
 
2552
2777
  init_status_vars();
 
2778
  if (opt_bootstrap) /* If running with bootstrap, do not start replication. */
 
2779
    opt_skip_slave_start= 1;
2553
2780
  /*
2554
2781
    init_slave() must be called after the thread keys are created.
2555
2782
    Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other
2561
2788
    unireg_abort(1);
2562
2789
  }
2563
2790
 
2564
 
  sql_print_information(_(ER(ER_STARTUP)),my_progname,server_version,
2565
 
                        "", mysqld_port, COMPILATION_COMMENT);
 
2791
  create_maintenance_thread();
 
2792
 
 
2793
  sql_print_information(ER(ER_STARTUP),my_progname,server_version,
 
2794
                        "", mysqld_port, MYSQL_COMPILATION_COMMENT);
2566
2795
 
2567
2796
 
2568
2797
  handle_connections_sockets();
2569
2798
 
2570
2799
  /* (void) pthread_attr_destroy(&connection_attrib); */
2571
 
 
 
2800
  
2572
2801
 
2573
2802
#ifdef EXTRA_DEBUG2
2574
 
  sql_print_error(_("Before Lock_thread_count"));
 
2803
  sql_print_error("Before Lock_thread_count");
2575
2804
#endif
2576
2805
  (void) pthread_mutex_lock(&LOCK_thread_count);
2577
2806
  select_thread_in_use=0;                       // For close_connections
2578
2807
  (void) pthread_mutex_unlock(&LOCK_thread_count);
2579
2808
  (void) pthread_cond_broadcast(&COND_thread_count);
2580
2809
#ifdef EXTRA_DEBUG2
2581
 
  sql_print_error(_("After lock_thread_count"));
 
2810
  sql_print_error("After lock_thread_count");
2582
2811
#endif
2583
2812
 
2584
2813
  /* Wait until cleanup is done */
2597
2826
 
2598
2827
    This function will create new thread to handle the incoming
2599
2828
    connection.  If there are idle cached threads one will be used.
2600
 
    'session' will be pushed into 'threads'.
 
2829
    'thd' will be pushed into 'threads'.
2601
2830
 
2602
2831
    In single-threaded mode (\#define ONE_THREAD) connection will be
2603
2832
    handled inside this function.
2604
2833
 
2605
 
  @param[in,out] session    Thread handle of future thread.
 
2834
  @param[in,out] thd    Thread handle of future thread.
2606
2835
*/
2607
2836
 
2608
 
static void create_new_thread(Session *session)
 
2837
static void create_new_thread(THD *thd)
2609
2838
{
2610
2839
 
2611
2840
  /*
2619
2848
  {
2620
2849
    pthread_mutex_unlock(&LOCK_connection_count);
2621
2850
 
2622
 
    close_connection(session, ER_CON_COUNT_ERROR, 1);
2623
 
    delete session;
 
2851
    close_connection(thd, ER_CON_COUNT_ERROR, 1);
 
2852
    delete thd;
2624
2853
    return;;
2625
2854
  }
2626
2855
 
2636
2865
  pthread_mutex_lock(&LOCK_thread_count);
2637
2866
 
2638
2867
  /*
2639
 
    The initialization of thread_id is done in create_embedded_session() for
 
2868
    The initialization of thread_id is done in create_embedded_thd() for
2640
2869
    the embedded library.
2641
2870
    TODO: refactor this to avoid code duplication there
2642
2871
  */
2643
 
  session->thread_id= session->variables.pseudo_thread_id= thread_id++;
 
2872
  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
2644
2873
 
2645
2874
  thread_count++;
2646
2875
 
2647
 
  thread_scheduler.add_connection(session);
 
2876
  thread_scheduler.add_connection(thd);
2648
2877
 
2649
2878
  return;;
2650
2879
}
2654
2883
inline void kill_broken_server()
2655
2884
{
2656
2885
  /* hack to get around signals ignored in syscalls for problem OS's */
2657
 
  if ((ip_sock == -1))
 
2886
  if ((!opt_disable_networking && ip_sock == INVALID_SOCKET))
2658
2887
  {
2659
2888
    select_thread_in_use = 0;
2660
2889
    /* The following call will never return */
2661
 
    kill_server((void*) DRIZZLE_KILL_SIGNAL);
 
2890
    kill_server((void*) MYSQL_KILL_SIGNAL);
2662
2891
  }
2663
2892
}
2664
2893
#define MAYBE_BROKEN_SYSCALL kill_broken_server();
2670
2899
 
2671
2900
void handle_connections_sockets()
2672
2901
{
2673
 
  int x;
2674
 
  int sock,new_sock;
2675
 
  uint32_t error_count=0;
2676
 
  Session *session;
 
2902
  my_socket sock,new_sock;
 
2903
  uint error_count=0;
 
2904
  uint max_used_connection= (uint)ip_sock+1;
 
2905
  fd_set readFDs,clientFDs;
 
2906
  THD *thd;
2677
2907
  struct sockaddr_storage cAddr;
 
2908
  int ip_flags=0, flags;
 
2909
  st_vio *vio_tmp;
2678
2910
 
 
2911
  FD_ZERO(&clientFDs);
 
2912
  if (ip_sock != INVALID_SOCKET)
 
2913
  {
 
2914
    FD_SET(ip_sock,&clientFDs);
 
2915
    ip_flags = fcntl(ip_sock, F_GETFL, 0);
 
2916
  }
2679
2917
  MAYBE_BROKEN_SYSCALL;
2680
2918
  while (!abort_loop)
2681
2919
  {
2682
 
    int number_of;
2683
 
 
2684
 
    if ((number_of= poll(fds, pollfd_count, -1)) == -1)
 
2920
    readFDs=clientFDs;
 
2921
    if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
2685
2922
    {
2686
 
      if (errno != EINTR)
 
2923
      if (socket_errno != SOCKET_EINTR)
2687
2924
      {
2688
 
        if (!select_errors++ && !abort_loop)    /* purecov: inspected */
2689
 
          sql_print_error(_("drizzled: Got error %d from select"),
2690
 
                          errno); /* purecov: inspected */
 
2925
        if (!select_errors++ && !abort_loop)    /* purecov: inspected */
 
2926
          sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
2691
2927
      }
2692
2928
      MAYBE_BROKEN_SYSCALL
2693
2929
      continue;
2694
2930
    }
2695
 
    if (number_of == 0)
2696
 
      continue;
2697
 
 
2698
 
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
2699
 
    assert(number_of > 1); /* Not handling this at the moment */
2700
 
#endif
2701
 
 
2702
2931
    if (abort_loop)
2703
2932
    {
2704
2933
      MAYBE_BROKEN_SYSCALL;
2705
2934
      break;
2706
2935
    }
2707
2936
 
2708
 
    for (x= 0, sock= -1; x < pollfd_count; x++)
 
2937
    /* Is this a new connection request ? */
2709
2938
    {
2710
 
      if (fds[x].revents == POLLIN)
2711
 
      {
2712
 
        sock= fds[x].fd;
2713
 
        break;
2714
 
      }
 
2939
      sock = ip_sock;
 
2940
      flags= ip_flags;
2715
2941
    }
2716
 
    assert(sock != -1);
2717
2942
 
2718
 
    for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2719
 
    {
2720
 
      SOCKET_SIZE_TYPE length= sizeof(struct sockaddr_storage);
 
2943
#if !defined(NO_FCNTL_NONBLOCK)
 
2944
    if (!(test_flags & TEST_BLOCKING))
 
2945
    {
 
2946
#if defined(O_NONBLOCK)
 
2947
      fcntl(sock, F_SETFL, flags | O_NONBLOCK);
 
2948
#elif defined(O_NDELAY)
 
2949
      fcntl(sock, F_SETFL, flags | O_NDELAY);
 
2950
#endif
 
2951
    }
 
2952
#endif /* NO_FCNTL_NONBLOCK */
 
2953
    for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
 
2954
    {
 
2955
      size_socket length= sizeof(struct sockaddr_storage);
2721
2956
      new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2722
2957
                       &length);
2723
 
      if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
 
2958
      if (new_sock != INVALID_SOCKET ||
 
2959
          (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
2724
2960
        break;
 
2961
      MAYBE_BROKEN_SYSCALL;
 
2962
#if !defined(NO_FCNTL_NONBLOCK)
 
2963
      if (!(test_flags & TEST_BLOCKING))
 
2964
      {
 
2965
        if (retry == MAX_ACCEPT_RETRY - 1)
 
2966
          fcntl(sock, F_SETFL, flags);          // Try without O_NONBLOCK
 
2967
      }
 
2968
#endif
2725
2969
    }
2726
 
 
2727
 
 
2728
 
    if (new_sock == -1)
 
2970
#if !defined(NO_FCNTL_NONBLOCK)
 
2971
    if (!(test_flags & TEST_BLOCKING))
 
2972
      fcntl(sock, F_SETFL, flags);
 
2973
#endif
 
2974
    if (new_sock == INVALID_SOCKET)
2729
2975
    {
2730
2976
      if ((error_count++ & 255) == 0)           // This can happen often
2731
2977
        sql_perror("Error in accept");
2732
2978
      MAYBE_BROKEN_SYSCALL;
2733
 
      if (errno == ENFILE || errno == EMFILE)
 
2979
      if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
2734
2980
        sleep(1);                               // Give other threads some time
2735
2981
      continue;
2736
2982
    }
2737
2983
 
2738
2984
    {
2739
 
      SOCKET_SIZE_TYPE dummyLen;
 
2985
      size_socket dummyLen;
2740
2986
      struct sockaddr_storage dummy;
2741
2987
      dummyLen = sizeof(dummy);
2742
 
      if (  getsockname(new_sock,(struct sockaddr *)&dummy,
2743
 
                        (socklen_t *)&dummyLen) < 0  )
2744
 
      {
2745
 
        sql_perror("Error on new connection socket");
2746
 
        (void) shutdown(new_sock, SHUT_RDWR);
2747
 
        (void) close(new_sock);
2748
 
        continue;
2749
 
      }
2750
 
      dummyLen = sizeof(dummy);
2751
 
      if ( getpeername(new_sock, (struct sockaddr *)&dummy,
2752
 
                       (socklen_t *)&dummyLen) < 0)
2753
 
      {
2754
 
        sql_perror("Error on new connection socket");
2755
 
        (void) shutdown(new_sock, SHUT_RDWR);
2756
 
        (void) close(new_sock);
2757
 
         continue;
 
2988
      if (  getsockname(new_sock,(struct sockaddr *)&dummy, 
 
2989
                  (socklen_t *)&dummyLen) < 0  )
 
2990
      {
 
2991
        sql_perror("Error on new connection socket");
 
2992
        (void) shutdown(new_sock, SHUT_RDWR);
 
2993
        (void) closesocket(new_sock);
 
2994
        continue;
2758
2995
      }
2759
2996
    }
2760
2997
 
2762
2999
    ** Don't allow too many connections
2763
3000
    */
2764
3001
 
2765
 
    if (!(session= new Session))
 
3002
    if (!(thd= new THD))
2766
3003
    {
2767
3004
      (void) shutdown(new_sock, SHUT_RDWR);
2768
 
      close(new_sock);
 
3005
      VOID(closesocket(new_sock));
2769
3006
      continue;
2770
3007
    }
2771
 
    if (net_init_sock(&session->net, new_sock, sock == 0))
 
3008
    if (!(vio_tmp=vio_new(new_sock, VIO_TYPE_TCPIP, sock == 0)) ||
 
3009
        my_net_init(&thd->net,vio_tmp))
2772
3010
    {
2773
 
      delete session;
 
3011
      /*
 
3012
        Only delete the temporary vio if we didn't already attach it to the
 
3013
        NET object. The destructor in THD will delete any initialized net
 
3014
        structure.
 
3015
      */
 
3016
      if (vio_tmp && thd->net.vio != vio_tmp)
 
3017
        vio_delete(vio_tmp);
 
3018
      else
 
3019
      {
 
3020
        (void) shutdown(new_sock, SHUT_RDWR);
 
3021
        (void) closesocket(new_sock);
 
3022
      }
 
3023
      delete thd;
2774
3024
      continue;
2775
3025
    }
2776
3026
 
2777
 
    create_new_thread(session);
 
3027
    create_new_thread(thd);
2778
3028
  }
2779
3029
}
2780
3030
 
2785
3035
 
2786
3036
enum options_mysqld
2787
3037
{
2788
 
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW,
2789
 
  OPT_SKIP_GRANT,
 
3038
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW, 
 
3039
  OPT_SKIP_GRANT,              OPT_SKIP_LOCK, 
2790
3040
  OPT_ENABLE_LOCK,             OPT_USE_LOCKING,
2791
3041
  OPT_SOCKET,                  OPT_UPDATE_LOG,
2792
 
  OPT_BIN_LOG,
 
3042
  OPT_BIN_LOG,                 
2793
3043
  OPT_BIN_LOG_INDEX,
2794
3044
  OPT_BIND_ADDRESS,            OPT_PID_FILE,
2795
 
  OPT_SKIP_PRIOR,
 
3045
  OPT_SKIP_PRIOR,              OPT_BIG_TABLES,
2796
3046
  OPT_STANDALONE,
2797
3047
  OPT_CONSOLE,                 OPT_LOW_PRIORITY_UPDATES,
2798
3048
  OPT_SHORT_LOG_FORMAT,
2799
3049
  OPT_FLUSH,                   OPT_SAFE,
 
3050
  OPT_BOOTSTRAP,               OPT_SKIP_SHOW_DB,
2800
3051
  OPT_STORAGE_ENGINE,          OPT_INIT_FILE,
2801
 
  OPT_DELAY_KEY_WRITE_ALL,
 
3052
  OPT_DELAY_KEY_WRITE_ALL,     OPT_SLOW_QUERY_LOG,
2802
3053
  OPT_DELAY_KEY_WRITE,         OPT_CHARSETS_DIR,
2803
3054
  OPT_MASTER_INFO_FILE,
2804
3055
  OPT_MASTER_RETRY_COUNT,      OPT_LOG_TC, OPT_LOG_TC_SIZE,
2806
3057
  OPT_REPLICATE_IGNORE_DB,     OPT_LOG_SLAVE_UPDATES,
2807
3058
  OPT_BINLOG_DO_DB,            OPT_BINLOG_IGNORE_DB,
2808
3059
  OPT_BINLOG_FORMAT,
2809
 
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
 
3060
#ifndef DBUG_OFF
 
3061
  OPT_BINLOG_SHOW_XID,
 
3062
#endif
 
3063
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 
2810
3064
  OPT_WANT_CORE,
2811
3065
  OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
2812
3066
  OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
2816
3070
  OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
2817
3071
  OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
2818
3072
  OPT_ABORT_SLAVE_EVENT_COUNT,
2819
 
  OPT_ENGINE_CONDITION_PUSHDOWN,
 
3073
  OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
 
3074
  OPT_ENGINE_CONDITION_PUSHDOWN, 
2820
3075
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
2821
3076
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
2822
3077
  OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
2832
3087
  OPT_SSL_CAPATH, OPT_SSL_CIPHER,
2833
3088
  OPT_BACK_LOG, OPT_BINLOG_CACHE_SIZE,
2834
3089
  OPT_CONNECT_TIMEOUT,
2835
 
  OPT_FLUSH_TIME,
 
3090
  OPT_FLUSH_TIME, OPT_FT_MIN_WORD_LEN, OPT_FT_BOOLEAN_SYNTAX,
2836
3091
  OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
2837
3092
  OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
2838
3093
  OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
2841
3096
  OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
2842
3097
  OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
2843
3098
  OPT_MAX_HEP_TABLE_SIZE,
2844
 
  OPT_MAX_JOIN_SIZE,
 
3099
  OPT_MAX_JOIN_SIZE, OPT_MAX_PREPARED_STMT_COUNT,
2845
3100
  OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH,
2846
3101
  OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
2847
3102
  OPT_MAX_LENGTH_FOR_SORT_DATA,
2855
3110
  OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
2856
3111
  OPT_OPEN_FILES_LIMIT,
2857
3112
  OPT_PRELOAD_BUFFER_SIZE,
2858
 
  OPT_RECORD_BUFFER,
 
3113
  OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_MIN_RES_UNIT, OPT_QUERY_CACHE_SIZE,
 
3114
  OPT_QUERY_CACHE_TYPE, OPT_QUERY_CACHE_WLOCK_INVALIDATE, OPT_RECORD_BUFFER,
2859
3115
  OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT,
2860
3116
  OPT_RELAY_LOG_PURGE,
2861
3117
  OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
2875
3131
  OPT_SYNC_REPLICATION_TIMEOUT,
2876
3132
  OPT_ENABLE_SHARED_MEMORY,
2877
3133
  OPT_SHARED_MEMORY_BASE_NAME,
 
3134
  OPT_OLD_PASSWORDS,
2878
3135
  OPT_OLD_ALTER_TABLE,
2879
3136
  OPT_EXPIRE_LOGS_DAYS,
2880
3137
  OPT_GROUP_CONCAT_MAX_LEN,
2888
3145
  OPT_DATE_FORMAT,
2889
3146
  OPT_TIME_FORMAT,
2890
3147
  OPT_DATETIME_FORMAT,
 
3148
  OPT_LOG_QUERIES_NOT_USING_INDEXES,
2891
3149
  OPT_DEFAULT_TIME_ZONE,
2892
3150
  OPT_SYSDATE_IS_NOW,
2893
3151
  OPT_OPTIMIZER_SEARCH_DEPTH,
2897
3155
  OPT_ENABLE_LARGE_PAGES,
2898
3156
  OPT_TIMED_MUTEXES,
2899
3157
  OPT_OLD_STYLE_USER_LIMITS,
 
3158
  OPT_LOG_SLOW_ADMIN_STATEMENTS,
2900
3159
  OPT_TABLE_LOCK_WAIT_TIMEOUT,
2901
3160
  OPT_PLUGIN_LOAD,
2902
3161
  OPT_PLUGIN_DIR,
 
3162
  OPT_LOG_OUTPUT,
2903
3163
  OPT_PORT_OPEN_TIMEOUT,
2904
3164
  OPT_PROFILING,
2905
3165
  OPT_KEEP_FILES_ON_CREATE,
2906
3166
  OPT_GENERAL_LOG,
 
3167
  OPT_SLOW_LOG,
2907
3168
  OPT_THREAD_HANDLING,
2908
3169
  OPT_INNODB_ROLLBACK_ON_TIMEOUT,
2909
3170
  OPT_SECURE_FILE_PRIV,
2910
3171
  OPT_MIN_EXAMINED_ROW_LIMIT,
 
3172
  OPT_LOG_SLOW_SLAVE_STATEMENTS,
2911
3173
  OPT_OLD_MODE,
2912
3174
  OPT_POOL_OF_THREADS,
2913
3175
  OPT_SLAVE_EXEC_MODE
2914
3176
};
2915
3177
 
2916
3178
 
2917
 
#define LONG_TIMEOUT ((uint32_t) 3600L*24L*365L)
 
3179
#define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
2918
3180
 
2919
3181
struct my_option my_long_options[] =
2920
3182
{
2921
 
  {"help", '?', N_("Display this help and exit."),
2922
 
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
3183
  {"help", '?', "Display this help and exit.", 
 
3184
   (uchar**) &opt_help, (uchar**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
2923
3185
   0, 0},
2924
3186
  {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT,
2925
 
   N_("Option used by mysql-test for debugging and testing of replication."),
2926
 
   (char**) &abort_slave_event_count,  (char**) &abort_slave_event_count,
 
3187
   "Option used by mysql-test for debugging and testing of replication.",
 
3188
   (uchar**) &abort_slave_event_count,  (uchar**) &abort_slave_event_count,
2927
3189
   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3190
  {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'.", 0, 0, 0,
 
3191
   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
2928
3192
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
2929
 
   N_("Auto-increment columns are incremented by this"),
2930
 
   (char**) &global_system_variables.auto_increment_increment,
2931
 
   (char**) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
 
3193
   "Auto-increment columns are incremented by this",
 
3194
   (uchar**) &global_system_variables.auto_increment_increment,
 
3195
   (uchar**) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
2932
3196
   OPT_ARG, 1, 1, 65535, 0, 1, 0 },
2933
3197
  {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
2934
 
   N_("Offset added to Auto-increment columns. Used when "
2935
 
      "auto-increment-increment != 1"),
2936
 
   (char**) &global_system_variables.auto_increment_offset,
2937
 
   (char**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
 
3198
   "Offset added to Auto-increment columns. Used when auto-increment-increment != 1",
 
3199
   (uchar**) &global_system_variables.auto_increment_offset,
 
3200
   (uchar**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
2938
3201
   1, 1, 65535, 0, 1, 0 },
2939
3202
  {"basedir", 'b',
2940
 
   N_("Path to installation directory. All paths are usually resolved "
2941
 
      "relative to this."),
2942
 
   (char**) &mysql_home_ptr, (char**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
 
3203
   "Path to installation directory. All paths are usually resolved relative to this.",
 
3204
   (uchar**) &mysql_home_ptr, (uchar**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
2943
3205
   0, 0, 0, 0, 0, 0},
2944
 
  {"bind-address", OPT_BIND_ADDRESS, N_("IP address to bind to."),
2945
 
   (char**) &my_bind_addr_str, (char**) &my_bind_addr_str, 0, GET_STR,
 
3206
  {"big-tables", OPT_BIG_TABLES,
 
3207
   "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors).",
 
3208
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3209
  {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
 
3210
   (uchar**) &my_bind_addr_str, (uchar**) &my_bind_addr_str, 0, GET_STR,
2946
3211
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2947
3212
  {"binlog_format", OPT_BINLOG_FORMAT,
2948
 
   N_("Does not have any effect without '--log-bin'. "
2949
 
      "Tell the master the form of binary logging to use: either 'row' for "
2950
 
      "row-based binary logging, or 'statement' for statement-based binary "
2951
 
      "logging, or 'mixed'. 'mixed' is statement-based binary logging except "
2952
 
      "for those statements where only row-based is correct: those which "
2953
 
      "involve user-defined functions (i.e. UDFs) or the UUID() function; for "
2954
 
      "those, row-based binary logging is automatically used. ")
2955
 
   ,(char**) &opt_binlog_format, (char**) &opt_binlog_format,
 
3213
   "Does not have any effect without '--log-bin'. "
 
3214
   "Tell the master the form of binary logging to use: either 'row' for "
 
3215
   "row-based binary logging, or 'statement' for statement-based binary "
 
3216
   "logging, or 'mixed'. 'mixed' is statement-based binary logging except "
 
3217
   "for those statements where only row-based is correct: those which "
 
3218
   "involve user-defined functions (i.e. UDFs) or the UUID() function; for "
 
3219
   "those, row-based binary logging is automatically used. "
 
3220
   ,(uchar**) &opt_binlog_format, (uchar**) &opt_binlog_format,
2956
3221
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2957
3222
  {"binlog-do-db", OPT_BINLOG_DO_DB,
2958
 
   N_("Tells the master it should log updates for the specified database, and "
2959
 
      "exclude all others not explicitly mentioned."),
 
3223
   "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.",
2960
3224
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2961
3225
  {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
2962
 
   N_("Tells the master that updates to the given database should not "
2963
 
      "be logged tothe binary log."),
 
3226
   "Tells the master that updates to the given database should not be logged tothe binary log.",
2964
3227
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2965
3228
  {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
2966
 
   N_("The maximum size of a row-based binary log event in bytes. Rows will "
2967
 
      "be grouped into events smaller than this size if possible. "
2968
 
      "The value has to be a multiple of 256."),
2969
 
   (char**) &opt_binlog_rows_event_max_size,
2970
 
   (char**) &opt_binlog_rows_event_max_size, 0,
2971
 
   GET_ULONG, REQUIRED_ARG,
2972
 
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX,
2973
 
   /* sub_size */     0, /* block_size */ 256,
 
3229
   "The maximum size of a row-based binary log event in bytes. Rows will be "
 
3230
   "grouped into events smaller than this size if possible. "
 
3231
   "The value has to be a multiple of 256.",
 
3232
   (uchar**) &opt_binlog_rows_event_max_size, 
 
3233
   (uchar**) &opt_binlog_rows_event_max_size, 0, 
 
3234
   GET_ULONG, REQUIRED_ARG, 
 
3235
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
 
3236
   /* sub_size */     0, /* block_size */ 256, 
2974
3237
   /* app_type */ 0
2975
3238
  },
 
3239
#ifndef DISABLE_GRANT_OPTIONS
 
3240
  {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
 
3241
   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3242
#endif
2976
3243
  {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
2977
 
   N_("Don't ignore client side character set value sent during handshake."),
2978
 
   (char**) &opt_character_set_client_handshake,
2979
 
   (char**) &opt_character_set_client_handshake,
 
3244
   "Don't ignore client side character set value sent during handshake.",
 
3245
   (uchar**) &opt_character_set_client_handshake,
 
3246
   (uchar**) &opt_character_set_client_handshake,
2980
3247
    0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
2981
3248
  {"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM,
2982
 
   N_("Set the filesystem character set."),
2983
 
   (char**) &character_set_filesystem_name,
2984
 
   (char**) &character_set_filesystem_name,
 
3249
   "Set the filesystem character set.",
 
3250
   (uchar**) &character_set_filesystem_name,
 
3251
   (uchar**) &character_set_filesystem_name,
2985
3252
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
2986
 
  {"character-set-server", 'C',
2987
 
   N_("Set the default character set."),
2988
 
   (char**) &default_character_set_name, (char**) &default_character_set_name,
 
3253
  {"character-set-server", 'C', "Set the default character set.",
 
3254
   (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
2989
3255
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
2990
3256
  {"character-sets-dir", OPT_CHARSETS_DIR,
2991
 
   N_("Directory where character sets are."), (char**) &charsets_dir,
2992
 
   (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2993
 
  {"chroot", 'r',
2994
 
   N_("Chroot mysqld daemon during startup."),
2995
 
   (char**) &mysqld_chroot, (char**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
 
3257
   "Directory where character sets are.", (uchar**) &charsets_dir,
 
3258
   (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3259
  {"chroot", 'r', "Chroot mysqld daemon during startup.",
 
3260
   (uchar**) &mysqld_chroot, (uchar**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
2996
3261
   0, 0, 0, 0, 0, 0},
2997
 
  {"collation-server", OPT_DEFAULT_COLLATION,
2998
 
   N_("Set the default collation."),
2999
 
   (char**) &default_collation_name, (char**) &default_collation_name,
 
3262
  {"collation-server", OPT_DEFAULT_COLLATION, "Set the default collation.",
 
3263
   (uchar**) &default_collation_name, (uchar**) &default_collation_name,
3000
3264
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3001
 
  {"completion-type", OPT_COMPLETION_TYPE,
3002
 
   N_("Default completion type."),
3003
 
   (char**) &global_system_variables.completion_type,
3004
 
   (char**) &max_system_variables.completion_type, 0, GET_ULONG,
 
3265
  {"completion-type", OPT_COMPLETION_TYPE, "Default completion type.",
 
3266
   (uchar**) &global_system_variables.completion_type,
 
3267
   (uchar**) &max_system_variables.completion_type, 0, GET_ULONG,
3005
3268
   REQUIRED_ARG, 0, 0, 2, 0, 1, 0},
3006
 
  {"console", OPT_CONSOLE,
3007
 
   N_("Write error output on screen."),
3008
 
   (char**) &opt_console, (char**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
 
3269
  {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.",
 
3270
   (uchar**) &opt_console, (uchar**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
3009
3271
   0, 0, 0},
3010
 
  {"core-file", OPT_WANT_CORE,
3011
 
   N_("Write core on errors."),
3012
 
   0, 0, 0, GET_NO_ARG,
 
3272
  {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG,
3013
3273
   NO_ARG, 0, 0, 0, 0, 0, 0},
3014
 
  {"datadir", 'h',
3015
 
   N_("Path to the database root."),
3016
 
   (char**) &mysql_data_home,
3017
 
   (char**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3274
  {"datadir", 'h', "Path to the database root.", (uchar**) &mysql_data_home,
 
3275
   (uchar**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3276
#ifndef DBUG_OFF
 
3277
  {"debug", '#', "Debug log.", (uchar**) &default_dbug_option,
 
3278
   (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3279
#endif
 
3280
  {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).",
 
3281
   (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
 
3282
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 
3283
  {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (deprecated option, use --collation-server instead).",
 
3284
   (uchar**) &default_collation_name, (uchar**) &default_collation_name,
 
3285
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3018
3286
  {"default-storage-engine", OPT_STORAGE_ENGINE,
3019
 
   N_("Set the default storage engine (table type) for tables."),
3020
 
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
3021
 
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3022
 
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE,
3023
 
   N_("Set the default time zone."),
3024
 
   (char**) &default_tz_name, (char**) &default_tz_name,
 
3287
   "Set the default storage engine (table type) for tables.",
 
3288
   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
 
3289
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3290
  {"default-table-type", OPT_STORAGE_ENGINE,
 
3291
   "(deprecated) Use --default-storage-engine.",
 
3292
   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
 
3293
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3294
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
 
3295
   (uchar**) &default_tz_name, (uchar**) &default_tz_name,
3025
3296
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3026
 
  {"delay-key-write", OPT_DELAY_KEY_WRITE,
3027
 
   N_("Type of DELAY_KEY_WRITE."),
 
3297
  {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.",
3028
3298
   0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3299
  {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
 
3300
   "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead).",
 
3301
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3029
3302
  {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
3030
 
   N_("Option used by mysql-test for debugging and testing of replication."),
3031
 
   (char**) &disconnect_slave_event_count,
3032
 
   (char**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
 
3303
   "Option used by mysql-test for debugging and testing of replication.",
 
3304
   (uchar**) &disconnect_slave_event_count,
 
3305
   (uchar**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
3033
3306
   0, 0, 0},
3034
3307
#ifdef HAVE_STACK_TRACE_ON_SEGV
3035
 
  {"enable-pstack", OPT_DO_PSTACK,
3036
 
   N_("Print a symbolic stack trace on failure."),
3037
 
   (char**) &opt_do_pstack, (char**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
 
3308
  {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure.",
 
3309
   (uchar**) &opt_do_pstack, (uchar**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
3038
3310
   0, 0, 0, 0},
3039
3311
#endif /* HAVE_STACK_TRACE_ON_SEGV */
3040
3312
  {"engine-condition-pushdown",
3041
3313
   OPT_ENGINE_CONDITION_PUSHDOWN,
3042
 
   N_("Push supported query conditions to the storage engine."),
3043
 
   (char**) &global_system_variables.engine_condition_pushdown,
3044
 
   (char**) &global_system_variables.engine_condition_pushdown,
3045
 
   0, GET_BOOL, NO_ARG, false, 0, 0, 0, 0, 0},
 
3314
   "Push supported query conditions to the storage engine.",
 
3315
   (uchar**) &global_system_variables.engine_condition_pushdown,
 
3316
   (uchar**) &global_system_variables.engine_condition_pushdown,
 
3317
   0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
3046
3318
  /* See how it's handled in get_one_option() */
3047
 
  {"exit-info", 'T',
3048
 
   N_("Used for debugging;  Use at your own risk!"),
3049
 
   0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
3050
 
  {"flush", OPT_FLUSH,
3051
 
   N_("Flush tables to disk between SQL commands."),
3052
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3319
  {"exit-info", 'T', "Used for debugging;  Use at your own risk!", 0, 0, 0,
 
3320
   GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3321
  {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands.", 0, 0, 0,
 
3322
   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3053
3323
  /* We must always support the next option to make scripts like mysqltest
3054
3324
     easier to do */
3055
3325
  {"gdb", OPT_DEBUGGING,
3056
 
   N_("Set up signals usable for debugging"),
3057
 
   (char**) &opt_debugging, (char**) &opt_debugging,
 
3326
   "Set up signals usable for debugging",
 
3327
   (uchar**) &opt_debugging, (uchar**) &opt_debugging,
3058
3328
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3059
 
  {"init-connect", OPT_INIT_CONNECT,
3060
 
   N_("Command(s) that are executed for each new connection"),
3061
 
   (char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
 
3329
  {"general-log", OPT_GENERAL_LOG,
 
3330
   "Enable|disable general log", (uchar**) &opt_log,
 
3331
   (uchar**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3332
  {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection",
 
3333
   (uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC,
3062
3334
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3063
 
  {"init-file", OPT_INIT_FILE,
3064
 
   N_("Read SQL commands from this file at startup."),
3065
 
   (char**) &opt_init_file, (char**) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
 
3335
  {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.",
 
3336
   (uchar**) &opt_init_file, (uchar**) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
3066
3337
   0, 0, 0, 0, 0, 0},
3067
 
  {"init-slave", OPT_INIT_SLAVE,
3068
 
   N_("Command(s) that are executed when a slave connects to this master"),
3069
 
   (char**) &opt_init_slave, (char**) &opt_init_slave, 0, GET_STR_ALLOC,
 
3338
  {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to this master",
 
3339
   (uchar**) &opt_init_slave, (uchar**) &opt_init_slave, 0, GET_STR_ALLOC,
3070
3340
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3071
3341
  {"language", 'L',
3072
 
   N_("(IGNORED)"),
3073
 
   (char**) &language_ptr, (char**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
 
3342
   "Client error messages in given language. May be given as a full path.",
 
3343
   (uchar**) &language_ptr, (uchar**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
3074
3344
   0, 0, 0, 0, 0, 0},
3075
3345
  {"lc-time-names", OPT_LC_TIME_NAMES,
3076
 
   N_("Set the language used for the month names and the days of the week."),
3077
 
   (char**) &lc_time_names_name,
3078
 
   (char**) &lc_time_names_name,
 
3346
   "Set the language used for the month names and the days of the week.",
 
3347
   (uchar**) &lc_time_names_name,
 
3348
   (uchar**) &lc_time_names_name,
3079
3349
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3080
3350
  {"local-infile", OPT_LOCAL_INFILE,
3081
 
   N_("Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)."),
3082
 
   (char**) &opt_local_infile,
3083
 
   (char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
 
3351
   "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).",
 
3352
   (uchar**) &opt_local_infile,
 
3353
   (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
3084
3354
   1, 0, 0, 0, 0, 0},
3085
 
  {"log", 'l',
3086
 
   N_("Log connections and queries to file."),
3087
 
   (char**) &opt_logname,
3088
 
   (char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3355
  {"log", 'l', "Log connections and queries to file.", (uchar**) &opt_logname,
 
3356
   (uchar**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3089
3357
  {"log-bin", OPT_BIN_LOG,
3090
 
   N_("Log update queries in binary format. Optional argument is the "
3091
 
      "location for the binary log files.(Strongly "
3092
 
      "recommended to avoid replication problems if server's hostname "
3093
 
      "changes)"),
3094
 
   (char**) &opt_bin_logname, (char**) &opt_bin_logname, 0, GET_STR_ALLOC,
 
3358
   "Log update queries in binary format. Optional (but strongly recommended "
 
3359
   "to avoid replication problems if server's hostname changes) argument "
 
3360
   "should be the chosen location for the binary log files.",
 
3361
   (uchar**) &opt_bin_logname, (uchar**) &opt_bin_logname, 0, GET_STR_ALLOC,
3095
3362
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3096
3363
  {"log-bin-index", OPT_BIN_LOG_INDEX,
3097
 
   N_("File that holds the names for last binary log files."),
3098
 
   (char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
 
3364
   "File that holds the names for last binary log files.",
 
3365
   (uchar**) &opt_binlog_index_name, (uchar**) &opt_binlog_index_name, 0, GET_STR,
3099
3366
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3100
 
  {"log-error", OPT_ERROR_LOG_FILE,
3101
 
   N_("Error log file."),
3102
 
   (char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
3103
 
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3104
 
  {"log-isam", OPT_ISAM_LOG,
3105
 
   N_("Log all MyISAM changes to file."),
3106
 
   (char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3107
 
   OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3367
  /*
 
3368
    This option starts with "log-bin" to emphasize that it is specific of
 
3369
    binary logging.
 
3370
  */
 
3371
  {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
 
3372
   "If equal to 0 (the default), then when --log-bin is used, creation of "
 
3373
   "a stored function (or trigger) is allowed only to users having the SUPER privilege "
 
3374
   "and only if this stored function (trigger) may not break binary logging."
 
3375
   "Note that if ALL connections to this server ALWAYS use row-based binary "
 
3376
   "logging, the security issues do not exist and the binary logging cannot "
 
3377
   "break, so you can safely set this to 1."
 
3378
   ,(uchar**) &trust_function_creators, (uchar**) &trust_function_creators, 0,
 
3379
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3380
  {"log-error", OPT_ERROR_LOG_FILE, "Error log file.",
 
3381
   (uchar**) &log_error_file_ptr, (uchar**) &log_error_file_ptr, 0, GET_STR,
 
3382
   OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3383
  {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
 
3384
   (uchar**) &myisam_log_filename, (uchar**) &myisam_log_filename, 0, GET_STR,
 
3385
   OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3386
  {"log-long-format", '0',
 
3387
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 
 
3388
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3389
#ifdef WITH_CSV_STORAGE_ENGINE
 
3390
  {"log-output", OPT_LOG_OUTPUT,
 
3391
   "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
 
3392
   "FILE or NONE.",
 
3393
   (uchar**) &log_output_str, (uchar**) &log_output_str, 0,
 
3394
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3395
#endif
 
3396
  {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
 
3397
   "Log queries that are executed without benefit of any index to the slow log if it is open.",
 
3398
   (uchar**) &opt_log_queries_not_using_indexes, (uchar**) &opt_log_queries_not_using_indexes,
 
3399
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3400
  {"log-short-format", OPT_SHORT_LOG_FORMAT,
 
3401
   "Don't log extra information to update and slow-query logs.",
 
3402
   (uchar**) &opt_short_log_format, (uchar**) &opt_short_log_format,
 
3403
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3108
3404
  {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
3109
 
   N_("Tells the slave to log the updates from the slave thread to the binary "
3110
 
      "log. You will need to turn it on if you plan to "
3111
 
      "daisy-chain the slaves."),
3112
 
   (char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3113
 
   0, GET_BOOL,
 
3405
   "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
 
3406
   (uchar**) &opt_log_slave_updates, (uchar**) &opt_log_slave_updates, 0, GET_BOOL,
3114
3407
   NO_ARG, 0, 0, 0, 0, 0, 0},
 
3408
  {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
 
3409
   "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open.",
 
3410
   (uchar**) &opt_log_slow_admin_statements,
 
3411
   (uchar**) &opt_log_slow_admin_statements,
 
3412
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3413
 {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
 
3414
  "Log slow statements executed by slave thread to the slow log if it is open.",
 
3415
  (uchar**) &opt_log_slow_slave_statements,
 
3416
  (uchar**) &opt_log_slow_slave_statements,
 
3417
  0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3418
  {"log-slow-queries", OPT_SLOW_QUERY_LOG,
 
3419
    "Log slow queries to a table or log file. Defaults logging to table mysql.slow_log or hostname-slow.log if --log-output=file is used. Must be enabled to activate other slow log options.",
 
3420
   (uchar**) &opt_slow_logname, (uchar**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
 
3421
   0, 0, 0, 0, 0, 0},
3115
3422
  {"log-tc", OPT_LOG_TC,
3116
 
   N_("Path to transaction coordinator log (used for transactions that affect "
3117
 
      "more than one storage engine, when binary log is disabled)"),
3118
 
   (char**) &opt_tc_log_file, (char**) &opt_tc_log_file, 0, GET_STR,
 
3423
   "Path to transaction coordinator log (used for transactions that affect "
 
3424
   "more than one storage engine, when binary log is disabled)",
 
3425
   (uchar**) &opt_tc_log_file, (uchar**) &opt_tc_log_file, 0, GET_STR,
3119
3426
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3120
3427
#ifdef HAVE_MMAP
3121
 
  {"log-tc-size", OPT_LOG_TC_SIZE,
3122
 
   N_("Size of transaction coordinator log."),
3123
 
   (char**) &opt_tc_log_size, (char**) &opt_tc_log_size, 0, GET_ULONG,
 
3428
  {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.",
 
3429
   (uchar**) &opt_tc_log_size, (uchar**) &opt_tc_log_size, 0, GET_ULONG,
3124
3430
   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
3125
3431
   TC_LOG_PAGE_SIZE, 0},
3126
3432
#endif
3127
 
  {"log-warnings", 'W',
3128
 
   N_("Log some not critical warnings to the log file."),
3129
 
   (char**) &global_system_variables.log_warnings,
3130
 
   (char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
 
3433
  {"log-warnings", 'W', "Log some not critical warnings to the log file.",
 
3434
   (uchar**) &global_system_variables.log_warnings,
 
3435
   (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
3131
3436
   0, 0, 0},
3132
3437
  {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
3133
 
   N_("INSERT/DELETE/UPDATE has lower priority than selects."),
3134
 
   (char**) &global_system_variables.low_priority_updates,
3135
 
   (char**) &max_system_variables.low_priority_updates,
 
3438
   "INSERT/DELETE/UPDATE has lower priority than selects.",
 
3439
   (uchar**) &global_system_variables.low_priority_updates,
 
3440
   (uchar**) &max_system_variables.low_priority_updates,
3136
3441
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3137
3442
  {"master-info-file", OPT_MASTER_INFO_FILE,
3138
 
   N_("The location and name of the file that remembers the master and "
3139
 
      "where the I/O replication thread is in the master's binlogs."),
3140
 
   (char**) &master_info_file, (char**) &master_info_file, 0, GET_STR,
 
3443
   "The location and name of the file that remembers the master and where the I/O replication \
 
3444
thread is in the master's binlogs.",
 
3445
   (uchar**) &master_info_file, (uchar**) &master_info_file, 0, GET_STR,
3141
3446
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3142
3447
  {"master-retry-count", OPT_MASTER_RETRY_COUNT,
3143
 
   N_("The number of tries the slave will make to connect to the master "
3144
 
      "before giving up."),
3145
 
   (char**) &master_retry_count, (char**) &master_retry_count, 0, GET_ULONG,
 
3448
   "The number of tries the slave will make to connect to the master before giving up.",
 
3449
   (uchar**) &master_retry_count, (uchar**) &master_retry_count, 0, GET_ULONG,
3146
3450
   REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
3147
3451
  {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS,
3148
 
   N_("Option used by mysql-test for debugging and testing of replication."),
3149
 
   (char**) &max_binlog_dump_events, (char**) &max_binlog_dump_events, 0,
 
3452
   "Option used by mysql-test for debugging and testing of replication.",
 
3453
   (uchar**) &max_binlog_dump_events, (uchar**) &max_binlog_dump_events, 0,
3150
3454
   GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3151
 
  {"memlock", OPT_MEMLOCK,
3152
 
   N_("Lock mysqld in memory."),
3153
 
   (char**) &locked_in_memory,
3154
 
   (char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3455
  {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (uchar**) &locked_in_memory,
 
3456
   (uchar**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3155
3457
  {"myisam-recover", OPT_MYISAM_RECOVER,
3156
 
   N_("Syntax: myisam-recover[=option[,option...]], where option can be "
3157
 
      "DEFAULT, BACKUP, FORCE or QUICK."),
3158
 
   (char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
 
3458
   "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.",
 
3459
   (uchar**) &myisam_recover_options_str, (uchar**) &myisam_recover_options_str, 0,
3159
3460
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3160
 
  {"new", 'n',
3161
 
   N_("Use very new possible 'unsafe' functions."),
3162
 
   (char**) &global_system_variables.new_mode,
3163
 
   (char**) &max_system_variables.new_mode,
 
3461
  {"new", 'n', "Use very new possible 'unsafe' functions.",
 
3462
   (uchar**) &global_system_variables.new_mode,
 
3463
   (uchar**) &max_system_variables.new_mode,
3164
3464
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3165
3465
  {"old-alter-table", OPT_OLD_ALTER_TABLE,
3166
 
   N_("Use old, non-optimized alter table."),
3167
 
   (char**) &global_system_variables.old_alter_table,
3168
 
   (char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
3169
 
   0, 0, 0, 0, 0, 0},
3170
 
  {"pid-file", OPT_PID_FILE,
3171
 
   N_("Pid file used by safe_mysqld."),
3172
 
   (char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
 
3466
   "Use old, non-optimized alter table.",
 
3467
   (uchar**) &global_system_variables.old_alter_table,
 
3468
   (uchar**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
 
3469
   0, 0, 0, 0, 0, 0},
 
3470
  {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).",
 
3471
   (uchar**) &global_system_variables.old_passwords,
 
3472
   (uchar**) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG,
 
3473
   0, 0, 0, 0, 0, 0},
 
3474
  {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS,
 
3475
   "Enable old-style user limits (before 5.0.3 user resources were counted per each user+host vs. per account)",
 
3476
   (uchar**) &opt_old_style_user_limits, (uchar**) &opt_old_style_user_limits,
 
3477
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3478
  {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.",
 
3479
   (uchar**) &pidfile_name_ptr, (uchar**) &pidfile_name_ptr, 0, GET_STR,
3173
3480
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3174
 
  {"port", 'P',
3175
 
   N_("Port number to use for connection or 0 for default to, in "
3176
 
      "order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
3177
 
      "built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
3178
 
   (char**) &mysqld_port,
3179
 
   (char**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3481
  {"port", 'P', "Port number to use for connection or 0 for default to, in "
 
3482
   "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 
3483
#if MYSQL_PORT_DEFAULT == 0
 
3484
   "/etc/services, "
 
3485
#endif
 
3486
   "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
 
3487
   (uchar**) &mysqld_port,
 
3488
   (uchar**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3180
3489
  {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
3181
 
   N_("Maximum time in seconds to wait for the port to become free. "
3182
 
      "(Default: no wait)"),
3183
 
   (char**) &mysqld_port_timeout,
3184
 
   (char**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3490
   "Maximum time in seconds to wait for the port to become free. "
 
3491
   "(Default: no wait)", (uchar**) &mysqld_port_timeout,
 
3492
   (uchar**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3185
3493
  {"relay-log", OPT_RELAY_LOG,
3186
 
   N_("The location and name to use for relay logs."),
3187
 
   (char**) &opt_relay_logname, (char**) &opt_relay_logname, 0,
 
3494
   "The location and name to use for relay logs.",
 
3495
   (uchar**) &opt_relay_logname, (uchar**) &opt_relay_logname, 0,
3188
3496
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3189
3497
  {"relay-log-index", OPT_RELAY_LOG_INDEX,
3190
 
   N_("The location and name to use for the file that keeps a list of the "
3191
 
      "last relay logs."),
3192
 
   (char**) &opt_relaylog_index_name, (char**) &opt_relaylog_index_name, 0,
 
3498
   "The location and name to use for the file that keeps a list of the last \
 
3499
relay logs.",
 
3500
   (uchar**) &opt_relaylog_index_name, (uchar**) &opt_relaylog_index_name, 0,
3193
3501
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3194
3502
  {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE,
3195
 
   N_("The location and name of the file that remembers where the SQL "
3196
 
      "replication thread is in the relay logs."),
3197
 
   (char**) &relay_log_info_file, (char**) &relay_log_info_file, 0, GET_STR,
 
3503
   "The location and name of the file that remembers where the SQL replication \
 
3504
thread is in the relay logs.",
 
3505
   (uchar**) &relay_log_info_file, (uchar**) &relay_log_info_file, 0, GET_STR,
3198
3506
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3199
3507
  {"replicate-do-db", OPT_REPLICATE_DO_DB,
3200
 
   N_("Tells the slave thread to restrict replication to the specified "
3201
 
      "database. To specify more than one database, use the directive "
3202
 
      "multiple times, once for each database. Note that this will only work "
3203
 
      "if you do not use cross-database queries such as UPDATE "
3204
 
      "some_db.some_table SET foo='bar' while having selected a different or "
3205
 
      "no database. If you need cross database updates to work, use "
3206
 
      "replicate-wild-do-table=db_name.%."),
 
3508
   "Tells the slave thread to restrict replication to the specified database. To specify more than one database, use the directive multiple times, once for each database. Note that this will only work if you do not use cross-database queries such as UPDATE some_db.some_table SET foo='bar' while having selected a different or no database. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-do-table=db_name.%.",
3207
3509
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3208
3510
  {"replicate-do-table", OPT_REPLICATE_DO_TABLE,
3209
 
   N_("Tells the slave thread to restrict replication to the specified table. "
3210
 
      "To specify more than one table, use the directive multiple times, once "
3211
 
      "for each table. This will work for cross-database updates, in contrast "
3212
 
      "to replicate-do-db."),
 
3511
   "Tells the slave thread to restrict replication to the specified table. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates, in contrast to replicate-do-db.",
3213
3512
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3214
3513
  {"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB,
3215
 
   N_("Tells the slave thread to not replicate to the specified database. To "
3216
 
      "specify more than one database to ignore, use the directive multiple "
3217
 
      "times, once for each database. This option will not work if you use "
3218
 
      "cross database updates. If you need cross database updates to work, "
3219
 
      "use replicate-wild-ignore-table=db_name.%. "),
 
3514
   "Tells the slave thread to not replicate to the specified database. To specify more than one database to ignore, use the directive multiple times, once for each database. This option will not work if you use cross database updates. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-ignore-table=db_name.%. ",
3220
3515
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3221
3516
  {"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
3222
 
   N_("Tells the slave thread to not replicate to the specified table. To "
3223
 
      "specify more than one table to ignore, use the directive multiple "
3224
 
      "times, once for each table. This will work for cross-datbase updates, "
3225
 
      "in contrast to replicate-ignore-db."),
 
3517
   "Tells the slave thread to not replicate to the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table. This will work for cross-datbase updates, in contrast to replicate-ignore-db.",
3226
3518
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3227
3519
  {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB,
3228
 
   N_("Updates to a database with a different name than the original. "
3229
 
      "Example: replicate-rewrite-db=master_db_name->slave_db_name."),
 
3520
   "Updates to a database with a different name than the original. Example: replicate-rewrite-db=master_db_name->slave_db_name.",
3230
3521
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3231
3522
  {"replicate-same-server-id", OPT_REPLICATE_SAME_SERVER_ID,
3232
 
   N_("In replication, if set to 1, do not skip events having our server id. "
3233
 
      "Default value is 0 (to break infinite loops in circular replication). "
3234
 
      "Can't be set to 1 if --log-slave-updates is used."),
3235
 
   (char**) &replicate_same_server_id,
3236
 
   (char**) &replicate_same_server_id,
 
3523
   "In replication, if set to 1, do not skip events having our server id. \
 
3524
Default value is 0 (to break infinite loops in circular replication). \
 
3525
Can't be set to 1 if --log-slave-updates is used.",
 
3526
   (uchar**) &replicate_same_server_id,
 
3527
   (uchar**) &replicate_same_server_id,
3237
3528
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3238
3529
  {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE,
3239
 
   N_("Tells the slave thread to restrict replication to the tables that "
3240
 
      "match the specified wildcard pattern. To specify more than one table, "
3241
 
      "use the directive multiple times, once for each table. This will work "
3242
 
      "for cross-database updates. Example: replicate-wild-do-table=foo%.bar% "
3243
 
      "will replicate only updates to tables in all databases that start with "
3244
 
      "foo and whose table names start with bar."),
 
3530
   "Tells the slave thread to restrict replication to the tables that match the specified wildcard pattern. To specify more than one table, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-do-table=foo%.bar% will replicate only updates to tables in all databases that start with foo and whose table names start with bar.",
3245
3531
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3246
3532
  {"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE,
3247
 
   N_("Tells the slave thread to not replicate to the tables that match the "
3248
 
      "given wildcard pattern. To specify more than one table to ignore, use "
3249
 
      "the directive multiple times, once for each table. This will work for "
3250
 
      "cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% "
3251
 
      "will not do updates to tables in databases that start with foo and "
3252
 
      "whose table names start with bar."),
 
3533
   "Tells the slave thread to not replicate to the tables that match the given wildcard pattern. To specify more than one table to ignore, use the directive multiple times, once for each table. This will work for cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% will not do updates to tables in databases that start with foo and whose table names start with bar.",
3253
3534
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3254
3535
  // In replication, we may need to tell the other servers how to connect
3255
3536
  {"report-host", OPT_REPORT_HOST,
3256
 
   N_("Hostname or IP of the slave to be reported to to the master during "
3257
 
      "slave registration. Will appear in the output of SHOW SLAVE HOSTS. "
3258
 
      "Leave unset if you do not want the slave to register itself with the "
3259
 
      "master. Note that it is not sufficient for the master to simply read "
3260
 
      "the IP of the slave off the socket once the slave connects. Due to NAT "
3261
 
      "and other routing issues, that IP may not be valid for connecting to "
3262
 
      "the slave from the master or other hosts."),
3263
 
   (char**) &report_host, (char**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
 
3537
   "Hostname or IP of the slave to be reported to to the master during slave registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not want the slave to register itself with the master. Note that it is not sufficient for the master to simply read the IP of the slave off the socket once the slave connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the slave from the master or other hosts.",
 
3538
   (uchar**) &report_host, (uchar**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
3264
3539
   0, 0, 0, 0},
3265
3540
  {"report-password", OPT_REPORT_PASSWORD, "Undocumented.",
3266
 
   (char**) &report_password, (char**) &report_password, 0, GET_STR,
 
3541
   (uchar**) &report_password, (uchar**) &report_password, 0, GET_STR,
3267
3542
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3268
3543
  {"report-port", OPT_REPORT_PORT,
3269
 
   N_("Port for connecting to slave reported to the master during slave "
3270
 
      "registration. Set it only if the slave is listening on a non-default "
3271
 
      "port or if you have a special tunnel from the master or other clients "
3272
 
      "to the slave. If not sure, leave this option unset."),
3273
 
   (char**) &report_port, (char**) &report_port, 0, GET_UINT, REQUIRED_ARG,
3274
 
   DRIZZLE_PORT, 0, 0, 0, 0, 0},
3275
 
  {"safe-mode", OPT_SAFE,
3276
 
   N_("Skip some optimize stages (for testing)."),
 
3544
   "Port for connecting to slave reported to the master during slave registration. Set it only if the slave is listening on a non-default port or if you have a special tunnel from the master or other clients to the slave. If not sure, leave this option unset.",
 
3545
   (uchar**) &report_port, (uchar**) &report_port, 0, GET_UINT, REQUIRED_ARG,
 
3546
   MYSQL_PORT, 0, 0, 0, 0, 0},
 
3547
  {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
3277
3548
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3278
3549
  {"secure-file-priv", OPT_SECURE_FILE_PRIV,
3279
 
   N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
3280
 
      "within specified directory"),
3281
 
   (char**) &opt_secure_file_priv, (char**) &opt_secure_file_priv, 0,
 
3550
   "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory",
 
3551
   (uchar**) &opt_secure_file_priv, (uchar**) &opt_secure_file_priv, 0,
3282
3552
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3283
3553
  {"server-id", OPT_SERVER_ID,
3284
 
   N_("Uniquely identifies the server instance in the community of "
3285
 
      "replication partners."),
3286
 
   (char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
 
3554
   "Uniquely identifies the server instance in the community of replication partners.",
 
3555
   (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
3287
3556
   0, 0, 0},
3288
 
  {"skip-new", OPT_SKIP_NEW,
3289
 
   N_("Don't use new, possible wrong routines."),
 
3557
  {"set-variable", 'O',
 
3558
   "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.",
 
3559
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3560
  {"skip-new", OPT_SKIP_NEW, "Don't use new, possible wrong routines.",
3290
3561
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3291
3562
  {"skip-slave-start", OPT_SKIP_SLAVE_START,
3292
 
   N_("If set, slave is not autostarted."),
3293
 
   (char**) &opt_skip_slave_start,
3294
 
   (char**) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
3563
   "If set, slave is not autostarted.", (uchar**) &opt_skip_slave_start,
 
3564
   (uchar**) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3295
3565
  {"skip-stack-trace", OPT_SKIP_STACK_TRACE,
3296
 
   N_("Don't print a stack trace on failure."),
3297
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
 
3566
   "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
3298
3567
   0, 0, 0, 0},
 
3568
  {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option.  Use --skip-symbolic-links instead.",
 
3569
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3299
3570
  {"skip-thread-priority", OPT_SKIP_PRIOR,
3300
 
   N_("Don't give threads different priorities."),
3301
 
   0, 0, 0, GET_NO_ARG, NO_ARG,
 
3571
   "Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG,
3302
3572
   DEFAULT_SKIP_THREAD_PRIORITY, 0, 0, 0, 0, 0},
3303
3573
  {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR,
3304
 
   N_("The location where the slave should put its temporary files when "
3305
 
      "replicating a LOAD DATA INFILE command."),
3306
 
   (char**) &slave_load_tmpdir, (char**) &slave_load_tmpdir, 0, GET_STR_ALLOC,
 
3574
   "The location where the slave should put its temporary files when \
 
3575
replicating a LOAD DATA INFILE command.",
 
3576
   (uchar**) &slave_load_tmpdir, (uchar**) &slave_load_tmpdir, 0, GET_STR_ALLOC,
3307
3577
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3308
3578
  {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS,
3309
 
   N_("Tells the slave thread to continue replication when a query event "
3310
 
      "returns an error from the provided list."),
 
3579
   "Tells the slave thread to continue replication when a query event returns an error from the provided list.",
3311
3580
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3312
3581
  {"slave-exec-mode", OPT_SLAVE_EXEC_MODE,
3313
 
   N_("Modes for how replication events should be executed.  Legal values are "
3314
 
      "STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, replication will "
3315
 
      "not stop for operations that are idempotent. In STRICT mode, "
3316
 
      "replication will stop on any unexpected difference between the master "
3317
 
      "and the slave."),
3318
 
   (char**) &slave_exec_mode_str, (char**) &slave_exec_mode_str,
3319
 
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3582
   "Modes for how replication events should be executed.  Legal values are STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, replication will not stop for operations that are idempotent. In STRICT mode, replication will stop on any unexpected difference between the master and the slave.",
 
3583
   (uchar**) &slave_exec_mode_str, (uchar**) &slave_exec_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3584
  {"slow-query-log", OPT_SLOW_LOG,
 
3585
   "Enable|disable slow query log", (uchar**) &opt_slow_log,
 
3586
   (uchar**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
3587
  {"sporadic-binlog-dump-fail", OPT_SPORADIC_BINLOG_DUMP_FAIL,
 
3588
   "Option used by mysql-test for debugging and testing of replication.",
 
3589
   (uchar**) &opt_sporadic_binlog_dump_fail,
 
3590
   (uchar**) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
 
3591
   0},
3320
3592
  {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
3321
 
   N_("(INGORED)"),
 
3593
   "The update log is deprecated since version 5.0, is replaced by the binary \
 
3594
log and this option does nothing anymore.",
3322
3595
   0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
3323
 
  {"symbolic-links", 's',
3324
 
   N_("Enable symbolic link support."),
3325
 
   (char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
 
3596
  {"symbolic-links", 's', "Enable symbolic link support.",
 
3597
   (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
3326
3598
   /*
3327
3599
     The system call realpath() produces warnings under valgrind and
3328
3600
     purify. These are not suppressed: instead we disable symlinks
3330
3602
   */
3331
3603
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
3332
3604
  {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
3333
 
   N_("Non-default option to alias SYSDATE() to NOW() to make it "
3334
 
      "safe-replicable."),
3335
 
   (char**) &global_system_variables.sysdate_is_now,
 
3605
   "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
 
3606
   (uchar**) &global_system_variables.sysdate_is_now,
3336
3607
   0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3337
3608
  {"tc-heuristic-recover", OPT_TC_HEURISTIC_RECOVER,
3338
 
   N_("Decision to use in heuristic recover process. Possible values are "
3339
 
      "COMMIT or ROLLBACK."),
3340
 
   (char**) &opt_tc_heuristic_recover, (char**) &opt_tc_heuristic_recover,
 
3609
   "Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.",
 
3610
   (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover,
3341
3611
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3342
3612
  {"temp-pool", OPT_TEMP_POOL,
3343
 
   N_("Using this option will cause most temporary files created to use a "
3344
 
      "small set of names, rather than a unique name for each new file."),
3345
 
   (char**) &use_temp_pool, (char**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
 
3613
   "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.",
 
3614
   (uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
3346
3615
   0, 0, 0, 0, 0},
3347
3616
  {"timed_mutexes", OPT_TIMED_MUTEXES,
3348
 
   N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
3349
 
      "supported)"),
3350
 
   (char**) &timed_mutexes, (char**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
 
3617
   "Specify whether to time mutexes (only InnoDB mutexes are currently supported)",
 
3618
   (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 
3351
3619
    0, 0, 0, 0, 0},
3352
3620
  {"tmpdir", 't',
3353
 
   N_("Path for temporary files. Several paths may be specified, separated "
3354
 
      "by a colon (:)"
3355
 
      ", in this case they are used in a round-robin fashion."),
3356
 
   (char**) &opt_mysql_tmpdir,
3357
 
   (char**) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
3621
   "Path for temporary files. Several paths may be specified, separated by a "
 
3622
   "colon (:)"
 
3623
   ", in this case they are used in a round-robin fashion.",
 
3624
   (uchar**) &opt_mysql_tmpdir,
 
3625
   (uchar**) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3358
3626
  {"transaction-isolation", OPT_TX_ISOLATION,
3359
 
   N_("Default transaction isolation level."),
3360
 
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
 
3627
   "Default transaction isolation level.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0,
3361
3628
   0, 0, 0, 0, 0},
3362
 
  {"user", 'u',
3363
 
   N_("Run mysqld daemon as user."),
3364
 
   0, 0, 0, GET_STR, REQUIRED_ARG,
 
3629
  {"use-symbolic-links", 's', "Enable symbolic link support. Deprecated option; use --symbolic-links instead.",
 
3630
   (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
 
3631
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
 
3632
  {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG,
3365
3633
   0, 0, 0, 0, 0, 0},
3366
 
  {"version", 'V',
3367
 
   N_("Output version information and exit."),
3368
 
   0, 0, 0, GET_NO_ARG,
 
3634
  {"verbose", 'v', "Used with --help option for detailed help",
 
3635
   (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
3636
   0, 0},
 
3637
  {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
3369
3638
   NO_ARG, 0, 0, 0, 0, 0, 0},
3370
 
  {"back_log", OPT_BACK_LOG,
3371
 
   N_("The number of outstanding connection requests MySQL can have. This "
3372
 
      "comes into play when the main MySQL thread gets very many connection "
3373
 
      "requests in a very short time."),
3374
 
    (char**) &back_log, (char**) &back_log, 0, GET_ULONG,
 
3639
  {"warnings", 'W', "Deprecated; use --log-warnings instead.",
 
3640
   (uchar**) &global_system_variables.log_warnings,
 
3641
   (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
 
3642
   1, 0, ULONG_MAX, 0, 0, 0},
 
3643
  { "back_log", OPT_BACK_LOG,
 
3644
    "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
 
3645
    (uchar**) &back_log, (uchar**) &back_log, 0, GET_ULONG,
3375
3646
    REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
3376
 
  { "binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
3377
 
    N_("The size of the cache to hold the SQL statements for the binary log "
3378
 
       "during a transaction. If you often use big, multi-statement "
3379
 
       "transactions you can increase this to get more performance."),
3380
 
    (char**) &binlog_cache_size, (char**) &binlog_cache_size, 0, GET_ULONG,
3381
 
    REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
3382
 
  { "bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
3383
 
    N_("Size of tree cache used in bulk insert optimisation. Note that this is "
3384
 
       "a limit per thread!"),
3385
 
    (char**) &global_system_variables.bulk_insert_buff_size,
3386
 
    (char**) &max_system_variables.bulk_insert_buff_size,
3387
 
    0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
3388
 
  { "connect_timeout", OPT_CONNECT_TIMEOUT,
3389
 
    N_("The number of seconds the mysqld server is waiting for a connect "
3390
 
       "packet before responding with 'Bad handshake'."),
3391
 
    (char**) &connect_timeout, (char**) &connect_timeout,
3392
 
    0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
 
3647
  {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
 
3648
   "The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.",
 
3649
   (uchar**) &binlog_cache_size, (uchar**) &binlog_cache_size, 0, GET_ULONG,
 
3650
   REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
 
3651
  {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
 
3652
   "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
 
3653
   (uchar**) &global_system_variables.bulk_insert_buff_size,
 
3654
   (uchar**) &max_system_variables.bulk_insert_buff_size,
 
3655
   0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
 
3656
  {"connect_timeout", OPT_CONNECT_TIMEOUT,
 
3657
   "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.",
 
3658
    (uchar**) &connect_timeout, (uchar**) &connect_timeout,
 
3659
   0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
3393
3660
  { "date_format", OPT_DATE_FORMAT,
3394
 
    N_("The DATE format (For future)."),
3395
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
3396
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
 
3661
    "The DATE format (For future).",
 
3662
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
 
3663
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
3397
3664
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3398
3665
  { "datetime_format", OPT_DATETIME_FORMAT,
3399
 
    N_("The DATETIME/TIMESTAMP format (for future)."),
3400
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
3401
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
 
3666
    "The DATETIME/TIMESTAMP format (for future).",
 
3667
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
 
3668
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
3402
3669
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3403
3670
  { "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
3404
 
    N_("The default week format used by WEEK() functions."),
3405
 
    (char**) &global_system_variables.default_week_format,
3406
 
    (char**) &max_system_variables.default_week_format,
 
3671
    "The default week format used by WEEK() functions.",
 
3672
    (uchar**) &global_system_variables.default_week_format,
 
3673
    (uchar**) &max_system_variables.default_week_format,
3407
3674
    0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0},
3408
 
  { "div_precision_increment", OPT_DIV_PRECINCREMENT,
3409
 
   N_("Precision of the result of '/' operator will be increased on that "
3410
 
      "value."),
3411
 
   (char**) &global_system_variables.div_precincrement,
3412
 
   (char**) &max_system_variables.div_precincrement, 0, GET_ULONG,
 
3675
  {"div_precision_increment", OPT_DIV_PRECINCREMENT,
 
3676
   "Precision of the result of '/' operator will be increased on that value.",
 
3677
   (uchar**) &global_system_variables.div_precincrement,
 
3678
   (uchar**) &max_system_variables.div_precincrement, 0, GET_ULONG,
3413
3679
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
3414
 
  { "expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
3415
 
    N_("If non-zero, binary logs will be purged after expire_logs_days "
3416
 
       "days; possible purges happen at startup and at binary log rotation."),
3417
 
    (char**) &expire_logs_days,
3418
 
    (char**) &expire_logs_days, 0, GET_ULONG,
3419
 
    REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
 
3680
  {"expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
 
3681
   "If non-zero, binary logs will be purged after expire_logs_days "
 
3682
   "days; possible purges happen at startup and at binary log rotation.",
 
3683
   (uchar**) &expire_logs_days,
 
3684
   (uchar**) &expire_logs_days, 0, GET_ULONG,
 
3685
   REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
 
3686
  { "flush_time", OPT_FLUSH_TIME,
 
3687
    "A dedicated thread is created to flush all tables at the given interval.",
 
3688
    (uchar**) &flush_time, (uchar**) &flush_time, 0, GET_ULONG, REQUIRED_ARG,
 
3689
    FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1, 0},
3420
3690
  { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
3421
 
    N_("The maximum length of the result of function  group_concat."),
3422
 
    (char**) &global_system_variables.group_concat_max_len,
3423
 
    (char**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
 
3691
    "The maximum length of the result of function  group_concat.",
 
3692
    (uchar**) &global_system_variables.group_concat_max_len,
 
3693
    (uchar**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
3424
3694
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
3425
 
  { "interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
3426
 
    N_("The number of seconds the server waits for activity on an interactive "
3427
 
       "connection before closing it."),
3428
 
   (char**) &global_system_variables.net_interactive_timeout,
3429
 
   (char**) &max_system_variables.net_interactive_timeout, 0,
 
3695
  {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
 
3696
   "The number of seconds the server waits for activity on an interactive connection before closing it.",
 
3697
   (uchar**) &global_system_variables.net_interactive_timeout,
 
3698
   (uchar**) &max_system_variables.net_interactive_timeout, 0,
3430
3699
   GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3431
 
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
3432
 
    N_("The size of the buffer that is used for full joins."),
3433
 
   (char**) &global_system_variables.join_buff_size,
3434
 
   (char**) &max_system_variables.join_buff_size, 0, GET_ULONG,
 
3700
  {"join_buffer_size", OPT_JOIN_BUFF_SIZE,
 
3701
   "The size of the buffer that is used for full joins.",
 
3702
   (uchar**) &global_system_variables.join_buff_size,
 
3703
   (uchar**) &max_system_variables.join_buff_size, 0, GET_ULONG,
3435
3704
   REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
3436
3705
   MALLOC_OVERHEAD, IO_SIZE, 0},
3437
3706
  {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
3438
 
   N_("Don't overwrite stale .MYD and .MYI even if no directory is specified."),
3439
 
   (char**) &global_system_variables.keep_files_on_create,
3440
 
   (char**) &max_system_variables.keep_files_on_create,
 
3707
   "Don't overwrite stale .MYD and .MYI even if no directory is specified.",
 
3708
   (uchar**) &global_system_variables.keep_files_on_create,
 
3709
   (uchar**) &max_system_variables.keep_files_on_create,
3441
3710
   0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3442
3711
  {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
3443
 
   N_("The size of the buffer used for index blocks for MyISAM tables. "
3444
 
      "Increase this to get better index handling (for all reads and multiple "
3445
 
      "writes) to as much as you can afford;"),
3446
 
   (char**) &dflt_key_cache_var.param_buff_size,
3447
 
   (char**) 0,
 
3712
   "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.",
 
3713
   (uchar**) &dflt_key_cache_var.param_buff_size,
 
3714
   (uchar**) 0,
3448
3715
   0, (GET_ULL | GET_ASK_ADDR),
3449
3716
   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
3450
3717
   IO_SIZE, 0},
3451
3718
  {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
3452
 
   N_("This characterizes the number of hits a hot block has to be untouched "
3453
 
      "until it is considered aged enough to be downgraded to a warm block. "
3454
 
      "This specifies the percentage ratio of that number of hits to the "
3455
 
      "total number of blocks in key cache"),
3456
 
   (char**) &dflt_key_cache_var.param_age_threshold,
3457
 
   (char**) 0,
3458
 
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
 
3719
   "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
 
3720
   (uchar**) &dflt_key_cache_var.param_age_threshold,
 
3721
   (uchar**) 0,
 
3722
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 
3459
3723
   300, 100, ULONG_MAX, 0, 100, 0},
3460
3724
  {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
3461
 
   N_("The default size of key cache blocks"),
3462
 
   (char**) &dflt_key_cache_var.param_block_size,
3463
 
   (char**) 0,
 
3725
   "The default size of key cache blocks",
 
3726
   (uchar**) &dflt_key_cache_var.param_block_size,
 
3727
   (uchar**) 0,
3464
3728
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
3465
3729
   KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
3466
3730
  {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
3467
 
   N_("The minimum percentage of warm blocks in key cache"),
3468
 
   (char**) &dflt_key_cache_var.param_division_limit,
3469
 
   (char**) 0,
 
3731
   "The minimum percentage of warm blocks in key cache",
 
3732
   (uchar**) &dflt_key_cache_var.param_division_limit,
 
3733
   (uchar**) 0,
3470
3734
   0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
3471
3735
   1, 100, 0, 1, 0},
 
3736
  {"long_query_time", OPT_LONG_QUERY_TIME,
 
3737
   "Log all queries that have taken more than long_query_time seconds to execute to file. "
 
3738
   "The argument will be treated as a decimal value with microsecond precission.",
 
3739
   (uchar**) &long_query_time, (uchar**) &long_query_time, 0, GET_DOUBLE,
 
3740
   REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
 
3741
  {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
 
3742
   "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive.  Should be set to 2 if you are using a case insensitive file system",
 
3743
   (uchar**) &lower_case_table_names,
 
3744
   (uchar**) &lower_case_table_names, 0, GET_UINT, OPT_ARG,
 
3745
#ifdef FN_NO_CASE_SENCE
 
3746
    1
 
3747
#else
 
3748
    0
 
3749
#endif
 
3750
   , 0, 2, 0, 1, 0},
3472
3751
  {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
3473
 
   N_("Max packetlength to send/receive from to server."),
3474
 
   (char**) &global_system_variables.max_allowed_packet,
3475
 
   (char**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
 
3752
   "Max packetlength to send/receive from to server.",
 
3753
   (uchar**) &global_system_variables.max_allowed_packet,
 
3754
   (uchar**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
3476
3755
   REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
3477
3756
  {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
3478
 
   N_("Can be used to restrict the total size used to cache a "
3479
 
      "multi-transaction query."),
3480
 
   (char**) &max_binlog_cache_size, (char**) &max_binlog_cache_size, 0,
 
3757
   "Can be used to restrict the total size used to cache a multi-transaction query.",
 
3758
   (uchar**) &max_binlog_cache_size, (uchar**) &max_binlog_cache_size, 0,
3481
3759
   GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
3482
3760
  {"max_binlog_size", OPT_MAX_BINLOG_SIZE,
3483
 
   N_("Binary log will be rotated automatically when the size exceeds this "
3484
 
      "value. Will also apply to relay logs if max_relay_log_size is 0. "
3485
 
      "The minimum value for this variable is 4096."),
3486
 
   (char**) &max_binlog_size, (char**) &max_binlog_size, 0, GET_ULONG,
 
3761
   "Binary log will be rotated automatically when the size exceeds this \
 
3762
value. Will also apply to relay logs if max_relay_log_size is 0. \
 
3763
The minimum value for this variable is 4096.",
 
3764
   (uchar**) &max_binlog_size, (uchar**) &max_binlog_size, 0, GET_ULONG,
3487
3765
   REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0},
3488
3766
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
3489
 
   N_("If there is more than this number of interrupted connections from a "
3490
 
      "host this host will be blocked from further connections."),
3491
 
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_ULONG,
3492
 
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
 
3767
   "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.",
 
3768
   (uchar**) &max_connect_errors, (uchar**) &max_connect_errors, 0, GET_ULONG,
 
3769
    REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
3493
3770
  // Default max_connections of 151 is larger than Apache's default max
3494
3771
  // children, to avoid "too many connections" error in a common setup
3495
3772
  {"max_connections", OPT_MAX_CONNECTIONS,
3496
 
   N_("The number of simultaneous clients allowed."),
3497
 
   (char**) &max_connections,
3498
 
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
 
3773
   "The number of simultaneous clients allowed.", (uchar**) &max_connections,
 
3774
   (uchar**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
3499
3775
   0},
3500
3776
  {"max_error_count", OPT_MAX_ERROR_COUNT,
3501
 
   N_("Max number of errors/warnings to store for a statement."),
3502
 
   (char**) &global_system_variables.max_error_count,
3503
 
   (char**) &max_system_variables.max_error_count,
 
3777
   "Max number of errors/warnings to store for a statement.",
 
3778
   (uchar**) &global_system_variables.max_error_count,
 
3779
   (uchar**) &max_system_variables.max_error_count,
3504
3780
   0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
3505
3781
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
3506
 
   N_("Don't allow creation of heap tables bigger than this."),
3507
 
   (char**) &global_system_variables.max_heap_table_size,
3508
 
   (char**) &max_system_variables.max_heap_table_size, 0, GET_ULL,
 
3782
   "Don't allow creation of heap tables bigger than this.",
 
3783
   (uchar**) &global_system_variables.max_heap_table_size,
 
3784
   (uchar**) &max_system_variables.max_heap_table_size, 0, GET_ULL,
3509
3785
   REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE,
3510
3786
   MALLOC_OVERHEAD, 1024, 0},
3511
3787
  {"max_join_size", OPT_MAX_JOIN_SIZE,
3512
 
   N_("Joins that are probably going to read more than max_join_size records "
3513
 
      "return an error."),
3514
 
   (char**) &global_system_variables.max_join_size,
3515
 
   (char**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
3516
 
   INT32_MAX, 1, INT32_MAX, 0, 1, 0},
3517
 
  {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
3518
 
   N_("Max number of bytes in sorted records."),
3519
 
   (char**) &global_system_variables.max_length_for_sort_data,
3520
 
   (char**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
3521
 
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
 
3788
   "Joins that are probably going to read more than max_join_size records return an error.",
 
3789
   (uchar**) &global_system_variables.max_join_size,
 
3790
   (uchar**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
 
3791
   ~0L, 1, ~0L, 0, 1, 0},
 
3792
   {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
 
3793
    "Max number of bytes in sorted records.",
 
3794
    (uchar**) &global_system_variables.max_length_for_sort_data,
 
3795
    (uchar**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
 
3796
    REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
3522
3797
  {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE,
3523
 
   N_("If non-zero: relay log will be rotated automatically when the size "
3524
 
      "exceeds this value; if zero (the default): when the size exceeds "
3525
 
      "max_binlog_size. 0 excepted, the minimum value for this variable "
3526
 
      "is 4096."),
3527
 
   (char**) &max_relay_log_size, (char**) &max_relay_log_size, 0, GET_ULONG,
 
3798
   "If non-zero: relay log will be rotated automatically when the size exceeds this value; if zero (the default): when the size exceeds max_binlog_size. 0 excepted, the minimum value for this variable is 4096.",
 
3799
   (uchar**) &max_relay_log_size, (uchar**) &max_relay_log_size, 0, GET_ULONG,
3528
3800
   REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0},
3529
3801
  { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
3530
 
    N_("Limit assumed max number of seeks when looking up rows based on a key"),
3531
 
    (char**) &global_system_variables.max_seeks_for_key,
3532
 
    (char**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
 
3802
    "Limit assumed max number of seeks when looking up rows based on a key",
 
3803
    (uchar**) &global_system_variables.max_seeks_for_key,
 
3804
    (uchar**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
3533
3805
    REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
3534
3806
  {"max_sort_length", OPT_MAX_SORT_LENGTH,
3535
 
   N_("The number of bytes to use when sorting BLOB or TEXT values "
3536
 
      "(only the first max_sort_length bytes of each value are used; the "
3537
 
      "rest are ignored)."),
3538
 
   (char**) &global_system_variables.max_sort_length,
3539
 
   (char**) &max_system_variables.max_sort_length, 0, GET_ULONG,
 
3807
   "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
 
3808
   (uchar**) &global_system_variables.max_sort_length,
 
3809
   (uchar**) &max_system_variables.max_sort_length, 0, GET_ULONG,
3540
3810
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
3541
3811
  {"max_tmp_tables", OPT_MAX_TMP_TABLES,
3542
 
   N_("Maximum number of temporary tables a client can keep open at a time."),
3543
 
   (char**) &global_system_variables.max_tmp_tables,
3544
 
   (char**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
 
3812
   "Maximum number of temporary tables a client can keep open at a time.",
 
3813
   (uchar**) &global_system_variables.max_tmp_tables,
 
3814
   (uchar**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
3545
3815
   REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
3546
3816
  {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
3547
 
   N_("After this many write locks, allow some read locks to run in between."),
3548
 
   (char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULONG,
 
3817
   "After this many write locks, allow some read locks to run in between.",
 
3818
   (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG,
3549
3819
   REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
3550
3820
  {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
3551
 
   N_("Don't log queries which examine less than min_examined_row_limit "
3552
 
      "rows to file."),
3553
 
   (char**) &global_system_variables.min_examined_row_limit,
3554
 
   (char**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
3555
 
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
 
3821
   "Don't log queries which examine less than min_examined_row_limit rows to file.",
 
3822
   (uchar**) &global_system_variables.min_examined_row_limit,
 
3823
   (uchar**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
 
3824
  REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
3556
3825
  {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
3557
 
   N_("Block size to be used for MyISAM index pages."),
3558
 
   (char**) &opt_myisam_block_size,
3559
 
   (char**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
 
3826
   "Block size to be used for MyISAM index pages.",
 
3827
   (uchar**) &opt_myisam_block_size,
 
3828
   (uchar**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
3560
3829
   MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
3561
3830
   0, MI_MIN_KEY_BLOCK_LENGTH, 0},
3562
3831
  {"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE,
3563
 
   N_("Default pointer size to be used for MyISAM tables."),
3564
 
   (char**) &myisam_data_pointer_size,
3565
 
   (char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
 
3832
   "Default pointer size to be used for MyISAM tables.",
 
3833
   (uchar**) &myisam_data_pointer_size,
 
3834
   (uchar**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
3566
3835
   6, 2, 7, 0, 1, 0},
 
3836
  {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
 
3837
   "Deprecated option",
 
3838
   (uchar**) &global_system_variables.myisam_max_extra_sort_file_size,
 
3839
   (uchar**) &max_system_variables.myisam_max_extra_sort_file_size,
 
3840
   0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH,
 
3841
   0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0},
3567
3842
  {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
3568
 
   N_("Don't use the fast sort index method to created index if the "
3569
 
      "temporary file would get bigger than this."),
3570
 
   (char**) &global_system_variables.myisam_max_sort_file_size,
3571
 
   (char**) &max_system_variables.myisam_max_sort_file_size, 0,
3572
 
   GET_ULL, REQUIRED_ARG, (int64_t) LONG_MAX, 0, (uint64_t) MAX_FILE_SIZE,
 
3843
   "Don't use the fast sort index method to created index if the temporary file would get bigger than this.",
 
3844
   (uchar**) &global_system_variables.myisam_max_sort_file_size,
 
3845
   (uchar**) &max_system_variables.myisam_max_sort_file_size, 0,
 
3846
   GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE,
3573
3847
   0, 1024*1024, 0},
3574
3848
  {"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS,
3575
 
   N_("Number of threads to use when repairing MyISAM tables. The value of "
3576
 
      "1 disables parallel repair."),
3577
 
   (char**) &global_system_variables.myisam_repair_threads,
3578
 
   (char**) &max_system_variables.myisam_repair_threads, 0,
 
3849
   "Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.",
 
3850
   (uchar**) &global_system_variables.myisam_repair_threads,
 
3851
   (uchar**) &max_system_variables.myisam_repair_threads, 0,
3579
3852
   GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
3580
3853
  {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
3581
 
   N_("The buffer that is allocated when sorting the index when doing a "
3582
 
      "REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
3583
 
   (char**) &global_system_variables.myisam_sort_buff_size,
3584
 
   (char**) &max_system_variables.myisam_sort_buff_size, 0,
3585
 
   GET_ULONG, REQUIRED_ARG, 8192*1024, 4, INT32_MAX, 0, 1, 0},
 
3854
   "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
 
3855
   (uchar**) &global_system_variables.myisam_sort_buff_size,
 
3856
   (uchar**) &max_system_variables.myisam_sort_buff_size, 0,
 
3857
   GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
3586
3858
  {"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
3587
 
   N_("Specifies how MyISAM index statistics collection code should threat "
3588
 
      "NULLs. Possible values of name are 'nulls_unequal' "
3589
 
      "(default behavior), "
3590
 
      "'nulls_equal' (emulate MySQL 4.0 behavior), and 'nulls_ignored'."),
3591
 
   (char**) &myisam_stats_method_str, (char**) &myisam_stats_method_str, 0,
 
3859
   "Specifies how MyISAM index statistics collection code should threat NULLs. "
 
3860
   "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
 
3861
   "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".",
 
3862
   (uchar**) &myisam_stats_method_str, (uchar**) &myisam_stats_method_str, 0,
3592
3863
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3593
3864
  {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
3594
 
   N_("Buffer length for TCP/IP and socket communication."),
3595
 
   (char**) &global_system_variables.net_buffer_length,
3596
 
   (char**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
 
3865
   "Buffer length for TCP/IP and socket communication.",
 
3866
   (uchar**) &global_system_variables.net_buffer_length,
 
3867
   (uchar**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
3597
3868
   REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
3598
3869
  {"net_read_timeout", OPT_NET_READ_TIMEOUT,
3599
 
   N_("Number of seconds to wait for more data from a connection before "
3600
 
      "aborting the read."),
3601
 
   (char**) &global_system_variables.net_read_timeout,
3602
 
   (char**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
 
3870
   "Number of seconds to wait for more data from a connection before aborting the read.",
 
3871
   (uchar**) &global_system_variables.net_read_timeout,
 
3872
   (uchar**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
3603
3873
   REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3604
3874
  {"net_retry_count", OPT_NET_RETRY_COUNT,
3605
 
   N_("If a read on a communication port is interrupted, retry this many "
3606
 
      "times before giving up."),
3607
 
   (char**) &global_system_variables.net_retry_count,
3608
 
   (char**) &max_system_variables.net_retry_count,0,
 
3875
   "If a read on a communication port is interrupted, retry this many times before giving up.",
 
3876
   (uchar**) &global_system_variables.net_retry_count,
 
3877
   (uchar**) &max_system_variables.net_retry_count,0,
3609
3878
   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
3610
3879
  {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
3611
 
   N_("Number of seconds to wait for a block to be written to a connection "
3612
 
      "before aborting the write."),
3613
 
   (char**) &global_system_variables.net_write_timeout,
3614
 
   (char**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
 
3880
   "Number of seconds to wait for a block to be written to a connection  before aborting the write.",
 
3881
   (uchar**) &global_system_variables.net_write_timeout,
 
3882
   (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
3615
3883
   REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3616
 
  { "old", OPT_OLD_MODE,
3617
 
    N_("Use compatible behavior."),
3618
 
    (char**) &global_system_variables.old_mode,
3619
 
    (char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
 
3884
  { "old", OPT_OLD_MODE, "Use compatible behavior.", 
 
3885
    (uchar**) &global_system_variables.old_mode,
 
3886
    (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 
3620
3887
    0, 0, 0, 0, 0, 0},
3621
3888
  {"open_files_limit", OPT_OPEN_FILES_LIMIT,
3622
 
   N_("If this is not 0, then mysqld will use this value to reserve file "
3623
 
      "descriptors to use with setrlimit(). If this value is 0 then mysqld "
3624
 
      "will reserve max_connections*5 or max_connections + table_cache*2 "
3625
 
      "(whichever is larger) number of files."),
3626
 
   (char**) &open_files_limit, (char**) &open_files_limit, 0, GET_ULONG,
 
3889
   "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
 
3890
   (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG,
3627
3891
   REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
3628
3892
  {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
3629
 
   N_("Controls the heuristic(s) applied during query optimization to prune "
3630
 
      "less-promising partial plans from the optimizer search space. Meaning: "
3631
 
      "0 - do not apply any heuristic, thus perform exhaustive search; "
3632
 
      "1 - prune plans based on number of retrieved rows."),
3633
 
   (char**) &global_system_variables.optimizer_prune_level,
3634
 
   (char**) &max_system_variables.optimizer_prune_level,
 
3893
   "Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows.",
 
3894
   (uchar**) &global_system_variables.optimizer_prune_level,
 
3895
   (uchar**) &max_system_variables.optimizer_prune_level,
3635
3896
   0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
3636
3897
  {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
3637
 
   N_("Maximum depth of search performed by the query optimizer. Values "
3638
 
      "larger than the number of relations in a query result in better query "
3639
 
      "plans, but take longer to compile a query. Smaller values than the "
3640
 
      "number of tables in a relation result in faster optimization, but may "
3641
 
      "produce very bad query plans. If set to 0, the system will "
3642
 
      "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
3643
 
      "optimizer will switch to the original find_best (used for "
3644
 
      "testing/comparison)."),
3645
 
   (char**) &global_system_variables.optimizer_search_depth,
3646
 
   (char**) &max_system_variables.optimizer_search_depth,
 
3898
   "Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Smaller values than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch to the original find_best (used for testing/comparison).",
 
3899
   (uchar**) &global_system_variables.optimizer_search_depth,
 
3900
   (uchar**) &max_system_variables.optimizer_search_depth,
3647
3901
   0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
3648
3902
  {"plugin_dir", OPT_PLUGIN_DIR,
3649
 
   N_("Directory for plugins."),
3650
 
   (char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
 
3903
   "Directory for plugins.",
 
3904
   (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
3651
3905
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3652
3906
  {"plugin_load", OPT_PLUGIN_LOAD,
3653
 
   N_("Optional comma separated list of plugins to load, where each plugin is "
3654
 
      "identified by the name of the shared library. "
3655
 
      "[for example: --plugin_load=libmd5udf.so]"),
3656
 
   (char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
 
3907
   "Optional colon separated list of plugins to load, where each plugin is "
 
3908
   "identified by name and path to library seperated by an equals.",
 
3909
   (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0,
3657
3910
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3658
3911
  {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
3659
 
   N_("The size of the buffer that is allocated when preloading indexes"),
3660
 
   (char**) &global_system_variables.preload_buff_size,
3661
 
   (char**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
 
3912
   "The size of the buffer that is allocated when preloading indexes",
 
3913
   (uchar**) &global_system_variables.preload_buff_size,
 
3914
   (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
3662
3915
   REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
3663
3916
  {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
3664
 
   N_("Allocation block size for query parsing and execution"),
3665
 
   (char**) &global_system_variables.query_alloc_block_size,
3666
 
   (char**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
 
3917
   "Allocation block size for query parsing and execution",
 
3918
   (uchar**) &global_system_variables.query_alloc_block_size,
 
3919
   (uchar**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
3667
3920
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3668
3921
  {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
3669
 
   N_("Persistent buffer for query parsing and execution"),
3670
 
   (char**) &global_system_variables.query_prealloc_size,
3671
 
   (char**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
 
3922
   "Persistent buffer for query parsing and execution",
 
3923
   (uchar**) &global_system_variables.query_prealloc_size,
 
3924
   (uchar**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
3672
3925
   REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
3673
3926
   ULONG_MAX, 0, 1024, 0},
3674
3927
  {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
3675
 
   N_("Allocation block size for storing ranges during optimization"),
3676
 
   (char**) &global_system_variables.range_alloc_block_size,
3677
 
   (char**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
 
3928
   "Allocation block size for storing ranges during optimization",
 
3929
   (uchar**) &global_system_variables.range_alloc_block_size,
 
3930
   (uchar**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
3678
3931
   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
3679
3932
   0, 1024, 0},
3680
3933
  {"read_buffer_size", OPT_RECORD_BUFFER,
3681
 
   N_("Each thread that does a sequential scan allocates a buffer of this "
3682
 
      "size for each table it scans. If you do many sequential scans, you may "
3683
 
      "want to increase this value."),
3684
 
   (char**) &global_system_variables.read_buff_size,
3685
 
   (char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
3686
 
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
 
3934
   "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
 
3935
   (uchar**) &global_system_variables.read_buff_size,
 
3936
   (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
 
3937
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT_MAX32, MALLOC_OVERHEAD, IO_SIZE,
3687
3938
   0},
3688
3939
  {"read_only", OPT_READONLY,
3689
 
   N_("Make all non-temporary tables read-only, with the exception for "
3690
 
      "replication (slave) threads and users with the SUPER privilege"),
3691
 
   (char**) &opt_readonly,
3692
 
   (char**) &opt_readonly,
 
3940
   "Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege",
 
3941
   (uchar**) &opt_readonly,
 
3942
   (uchar**) &opt_readonly,
3693
3943
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3694
3944
  {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
3695
 
   N_("When reading rows in sorted order after a sort, the rows are read "
3696
 
      "through this buffer to avoid a disk seeks. If not set, then it's set "
3697
 
      "to the value of record_buffer."),
3698
 
   (char**) &global_system_variables.read_rnd_buff_size,
3699
 
   (char**) &max_system_variables.read_rnd_buff_size, 0,
 
3945
   "When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.",
 
3946
   (uchar**) &global_system_variables.read_rnd_buff_size,
 
3947
   (uchar**) &max_system_variables.read_rnd_buff_size, 0,
3700
3948
   GET_ULONG, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
3701
 
   INT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
 
3949
   INT_MAX32, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
3702
3950
  {"record_buffer", OPT_RECORD_BUFFER,
3703
3951
   "Alias for read_buffer_size",
3704
 
   (char**) &global_system_variables.read_buff_size,
3705
 
   (char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
3706
 
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
3707
 
   INT32_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
 
3952
   (uchar**) &global_system_variables.read_buff_size,
 
3953
   (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
 
3954
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0},
3708
3955
  {"relay_log_purge", OPT_RELAY_LOG_PURGE,
3709
 
   N_("0 = do not purge relay logs. "
3710
 
      "1 = purge them as soon as they are no more needed."),
3711
 
   (char**) &relay_log_purge,
3712
 
   (char**) &relay_log_purge, 0, GET_BOOL, NO_ARG,
 
3956
   "0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.",
 
3957
   (uchar**) &relay_log_purge,
 
3958
   (uchar**) &relay_log_purge, 0, GET_BOOL, NO_ARG,
3713
3959
   1, 0, 1, 0, 1, 0},
3714
3960
  {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
3715
 
   N_("Maximum space to use for all relay logs."),
3716
 
   (char**) &relay_log_space_limit,
3717
 
   (char**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
3718
 
   (int64_t) ULONG_MAX, 0, 1, 0},
 
3961
   "Maximum space to use for all relay logs.",
 
3962
   (uchar**) &relay_log_space_limit,
 
3963
   (uchar**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
 
3964
   (longlong) ULONG_MAX, 0, 1, 0},
3719
3965
  {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL,
3720
 
   N_("Use compression on master/slave protocol."),
3721
 
   (char**) &opt_slave_compressed_protocol,
3722
 
   (char**) &opt_slave_compressed_protocol,
 
3966
   "Use compression on master/slave protocol.",
 
3967
   (uchar**) &opt_slave_compressed_protocol,
 
3968
   (uchar**) &opt_slave_compressed_protocol,
3723
3969
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3724
3970
  {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT,
3725
 
   N_("Number of seconds to wait for more data from a master/slave connection "
3726
 
      "before aborting the read."),
3727
 
   (char**) &slave_net_timeout, (char**) &slave_net_timeout, 0,
 
3971
   "Number of seconds to wait for more data from a master/slave connection before aborting the read.",
 
3972
   (uchar**) &slave_net_timeout, (uchar**) &slave_net_timeout, 0,
3728
3973
   GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3729
3974
  {"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES,
3730
 
   N_("Number of times the slave SQL thread will retry a transaction in case "
3731
 
      "it failed with a deadlock or elapsed lock wait timeout, "
3732
 
      "before giving up and stopping."),
3733
 
   (char**) &slave_trans_retries, (char**) &slave_trans_retries, 0,
3734
 
   GET_ULONG, REQUIRED_ARG, 10L, 0L, (int64_t) ULONG_MAX, 0, 1, 0},
 
3975
   "Number of times the slave SQL thread will retry a transaction in case "
 
3976
   "it failed with a deadlock or elapsed lock wait timeout, "
 
3977
   "before giving up and stopping.",
 
3978
   (uchar**) &slave_trans_retries, (uchar**) &slave_trans_retries, 0,
 
3979
   GET_ULONG, REQUIRED_ARG, 10L, 0L, (longlong) ULONG_MAX, 0, 1, 0},
3735
3980
  {"slave-allow-batching", OPT_SLAVE_ALLOW_BATCHING,
3736
 
   N_("Allow slave to batch requests."),
3737
 
   (char**) &slave_allow_batching, (char**) &slave_allow_batching,
 
3981
   "Allow slave to batch requests.",
 
3982
   (uchar**) &slave_allow_batching, (uchar**) &slave_allow_batching,
3738
3983
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3739
3984
  {"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
3740
 
   N_("If creating the thread takes longer than this value (in seconds), the "
3741
 
      "Slow_launch_threads counter will be incremented."),
3742
 
   (char**) &slow_launch_time, (char**) &slow_launch_time, 0, GET_ULONG,
 
3985
   "If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
 
3986
   (uchar**) &slow_launch_time, (uchar**) &slow_launch_time, 0, GET_ULONG,
3743
3987
   REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
3744
3988
  {"sort_buffer_size", OPT_SORT_BUFFER,
3745
 
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
3746
 
   (char**) &global_system_variables.sortbuff_size,
3747
 
   (char**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
 
3989
   "Each thread that needs to do a sort allocates a buffer of this size.",
 
3990
   (uchar**) &global_system_variables.sortbuff_size,
 
3991
   (uchar**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
3748
3992
   MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ULONG_MAX,
3749
3993
   MALLOC_OVERHEAD, 1, 0},
3750
3994
  {"sync-binlog", OPT_SYNC_BINLOG,
3751
 
   N_("Synchronously flush binary log to disk after every #th event. "
3752
 
      "Use 0 (default) to disable synchronous flushing."),
3753
 
   (char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
 
3995
   "Synchronously flush binary log to disk after every #th event. "
 
3996
   "Use 0 (default) to disable synchronous flushing.",
 
3997
   (uchar**) &sync_binlog_period, (uchar**) &sync_binlog_period, 0, GET_ULONG,
3754
3998
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
 
3999
  {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
 
4000
   (uchar**) &opt_sync_frm, (uchar**) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
 
4001
   0, 0, 0, 0},
 
4002
  {"table_cache", OPT_TABLE_OPEN_CACHE,
 
4003
   "Deprecated; use --table_open_cache instead.",
 
4004
   (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG,
 
4005
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
3755
4006
  {"table_definition_cache", OPT_TABLE_DEF_CACHE,
3756
 
   N_("The number of cached table definitions."),
3757
 
   (char**) &table_def_size, (char**) &table_def_size,
 
4007
   "The number of cached table definitions.",
 
4008
   (uchar**) &table_def_size, (uchar**) &table_def_size,
3758
4009
   0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
3759
4010
  {"table_open_cache", OPT_TABLE_OPEN_CACHE,
3760
 
   N_("The number of cached open tables."),
3761
 
   (char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
 
4011
   "The number of cached open tables.",
 
4012
   (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG,
3762
4013
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
3763
4014
  {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
3764
 
   N_("Timeout in seconds to wait for a table level lock before returning an "
3765
 
      "error. Used only if the connection has active cursors."),
3766
 
   (char**) &table_lock_wait_timeout, (char**) &table_lock_wait_timeout,
 
4015
   "Timeout in seconds to wait for a table level lock before returning an "
 
4016
   "error. Used only if the connection has active cursors.",
 
4017
   (uchar**) &table_lock_wait_timeout, (uchar**) &table_lock_wait_timeout,
3767
4018
   0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
3768
4019
  {"thread_cache_size", OPT_THREAD_CACHE_SIZE,
3769
 
   N_("How many threads we should keep in a cache for reuse."),
3770
 
   (char**) &thread_cache_size, (char**) &thread_cache_size, 0, GET_ULONG,
 
4020
   "How many threads we should keep in a cache for reuse.",
 
4021
   (uchar**) &thread_cache_size, (uchar**) &thread_cache_size, 0, GET_ULONG,
3771
4022
   REQUIRED_ARG, 0, 0, 16384, 0, 1, 0},
3772
4023
  {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
3773
 
   N_("How many threads we should create to handle query requests in case of "
3774
 
      "'thread_handling=pool-of-threads'"),
3775
 
   (char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULONG,
3776
 
   REQUIRED_ARG, 8, 1, 16384, 0, 1, 0},
 
4024
   "How many threads we should create to handle query requests in case of 'thread_handling=pool-of-threads'",
 
4025
   (uchar**) &thread_pool_size, (uchar**) &thread_pool_size, 0, GET_ULONG,
 
4026
   REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
3777
4027
  {"thread_stack", OPT_THREAD_STACK,
3778
 
   N_("The stack size for each thread."),
3779
 
   (char**) &my_thread_stack_size,
3780
 
   (char**) &my_thread_stack_size, 0, GET_ULONG,
3781
 
   REQUIRED_ARG,DEFAULT_THREAD_STACK,
 
4028
   "The stack size for each thread.", (uchar**) &my_thread_stack_size,
 
4029
   (uchar**) &my_thread_stack_size, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
3782
4030
   1024L*128L, ULONG_MAX, 0, 1024, 0},
3783
4031
  { "time_format", OPT_TIME_FORMAT,
3784
 
    N_("The TIME format (for future)."),
3785
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
3786
 
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
 
4032
    "The TIME format (for future).",
 
4033
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
 
4034
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
3787
4035
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3788
4036
  {"tmp_table_size", OPT_TMP_TABLE_SIZE,
3789
 
   N_("If an internal in-memory temporary table exceeds this size, MySQL will"
3790
 
      " automatically convert it to an on-disk MyISAM table."),
3791
 
   (char**) &global_system_variables.tmp_table_size,
3792
 
   (char**) &max_system_variables.tmp_table_size, 0, GET_ULL,
 
4037
   "If an internal in-memory temporary table exceeds this size, MySQL will"
 
4038
   " automatically convert it to an on-disk MyISAM table.",
 
4039
   (uchar**) &global_system_variables.tmp_table_size,
 
4040
   (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL,
3793
4041
   REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
3794
4042
  {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
3795
 
   N_("Allocation block size for transactions to be stored in binary log"),
3796
 
   (char**) &global_system_variables.trans_alloc_block_size,
3797
 
   (char**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
 
4043
   "Allocation block size for transactions to be stored in binary log",
 
4044
   (uchar**) &global_system_variables.trans_alloc_block_size,
 
4045
   (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
3798
4046
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3799
4047
  {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
3800
 
   N_("Persistent buffer for transactions to be stored in binary log"),
3801
 
   (char**) &global_system_variables.trans_prealloc_size,
3802
 
   (char**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
 
4048
   "Persistent buffer for transactions to be stored in binary log",
 
4049
   (uchar**) &global_system_variables.trans_prealloc_size,
 
4050
   (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
3803
4051
   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3804
4052
  {"wait_timeout", OPT_WAIT_TIMEOUT,
3805
 
   N_("The number of seconds the server waits for activity on a connection "
3806
 
      "before closing it."),
3807
 
   (char**) &global_system_variables.net_wait_timeout,
3808
 
   (char**) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
3809
 
   REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
 
4053
   "The number of seconds the server waits for activity on a connection before closing it.",
 
4054
   (uchar**) &global_system_variables.net_wait_timeout,
 
4055
   (uchar**) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
 
4056
   REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
3810
4057
   0, 1, 0},
3811
4058
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
3812
4059
};
3813
4060
 
3814
 
static int show_net_compression(Session *session __attribute__((unused)),
3815
 
                                SHOW_VAR *var,
3816
 
                                char *buff __attribute__((unused)))
 
4061
static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff)
3817
4062
{
3818
4063
  var->type= SHOW_MY_BOOL;
3819
 
  var->value= (char *)&session->net.compress;
3820
 
  return 0;
3821
 
}
3822
 
 
3823
 
static st_show_var_func_container
3824
 
show_net_compression_cont= { &show_net_compression };
3825
 
 
3826
 
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
3827
 
{
3828
 
  var->type= SHOW_LONG;
3829
 
  var->value= buff;
3830
 
  *((long *)buff)= (long) (session->query_start() - server_start_time);
3831
 
  return 0;
3832
 
}
3833
 
 
3834
 
static st_show_var_func_container
3835
 
show_starttime_cont= { &show_starttime };
3836
 
 
3837
 
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
3838
 
{
3839
 
  var->type= SHOW_LONG;
3840
 
  var->value= buff;
3841
 
  *((long *)buff)= (long) (session->query_start() - flush_status_time);
3842
 
  return 0;
3843
 
}
3844
 
 
3845
 
static st_show_var_func_container
3846
 
show_flushstatustime_cont= { &show_flushstatustime };
3847
 
 
3848
 
static int show_slave_running(Session *session __attribute__((unused)),
3849
 
                              SHOW_VAR *var, char *buff)
 
4064
  var->value= (char *)&thd->net.compress;
 
4065
  return 0;
 
4066
}
 
4067
 
 
4068
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
 
4069
{
 
4070
  var->type= SHOW_LONG;
 
4071
  var->value= buff;
 
4072
  *((long *)buff)= (long) (thd->query_start() - server_start_time);
 
4073
  return 0;
 
4074
}
 
4075
 
 
4076
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
 
4077
{
 
4078
  var->type= SHOW_LONG;
 
4079
  var->value= buff;
 
4080
  *((long *)buff)= (long) (thd->query_start() - flush_status_time);
 
4081
  return 0;
 
4082
}
 
4083
 
 
4084
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
3850
4085
{
3851
4086
  var->type= SHOW_MY_BOOL;
3852
4087
  pthread_mutex_lock(&LOCK_active_mi);
3853
4088
  var->value= buff;
3854
 
  *((bool *)buff)= (bool) (active_mi && active_mi->slave_running &&
 
4089
  *((my_bool *)buff)= (my_bool) (active_mi && active_mi->slave_running &&
3855
4090
                                 active_mi->rli.slave_running);
3856
4091
  pthread_mutex_unlock(&LOCK_active_mi);
3857
4092
  return 0;
3858
4093
}
3859
4094
 
3860
 
static st_show_var_func_container
3861
 
show_slave_running_cont= { &show_slave_running };
3862
 
 
3863
 
static int show_slave_retried_trans(Session *session __attribute__((unused)),
3864
 
                                    SHOW_VAR *var, char *buff)
 
4095
static int show_slave_retried_trans(THD *thd, SHOW_VAR *var, char *buff)
3865
4096
{
3866
4097
  /*
3867
4098
    TODO: with multimaster, have one such counter per line in
3882
4113
  return 0;
3883
4114
}
3884
4115
 
3885
 
static st_show_var_func_container
3886
 
show_slave_retried_trans_cont= { &show_slave_retried_trans };
3887
 
 
3888
 
static int show_slave_received_heartbeats(Session *session __attribute__((unused)),
3889
 
                                          SHOW_VAR *var, char *buff)
 
4116
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
3890
4117
{
3891
4118
  pthread_mutex_lock(&LOCK_active_mi);
3892
4119
  if (active_mi)
3894
4121
    var->type= SHOW_LONGLONG;
3895
4122
    var->value= buff;
3896
4123
    pthread_mutex_lock(&active_mi->rli.data_lock);
3897
 
    *((int64_t *)buff)= active_mi->received_heartbeats;
 
4124
    *((longlong *)buff)= active_mi->received_heartbeats;
3898
4125
    pthread_mutex_unlock(&active_mi->rli.data_lock);
3899
4126
  }
3900
4127
  else
3903
4130
  return 0;
3904
4131
}
3905
4132
 
3906
 
static st_show_var_func_container
3907
 
show_slave_received_heartbeats_cont= { &show_slave_received_heartbeats };
3908
 
 
3909
 
static int show_heartbeat_period(Session *session __attribute__((unused)),
3910
 
                                 SHOW_VAR *var, char *buff)
 
4133
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
3911
4134
{
3912
4135
  pthread_mutex_lock(&LOCK_active_mi);
3913
4136
  if (active_mi)
3914
4137
  {
3915
4138
    var->type= SHOW_CHAR;
3916
4139
    var->value= buff;
3917
 
    sprintf(buff, "%.3f",active_mi->heartbeat_period);
 
4140
    my_sprintf(buff, (buff, "%.3f",active_mi->heartbeat_period));
3918
4141
  }
3919
4142
  else
3920
4143
    var->type= SHOW_UNDEF;
3922
4145
  return 0;
3923
4146
}
3924
4147
 
3925
 
static st_show_var_func_container
3926
 
show_heartbeat_period_cont= { &show_heartbeat_period};
3927
4148
 
3928
 
static int show_open_tables(Session *session __attribute__((unused)),
3929
 
                            SHOW_VAR *var, char *buff)
 
4149
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
3930
4150
{
3931
4151
  var->type= SHOW_LONG;
3932
4152
  var->value= buff;
3934
4154
  return 0;
3935
4155
}
3936
4156
 
3937
 
static int show_table_definitions(Session *session __attribute__((unused)),
3938
 
                                  SHOW_VAR *var, char *buff)
 
4157
static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff)
3939
4158
{
3940
4159
  var->type= SHOW_LONG;
3941
4160
  var->value= buff;
3943
4162
  return 0;
3944
4163
}
3945
4164
 
3946
 
static st_show_var_func_container
3947
 
show_open_tables_cont= { &show_open_tables };
3948
 
static st_show_var_func_container
3949
 
show_table_definitions_cont= { &show_table_definitions };
3950
 
 
3951
4165
/*
3952
4166
  Variables shown by SHOW STATUS in alphabetical order
3953
4167
*/
3960
4174
  {"Bytes_received",           (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
3961
4175
  {"Bytes_sent",               (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
3962
4176
  {"Com",                      (char*) com_status_vars, SHOW_ARRAY},
3963
 
  {"Compression",              (char*) &show_net_compression_cont, SHOW_FUNC},
 
4177
  {"Compression",              (char*) &show_net_compression, SHOW_FUNC},
3964
4178
  {"Connections",              (char*) &thread_id,              SHOW_LONG_NOFLUSH},
3965
4179
  {"Created_tmp_disk_tables",  (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
3966
4180
  {"Created_tmp_files",        (char*) &my_tmp_file_created,    SHOW_LONG},
3992
4206
  {"Max_used_connections",     (char*) &max_used_connections,  SHOW_LONG},
3993
4207
  {"Open_files",               (char*) &my_file_opened,         SHOW_LONG_NOFLUSH},
3994
4208
  {"Open_streams",             (char*) &my_stream_opened,       SHOW_LONG_NOFLUSH},
3995
 
  {"Open_table_definitions",   (char*) &show_table_definitions_cont, SHOW_FUNC},
3996
 
  {"Open_tables",              (char*) &show_open_tables_cont,       SHOW_FUNC},
 
4209
  {"Open_table_definitions",   (char*) &show_table_definitions, SHOW_FUNC},
 
4210
  {"Open_tables",              (char*) &show_open_tables,       SHOW_FUNC},
3997
4211
  {"Opened_files",             (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
3998
4212
  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
3999
4213
  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
4004
4218
  {"Select_range_check",       (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
4005
4219
  {"Select_scan",              (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
4006
4220
  {"Slave_open_temp_tables",   (char*) &slave_open_temp_tables, SHOW_LONG},
4007
 
  {"Slave_retried_transactions",(char*) &show_slave_retried_trans_cont, SHOW_FUNC},
4008
 
  {"Slave_heartbeat_period",   (char*) &show_heartbeat_period_cont, SHOW_FUNC},
4009
 
  {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats_cont, SHOW_FUNC},
4010
 
  {"Slave_running",            (char*) &show_slave_running_cont,     SHOW_FUNC},
 
4221
  {"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
 
4222
  {"Slave_heartbeat_period",   (char*) &show_heartbeat_period, SHOW_FUNC},
 
4223
  {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats, SHOW_FUNC},
 
4224
  {"Slave_running",            (char*) &show_slave_running,     SHOW_FUNC},
4011
4225
  {"Slow_launch_threads",      (char*) &slow_launch_threads,    SHOW_LONG},
4012
4226
  {"Slow_queries",             (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
4013
4227
  {"Sort_merge_passes",        (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
4021
4235
  {"Tc_log_page_size",         (char*) &tc_log_page_size,       SHOW_LONG},
4022
4236
  {"Tc_log_page_waits",        (char*) &tc_log_page_waits,      SHOW_LONG},
4023
4237
#endif
 
4238
  {"Threads_cached",           (char*) &cached_thread_count,    SHOW_LONG_NOFLUSH},
4024
4239
  {"Threads_connected",        (char*) &connection_count,       SHOW_INT},
4025
4240
  {"Threads_created",          (char*) &thread_created,         SHOW_LONG_NOFLUSH},
4026
4241
  {"Threads_running",          (char*) &thread_running,         SHOW_INT},
4027
 
  {"Uptime",                   (char*) &show_starttime_cont,         SHOW_FUNC},
4028
 
  {"Uptime_since_flush_status",(char*) &show_flushstatustime_cont,   SHOW_FUNC},
4029
 
  {NULL, NULL, SHOW_LONG}
 
4242
  {"Uptime",                   (char*) &show_starttime,         SHOW_FUNC},
 
4243
  {"Uptime_since_flush_status",(char*) &show_flushstatustime,   SHOW_FUNC},
 
4244
  {NullS, NullS, SHOW_LONG}
4030
4245
};
4031
4246
 
4032
4247
static void print_version(void)
4037
4252
    version from the output of 'mysqld --version', so don't change it!
4038
4253
  */
4039
4254
  printf("%s  Ver %s for %s on %s (%s)\n",my_progname,
4040
 
         server_version,SYSTEM_TYPE,MACHINE_TYPE, COMPILATION_COMMENT);
 
4255
         server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT);
4041
4256
}
4042
4257
 
4043
4258
static void usage(void)
4049
4264
  if (!default_collation_name)
4050
4265
    default_collation_name= (char*) default_charset_info->name;
4051
4266
  print_version();
4052
 
  puts(_("Copyright (C) 2000 MySQL AB, by Monty and others\n"
4053
 
         "This software comes with ABSOLUTELY NO WARRANTY. "
4054
 
         "This is free software,\n"
4055
 
         "and you are welcome to modify and redistribute it under the GPL "
4056
 
         "license\n\n"
4057
 
         "Starts the Drizzle database server\n"));
 
4267
  puts("\
 
4268
Copyright (C) 2000 MySQL AB, by Monty and others\n\
 
4269
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
 
4270
and you are welcome to modify and redistribute it under the GPL license\n\n\
 
4271
Starts the MySQL database server\n");
4058
4272
 
4059
 
  printf(_("Usage: %s [OPTIONS]\n"), my_progname);
 
4273
  printf("Usage: %s [OPTIONS]\n", my_progname);
 
4274
  if (!opt_verbose)
 
4275
    puts("\nFor more help options (several pages), use mysqld --verbose --help");
 
4276
  else
4060
4277
  {
4061
 
#ifdef FOO
4062
 
  print_defaults(DRIZZLE_CONFIG_NAME,load_default_groups);
 
4278
  print_defaults(MYSQL_CONFIG_NAME,load_default_groups);
4063
4279
  puts("");
4064
4280
  set_ports();
4065
 
#endif
4066
4281
 
4067
4282
  /* Print out all the options including plugin supplied options */
4068
4283
  my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
4069
4284
 
4070
 
  puts(_("\nTo see what values a running Drizzle server is using, type\n"
4071
 
         "'drizzleadmin variables' instead of 'drizzled --help'."));
 
4285
  puts("\n\
 
4286
To see what values a running MySQL server is using, type\n\
 
4287
'mysqladmin variables' instead of 'mysqld --verbose --help'.");
4072
4288
  }
4073
4289
}
4074
4290
 
4094
4310
  /* Things reset to zero */
4095
4311
  opt_skip_slave_start= opt_reckless_slave = 0;
4096
4312
  mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
 
4313
  opt_log= opt_slow_log= 0;
4097
4314
  log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4098
4315
  opt_bin_log= 0;
4099
 
  opt_skip_show_db=0;
4100
 
  opt_logname= opt_binlog_index_name= 0;
 
4316
  opt_disable_networking= opt_skip_show_db=0;
 
4317
  opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
4101
4318
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
 
4319
  opt_secure_auth= 0;
4102
4320
  opt_secure_file_priv= 0;
 
4321
  opt_bootstrap= opt_myisam_log= 0;
 
4322
  mqh_used= 0;
4103
4323
  segfaulted= kill_in_progress= 0;
4104
4324
  cleanup_done= 0;
4105
4325
  defaults_argc= 0;
4106
4326
  defaults_argv= 0;
4107
4327
  server_id_supplied= 0;
4108
4328
  test_flags= select_errors= dropping_tables= ha_open_options=0;
4109
 
  thread_count= thread_running= wake_thread=0;
 
4329
  thread_count= thread_running= kill_cached_threads= wake_thread=0;
4110
4330
  slave_open_temp_tables= 0;
 
4331
  cached_thread_count= 0;
4111
4332
  opt_endinfo= using_udf_functions= 0;
4112
4333
  opt_using_transactions= using_update_log= 0;
4113
4334
  abort_loop= select_thread_in_use= signal_thread_in_use= 0;
4117
4338
  binlog_cache_use=  binlog_cache_disk_use= 0;
4118
4339
  max_used_connections= slow_launch_threads = 0;
4119
4340
  mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4120
 
  opt_mysql_tmpdir= my_bind_addr_str= NULL;
4121
 
  memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4122
 
  memset(&global_status_var, 0, sizeof(global_status_var));
 
4341
  errmesg= 0;
 
4342
  opt_mysql_tmpdir= my_bind_addr_str= NullS;
 
4343
  bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
 
4344
  bzero((char *) &global_status_var, sizeof(global_status_var));
4123
4345
  key_map_full.set_all();
4124
4346
 
4125
4347
  /* Character sets */
4136
4358
  slave_exec_mode_options= 0;
4137
4359
  slave_exec_mode_options= (uint)
4138
4360
    find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
 
4361
  opt_specialflag= SPECIAL_ENGLISH;
 
4362
  ip_sock= INVALID_SOCKET;
4139
4363
  mysql_home_ptr= mysql_home;
4140
4364
  pidfile_name_ptr= pidfile_name;
4141
4365
  log_error_file_ptr= log_error_file;
4142
4366
  language_ptr= language;
4143
4367
  mysql_data_home= mysql_real_data_home;
4144
 
  session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
 
4368
  thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4145
4369
                        OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
4146
4370
  protocol_version= PROTOCOL_VERSION;
4147
4371
  what_to_log= ~ (1L << (uint) COM_TIME);
4148
4372
  refresh_version= 1L;  /* Increments on each reload */
4149
 
  thread_id= 1;
4150
 
  my_stpcpy(server_version, VERSION);
 
4373
  global_query_id= thread_id= 1L;
 
4374
  strmov(server_version, MYSQL_SERVER_VERSION);
4151
4375
  myisam_recover_options_str= "OFF";
4152
4376
  myisam_stats_method_str= "nulls_unequal";
4153
4377
  threads.empty();
4175
4399
 
4176
4400
  /* Variables in libraries */
4177
4401
  charsets_dir= 0;
4178
 
  default_character_set_name= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
 
4402
  default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME;
4179
4403
  default_collation_name= compiled_default_collation_name;
 
4404
  sys_charset_system.set((char*) system_charset_info->csname);
4180
4405
  character_set_filesystem_name= (char*) "binary";
4181
4406
  lc_time_names_name= (char*) "en_US";
4182
4407
  /* Set default values for some option variables */
4183
 
  default_storage_engine_str= (char*) "innodb";
 
4408
  default_storage_engine_str= (char*) "MyISAM";
4184
4409
  global_system_variables.table_plugin= NULL;
4185
4410
  global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
4186
 
  global_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
4187
 
  max_system_variables.select_limit=    (uint64_t) HA_POS_ERROR;
4188
 
  global_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
4189
 
  max_system_variables.max_join_size=   (uint64_t) HA_POS_ERROR;
 
4411
  global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
 
4412
  max_system_variables.select_limit=    (ulonglong) HA_POS_ERROR;
 
4413
  global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
 
4414
  max_system_variables.max_join_size=   (ulonglong) HA_POS_ERROR;
 
4415
  global_system_variables.old_passwords= 0;
4190
4416
  global_system_variables.old_alter_table= 0;
4191
4417
  global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
4192
4418
  /*
4196
4422
  global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4197
4423
 
4198
4424
  /* Variables that depends on compile options */
4199
 
  opt_error_log= 0;
 
4425
#ifndef DBUG_OFF
 
4426
  default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
 
4427
                             "d:t:i:o,/tmp/mysqld.trace");
 
4428
#endif
 
4429
  opt_error_log= IF_WIN(1,0);
4200
4430
#ifdef HAVE_BROKEN_REALPATH
4201
4431
  have_symlink=SHOW_OPTION_NO;
4202
4432
#else
4203
4433
  have_symlink=SHOW_OPTION_YES;
4204
4434
#endif
 
4435
#ifdef HAVE_DLOPEN
 
4436
  have_dlopen=SHOW_OPTION_YES;
 
4437
#else
 
4438
  have_dlopen=SHOW_OPTION_NO;
 
4439
#endif
 
4440
#ifdef HAVE_CRYPT
 
4441
  have_crypt=SHOW_OPTION_YES;
 
4442
#else
 
4443
  have_crypt=SHOW_OPTION_NO;
 
4444
#endif
4205
4445
#ifdef HAVE_COMPRESS
4206
4446
  have_compress= SHOW_OPTION_YES;
4207
4447
#else
4210
4450
 
4211
4451
  const char *tmpenv;
4212
4452
  if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
4213
 
    tmpenv = DEFAULT_DRIZZLE_HOME;
 
4453
    tmpenv = DEFAULT_MYSQL_HOME;
4214
4454
  (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
4215
4455
}
4216
4456
 
4217
4457
 
4218
 
bool
 
4458
my_bool
4219
4459
mysqld_get_one_option(int optid,
4220
4460
                      const struct my_option *opt __attribute__((unused)),
4221
4461
                      char *argument)
4222
4462
{
4223
4463
  switch(optid) {
4224
4464
  case '#':
 
4465
#ifndef DBUG_OFF
 
4466
    DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
 
4467
#endif
4225
4468
    opt_endinfo=1;                              /* unireg: memory allocation */
4226
4469
    break;
4227
4470
  case 'a':
4234
4477
    if (default_collation_name == compiled_default_collation_name)
4235
4478
      default_collation_name= 0;
4236
4479
    break;
 
4480
  case 'l':
 
4481
    opt_log=1;
 
4482
    break;
4237
4483
  case 'h':
4238
4484
    strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
4239
4485
    /* Correct pointer set by my_getopt (for embedded library) */
4244
4490
    if (!mysqld_user || !strcmp(mysqld_user, argument))
4245
4491
      mysqld_user= argument;
4246
4492
    else
4247
 
      sql_print_warning(_("Ignoring user change to '%s' because the user was "
4248
 
                          "set to '%s' earlier on the command line\n"),
4249
 
                        argument, mysqld_user);
 
4493
      sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user);
4250
4494
    break;
4251
4495
  case 'L':
4252
4496
    strmake(language, argument, sizeof(language)-1);
4273
4517
    test_flags= argument ? (uint) atoi(argument) : 0;
4274
4518
    opt_endinfo=1;
4275
4519
    break;
 
4520
  case (int) OPT_BIG_TABLES:
 
4521
    thd_startup_options|=OPTION_BIG_TABLES;
 
4522
    break;
 
4523
  case (int) OPT_ISAM_LOG:
 
4524
    opt_myisam_log=1;
 
4525
    break;
4276
4526
  case (int) OPT_BIN_LOG:
4277
4527
    opt_bin_log= test(argument != disabled_my_option);
4278
4528
    break;
4280
4530
    opt_error_log= 1;
4281
4531
    break;
4282
4532
  case (int)OPT_REPLICATE_IGNORE_DB:
4283
 
    {
4284
 
      rpl_filter->add_ignore_db(argument);
4285
 
      break;
4286
 
    }
 
4533
  {
 
4534
    rpl_filter->add_ignore_db(argument);
 
4535
    break;
 
4536
  }
4287
4537
  case (int)OPT_REPLICATE_DO_DB:
4288
 
    {
4289
 
      rpl_filter->add_do_db(argument);
4290
 
      break;
4291
 
    }
 
4538
  {
 
4539
    rpl_filter->add_do_db(argument);
 
4540
    break;
 
4541
  }
4292
4542
  case (int)OPT_REPLICATE_REWRITE_DB:
4293
 
    {
4294
 
      char* key = argument,*p, *val;
4295
 
 
4296
 
      if (!(p= strstr(argument, "->")))
4297
 
      {
4298
 
        fprintf(stderr,
4299
 
                _("Bad syntax in replicate-rewrite-db - missing '->'!\n"));
4300
 
        exit(1);
4301
 
      }
4302
 
      val= p--;
4303
 
      while (my_isspace(mysqld_charset, *p) && p > argument)
4304
 
        *p-- = 0;
4305
 
      if (p == argument)
4306
 
      {
4307
 
        fprintf(stderr,
4308
 
                _("Bad syntax in replicate-rewrite-db - empty FROM db!\n"));
4309
 
        exit(1);
4310
 
      }
4311
 
      *val= 0;
4312
 
      val+= 2;
4313
 
      while (*val && my_isspace(mysqld_charset, *val))
4314
 
        *val++;
4315
 
      if (!*val)
4316
 
      {
4317
 
        fprintf(stderr,
4318
 
                _("Bad syntax in replicate-rewrite-db - empty TO db!\n"));
4319
 
        exit(1);
4320
 
      }
4321
 
 
4322
 
      rpl_filter->add_db_rewrite(key, val);
4323
 
      break;
4324
 
    }
 
4543
  {
 
4544
    char* key = argument,*p, *val;
 
4545
 
 
4546
    if (!(p= strstr(argument, "->")))
 
4547
    {
 
4548
      fprintf(stderr,
 
4549
              "Bad syntax in replicate-rewrite-db - missing '->'!\n");
 
4550
      exit(1);
 
4551
    }
 
4552
    val= p--;
 
4553
    while (my_isspace(mysqld_charset, *p) && p > argument)
 
4554
      *p-- = 0;
 
4555
    if (p == argument)
 
4556
    {
 
4557
      fprintf(stderr,
 
4558
              "Bad syntax in replicate-rewrite-db - empty FROM db!\n");
 
4559
      exit(1);
 
4560
    }
 
4561
    *val= 0;
 
4562
    val+= 2;
 
4563
    while (*val && my_isspace(mysqld_charset, *val))
 
4564
      *val++;
 
4565
    if (!*val)
 
4566
    {
 
4567
      fprintf(stderr,
 
4568
              "Bad syntax in replicate-rewrite-db - empty TO db!\n");
 
4569
      exit(1);
 
4570
    }
 
4571
 
 
4572
    rpl_filter->add_db_rewrite(key, val);
 
4573
    break;
 
4574
  }
4325
4575
 
4326
4576
  case (int)OPT_BINLOG_IGNORE_DB:
4327
 
    {
4328
 
      binlog_filter->add_ignore_db(argument);
4329
 
      break;
4330
 
    }
 
4577
  {
 
4578
    binlog_filter->add_ignore_db(argument);
 
4579
    break;
 
4580
  }
4331
4581
  case OPT_BINLOG_FORMAT:
4332
 
    {
4333
 
      int id;
4334
 
      id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
4335
 
      global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
4336
 
      break;
4337
 
    }
 
4582
  {
 
4583
    int id;
 
4584
    id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
 
4585
    global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
 
4586
    break;
 
4587
  }
4338
4588
  case (int)OPT_BINLOG_DO_DB:
4339
 
    {
4340
 
      binlog_filter->add_do_db(argument);
4341
 
      break;
4342
 
    }
 
4589
  {
 
4590
    binlog_filter->add_do_db(argument);
 
4591
    break;
 
4592
  }
4343
4593
  case (int)OPT_REPLICATE_DO_TABLE:
 
4594
  {
 
4595
    if (rpl_filter->add_do_table(argument))
4344
4596
    {
4345
 
      if (rpl_filter->add_do_table(argument))
4346
 
      {
4347
 
        fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
4348
 
        exit(1);
4349
 
      }
4350
 
      break;
 
4597
      fprintf(stderr, "Could not add do table rule '%s'!\n", argument);
 
4598
      exit(1);
4351
4599
    }
 
4600
    break;
 
4601
  }
4352
4602
  case (int)OPT_REPLICATE_WILD_DO_TABLE:
 
4603
  {
 
4604
    if (rpl_filter->add_wild_do_table(argument))
4353
4605
    {
4354
 
      if (rpl_filter->add_wild_do_table(argument))
4355
 
      {
4356
 
        fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
4357
 
        exit(1);
4358
 
      }
4359
 
      break;
 
4606
      fprintf(stderr, "Could not add do table rule '%s'!\n", argument);
 
4607
      exit(1);
4360
4608
    }
 
4609
    break;
 
4610
  }
4361
4611
  case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
 
4612
  {
 
4613
    if (rpl_filter->add_wild_ignore_table(argument))
4362
4614
    {
4363
 
      if (rpl_filter->add_wild_ignore_table(argument))
4364
 
      {
4365
 
        fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
4366
 
        exit(1);
4367
 
      }
4368
 
      break;
 
4615
      fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument);
 
4616
      exit(1);
4369
4617
    }
 
4618
    break;
 
4619
  }
4370
4620
  case (int)OPT_REPLICATE_IGNORE_TABLE:
4371
 
    {
4372
 
      if (rpl_filter->add_ignore_table(argument))
4373
 
      {
4374
 
        fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
4375
 
        exit(1);
4376
 
      }
4377
 
      break;
4378
 
    }
 
4621
  {
 
4622
    if (rpl_filter->add_ignore_table(argument))
 
4623
    {
 
4624
      fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument);
 
4625
      exit(1);
 
4626
    }
 
4627
    break;
 
4628
  }
 
4629
  case (int) OPT_SLOW_QUERY_LOG:
 
4630
    opt_slow_log= 1;
 
4631
    break;
 
4632
#ifdef WITH_CSV_STORAGE_ENGINE
 
4633
  case  OPT_LOG_OUTPUT:
 
4634
  {
 
4635
    if (!argument || !argument[0])
 
4636
    {
 
4637
      log_output_options= LOG_FILE;
 
4638
      log_output_str= log_output_typelib.type_names[1];
 
4639
    }
 
4640
    else
 
4641
    {
 
4642
      log_output_str= argument;
 
4643
      log_output_options=
 
4644
        find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
 
4645
  }
 
4646
    break;
 
4647
  }
 
4648
#endif
 
4649
  case (int) OPT_SKIP_NEW:
 
4650
    opt_specialflag|= SPECIAL_NO_NEW_FUNC;
 
4651
    delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
 
4652
    myisam_concurrent_insert=0;
 
4653
    myisam_recover_options= HA_RECOVER_NONE;
 
4654
    my_use_symdir=0;
 
4655
    ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE);
 
4656
    break;
 
4657
  case (int) OPT_SAFE:
 
4658
    opt_specialflag|= SPECIAL_SAFE_MODE;
 
4659
    delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
 
4660
    myisam_recover_options= HA_RECOVER_DEFAULT;
 
4661
    ha_open_options&= ~(HA_OPEN_DELAY_KEY_WRITE);
 
4662
    break;
 
4663
  case (int) OPT_SKIP_PRIOR:
 
4664
    opt_specialflag|= SPECIAL_NO_PRIOR;
 
4665
    break;
 
4666
  case (int) OPT_SKIP_LOCK:
 
4667
    opt_external_locking=0;
 
4668
    break;
 
4669
  case (int) OPT_SKIP_SHOW_DB:
 
4670
    opt_skip_show_db=1;
 
4671
    opt_specialflag|=SPECIAL_SKIP_SHOW_DB;
 
4672
    break;
4379
4673
  case (int) OPT_WANT_CORE:
4380
4674
    test_flags |= TEST_CORE_ON_SIGNAL;
4381
4675
    break;
4387
4681
    break;
4388
4682
  case (int) OPT_BIND_ADDRESS:
4389
4683
    {
4390
 
      struct addrinfo *res_lst, hints;
 
4684
      struct addrinfo *res_lst, hints;    
4391
4685
 
4392
 
      memset(&hints, 0, sizeof(struct addrinfo));
 
4686
      bzero(&hints, sizeof(struct addrinfo));
4393
4687
      hints.ai_socktype= SOCK_STREAM;
4394
4688
      hints.ai_protocol= IPPROTO_TCP;
4395
4689
 
4396
 
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
 
4690
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0) 
4397
4691
      {
4398
 
        sql_print_error(_("Can't start server: cannot resolve hostname!"));
 
4692
        sql_print_error("Can't start server: cannot resolve hostname!");
4399
4693
        exit(1);
4400
4694
      }
4401
4695
 
4402
4696
      if (res_lst->ai_next)
4403
4697
      {
4404
 
        sql_print_error(_("Can't start server: bind-address refers to "
4405
 
                          "multiple interfaces!"));
 
4698
        sql_print_error("Can't start server: bind-address refers to multiple interfaces!");
4406
4699
        exit(1);
4407
4700
      }
4408
4701
      freeaddrinfo(res_lst);
4415
4708
    if (opt_console)
4416
4709
      opt_error_log= 0;                 // Force logs to stdout
4417
4710
    break;
 
4711
  case (int) OPT_FLUSH:
 
4712
    myisam_flush=1;
 
4713
    flush_time=0;                       // No auto flush
 
4714
    break;
4418
4715
  case OPT_LOW_PRIORITY_UPDATES:
4419
4716
    thr_upgraded_concurrent_insert_lock= TL_WRITE_LOW_PRIORITY;
4420
4717
    global_system_variables.low_priority_updates=1;
4421
4718
    break;
 
4719
  case OPT_BOOTSTRAP:
 
4720
    opt_noacl=opt_bootstrap=1;
 
4721
    break;
4422
4722
  case OPT_SERVER_ID:
4423
4723
    server_id_supplied = 1;
4424
4724
    break;
4443
4743
    charsets_dir = mysql_charsets_dir;
4444
4744
    break;
4445
4745
  case OPT_TX_ISOLATION:
4446
 
    {
4447
 
      int type;
4448
 
      type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
4449
 
      global_system_variables.tx_isolation= (type-1);
4450
 
      break;
4451
 
    }
 
4746
  {
 
4747
    int type;
 
4748
    type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
 
4749
    global_system_variables.tx_isolation= (type-1);
 
4750
    break;
 
4751
  }
4452
4752
  case OPT_MYISAM_RECOVER:
4453
 
    {
4454
 
      if (!argument)
4455
 
      {
4456
 
        myisam_recover_options=    HA_RECOVER_DEFAULT;
4457
 
        myisam_recover_options_str= myisam_recover_typelib.type_names[0];
4458
 
      }
4459
 
      else if (!argument[0])
4460
 
      {
4461
 
        myisam_recover_options= HA_RECOVER_NONE;
4462
 
        myisam_recover_options_str= "OFF";
4463
 
      }
4464
 
      else
4465
 
      {
4466
 
        myisam_recover_options_str=argument;
4467
 
        myisam_recover_options=
4468
 
          find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
4469
 
      }
4470
 
      ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
4471
 
      break;
4472
 
    }
 
4753
  {
 
4754
    if (!argument)
 
4755
    {
 
4756
      myisam_recover_options=    HA_RECOVER_DEFAULT;
 
4757
      myisam_recover_options_str= myisam_recover_typelib.type_names[0];
 
4758
    }
 
4759
    else if (!argument[0])
 
4760
    {
 
4761
      myisam_recover_options= HA_RECOVER_NONE;
 
4762
      myisam_recover_options_str= "OFF";
 
4763
    }
 
4764
    else
 
4765
    {
 
4766
      myisam_recover_options_str=argument;
 
4767
      myisam_recover_options=
 
4768
        find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
 
4769
    }
 
4770
    ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
 
4771
    break;
 
4772
  }
4473
4773
  case OPT_TC_HEURISTIC_RECOVER:
4474
4774
    tc_heuristic_recover= find_type_or_exit(argument,
4475
4775
                                            &tc_heuristic_recover_typelib,
4476
4776
                                            opt->name);
4477
4777
    break;
4478
4778
  case OPT_MYISAM_STATS_METHOD:
4479
 
    {
4480
 
      uint32_t method_conv;
4481
 
      int method;
 
4779
  {
 
4780
    ulong method_conv;
 
4781
    int method;
4482
4782
 
4483
 
      myisam_stats_method_str= argument;
4484
 
      method= find_type_or_exit(argument, &myisam_stats_method_typelib,
4485
 
                                opt->name);
4486
 
      switch (method-1) {
4487
 
      case 2:
4488
 
        method_conv= MI_STATS_METHOD_IGNORE_NULLS;
4489
 
        break;
4490
 
      case 1:
4491
 
        method_conv= MI_STATS_METHOD_NULLS_EQUAL;
4492
 
        break;
4493
 
      case 0:
4494
 
      default:
4495
 
        method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4496
 
        break;
4497
 
      }
4498
 
      global_system_variables.myisam_stats_method= method_conv;
 
4783
    myisam_stats_method_str= argument;
 
4784
    method= find_type_or_exit(argument, &myisam_stats_method_typelib,
 
4785
                              opt->name);
 
4786
    switch (method-1) {
 
4787
    case 2:
 
4788
      method_conv= MI_STATS_METHOD_IGNORE_NULLS;
 
4789
      break;
 
4790
    case 1:
 
4791
      method_conv= MI_STATS_METHOD_NULLS_EQUAL;
 
4792
      break;
 
4793
    case 0:
 
4794
    default:
 
4795
      method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4499
4796
      break;
4500
4797
    }
 
4798
    global_system_variables.myisam_stats_method= method_conv;
 
4799
    break;
 
4800
  }
 
4801
  case OPT_LOWER_CASE_TABLE_NAMES:
 
4802
    lower_case_table_names= argument ? atoi(argument) : 1;
 
4803
    lower_case_table_names_used= 1;
 
4804
    break;
4501
4805
  }
4502
4806
  return 0;
4503
4807
}
4505
4809
 
4506
4810
/** Handle arguments for multiple key caches. */
4507
4811
 
4508
 
extern "C" char **mysql_getopt_value(const char *keyname, uint32_t key_length,
 
4812
extern "C" uchar **mysql_getopt_value(const char *keyname, uint key_length,
4509
4813
                                      const struct my_option *option);
4510
4814
 
4511
 
char**
4512
 
mysql_getopt_value(const char *keyname, uint32_t key_length,
 
4815
uchar* *
 
4816
mysql_getopt_value(const char *keyname, uint key_length,
4513
4817
                   const struct my_option *option)
4514
4818
{
4515
4819
  switch (option->id) {
4523
4827
      exit(1);
4524
4828
    switch (option->id) {
4525
4829
    case OPT_KEY_BUFFER_SIZE:
4526
 
      return (char**) &key_cache->param_buff_size;
 
4830
      return (uchar**) &key_cache->param_buff_size;
4527
4831
    case OPT_KEY_CACHE_BLOCK_SIZE:
4528
 
      return (char**) &key_cache->param_block_size;
 
4832
      return (uchar**) &key_cache->param_block_size;
4529
4833
    case OPT_KEY_CACHE_DIVISION_LIMIT:
4530
 
      return (char**) &key_cache->param_division_limit;
 
4834
      return (uchar**) &key_cache->param_division_limit;
4531
4835
    case OPT_KEY_CACHE_AGE_THRESHOLD:
4532
 
      return (char**) &key_cache->param_age_threshold;
 
4836
      return (uchar**) &key_cache->param_age_threshold;
4533
4837
    }
4534
4838
  }
4535
4839
  }
4536
 
  return (char **)option->value;
 
4840
  return option->value;
4537
4841
}
4538
4842
 
4539
4843
 
4545
4849
  va_start(args, format);
4546
4850
 
4547
4851
  /* Don't print warnings for --loose options during bootstrap */
4548
 
  if (level == ERROR_LEVEL || global_system_variables.log_warnings)
 
4852
  if (level == ERROR_LEVEL || !opt_bootstrap ||
 
4853
      global_system_variables.log_warnings)
4549
4854
  {
4550
4855
    vprint_msg_to_log(level, format, args);
4551
4856
  }
4565
4870
  my_getopt_error_reporter= option_error_reporter;
4566
4871
 
4567
4872
  /* Skip unknown options so that they may be processed later by plugins */
4568
 
  my_getopt_skip_unknown= true;
 
4873
  my_getopt_skip_unknown= TRUE;
4569
4874
 
4570
4875
  if ((ho_error= handle_options(argc, &argv, my_long_options,
4571
4876
                                mysqld_get_one_option)))
4573
4878
  (*argc)++; /* add back one for the progname handle_options removes */
4574
4879
             /* no need to do this for argv as we are discarding it. */
4575
4880
 
 
4881
  if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
 
4882
       opt_log_slow_slave_statements) &&
 
4883
      !opt_slow_log)
 
4884
    sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log-slow-queries is not set");
 
4885
 
4576
4886
#if defined(HAVE_BROKEN_REALPATH)
4577
4887
  my_use_symdir=0;
4578
4888
  my_disable_symlinks=1;
4591
4901
    test_flags&= ~TEST_CORE_ON_SIGNAL;
4592
4902
  }
4593
4903
  /* Set global MyISAM variables from delay_key_write_options */
4594
 
  fix_delay_key_write((Session*) 0, OPT_GLOBAL);
 
4904
  fix_delay_key_write((THD*) 0, OPT_GLOBAL);
4595
4905
  /* Set global slave_exec_mode from its option */
4596
4906
  fix_slave_exec_mode(OPT_GLOBAL);
4597
4907
 
4603
4913
    Set some global variables from the global_system_variables
4604
4914
    In most cases the global variables will not be used
4605
4915
  */
 
4916
  my_disable_locking= myisam_single_user= test(opt_external_locking == 0);
4606
4917
  my_default_record_cache_size=global_system_variables.read_buff_size;
4607
4918
  myisam_max_temp_length=
4608
4919
    (my_off_t) global_system_variables.myisam_max_sort_file_size;
4610
4921
  /* Set global variables based on startup options */
4611
4922
  myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
4612
4923
 
4613
 
  if (init_global_datetime_format(DRIZZLE_TIMESTAMP_DATE,
 
4924
  /* long_query_time is in microseconds */
 
4925
  global_system_variables.long_query_time= max_system_variables.long_query_time=
 
4926
    (longlong) (long_query_time * 1000000.0);
 
4927
 
 
4928
  if (opt_short_log_format)
 
4929
    opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
 
4930
 
 
4931
  if (init_global_datetime_format(MYSQL_TIMESTAMP_DATE,
4614
4932
                                  &global_system_variables.date_format) ||
4615
 
      init_global_datetime_format(DRIZZLE_TIMESTAMP_TIME,
 
4933
      init_global_datetime_format(MYSQL_TIMESTAMP_TIME,
4616
4934
                                  &global_system_variables.time_format) ||
4617
 
      init_global_datetime_format(DRIZZLE_TIMESTAMP_DATETIME,
 
4935
      init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME,
4618
4936
                                  &global_system_variables.datetime_format))
4619
4937
    exit(1);
4620
4938
 
4626
4944
  Create version name for running mysqld version
4627
4945
  We automaticly add suffixes -debug, -embedded and -log to the version
4628
4946
  name to make the version more descriptive.
4629
 
  (DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
 
4947
  (MYSQL_SERVER_SUFFIX is set by the compilation environment)
4630
4948
*/
4631
4949
 
4632
 
#ifdef DRIZZLE_SERVER_SUFFIX
4633
 
#define DRIZZLE_SERVER_SUFFIX_STR STRINGIFY_ARG(DRIZZLE_SERVER_SUFFIX)
4634
 
#else
4635
 
#define DRIZZLE_SERVER_SUFFIX_STR ""
4636
 
#endif
4637
 
 
4638
4950
static void set_server_version(void)
4639
4951
{
4640
 
  char *end= strxmov(server_version, VERSION,
4641
 
                     DRIZZLE_SERVER_SUFFIX_STR, NULL);
4642
 
  if (opt_bin_log)
4643
 
    my_stpcpy(end, "-log");                        // This may slow down system
 
4952
  char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
 
4953
                     MYSQL_SERVER_SUFFIX_STR, NullS);
 
4954
#ifndef DBUG_OFF
 
4955
  if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
 
4956
    end= strmov(end, "-debug");
 
4957
#endif
 
4958
  if (opt_log || opt_slow_log || opt_bin_log)
 
4959
    strmov(end, "-log");                        // This may slow down system
4644
4960
}
4645
4961
 
4646
4962
 
4647
4963
static char *get_relative_path(const char *path)
4648
4964
{
4649
4965
  if (test_if_hard_path(path) &&
4650
 
      is_prefix(path,DEFAULT_DRIZZLE_HOME) &&
4651
 
      strcmp(DEFAULT_DRIZZLE_HOME,FN_ROOTDIR))
 
4966
      is_prefix(path,DEFAULT_MYSQL_HOME) &&
 
4967
      strcmp(DEFAULT_MYSQL_HOME,FN_ROOTDIR))
4652
4968
  {
4653
 
    path+=(uint) strlen(DEFAULT_DRIZZLE_HOME);
 
4969
    path+=(uint) strlen(DEFAULT_MYSQL_HOME);
4654
4970
    while (*path == FN_LIBCHAR)
4655
4971
      path++;
4656
4972
  }
4672
4988
  char tmp_path[FN_REFLEN];
4673
4989
  if (!test_if_hard_path(dir))
4674
4990
  {
4675
 
    strcpy(tmp_path, mysql_real_data_home);
4676
 
    strncat(tmp_path, dir, sizeof(tmp_path)-strlen(mysql_real_data_home)-1);
 
4991
    strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home,
 
4992
             dir, NullS);
4677
4993
    dir=tmp_path;
4678
4994
  }
4679
4995
  return !fn_format(to, name, dir, extension,
4684
5000
static void fix_paths(void)
4685
5001
{
4686
5002
  char buff[FN_REFLEN],*pos;
4687
 
  convert_dirname(mysql_home,mysql_home,NULL);
 
5003
  convert_dirname(mysql_home,mysql_home,NullS);
4688
5004
  /* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
4689
5005
  my_realpath(mysql_home,mysql_home,MYF(0));
4690
5006
  /* Ensure that mysql_home ends in FN_LIBCHAR */
4691
 
  pos= strchr(mysql_home, '\0');
 
5007
  pos=strend(mysql_home);
4692
5008
  if (pos[-1] != FN_LIBCHAR)
4693
5009
  {
4694
5010
    pos[0]= FN_LIBCHAR;
4695
5011
    pos[1]= 0;
4696
5012
  }
4697
 
  convert_dirname(mysql_real_data_home,mysql_real_data_home,NULL);
 
5013
  convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
4698
5014
  (void) fn_format(buff, mysql_real_data_home, "", "",
4699
5015
                   (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
4700
5016
  (void) unpack_dirname(mysql_unpacked_real_data_home, buff);
4701
 
  convert_dirname(language,language,NULL);
 
5017
  convert_dirname(language,language,NullS);
4702
5018
  (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
4703
5019
  (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
4704
5020
  (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
4708
5024
 
4709
5025
  char *sharedir=get_relative_path(SHAREDIR);
4710
5026
  if (test_if_hard_path(sharedir))
4711
 
    strncpy(buff,sharedir,sizeof(buff)-1);              /* purecov: tested */
 
5027
    strmake(buff,sharedir,sizeof(buff)-1);              /* purecov: tested */
4712
5028
  else
4713
 
  {
4714
 
    strcpy(buff, mysql_home);
4715
 
    strncat(buff, sharedir, sizeof(buff)-strlen(mysql_home)-1);
4716
 
  }
4717
 
  convert_dirname(buff,buff,NULL);
 
5029
    strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
 
5030
  convert_dirname(buff,buff,NullS);
4718
5031
  (void) my_load_path(language,language,buff);
4719
5032
 
4720
5033
  /* If --character-sets-dir isn't given, use shared library dir */
4721
5034
  if (charsets_dir != mysql_charsets_dir)
4722
5035
  {
4723
 
    strcpy(mysql_charsets_dir, buff);
4724
 
    strncat(mysql_charsets_dir, CHARSET_DIR,
4725
 
            sizeof(mysql_charsets_dir)-strlen(buff)-1);
 
5036
    strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
 
5037
             CHARSET_DIR, NullS);
4726
5038
  }
4727
5039
  (void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
4728
 
  convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NULL);
 
5040
  convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
4729
5041
  charsets_dir=mysql_charsets_dir;
4730
5042
 
4731
5043
  if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
4741
5053
   */
4742
5054
  if (opt_secure_file_priv)
4743
5055
  {
4744
 
    convert_dirname(buff, opt_secure_file_priv, NULL);
4745
 
    free(opt_secure_file_priv);
 
5056
    convert_dirname(buff, opt_secure_file_priv, NullS);
 
5057
    my_free(opt_secure_file_priv, MYF(0));
4746
5058
    opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
4747
5059
  }
4748
5060
}
4749
5061
 
4750
5062
 
4751
 
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
 
5063
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
4752
5064
                                   const char *option)
4753
5065
{
4754
 
  uint32_t res;
 
5066
  ulong res;
4755
5067
 
4756
5068
  const char **ptr;
4757
 
 
4758
 
  if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
 
5069
  
 
5070
  if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
4759
5071
  {
4760
5072
    ptr= bit_lib->type_names;
4761
5073
    if (!*x)
4762
 
      fprintf(stderr, _("No option given to %s\n"), option);
 
5074
      fprintf(stderr, "No option given to %s\n", option);
4763
5075
    else
4764
 
      fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
4765
 
              option, x);
4766
 
    fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
 
5076
      fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x);
 
5077
    fprintf(stderr, "Alternatives are: '%s'", *ptr);
4767
5078
    while (*++ptr)
4768
5079
      fprintf(stderr, ",'%s'", *ptr);
4769
5080
    fprintf(stderr, "\n");
4777
5088
  @return
4778
5089
    a bitfield from a string of substrings separated by ','
4779
5090
    or
4780
 
    ~(uint32_t) 0 on error.
 
5091
    ~(ulong) 0 on error.
4781
5092
*/
4782
5093
 
4783
 
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
 
5094
static ulong find_bit_type(const char *x, TYPELIB *bit_lib)
4784
5095
{
4785
5096
  bool found_end;
4786
5097
  int  found_count;
4787
5098
  const char *end,*i,*j;
4788
5099
  const char **array, *pos;
4789
 
  uint32_t found,found_int,bit;
 
5100
  ulong found,found_int,bit;
4790
5101
 
4791
5102
  found=0;
4792
5103
  found_end= 0;
4795
5106
  found_end= *pos == 0;
4796
5107
  while (!found_end)
4797
5108
  {
4798
 
    if ((end=strrchr(pos,',')) != NULL)         /* Let end point at fieldend */
 
5109
    if (!*(end=strcend(pos,',')))               /* Let end point at fieldend */
4799
5110
    {
4800
5111
      while (end > pos && end[-1] == ' ')
4801
5112
        end--;                                  /* Skip end-space */
4802
5113
      found_end=1;
4803
5114
    }
4804
 
    else
4805
 
    {
4806
 
        end=pos+strlen(pos);
4807
 
        found_end=1;
4808
 
    }
4809
5115
    found_int=0; found_count=0;
4810
5116
    for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
4811
5117
    {
4829
5135
skip: ;
4830
5136
    }
4831
5137
    if (found_count != 1)
4832
 
      return(~(uint32_t) 0);                            // No unique value
 
5138
      return(~(ulong) 0);                               // No unique value
4833
5139
    found|=found_int;
4834
5140
    pos=end+1;
4835
5141
  }
4839
5145
 
4840
5146
 
4841
5147
/**
 
5148
  Check if file system used for databases is case insensitive.
 
5149
 
 
5150
  @param dir_name                       Directory to test
 
5151
 
 
5152
  @retval
 
5153
    -1  Don't know (Test failed)
 
5154
  @retval
 
5155
    0   File system is case sensitive
 
5156
  @retval
 
5157
    1   File system is case insensitive
 
5158
*/
 
5159
 
 
5160
static int test_if_case_insensitive(const char *dir_name)
 
5161
{
 
5162
  int result= 0;
 
5163
  File file;
 
5164
  char buff[FN_REFLEN], buff2[FN_REFLEN];
 
5165
  struct stat stat_info;
 
5166
 
 
5167
  fn_format(buff, glob_hostname, dir_name, ".lower-test",
 
5168
            MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR);
 
5169
  fn_format(buff2, glob_hostname, dir_name, ".LOWER-TEST",
 
5170
            MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR);
 
5171
  (void) my_delete(buff2, MYF(0));
 
5172
  if ((file= my_create(buff, 0666, O_RDWR, MYF(0))) < 0)
 
5173
  {
 
5174
    sql_print_warning("Can't create test file %s", buff);
 
5175
    return(-1);
 
5176
  }
 
5177
  my_close(file, MYF(0));
 
5178
  if (!stat(buff2, &stat_info))
 
5179
    result= 1;                                  // Can access file
 
5180
  (void) my_delete(buff, MYF(MY_WME));
 
5181
  return(result);
 
5182
}
 
5183
 
 
5184
 
 
5185
/**
4842
5186
  Create file to store pid number.
4843
5187
*/
4844
5188
static void create_pid_file()
4850
5194
    char buff[21], *end;
4851
5195
    end= int10_to_str((long) getpid(), buff, 10);
4852
5196
    *end++= '\n';
4853
 
    if (!my_write(file, (unsigned char*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
 
5197
    if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
4854
5198
    {
4855
5199
      (void) my_close(file, MYF(0));
4856
5200
      return;
4862
5206
}
4863
5207
 
4864
5208
/** Clear most status variables. */
4865
 
void refresh_status(Session *session)
 
5209
void refresh_status(THD *thd)
4866
5210
{
4867
5211
  pthread_mutex_lock(&LOCK_status);
4868
5212
 
4869
5213
  /* Add thread's status variabes to global status */
4870
 
  add_to_status(&global_status_var, &session->status_var);
 
5214
  add_to_status(&global_status_var, &thd->status_var);
4871
5215
 
4872
5216
  /* Reset thread's status variables */
4873
 
  memset(&session->status_var, 0, sizeof(session->status_var));
 
5217
  bzero((uchar*) &thd->status_var, sizeof(thd->status_var));
4874
5218
 
4875
5219
  /* Reset some global variables */
4876
5220
  reset_status_vars();
4898
5242
 
4899
5243
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
4900
5244
/* Used templates */
4901
 
template class I_List<Session>;
4902
 
template class I_List_iterator<Session>;
 
5245
template class I_List<THD>;
 
5246
template class I_List_iterator<THD>;
4903
5247
template class I_List<i_string>;
4904
5248
template class I_List<i_string_pair>;
4905
5249
template class I_List<NAMED_LIST>;