~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/mysqld.cc

  • Committer: Brian Aker
  • Date: 2008-07-07 16:07:49 UTC
  • mfrom: (80.1.1 food)
  • Revision ID: brian@tangent.org-20080707160749-qj89fnnwufz4xgop
Clean up install, we no longer have system tables.

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