~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/mysqld.cc

  • Committer: Monty Taylor
  • Date: 2008-07-05 11:08:18 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: monty@inaugust.com-20080705110818-xyc8ehdym3r7nf6t
Add Jay's test optoins at the target of make test.

Show diffs side-by-side

added added

removed removed

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