~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2003 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
16
#include <drizzled/server_includes.h>
212.5.28 by Monty Taylor
Moved my_bit and my_list
17
#include <mysys/my_bit.h>
1 by brian
clean slate
18
#include "slave.h"
19
#include "rpl_mi.h"
20
#include "sql_repl.h"
21
#include "rpl_filter.h"
22
#include "repl_failsafe.h"
23
#include "stacktrace.h"
24
#include "mysqld_suffix.h"
212.5.13 by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys.
25
#include <mysys/mysys_err.h>
230.1.5 by Monty Taylor
Fixed a quick includes in drizzled.cc.
26
#include <sys/poll.h>
27
#include <netinet/tcp.h>
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
28
#include <drizzled/drizzled_error_messages.h>
1 by brian
clean slate
29
230.1.5 by Monty Taylor
Fixed a quick includes in drizzled.cc.
30
#include <storage/myisam/ha_myisam.h>
1 by brian
clean slate
31
32
#ifdef HAVE_SYS_PRCTL_H
33
#include <sys/prctl.h>
34
#endif
35
36
#ifndef DEFAULT_SKIP_THREAD_PRIORITY
37
#define DEFAULT_SKIP_THREAD_PRIORITY 0
38
#endif
39
212.5.7 by Monty Taylor
Move thr_*h to mysys.
40
#include <mysys/thr_alarm.h>
212.5.41 by Monty Taylor
Moved errmsg.h.
41
#include <libdrizzle/errmsg.h>
202.3.8 by Monty Taylor
Actually turn gettext on...
42
#include <locale.h>
1 by brian
clean slate
43
44
#define mysqld_charset &my_charset_latin1
45
46
#ifdef HAVE_purify
47
#define IF_PURIFY(A,B) (A)
48
#else
49
#define IF_PURIFY(A,B) (B)
50
#endif
51
52
#if SIZEOF_CHARP == 4
366 by Patrick Galbraith
Ulong conversion
53
#define MAX_MEM_TABLE_SIZE ~(uint32_t) 0
1 by brian
clean slate
54
#else
151 by Brian Aker
Ulonglong to uint64_t
55
#define MAX_MEM_TABLE_SIZE ~(uint64_t) 0
1 by brian
clean slate
56
#endif
57
58
/* We have HAVE_purify below as this speeds up the shutdown of MySQL */
59
60
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_purify) && defined(__linux__)
61
#define HAVE_CLOSE_SERVER_SOCK 1
62
#endif
63
64
extern "C" {					// Because of SCO 3.2V4.2
65
#include <errno.h>
66
#include <sys/stat.h>
67
#ifndef __GNU_LIBRARY__
68
#define __GNU_LIBRARY__				// Skip warnings in getopt.h
69
#endif
212.5.21 by Monty Taylor
Moved my_getopt.h
70
#include <mysys/my_getopt.h>
1 by brian
clean slate
71
#ifdef HAVE_SYSENT_H
72
#include <sysent.h>
73
#endif
74
#ifdef HAVE_PWD_H
75
#include <pwd.h>				// For getpwent
76
#endif
77
#ifdef HAVE_GRP_H
78
#include <grp.h>
79
#endif
80
81
#include <sys/resource.h>
82
83
#ifdef HAVE_SELECT_H
84
#  include <select.h>
85
#endif
86
87
#ifdef HAVE_SYS_SELECT_H
88
#include <sys/select.h>
89
#endif
90
91
#include <sys/utsname.h>
92
93
#ifdef HAVE_SYS_MMAN_H
94
#include <sys/mman.h>
95
#endif
96
97
#define SIGNAL_FMT "signal %d"
236.1.40 by Monty Taylor
A few meaningless changes.
98
1 by brian
clean slate
99
100
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
101
#include <ieeefp.h>
102
#ifdef HAVE_FP_EXCEPT				// Fix type conflict
103
typedef fp_except fp_except_t;
104
#endif
105
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
106
107
#ifdef HAVE_FPU_CONTROL_H
108
#include <fpu_control.h>
109
#endif
110
111
#ifdef HAVE_SYS_FPU_H
112
/* for IRIX to use set_fpc_csr() */
113
#include <sys/fpu.h>
114
#endif
115
116
inline void setup_fpu()
117
{
118
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
119
  /*
120
     We can't handle floating point exceptions with threads, so disable
121
     this on freebsd.
122
     Don't fall for overflow, underflow,divide-by-zero or loss of precision
123
  */
124
#if defined(__i386__)
125
  fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ |
126
	      FP_X_IMP));
127
#else
128
  fpsetmask(~(FP_X_INV |             FP_X_OFL | FP_X_UFL | FP_X_DZ |
129
              FP_X_IMP));
130
#endif /* __i386__ */
131
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
132
133
  /*
134
    x86 (32-bit) requires FPU precision to be explicitly set to 64 bit for
135
    portable results of floating point operations
136
  */
137
#if defined(__i386__) && defined(HAVE_FPU_CONTROL_H) && defined(_FPU_DOUBLE)
138
  fpu_control_t cw;
139
  _FPU_GETCW(cw);
140
  cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
141
  _FPU_SETCW(cw);
142
#endif /* __i386__ && HAVE_FPU_CONTROL_H && _FPU_DOUBLE */
143
}
144
145
} /* cplusplus */
146
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
147
#define DRIZZLE_KILL_SIGNAL SIGTERM
1 by brian
clean slate
148
212.5.13 by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys.
149
#include <mysys/my_pthread.h>			// For thr_setconcurency()
1 by brian
clean slate
150
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
151
#include <libdrizzle/gettext.h>
152
1 by brian
clean slate
153
#ifdef SOLARIS
154
extern "C" int gethostname(char *name, int namelen);
155
#endif
156
157
extern "C" sig_handler handle_segfault(int sig);
158
159
/* Constants */
160
161
const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
162
/*
163
  WARNING: When adding new SQL modes don't forget to update the
164
           tables definitions that stores it's value.
165
           (ie: mysql.event, mysql.proc)
166
*/
167
static const char *optimizer_switch_names[]=
168
{
169
  "no_materialization", "no_semijoin",
170
  NullS
171
};
172
173
/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */
174
static const unsigned int optimizer_switch_names_len[]=
175
{
176
  /*no_materialization*/          19,
177
  /*no_semijoin*/                 11
178
};
179
180
TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"",
181
                                    optimizer_switch_names,
182
                                    (unsigned int *)optimizer_switch_names_len };
183
184
static const char *tc_heuristic_recover_names[]=
185
{
186
  "COMMIT", "ROLLBACK", NullS
187
};
188
static TYPELIB tc_heuristic_recover_typelib=
189
{
190
  array_elements(tc_heuristic_recover_names)-1,"",
191
  tc_heuristic_recover_names, NULL
192
};
193
194
const char *first_keyword= "first", *binary_keyword= "BINARY";
195
const char *my_localhost= "localhost";
196
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
197
#define GET_HA_ROWS GET_ULL
198
#else
199
#define GET_HA_ROWS GET_ULONG
200
#endif
201
202
/*
203
  Used with --help for detailed option
204
*/
259 by Brian Aker
First pass on PAM auth
205
static bool opt_help= false;
1 by brian
clean slate
206
207
arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
208
{{&Arg_comparator::compare_string,     &Arg_comparator::compare_e_string},
209
 {&Arg_comparator::compare_real,       &Arg_comparator::compare_e_real},
210
 {&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
211
 {&Arg_comparator::compare_row,        &Arg_comparator::compare_e_row},
212
 {&Arg_comparator::compare_decimal,    &Arg_comparator::compare_e_decimal}};
213
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
214
const char *log_output_names[] = { "NONE", "FILE", NullS};
215
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
1 by brian
clean slate
216
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
236.1.40 by Monty Taylor
A few meaningless changes.
217
                             log_output_names,
1 by brian
clean slate
218
                             (unsigned int *) log_output_names_len};
219
220
/* static variables */
221
222
/* the default log output is log tables */
223
static bool volatile select_thread_in_use, signal_thread_in_use;
224
static bool volatile ready_to_exit;
77.1.96 by Monty Taylor
Removed skip-external-locking.
225
static bool opt_debugging= 0, opt_console= 0;
1 by brian
clean slate
226
static uint kill_cached_threads, wake_thread;
366 by Patrick Galbraith
Ulong conversion
227
static uint32_t killed_threads, thread_created;
228
static uint32_t max_used_connections;
229
static volatile uint32_t cached_thread_count= 0;
1 by brian
clean slate
230
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
231
static char *opt_init_slave, *language_ptr, *opt_init_connect;
232
static char *default_character_set_name;
233
static char *character_set_filesystem_name;
234
static char *lc_time_names_name;
235
static char *my_bind_addr_str;
236.1.40 by Monty Taylor
A few meaningless changes.
236
static char *default_collation_name;
1 by brian
clean slate
237
static char *default_storage_engine_str;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
238
static char compiled_default_collation_name[]= DRIZZLE_DEFAULT_COLLATION_NAME;
1 by brian
clean slate
239
static I_List<THD> thread_cache;
240
static double long_query_time;
241
242
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
243
244
/* Global variables */
245
92 by Brian Aker
Removed opt_update_log
246
bool opt_bin_log;
236.1.40 by Monty Taylor
A few meaningless changes.
247
bool opt_log;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
248
bool opt_slow_log;
1 by brian
clean slate
249
ulong log_output_options;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
250
bool opt_log_queries_not_using_indexes= false;
287.3.32 by Monty Taylor
Removed another useless define.
251
bool opt_error_log= 0;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
252
bool opt_skip_show_db= false;
150 by Brian Aker
More bool removal. More cow bell!
253
bool opt_character_set_client_handshake= 1;
1 by brian
clean slate
254
bool server_id_supplied = 0;
255
bool opt_endinfo, using_udf_functions;
150 by Brian Aker
More bool removal. More cow bell!
256
bool locked_in_memory;
1 by brian
clean slate
257
bool opt_using_transactions, using_update_log;
258
bool volatile abort_loop;
259
bool volatile shutdown_in_progress;
150 by Brian Aker
More bool removal. More cow bell!
260
bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted
261
bool opt_reckless_slave = 0;
262
bool opt_enable_named_pipe= 0;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
263
bool opt_local_infile;
264
bool opt_slave_compressed_protocol;
150 by Brian Aker
More bool removal. More cow bell!
265
bool opt_safe_user_create = 0;
266
bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
267
bool opt_log_slave_updates= 0;
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
268
static struct pollfd fds[UINT8_MAX];
269
static uint8_t pollfd_count= 0;
1 by brian
clean slate
270
271
/*
272
  Legacy global handlerton. These will be removed (please do not add more).
273
*/
274
handlerton *heap_hton;
275
handlerton *myisam_hton;
276
147 by Brian Aker
More my_bool conversion. This time the set_var class.
277
bool opt_readonly;
150 by Brian Aker
More bool removal. More cow bell!
278
bool use_temp_pool;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
279
bool relay_log_purge;
280
bool opt_sync_frm;
281
bool opt_secure_auth= false;
1 by brian
clean slate
282
char* opt_secure_file_priv= 0;
150 by Brian Aker
More bool removal. More cow bell!
283
bool opt_log_slow_admin_statements= 0;
284
bool opt_log_slow_slave_statements= 0;
285
bool opt_old_style_user_limits= 0;
286
bool trust_function_creators= 0;
1 by brian
clean slate
287
/*
288
  True if there is at least one per-hour limit for some user, so we should
289
  check them before each query (and possibly reset counters when hour is
290
  changed). False otherwise.
291
*/
150 by Brian Aker
More bool removal. More cow bell!
292
bool opt_noacl;
1 by brian
clean slate
293
294
ulong opt_binlog_rows_event_max_size;
295
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
296
TYPELIB binlog_format_typelib=
297
  { array_elements(binlog_format_names) - 1, "",
298
    binlog_format_names, NULL };
366 by Patrick Galbraith
Ulong conversion
299
uint32_t opt_binlog_format_id= (uint32_t) BINLOG_FORMAT_UNSPEC;
1 by brian
clean slate
300
const char *opt_binlog_format= binlog_format_names[opt_binlog_format_id];
301
#ifdef HAVE_INITGROUPS
163 by Brian Aker
Merge Monty's code.
302
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
1 by brian
clean slate
303
#endif
304
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
305
uint mysqld_port_timeout;
306
uint delay_key_write_options, protocol_version;
224.2.1 by Brian Aker
First pass for table name issue across platforms.
307
uint lower_case_table_names= 1;
1 by brian
clean slate
308
uint tc_heuristic_recover= 0;
309
uint volatile thread_count, thread_running;
151 by Brian Aker
Ulonglong to uint64_t
310
uint64_t thd_startup_options;
9 by Brian Aker
Warnings cleanup
311
ulong back_log, connect_timeout, server_id;
1 by brian
clean slate
312
ulong table_cache_size, table_def_size;
313
ulong what_to_log;
366 by Patrick Galbraith
Ulong conversion
314
ulong slow_launch_time, slave_open_temp_tables;
315
ulong open_files_limit;
316
ulong max_binlog_size;
317
ulong max_relay_log_size;
318
ulong slave_net_timeout;
319
ulong slave_trans_retries;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
320
bool slave_allow_batching;
1 by brian
clean slate
321
ulong slave_exec_mode_options;
322
const char *slave_exec_mode_str= "STRICT";
366 by Patrick Galbraith
Ulong conversion
323
ulong thread_cache_size= 0;
324
ulong thread_pool_size= 0;
325
ulong binlog_cache_size= 0;
326
ulong max_binlog_cache_size= 0;
327
uint32_t refresh_version;  /* Increments on each reload */
1 by brian
clean slate
328
query_id_t global_query_id;
366 by Patrick Galbraith
Ulong conversion
329
ulong aborted_threads;
330
ulong aborted_connects;
331
ulong specialflag= 0;
332
ulong binlog_cache_use= 0;
333
ulong binlog_cache_disk_use= 0;
334
ulong max_connections;
335
ulong max_connect_errors;
1 by brian
clean slate
336
uint  max_user_connections= 0;
366 by Patrick Galbraith
Ulong conversion
337
ulong thread_id=1L;
338
ulong current_pid;
339
ulong slow_launch_threads = 0;
340
ulong sync_binlog_period;
1 by brian
clean slate
341
ulong expire_logs_days = 0;
342
ulong rpl_recovery_rank=0;
343
const char *log_output_str= "FILE";
344
345
const double log_10[] = {
346
  1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
347
  1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
348
  1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029,
349
  1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039,
350
  1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049,
351
  1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059,
352
  1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069,
353
  1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079,
354
  1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089,
355
  1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099,
356
  1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
357
  1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
358
  1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
359
  1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
360
  1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
361
  1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
362
  1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169,
363
  1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179,
364
  1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189,
365
  1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199,
366
  1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209,
367
  1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219,
368
  1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229,
369
  1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239,
370
  1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249,
371
  1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259,
372
  1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269,
373
  1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279,
374
  1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289,
375
  1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299,
376
  1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308
377
};
378
379
time_t server_start_time, flush_status_time;
380
381
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
382
char *default_tz_name;
383
char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
384
char mysql_real_data_home[FN_REFLEN],
385
     language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
386
     *opt_init_file, *opt_tc_log_file;
387
char mysql_unpacked_real_data_home[FN_REFLEN];
388
uint reg_ext_length;
389
const key_map key_map_empty(0);
390
key_map key_map_full(0);                        // Will be initialized later
391
392
const char *opt_date_time_formats[3];
393
394
uint mysql_data_home_len;
395
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
396
char server_version[SERVER_VERSION_LENGTH];
11 by Brian Aker
Removing old UNIX socket bits
397
char *opt_mysql_tmpdir;
1 by brian
clean slate
398
const char *myisam_recover_options_str="OFF";
399
const char *myisam_stats_method_str="nulls_unequal";
400
401
/** name of reference on left espression in rewritten IN subquery */
402
const char *in_left_expr_name= "<left expr>";
403
/** name of additional condition */
404
const char *in_additional_cond= "<IN COND>";
405
const char *in_having_cond= "<IN HAVING>";
406
407
my_decimal decimal_zero;
408
/* classes for comparation parsing/processing */
409
Eq_creator eq_creator;
410
Ne_creator ne_creator;
411
Gt_creator gt_creator;
412
Lt_creator lt_creator;
413
Ge_creator ge_creator;
414
Le_creator le_creator;
415
416
FILE *stderror_file=0;
417
418
I_List<THD> threads;
419
I_List<NAMED_LIST> key_caches;
420
Rpl_filter* rpl_filter;
421
Rpl_filter* binlog_filter;
422
423
struct system_variables global_system_variables;
424
struct system_variables max_system_variables;
425
struct system_status_var global_status_var;
426
427
MY_TMPDIR mysql_tmpdir_list;
428
MY_BITMAP temp_pool;
429
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
430
const CHARSET_INFO *system_charset_info, *files_charset_info ;
431
const CHARSET_INFO *national_charset_info, *table_alias_charset;
432
const CHARSET_INFO *character_set_filesystem;
1 by brian
clean slate
433
434
MY_LOCALE *my_default_lc_time_names;
435
177.3.1 by mark
remove ifdef HAVE_DLOPEN, make configure require dlopen()
436
SHOW_COMP_OPTION have_symlink;
437
SHOW_COMP_OPTION have_compress;
1 by brian
clean slate
438
439
/* Thread specific variables */
440
441
pthread_key(MEM_ROOT**,THR_MALLOC);
442
pthread_key(THD*, THR_THD);
443
pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
327.2.2 by Brian Aker
Removed dead/not used code.
444
		LOCK_status, LOCK_global_read_lock,
1 by brian
clean slate
445
		LOCK_error_log, LOCK_uuid_generator,
446
	        LOCK_global_system_variables,
447
		LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
448
                LOCK_connection_count;
449
450
rw_lock_t	LOCK_sys_init_connect, LOCK_sys_init_slave;
451
rw_lock_t	LOCK_system_variables_hash;
452
pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
453
pthread_t signal_thread;
454
pthread_attr_t connection_attrib;
455
pthread_cond_t  COND_server_started;
456
457
/* replication parameters, if master_host is not NULL, we are a slave */
301 by Brian Aker
Clean up port startup
458
uint report_port= DRIZZLE_PORT;
130 by Brian Aker
ulong cleanup
459
uint32_t master_retry_count= 0;
1 by brian
clean slate
460
char *master_info_file;
461
char *relay_log_info_file, *report_user, *report_password, *report_host;
462
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
463
char *opt_logname, *opt_slow_logname;
464
465
/* Static variables */
466
467
static bool kill_in_progress, segfaulted;
468
#ifdef HAVE_STACK_TRACE_ON_SEGV
150 by Brian Aker
More bool removal. More cow bell!
469
static bool opt_do_pstack;
1 by brian
clean slate
470
#endif /* HAVE_STACK_TRACE_ON_SEGV */
471
static int cleanup_done;
366 by Patrick Galbraith
Ulong conversion
472
static uint32_t opt_myisam_block_size;
92 by Brian Aker
Removed opt_update_log
473
static char *opt_binlog_index_name;
1 by brian
clean slate
474
static char *opt_tc_heuristic_recover;
475
static char *mysql_home_ptr, *pidfile_name_ptr;
476
static int defaults_argc;
477
static char **defaults_argv;
478
static char *opt_bin_logname;
479
480
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
481
482
struct passwd *user_info;
483
static pthread_t select_thread;
484
static uint thr_kill_signal;
485
486
/* OS specific variables */
487
488
bool mysqld_embedded=0;
489
490
scheduler_functions thread_scheduler;
491
492
/**
493
  Number of currently active user connections. The variable is protected by
494
  LOCK_connection_count.
495
*/
496
uint connection_count= 0;
497
498
/* Function declarations */
499
500
pthread_handler_t signal_hand(void *arg);
501
static void mysql_init_variables(void);
502
static void get_options(int *argc,char **argv);
143 by Brian Aker
Bool cleanup.
503
extern "C" bool mysqld_get_one_option(int, const struct my_option *, char *);
1 by brian
clean slate
504
static void set_server_version(void);
505
static int init_thread_environment();
506
static char *get_relative_path(const char *path);
507
static void fix_paths(void);
11 by Brian Aker
Removing old UNIX socket bits
508
void handle_connections_sockets();
1 by brian
clean slate
509
pthread_handler_t kill_server_thread(void *arg);
510
pthread_handler_t handle_slave(void *arg);
366 by Patrick Galbraith
Ulong conversion
511
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib);
512
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
1 by brian
clean slate
513
                                   const char *option);
514
static void clean_up(bool print_message);
515
516
static void usage(void);
517
static void start_signal_handler(void);
518
static void close_server_sock();
519
static void clean_up_mutexes(void);
520
static void wait_for_signal_thread_to_end(void);
521
static void create_pid_file();
522
static void mysqld_exit(int exit_code) __attribute__((noreturn));
523
524
/****************************************************************************
525
** Code to end mysqld
526
****************************************************************************/
527
528
static void close_connections(void)
529
{
530
#ifdef EXTRA_DEBUG
531
  int count=0;
532
#endif
533
534
  /* Clear thread cache */
535
  kill_cached_threads++;
536
  flush_thread_cache();
537
538
  /* kill connection thread */
539
  (void) pthread_mutex_lock(&LOCK_thread_count);
540
541
  while (select_thread_in_use)
542
  {
543
    struct timespec abstime;
544
    int error;
545
546
#ifndef DONT_USE_THR_ALARM
547
    if (pthread_kill(select_thread, thr_client_alarm))
548
      break;					// allready dead
549
#endif
550
    set_timespec(abstime, 2);
551
    for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
552
    {
553
      error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count,
554
				   &abstime);
555
      if (error != EINTR)
556
	break;
557
    }
558
#ifdef EXTRA_DEBUG
559
    if (error != 0 && !count++)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
560
      sql_print_error(_("Got error %d from pthread_cond_timedwait"),error);
1 by brian
clean slate
561
#endif
562
    close_server_sock();
563
  }
564
  (void) pthread_mutex_unlock(&LOCK_thread_count);
565
566
567
  /* Abort listening to new connections */
568
  {
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
569
    int x;
236.1.40 by Monty Taylor
A few meaningless changes.
570
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
571
    for (x= 0; x < pollfd_count; x++)
572
    {
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
573
      if (fds[x].fd != -1)
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
574
      {
575
        (void) shutdown(fds[x].fd, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
576
        (void) close(fds[x].fd);
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
577
        fds[x].fd= -1;
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
578
      }
579
    }
1 by brian
clean slate
580
  }
228 by Brian Aker
First pass on socket cleanup.
581
1 by brian
clean slate
582
  end_thr_alarm(0);			 // Abort old alarms.
583
584
  /*
585
    First signal all threads that it's time to die
586
    This will give the threads some time to gracefully abort their
587
    statements and inform their clients that the server is about to die.
588
  */
589
590
  THD *tmp;
591
  (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
592
593
  I_List_iterator<THD> it(threads);
594
  while ((tmp=it++))
595
  {
596
    /* We skip slave threads & scheduler on this first loop through. */
597
    if (tmp->slave_thread)
598
      continue;
599
600
    tmp->killed= THD::KILL_CONNECTION;
601
    thread_scheduler.post_kill_notification(tmp);
602
    if (tmp->mysys_var)
603
    {
604
      tmp->mysys_var->abort=1;
605
      pthread_mutex_lock(&tmp->mysys_var->mutex);
606
      if (tmp->mysys_var->current_cond)
607
      {
608
	pthread_mutex_lock(tmp->mysys_var->current_mutex);
609
	pthread_cond_broadcast(tmp->mysys_var->current_cond);
610
	pthread_mutex_unlock(tmp->mysys_var->current_mutex);
611
      }
612
      pthread_mutex_unlock(&tmp->mysys_var->mutex);
613
    }
614
  }
615
  (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
616
617
  end_slave();
618
619
  if (thread_count)
620
    sleep(2);					// Give threads time to die
621
622
  /*
623
    Force remaining threads to die by closing the connection to the client
624
    This will ensure that threads that are waiting for a command from the
625
    client on a blocking read call are aborted.
626
  */
627
628
  for (;;)
629
  {
630
    (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
631
    if (!(tmp=threads.get()))
632
    {
633
      (void) pthread_mutex_unlock(&LOCK_thread_count);
634
      break;
635
    }
636
    if (tmp->vio_ok())
637
    {
638
      if (global_system_variables.log_warnings)
639
        sql_print_warning(ER(ER_FORCING_CLOSE),my_progname,
640
                          tmp->thread_id,
641
                          (tmp->main_security_ctx.user ?
642
                           tmp->main_security_ctx.user : ""));
643
      close_connection(tmp,0,0);
644
    }
645
    (void) pthread_mutex_unlock(&LOCK_thread_count);
646
  }
647
  /* All threads has now been aborted */
648
  (void) pthread_mutex_lock(&LOCK_thread_count);
649
  while (thread_count)
650
  {
651
    (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
652
  }
653
  (void) pthread_mutex_unlock(&LOCK_thread_count);
654
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
655
  return;;
1 by brian
clean slate
656
}
657
658
659
static void close_server_sock()
660
{
661
#ifdef HAVE_CLOSE_SERVER_SOCK
662
  {
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
663
    int x;
236.1.40 by Monty Taylor
A few meaningless changes.
664
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
665
    for (x= 0; x < pollfd_count; x++)
666
    {
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
667
      if (fds[x].fd != -1)
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
668
      {
669
        (void) shutdown(fds[x].fd, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
670
        (void) close(fds[x].fd);
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
671
        fds[x].fd= -1;
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
672
      }
673
    }
1 by brian
clean slate
674
  }
675
#endif
676
}
677
678
679
void kill_mysql(void)
680
{
681
682
#if defined(SIGNALS_DONT_BREAK_READ)
683
  abort_loop=1;					// Break connection loops
684
  close_server_sock();				// Force accept to wake up
685
#endif
686
687
#if defined(HAVE_PTHREAD_KILL)
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
688
  pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
1 by brian
clean slate
689
#elif !defined(SIGNALS_DONT_BREAK_READ)
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
690
  kill(current_pid, DRIZZLE_KILL_SIGNAL);
1 by brian
clean slate
691
#endif
692
  shutdown_in_progress=1;			// Safety if kill didn't work
693
#ifdef SIGNALS_DONT_BREAK_READ
694
  if (!kill_in_progress)
695
  {
696
    pthread_t tmp;
697
    abort_loop=1;
698
    if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
699
			   (void*) 0))
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
700
      sql_print_error(_("Can't create thread to kill server"));
1 by brian
clean slate
701
  }
702
#endif
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
703
  return;;
1 by brian
clean slate
704
}
705
706
/**
707
  Force server down. Kill all connections and threads and exit.
708
709
  @param  sig_ptr       Signal number that caused kill_server to be called.
710
711
  @note
712
    A signal number of 0 mean that the function was not called
713
    from a signal handler and there is thus no signal to block
714
    or stop, we just want to kill the server.
715
*/
716
717
static void *kill_server(void *sig_ptr)
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
718
#define RETURN_FROM_KILL_SERVER return(0)
1 by brian
clean slate
719
{
720
  int sig=(int) (long) sig_ptr;			// This is passed a int
721
  // if there is a signal during the kill in progress, ignore the other
722
  if (kill_in_progress)				// Safety
723
    RETURN_FROM_KILL_SERVER;
163 by Brian Aker
Merge Monty's code.
724
  kill_in_progress=true;
1 by brian
clean slate
725
  abort_loop=1;					// This should be set
726
  if (sig != 0) // 0 is not a valid signal number
727
    my_sigset(sig, SIG_IGN);                    /* purify inspected */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
728
  if (sig == DRIZZLE_KILL_SIGNAL || sig == 0)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
729
    sql_print_information(_(ER(ER_NORMAL_SHUTDOWN)),my_progname);
1 by brian
clean slate
730
  else
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
731
    sql_print_error(_(ER(ER_GOT_SIGNAL)),my_progname,sig); /* purecov: inspected */
236.1.40 by Monty Taylor
A few meaningless changes.
732
1 by brian
clean slate
733
  close_connections();
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
734
  if (sig != DRIZZLE_KILL_SIGNAL &&
1 by brian
clean slate
735
      sig != 0)
736
    unireg_abort(1);				/* purecov: inspected */
737
  else
738
    unireg_end();
739
740
  /* purecov: begin deadcode */
741
742
  my_thread_end();
743
  pthread_exit(0);
744
  /* purecov: end */
745
746
  RETURN_FROM_KILL_SERVER;
747
}
748
749
750
#if defined(USE_ONE_SIGNAL_HAND)
751
pthread_handler_t kill_server_thread(void *arg __attribute__((unused)))
752
{
753
  my_thread_init();				// Initialize new thread
754
  kill_server(0);
755
  /* purecov: begin deadcode */
756
  my_thread_end();
757
  pthread_exit(0);
758
  return 0;
759
  /* purecov: end */
760
}
761
#endif
762
763
764
extern "C" sig_handler print_signal_warning(int sig)
765
{
766
  if (global_system_variables.log_warnings)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
767
    sql_print_warning(_("Got signal %d from thread %ld"), sig,my_thread_id());
1 by brian
clean slate
768
#ifdef DONT_REMEMBER_SIGNAL
769
  my_sigset(sig,print_signal_warning);		/* int. thread system calls */
770
#endif
771
  if (sig == SIGALRM)
772
    alarm(2);					/* reschedule alarm */
773
}
774
775
/**
776
  cleanup all memory and end program nicely.
777
778
    If SIGNALS_DONT_BREAK_READ is defined, this function is called
779
    by the main thread. To get MySQL to shut down nicely in this case
780
    (Mac OS X) we have to call exit() instead if pthread_exit().
781
782
  @note
783
    This function never returns.
784
*/
785
void unireg_end(void)
786
{
787
  clean_up(1);
788
  my_thread_end();
789
#if defined(SIGNALS_DONT_BREAK_READ)
790
  exit(0);
791
#else
792
  pthread_exit(0);				// Exit is in main thread
793
#endif
794
}
795
796
797
extern "C" void unireg_abort(int exit_code)
798
{
799
800
  if (exit_code)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
801
    sql_print_error(_("Aborting\n"));
1 by brian
clean slate
802
  else if (opt_help)
803
    usage();
228 by Brian Aker
First pass on socket cleanup.
804
  clean_up(!opt_help && (exit_code)); /* purecov: inspected */
1 by brian
clean slate
805
  mysqld_exit(exit_code);
806
}
807
808
809
static void mysqld_exit(int exit_code)
810
{
811
  wait_for_signal_thread_to_end();
812
  clean_up_mutexes();
813
  my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
814
  exit(exit_code); /* purecov: inspected */
815
}
816
817
818
void clean_up(bool print_message)
819
{
820
  if (cleanup_done++)
821
    return; /* purecov: inspected */
822
823
  /*
824
    make sure that handlers finish up
825
    what they have that is dependent on the binlog
826
  */
827
  ha_binlog_end(current_thd);
828
829
  logger.cleanup_base();
830
831
  mysql_bin_log.cleanup();
832
833
  if (use_slave_mask)
834
    bitmap_free(&slave_error_mask);
835
  my_database_names_free();
836
  table_cache_free();
837
  table_def_free();
838
  lex_free();				/* Free some memory */
839
  item_create_cleanup();
840
  set_var_free();
841
  free_charsets();
842
  udf_free();
843
  plugin_shutdown();
844
  ha_end();
845
  if (tc_log)
846
    tc_log->close();
847
  xid_cache_free();
848
  delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
849
  multi_keycache_free();
850
  free_status_vars();
851
  end_thr_alarm(1);			/* Free allocated memory */
852
  my_free_open_file_info();
853
  my_free((char*) global_system_variables.date_format,
854
	  MYF(MY_ALLOW_ZERO_PTR));
855
  my_free((char*) global_system_variables.time_format,
856
	  MYF(MY_ALLOW_ZERO_PTR));
857
  my_free((char*) global_system_variables.datetime_format,
858
	  MYF(MY_ALLOW_ZERO_PTR));
859
  if (defaults_argv)
860
    free_defaults(defaults_argv);
861
  my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR));
862
  my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR));
863
  my_free(sys_var_general_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
864
  my_free(sys_var_slow_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
865
  free_tmpdir(&mysql_tmpdir_list);
866
  my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
867
  x_free(opt_bin_logname);
868
  x_free(opt_relay_logname);
869
  x_free(opt_secure_file_priv);
870
  bitmap_free(&temp_pool);
871
  end_slave_list();
872
  delete binlog_filter;
873
  delete rpl_filter;
874
  vio_end();
875
228 by Brian Aker
First pass on socket cleanup.
876
  (void) my_delete(pidfile_name,MYF(0));	// This may not always exist
877
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
878
  if (print_message && server_start_time)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
879
    sql_print_information(_(ER(ER_SHUTDOWN_COMPLETE)),my_progname);
1 by brian
clean slate
880
  thread_scheduler.end();
202.3.7 by Monty Taylor
Gettext error compiles and passes test!
881
  /* Returns NULL on globerrs, we don't want to try to free that */
882
  //void *freeme=
883
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
884
  // TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
885
/*  if (freeme != NULL)
886
    my_free(freeme, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));  */
1 by brian
clean slate
887
  /* Tell main we are ready */
888
  logger.cleanup_end();
889
  (void) pthread_mutex_lock(&LOCK_thread_count);
890
  ready_to_exit=1;
891
  /* do the broadcast inside the lock to ensure that my_end() is not called */
892
  (void) pthread_cond_broadcast(&COND_thread_count);
893
  (void) pthread_mutex_unlock(&LOCK_thread_count);
894
895
  /*
896
    The following lines may never be executed as the main thread may have
897
    killed us
898
  */
899
} /* clean_up */
900
901
902
/**
903
  This is mainly needed when running with purify, but it's still nice to
904
  know that all child threads have died when mysqld exits.
905
*/
906
static void wait_for_signal_thread_to_end()
907
{
908
  uint i;
909
  /*
910
    Wait up to 10 seconds for signal thread to die. We use this mainly to
911
    avoid getting warnings that my_thread_end has not been called
912
  */
913
  for (i= 0 ; i < 100 && signal_thread_in_use; i++)
914
  {
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
915
    if (pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL) != ESRCH)
1 by brian
clean slate
916
      break;
917
    my_sleep(100);				// Give it time to die
918
  }
919
}
920
921
922
static void clean_up_mutexes()
923
{
924
  (void) pthread_mutex_destroy(&LOCK_mysql_create_db);
925
  (void) pthread_mutex_destroy(&LOCK_lock_db);
926
  (void) pthread_mutex_destroy(&LOCK_open);
927
  (void) pthread_mutex_destroy(&LOCK_thread_count);
928
  (void) pthread_mutex_destroy(&LOCK_status);
929
  (void) pthread_mutex_destroy(&LOCK_error_log);
930
  (void) pthread_mutex_destroy(&LOCK_user_conn);
931
  (void) pthread_mutex_destroy(&LOCK_connection_count);
932
  (void) pthread_mutex_destroy(&LOCK_rpl_status);
933
  (void) pthread_cond_destroy(&COND_rpl_status);
934
  (void) pthread_mutex_destroy(&LOCK_active_mi);
935
  (void) rwlock_destroy(&LOCK_sys_init_connect);
936
  (void) rwlock_destroy(&LOCK_sys_init_slave);
937
  (void) pthread_mutex_destroy(&LOCK_global_system_variables);
938
  (void) rwlock_destroy(&LOCK_system_variables_hash);
939
  (void) pthread_mutex_destroy(&LOCK_global_read_lock);
940
  (void) pthread_mutex_destroy(&LOCK_uuid_generator);
941
  (void) pthread_cond_destroy(&COND_thread_count);
942
  (void) pthread_cond_destroy(&COND_refresh);
943
  (void) pthread_cond_destroy(&COND_global_read_lock);
944
  (void) pthread_cond_destroy(&COND_thread_cache);
945
  (void) pthread_cond_destroy(&COND_flush_thread_cache);
946
}
947
948
949
/****************************************************************************
950
** Init IP and UNIX socket
951
****************************************************************************/
952
953
static void set_ports()
954
{
955
  char	*env;
228 by Brian Aker
First pass on socket cleanup.
956
  if (!mysqld_port)
1 by brian
clean slate
957
  {					// Get port if not from commandline
301 by Brian Aker
Clean up port startup
958
    mysqld_port= DRIZZLE_PORT;
1 by brian
clean slate
959
960
    /*
961
      if builder specifically requested a default port, use that
962
      (even if it coincides with our factory default).
963
      only if they didn't do we check /etc/services (and, failing
165.1.1 by Elliot Murphy
new port number from IANA
964
      on that, fall back to the factory default of 4427).
1 by brian
clean slate
965
      either default can be overridden by the environment variable
301 by Brian Aker
Clean up port startup
966
      DRIZZLE_TCP_PORT, which in turn can be overridden with command
1 by brian
clean slate
967
      line options.
968
    */
969
970
    struct  servent *serv_ptr;
301 by Brian Aker
Clean up port startup
971
    if ((serv_ptr= getservbyname("drizzle", "tcp")))
1 by brian
clean slate
972
      mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
973
301 by Brian Aker
Clean up port startup
974
    if ((env = getenv("DRIZZLE_TCP_PORT")))
1 by brian
clean slate
975
      mysqld_port= (uint) atoi(env);		/* purecov: inspected */
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
976
977
    assert(mysqld_port);
1 by brian
clean slate
978
  }
979
}
980
981
/* Change to run as another user if started with --user */
982
983
static struct passwd *check_user(const char *user)
984
{
985
  struct passwd *tmp_user_info;
986
  uid_t user_id= geteuid();
987
988
  // Don't bother if we aren't superuser
989
  if (user_id)
990
  {
991
    if (user)
992
    {
993
      /* Don't give a warning, if real user is same as given with --user */
994
      /* purecov: begin tested */
995
      tmp_user_info= getpwnam(user);
996
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
997
          global_system_variables.log_warnings)
998
        sql_print_warning(_("One can only use the --user switch "
999
                            "if running as root\n"));
1 by brian
clean slate
1000
      /* purecov: end */
1001
    }
1002
    return NULL;
1003
  }
1004
  if (!user)
1005
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1006
    sql_print_error(_("Fatal error: Please read \"Security\" section of "
1007
                      "the manual to find out how to run mysqld as root!\n"));
228 by Brian Aker
First pass on socket cleanup.
1008
    unireg_abort(1);
1009
1 by brian
clean slate
1010
    return NULL;
1011
  }
1012
  /* purecov: begin tested */
1013
  if (!strcmp(user,"root"))
1014
    return NULL;                        // Avoid problem with dynamic libraries
1015
1016
  if (!(tmp_user_info= getpwnam(user)))
1017
  {
1018
    // Allow a numeric uid to be used
1019
    const char *pos;
1020
    for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
1021
    if (*pos)                                   // Not numeric id
1022
      goto err;
1023
    if (!(tmp_user_info= getpwuid(atoi(user))))
1024
      goto err;
1025
  }
1026
  return tmp_user_info;
1027
  /* purecov: end */
1028
1029
err:
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1030
  sql_print_error(_("Fatal error: Can't change to run as user '%s' ;  "
1031
                    "Please check that the user exists!\n"),user);
1 by brian
clean slate
1032
  unireg_abort(1);
1033
1034
#ifdef PR_SET_DUMPABLE
1035
  if (test_flags & TEST_CORE_ON_SIGNAL)
1036
  {
1037
    /* inform kernel that process is dumpable */
1038
    (void) prctl(PR_SET_DUMPABLE, 1);
1039
  }
1040
#endif
1041
1042
  return NULL;
1043
}
1044
1045
static void set_user(const char *user, struct passwd *user_info_arg)
1046
{
1047
  /* purecov: begin tested */
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1048
  assert(user_info_arg != 0);
1 by brian
clean slate
1049
#ifdef HAVE_INITGROUPS
1050
  /*
1051
    We can get a SIGSEGV when calling initgroups() on some systems when NSS
1052
    is configured to use LDAP and the server is statically linked.  We set
1053
    calling_initgroups as a flag to the SIGSEGV handler that is then used to
1054
    output a specific message to help the user resolve this problem.
1055
  */
163 by Brian Aker
Merge Monty's code.
1056
  calling_initgroups= true;
1 by brian
clean slate
1057
  initgroups((char*) user, user_info_arg->pw_gid);
163 by Brian Aker
Merge Monty's code.
1058
  calling_initgroups= false;
1 by brian
clean slate
1059
#endif
1060
  if (setgid(user_info_arg->pw_gid) == -1)
1061
  {
1062
    sql_perror("setgid");
1063
    unireg_abort(1);
1064
  }
1065
  if (setuid(user_info_arg->pw_uid) == -1)
1066
  {
1067
    sql_perror("setuid");
1068
    unireg_abort(1);
1069
  }
1070
  /* purecov: end */
1071
}
1072
1073
1074
static void set_effective_user(struct passwd *user_info_arg)
1075
{
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1076
  assert(user_info_arg != 0);
1 by brian
clean slate
1077
  if (setregid((gid_t)-1, user_info_arg->pw_gid) == -1)
1078
  {
1079
    sql_perror("setregid");
1080
    unireg_abort(1);
1081
  }
1082
  if (setreuid((uid_t)-1, user_info_arg->pw_uid) == -1)
1083
  {
1084
    sql_perror("setreuid");
1085
    unireg_abort(1);
1086
  }
1087
}
1088
1089
1090
/** Change root user if started with @c --chroot . */
1091
static void set_root(const char *path)
1092
{
1093
  if (chroot(path) == -1)
1094
  {
1095
    sql_perror("chroot");
1096
    unireg_abort(1);
1097
  }
1098
  my_setwd("/", MYF(0));
1099
}
1100
1101
1102
static void network_init(void)
1103
{
1104
  int   ret;
1105
  uint  waited;
1106
  uint  this_wait;
1107
  uint  retry;
1108
  char port_buf[NI_MAXSERV];
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1109
  struct addrinfo *ai;
1110
  struct addrinfo *next;
1111
  struct addrinfo hints;
1112
  int error;
1 by brian
clean slate
1113
1114
  if (thread_scheduler.init())
1115
    unireg_abort(1);			/* purecov: inspected */
1116
1117
  set_ports();
1118
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1119
  memset(fds, 0, sizeof(struct pollfd) * UINT8_MAX);
1120
  memset(&hints, 0, sizeof (hints));
1121
  hints.ai_flags= AI_PASSIVE;
1122
  hints.ai_socktype= SOCK_STREAM;
1123
1124
  snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
1125
  error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
1126
  if (error != 0)
1127
  {
1128
    sql_perror(ER(ER_IPSOCK_ERROR));		/* purecov: tested */
1129
    unireg_abort(1);				/* purecov: tested */
1130
  }
1131
1132
  for (next= ai, pollfd_count= 0; next; next= next->ai_next, pollfd_count++)
1133
  {
1134
    int ip_sock;
1135
1136
    ip_sock= socket(next->ai_family, next->ai_socktype, next->ai_protocol);
1 by brian
clean slate
1137
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
1138
    if (ip_sock == -1)
1 by brian
clean slate
1139
    {
1140
      sql_perror(ER(ER_IPSOCK_ERROR));		/* purecov: tested */
1141
      unireg_abort(1);				/* purecov: tested */
1142
    }
1143
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1144
    fds[pollfd_count].fd= ip_sock;
1145
    fds[pollfd_count].events= POLLIN | POLLERR;
1146
231 by Brian Aker
Move reuse to working location :)
1147
    /* Add options for our listening socket */
1148
    {
267 by Brian Aker
More error control around socket calls.
1149
      int error;
231 by Brian Aker
Move reuse to working location :)
1150
      struct linger ling = {0, 0};
1151
      int flags =1;
1152
287.2.3 by Andrew Garner
fixed identation problems
1153
#ifdef IPV6_V6ONLY
293 by Brian Aker
Merge + closesocket() fix
1154
      if (next->ai_family == AF_INET6) 
1155
      {
287.2.3 by Andrew Garner
fixed identation problems
1156
        error= setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags));
287.2.1 by Andrew Garner
enable ipv6 in drizzled
1157
        if (error != 0)
1158
        {
1159
          perror("setsockopt");
1160
          assert(error == 0);
1161
        }
1162
      }
287.2.3 by Andrew Garner
fixed identation problems
1163
#endif   
267 by Brian Aker
More error control around socket calls.
1164
      error= setsockopt(ip_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&flags, sizeof(flags));
1165
      if (error != 0)
1166
      {
1167
        perror("setsockopt");
1168
        assert(error == 0);
1169
      }
1170
      error= setsockopt(ip_sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags));
1171
      if (error != 0)
1172
      {
1173
        perror("setsockopt");
1174
        assert(error == 0);
1175
      }
1176
      error= setsockopt(ip_sock, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling));
1177
      if (error != 0)
1178
      {
1179
        perror("setsockopt");
1180
        assert(error == 0);
1181
      }
1182
      error= setsockopt(ip_sock, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags));
1183
      if (error != 0)
1184
      {
1185
        perror("setsockopt");
1186
        assert(error == 0);
1187
      }
231 by Brian Aker
Move reuse to working location :)
1188
    }
1189
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1190
1 by brian
clean slate
1191
    /*
1192
      Sometimes the port is not released fast enough when stopping and
1193
      restarting the server. This happens quite often with the test suite
1194
      on busy Linux systems. Retry to bind the address at these intervals:
1195
      Sleep intervals: 1, 2, 4,  6,  9, 13, 17, 22, ...
1196
      Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ...
1197
      Limit the sequence by mysqld_port_timeout (set --port-open-timeout=#).
1198
    */
1199
    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1200
    {
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1201
      if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1 by brian
clean slate
1202
          (socket_errno != SOCKET_EADDRINUSE) ||
1203
          (waited >= mysqld_port_timeout))
1204
        break;
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1205
      sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
1 by brian
clean slate
1206
      this_wait= retry * retry / 3 + 1;
1207
      sleep(this_wait);
1208
    }
1209
    if (ret < 0)
1210
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1211
      sql_perror(_("Can't start server: Bind on TCP/IP port"));
1212
      sql_print_error(_("Do you already have another drizzled server running "
1213
                        "on port: %d ?"),mysqld_port);
1 by brian
clean slate
1214
      unireg_abort(1);
1215
    }
1216
    if (listen(ip_sock,(int) back_log) < 0)
1217
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1218
      sql_perror(_("Can't start server: listen() on TCP/IP port"));
1219
      sql_print_error(_("listen() on TCP/IP failed with error %d"),
1220
                      socket_errno);
1 by brian
clean slate
1221
      unireg_abort(1);
1222
    }
1223
  }
1224
287.2.1 by Andrew Garner
enable ipv6 in drizzled
1225
  freeaddrinfo(ai);
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
1226
  return;
1 by brian
clean slate
1227
}
1228
1229
/**
1230
  Close a connection.
1231
1232
  @param thd		Thread handle
1233
  @param errcode	Error code to print to console
1234
  @param lock	        1 if we have have to lock LOCK_thread_count
1235
1236
  @note
1237
    For the connection that is doing shutdown, this is called twice
1238
*/
1239
void close_connection(THD *thd, uint errcode, bool lock)
1240
{
1241
  st_vio *vio;
1242
  if (lock)
1243
    (void) pthread_mutex_lock(&LOCK_thread_count);
1244
  thd->killed= THD::KILL_CONNECTION;
1245
  if ((vio= thd->net.vio) != 0)
1246
  {
1247
    if (errcode)
1248
      net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
1249
    vio_close(vio);			/* vio is freed in delete thd */
1250
  }
1251
  if (lock)
1252
    (void) pthread_mutex_unlock(&LOCK_thread_count);
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1253
  return;;
1 by brian
clean slate
1254
}
1255
1256
1257
/** Called when a thread is aborted. */
1258
/* ARGSUSED */
1259
extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
1260
{
1261
  THD *thd=current_thd;
1262
  if (thd && ! thd->bootstrap)
1263
  {
1264
    statistic_increment(killed_threads, &LOCK_status);
1265
    thread_scheduler.end_thread(thd,0);		/* purecov: inspected */
1266
  }
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1267
  return;;				/* purecov: deadcode */
1 by brian
clean slate
1268
}
1269
1270
1271
/*
1272
  Unlink thd from global list of available connections and free thd
1273
1274
  SYNOPSIS
1275
    unlink_thd()
1276
    thd		 Thread handler
1277
1278
  NOTES
1279
    LOCK_thread_count is locked and left locked
1280
*/
1281
1282
void unlink_thd(THD *thd)
1283
{
1284
  thd->cleanup();
1285
1286
  pthread_mutex_lock(&LOCK_connection_count);
1287
  --connection_count;
1288
  pthread_mutex_unlock(&LOCK_connection_count);
1289
1290
  (void) pthread_mutex_lock(&LOCK_thread_count);
1291
  thread_count--;
1292
  delete thd;
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1293
  return;;
1 by brian
clean slate
1294
}
1295
1296
1297
/*
1298
  Store thread in cache for reuse by new connections
1299
1300
  SYNOPSIS
1301
    cache_thread()
1302
1303
  NOTES
1304
    LOCK_thread_count has to be locked
1305
1306
  RETURN
1307
    0  Thread was not put in cache
1308
    1  Thread is to be reused by new connection.
1309
       (ie, caller should return, not abort with pthread_exit())
1310
*/
1311
1312
1313
static bool cache_thread()
1314
{
1315
  safe_mutex_assert_owner(&LOCK_thread_count);
1316
  if (cached_thread_count < thread_cache_size &&
1317
      ! abort_loop && !kill_cached_threads)
1318
  {
1319
    /* Don't kill the thread, just put it in cache for reuse */
1320
    cached_thread_count++;
1321
    while (!abort_loop && ! wake_thread && ! kill_cached_threads)
1322
      (void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
1323
    cached_thread_count--;
1324
    if (kill_cached_threads)
1325
      pthread_cond_signal(&COND_flush_thread_cache);
1326
    if (wake_thread)
1327
    {
1328
      THD *thd;
1329
      wake_thread--;
1330
      thd= thread_cache.get();
1331
      thd->thread_stack= (char*) &thd;          // For store_globals
1332
      (void) thd->store_globals();
1333
      /*
1334
        THD::mysys_var::abort is associated with physical thread rather
1335
        than with THD object. So we need to reset this flag before using
1336
        this thread for handling of new THD object/connection.
1337
      */
1338
      thd->mysys_var->abort= 0;
1339
      thd->thr_create_utime= my_micro_time();
1340
      threads.append(thd);
1341
      return(1);
1342
    }
1343
  }
1344
  return(0);
1345
}
1346
1347
1348
/*
1349
  End thread for the current connection
1350
1351
  SYNOPSIS
1352
    one_thread_per_connection_end()
1353
    thd		  Thread handler
1354
    put_in_cache  Store thread in cache, if there is room in it
1355
                  Normally this is true in all cases except when we got
1356
                  out of resources initializing the current thread
1357
1358
  NOTES
1359
    If thread is cached, we will wait until thread is scheduled to be
1360
    reused and then we will return.
1361
    If thread is not cached, we end the thread.
1362
1363
  RETURN
1364
    0    Signal to handle_one_connection to reuse connection
1365
*/
1366
1367
bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
1368
{
1369
  unlink_thd(thd);
1370
  if (put_in_cache)
1371
    put_in_cache= cache_thread();
1372
  pthread_mutex_unlock(&LOCK_thread_count);
1373
  if (put_in_cache)
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1374
    return(0);                             // Thread is reused
1 by brian
clean slate
1375
1376
  /* It's safe to broadcast outside a lock (COND... is not deleted here) */
1377
  my_thread_end();
1378
  (void) pthread_cond_broadcast(&COND_thread_count);
1379
1380
  pthread_exit(0);
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1381
  return(0);                               // Impossible
1 by brian
clean slate
1382
}
1383
1384
1385
void flush_thread_cache()
1386
{
1387
  (void) pthread_mutex_lock(&LOCK_thread_count);
1388
  kill_cached_threads++;
1389
  while (cached_thread_count)
1390
  {
1391
    pthread_cond_broadcast(&COND_thread_cache);
1392
    pthread_cond_wait(&COND_flush_thread_cache,&LOCK_thread_count);
1393
  }
1394
  kill_cached_threads--;
1395
  (void) pthread_mutex_unlock(&LOCK_thread_count);
1396
}
1397
1398
1399
#ifdef THREAD_SPECIFIC_SIGPIPE
1400
/**
1401
  Aborts a thread nicely. Comes here on SIGPIPE.
1402
1403
  @todo
1404
    One should have to fix that thr_alarm know about this thread too.
1405
*/
1406
extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
1407
{
1408
  THD *thd=current_thd;
1409
  if (thd)
1410
    thd->killed= THD::KILL_CONNECTION;
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1411
  return;;
1 by brian
clean slate
1412
}
1413
#endif
1414
1415
#if BACKTRACE_DEMANGLE
1416
#include <cxxabi.h>
1417
extern "C" char *my_demangle(const char *mangled_name, int *status)
1418
{
1419
  return abi::__cxa_demangle(mangled_name, NULL, NULL, status);
1420
}
1421
#endif
1422
1423
1424
extern "C" sig_handler handle_segfault(int sig)
1425
{
1426
  time_t curr_time;
1427
  struct tm tm;
1428
1429
  /*
1430
    Strictly speaking, one needs a mutex here
1431
    but since we have got SIGSEGV already, things are a mess
1432
    so not having the mutex is not as bad as possibly using a buggy
1433
    mutex - so we keep things simple
1434
  */
1435
  if (segfaulted)
1436
  {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1437
    fprintf(stderr, _("Fatal " SIGNAL_FMT " while backtracing\n"), sig);
1 by brian
clean slate
1438
    exit(1);
1439
  }
1440
1441
  segfaulted = 1;
1442
1443
  curr_time= my_time(0);
1444
  localtime_r(&curr_time, &tm);
1445
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1446
  fprintf(stderr,"%02d%02d%02d %2d:%02d:%02d - mysqld got "
1447
          SIGNAL_FMT " ;\n"
1448
          "This could be because you hit a bug. It is also possible that "
1449
          "this binary\n or one of the libraries it was linked against is "
1450
          "corrupt, improperly built,\n or misconfigured. This error can "
1451
          "also be caused by malfunctioning hardware.\n",
1 by brian
clean slate
1452
          tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
1453
          tm.tm_hour, tm.tm_min, tm.tm_sec,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1454
          sig);
1455
  fprintf(stderr, _("We will try our best to scrape up some info that "
1456
                    "will hopefully help diagnose\n"
1457
                    "the problem, but since we have already crashed, "
1458
                    "something is definitely wrong\nand this may fail.\n\n"));
366 by Patrick Galbraith
Ulong conversion
1459
  fprintf(stderr, "key_buffer_size=%u\n",
1460
          (uint32_t) dflt_key_cache->key_cache_mem_size);
1 by brian
clean slate
1461
  fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
366 by Patrick Galbraith
Ulong conversion
1462
  fprintf(stderr, "max_used_connections=%u\n", max_used_connections);
1 by brian
clean slate
1463
  fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
1464
  fprintf(stderr, "thread_count=%u\n", thread_count);
1465
  fprintf(stderr, "connection_count=%u\n", connection_count);
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1466
  fprintf(stderr, _("It is possible that mysqld could use up to \n"
1467
                    "key_buffer_size + (read_buffer_size + "
1468
                    "sort_buffer_size)*max_threads = %lu K\n"
1469
                    "bytes of memory\n"
1470
                    "Hope that's ok; if not, decrease some variables in the "
1471
                    "equation.\n\n"),
366 by Patrick Galbraith
Ulong conversion
1472
                    ((uint32_t) dflt_key_cache->key_cache_mem_size +
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1473
                     (global_system_variables.read_buff_size +
1474
                      global_system_variables.sortbuff_size) *
1475
                     thread_scheduler.max_threads +
1 by brian
clean slate
1476
                     max_connections * sizeof(THD)) / 1024);
1477
1478
#ifdef HAVE_STACKTRACE
182.1.2 by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency.
1479
  THD *thd= current_thd;
1480
1 by brian
clean slate
1481
  if (!(test_flags & TEST_NO_STACKTRACE))
1482
  {
1483
    fprintf(stderr,"thd: 0x%lx\n",(long) thd);
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1484
    fprintf(stderr,_("Attempting backtrace. You can use the following "
1485
                     "information to find out\n"
1486
                     "where mysqld died. If you see no messages after this, "
1487
                     "something went\n"
1488
                     "terribly wrong...\n"));
1 by brian
clean slate
1489
    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
1490
                     my_thread_stack_size);
1491
  }
1492
  if (thd)
1493
  {
1494
    const char *kreason= "UNKNOWN";
1495
    switch (thd->killed) {
1496
    case THD::NOT_KILLED:
1497
      kreason= "NOT_KILLED";
1498
      break;
1499
    case THD::KILL_BAD_DATA:
1500
      kreason= "KILL_BAD_DATA";
1501
      break;
1502
    case THD::KILL_CONNECTION:
1503
      kreason= "KILL_CONNECTION";
1504
      break;
1505
    case THD::KILL_QUERY:
1506
      kreason= "KILL_QUERY";
1507
      break;
1508
    case THD::KILLED_NO_VALUE:
1509
      kreason= "KILLED_NO_VALUE";
1510
      break;
1511
    }
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1512
    fprintf(stderr, _("Trying to get some variables.\n"
1513
                      "Some pointers may be invalid and cause the "
1514
                      "dump to abort...\n"));
1 by brian
clean slate
1515
    safe_print_str("thd->query", thd->query, 1024);
366 by Patrick Galbraith
Ulong conversion
1516
    fprintf(stderr, "thd->thread_id=%lu\n", (uint32_t) thd->thread_id);
1 by brian
clean slate
1517
    fprintf(stderr, "thd->killed=%s\n", kreason);
1518
  }
1519
  fflush(stderr);
1520
#endif /* HAVE_STACKTRACE */
1521
1522
#ifdef HAVE_INITGROUPS
1523
  if (calling_initgroups)
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1524
    fprintf(stderr, _("\nThis crash occured while the server was calling "
1525
                      "initgroups(). This is\n"
1526
                      "often due to the use of a drizzled that is statically "
1527
                      "linked against glibc\n"
1528
                      "and configured to use LDAP in /etc/nsswitch.conf. "
1529
                      "You will need to either\n"
1530
                      "upgrade to a version of glibc that does not have this "
1531
                      "problem (2.3.4 or\n"
1532
                      "later when used with nscd), disable LDAP in your "
1533
                      "nsswitch.conf, or use a\n"
1534
                      "drizzled that is not statically linked.\n"));
1 by brian
clean slate
1535
#endif
1536
1537
  if (thd_lib_detected == THD_LIB_LT && !getenv("LD_ASSUME_KERNEL"))
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1538
    fprintf(stderr,
1539
            _("\nYou are running a statically-linked LinuxThreads binary "
1540
              "on an NPTL system.\n"
1541
              "This can result in crashes on some distributions due "
1542
              "to LT/NPTL conflicts.\n"
1543
              "You should either build a dynamically-linked binary, or force "
1544
              "LinuxThreads\n"
1545
              "to be used with the LD_ASSUME_KERNEL environment variable. "
1546
              "Please consult\n"
1547
              "the documentation for your distribution on how to do that.\n"));
236.1.40 by Monty Taylor
A few meaningless changes.
1548
1 by brian
clean slate
1549
  if (locked_in_memory)
1550
  {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1551
    fprintf(stderr,
1552
            _("\nThe '--memlock' argument, which was enabled, uses system "
1553
              "calls that are\n"
1554
              "unreliable and unstable on some operating systems and "
1555
              "operating-system\n"
1556
              "versions (notably, some versions of Linux).  "
1557
              "This crash could be due to use\n"
1558
              "of those buggy OS calls.  You should consider whether you "
1559
              "really need the\n"
1560
              "'--memlock' parameter and/or consult the OS "
1561
              "distributor about 'mlockall'\n bugs.\n"));
1 by brian
clean slate
1562
  }
1563
1564
#ifdef HAVE_WRITE_CORE
1565
  if (test_flags & TEST_CORE_ON_SIGNAL)
1566
  {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1567
    fprintf(stderr, _("Writing a core file\n"));
1 by brian
clean slate
1568
    fflush(stderr);
1569
    write_core(sig);
1570
  }
1571
#endif
1572
1573
  exit(1);
1574
}
1575
1576
#ifndef SA_RESETHAND
1577
#define SA_RESETHAND 0
1578
#endif
1579
#ifndef SA_NODEFER
1580
#define SA_NODEFER 0
1581
#endif
1582
1583
static void init_signals(void)
1584
{
1585
  sigset_t set;
1586
  struct sigaction sa;
1587
1588
  my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
1589
1590
  if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
1591
  {
1592
    sa.sa_flags = SA_RESETHAND | SA_NODEFER;
1593
    sigemptyset(&sa.sa_mask);
1594
    sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
1595
1596
    init_stacktrace();
1597
    sa.sa_handler=handle_segfault;
1598
    sigaction(SIGSEGV, &sa, NULL);
1599
    sigaction(SIGABRT, &sa, NULL);
1600
#ifdef SIGBUS
1601
    sigaction(SIGBUS, &sa, NULL);
1602
#endif
1603
    sigaction(SIGILL, &sa, NULL);
1604
    sigaction(SIGFPE, &sa, NULL);
1605
  }
1606
1607
#ifdef HAVE_GETRLIMIT
1608
  if (test_flags & TEST_CORE_ON_SIGNAL)
1609
  {
1610
    /* Change limits so that we will get a core file */
1611
    STRUCT_RLIMIT rl;
1612
    rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
1613
    if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1614
      sql_print_warning(_("setrlimit could not change the size of core files "
1615
                          "to 'infinity';  We may not be able to generate a "
1616
                          "core file on signals"));
1 by brian
clean slate
1617
  }
1618
#endif
1619
  (void) sigemptyset(&set);
1620
  my_sigset(SIGPIPE,SIG_IGN);
1621
  sigaddset(&set,SIGPIPE);
1622
#ifndef IGNORE_SIGHUP_SIGQUIT
1623
  sigaddset(&set,SIGQUIT);
1624
  sigaddset(&set,SIGHUP);
1625
#endif
1626
  sigaddset(&set,SIGTERM);
1627
1628
  /* Fix signals if blocked by parents (can happen on Mac OS X) */
1629
  sigemptyset(&sa.sa_mask);
1630
  sa.sa_flags = 0;
1631
  sa.sa_handler = print_signal_warning;
1632
  sigaction(SIGTERM, &sa, (struct sigaction*) 0);
1633
  sa.sa_flags = 0;
1634
  sa.sa_handler = print_signal_warning;
1635
  sigaction(SIGHUP, &sa, (struct sigaction*) 0);
1636
#ifdef SIGTSTP
1637
  sigaddset(&set,SIGTSTP);
1638
#endif
1639
  if (thd_lib_detected != THD_LIB_LT)
1640
    sigaddset(&set,THR_SERVER_ALARM);
1641
  if (test_flags & TEST_SIGINT)
1642
  {
1643
    my_sigset(thr_kill_signal, end_thread_signal);
1644
    // May be SIGINT
1645
    sigdelset(&set, thr_kill_signal);
1646
  }
1647
  else
1648
    sigaddset(&set,SIGINT);
1649
  sigprocmask(SIG_SETMASK,&set,NULL);
1650
  pthread_sigmask(SIG_SETMASK,&set,NULL);
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1651
  return;;
1 by brian
clean slate
1652
}
1653
1654
1655
static void start_signal_handler(void)
1656
{
1657
  int error;
1658
  pthread_attr_t thr_attr;
1659
1660
  (void) pthread_attr_init(&thr_attr);
6 by Brian Aker
Second pass on pthread cleanup
1661
  pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
1662
  (void) pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
1663
  {
1664
    struct sched_param tmp_sched_param;
1665
1666
    memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
1667
    tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1668
    (void)pthread_attr_setschedparam(&thr_attr, &tmp_sched_param);
1669
  }
1 by brian
clean slate
1670
#if defined(__ia64__) || defined(__ia64)
1671
  /*
1672
    Peculiar things with ia64 platforms - it seems we only have half the
1673
    stack size in reality, so we have to double it here
1674
  */
1675
  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
1676
#else
1677
  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
1678
1679
  (void) pthread_mutex_lock(&LOCK_thread_count);
1680
  if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0)))
1681
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1682
    sql_print_error(_("Can't create interrupt-thread (error %d, errno: %d)"),
1683
                    error,errno);
1 by brian
clean slate
1684
    exit(1);
1685
  }
1686
  (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
1687
  pthread_mutex_unlock(&LOCK_thread_count);
1688
1689
  (void) pthread_attr_destroy(&thr_attr);
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1690
  return;;
1 by brian
clean slate
1691
}
1692
1693
1694
/** This threads handles all signals and alarms. */
1695
/* ARGSUSED */
1696
pthread_handler_t signal_hand(void *arg __attribute__((unused)))
1697
{
1698
  sigset_t set;
1699
  int sig;
1700
  my_thread_init();				// Init new thread
1701
  signal_thread_in_use= 1;
1702
1703
  /*
1704
    Setup alarm handler
1705
    This should actually be '+ max_number_of_slaves' instead of +10,
1706
    but the +10 should be quite safe.
1707
  */
1708
  init_thr_alarm(thread_scheduler.max_threads + 10);
1709
  if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT))
1710
  {
1711
    (void) sigemptyset(&set);			// Setup up SIGINT for debug
1712
    (void) sigaddset(&set,SIGINT);		// For debugging
1713
    (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
1714
  }
1715
  (void) sigemptyset(&set);			// Setup up SIGINT for debug
1716
#ifdef USE_ONE_SIGNAL_HAND
1717
  (void) sigaddset(&set,THR_SERVER_ALARM);	// For alarms
1718
#endif
1719
#ifndef IGNORE_SIGHUP_SIGQUIT
1720
  (void) sigaddset(&set,SIGQUIT);
1721
  (void) sigaddset(&set,SIGHUP);
1722
#endif
1723
  (void) sigaddset(&set,SIGTERM);
1724
  (void) sigaddset(&set,SIGTSTP);
1725
1726
  /* Save pid to this process (or thread on Linux) */
228 by Brian Aker
First pass on socket cleanup.
1727
  create_pid_file();
1 by brian
clean slate
1728
1729
#ifdef HAVE_STACK_TRACE_ON_SEGV
1730
  if (opt_do_pstack)
1731
  {
366 by Patrick Galbraith
Ulong conversion
1732
    sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (uint32_t)getpid());
1 by brian
clean slate
1733
    pstack_install_segv_action(pstack_file_name);
1734
  }
1735
#endif /* HAVE_STACK_TRACE_ON_SEGV */
1736
1737
  /*
1738
    signal to start_signal_handler that we are ready
1739
    This works by waiting for start_signal_handler to free mutex,
1740
    after which we signal it that we are ready.
1741
    At this pointer there is no other threads running, so there
1742
    should not be any other pthread_cond_signal() calls.
1743
  */
1744
  (void) pthread_mutex_lock(&LOCK_thread_count);
1745
  (void) pthread_mutex_unlock(&LOCK_thread_count);
1746
  (void) pthread_cond_broadcast(&COND_thread_count);
1747
1748
  (void) pthread_sigmask(SIG_BLOCK,&set,NULL);
1749
  for (;;)
1750
  {
1751
    int error;					// Used when debugging
1752
    if (shutdown_in_progress && !abort_loop)
1753
    {
1754
      sig= SIGTERM;
1755
      error=0;
1756
    }
1757
    else
1758
      while ((error=my_sigwait(&set,&sig)) == EINTR) ;
1759
    if (cleanup_done)
1760
    {
1761
      my_thread_end();
1762
      signal_thread_in_use= 0;
1763
      pthread_exit(0);				// Safety
1764
    }
1765
    switch (sig) {
1766
    case SIGTERM:
1767
    case SIGQUIT:
1768
    case SIGKILL:
1769
#ifdef EXTRA_DEBUG
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1770
      sql_print_information(_("Got signal %d to shutdown mysqld"),sig);
1 by brian
clean slate
1771
#endif
1772
      /* switch to the old log message processing */
1773
      logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
1774
                          opt_log ? LOG_FILE:LOG_NONE);
1775
      if (!abort_loop)
1776
      {
1777
	abort_loop=1;				// mark abort for threads
1778
#ifdef USE_ONE_SIGNAL_HAND
1779
	pthread_t tmp;
6 by Brian Aker
Second pass on pthread cleanup
1780
        {
1781
          struct sched_param tmp_sched_param;
1782
1783
          memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
1784
          tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1785
          (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
1786
        }
1 by brian
clean slate
1787
	if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
1788
			   (void*) &sig))
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1789
          sql_print_error(_("Can't create thread to kill server"));
1 by brian
clean slate
1790
#else
1791
	kill_server((void*) sig);	// MIT THREAD has a alarm thread
1792
#endif
1793
      }
1794
      break;
1795
    case SIGHUP:
1796
      if (!abort_loop)
1797
      {
1798
        bool not_used;
1799
        reload_cache((THD*) 0,
1800
                     (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
1801
                      REFRESH_GRANT |
1802
                      REFRESH_THREADS | REFRESH_HOSTS),
327.2.4 by Brian Aker
Refactoring table.h
1803
                     (TableList*) 0, &not_used); // Flush logs
1 by brian
clean slate
1804
      }
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
1805
      logger.set_handlers(LOG_FILE,
1806
                          opt_slow_log ? log_output_options : LOG_NONE,
1807
                          opt_log ? log_output_options : LOG_NONE);
1 by brian
clean slate
1808
      break;
1809
#ifdef USE_ONE_SIGNAL_HAND
1810
    case THR_SERVER_ALARM:
1811
      process_alarm(sig);			// Trigger alarms.
1812
      break;
1813
#endif
1814
    default:
1815
#ifdef EXTRA_DEBUG
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
1816
      sql_print_warning(_("Got signal: %d  error: %d"),sig,error); /* purecov: tested */
1 by brian
clean slate
1817
#endif
1818
      break;					/* purecov: tested */
1819
    }
1820
  }
1821
  return(0);					/* purecov: deadcode */
1822
}
1823
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
1824
static void check_data_home(const char *path __attribute__((unused)))
1 by brian
clean slate
1825
{}
1826
1827
#endif	/* __WIN__*/
1828
1829
1830
/**
1831
  All global error messages are sent here where the first one is stored
1832
  for the client.
1833
*/
1834
/* ARGSUSED */
1835
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
1836
1837
void my_message_sql(uint error, const char *str, myf MyFlags)
1838
{
1839
  THD *thd;
1840
  /*
1841
    Put here following assertion when situation with EE_* error codes
1842
    will be fixed
1843
  */
1844
  if ((thd= current_thd))
1845
  {
1846
    if (MyFlags & ME_FATALERROR)
1847
      thd->is_fatal_error= 1;
1848
1849
#ifdef BUG_36098_FIXED
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1850
    mysql_audit_general(thd,DRIZZLE_AUDIT_GENERAL_ERROR,error,my_time(0),
1 by brian
clean slate
1851
                        0,0,str,str ? strlen(str) : 0,
1852
                        thd->query,thd->query_length,
1853
                        thd->variables.character_set_client,
1854
                        thd->row_count);
1855
#endif
1856
1857
1858
    /*
1859
      TODO: There are two exceptions mechanism (THD and sp_rcontext),
1860
      this could be improved by having a common stack of handlers.
1861
    */
1862
    if (thd->handle_error(error, str,
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1863
                          DRIZZLE_ERROR::WARN_LEVEL_ERROR))
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1864
      return;;
1 by brian
clean slate
1865
1866
    thd->is_slave_error=  1; // needed to catch query errors during replication
1867
1868
    /*
1869
      thd->lex->current_select == 0 if lex structure is not inited
1870
      (not query command (COM_QUERY))
1871
    */
51.1.78 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
1872
    if (! (thd->lex->current_select &&
1873
        thd->lex->current_select->no_error && !thd->is_fatal_error))
1 by brian
clean slate
1874
    {
1875
      if (! thd->main_da.is_error())            // Return only first message
1876
      {
1877
        if (error == 0)
1878
          error= ER_UNKNOWN_ERROR;
1879
        if (str == NULL)
1880
          str= ER(error);
1881
        thd->main_da.set_error_status(thd, error, str);
1882
      }
1883
    }
1884
1885
    if (!thd->no_warnings_for_error && !thd->is_fatal_error)
1886
    {
1887
      /*
1888
        Suppress infinite recursion if there a memory allocation error
1889
        inside push_warning.
1890
      */
163 by Brian Aker
Merge Monty's code.
1891
      thd->no_warnings_for_error= true;
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1892
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
163 by Brian Aker
Merge Monty's code.
1893
      thd->no_warnings_for_error= false;
1 by brian
clean slate
1894
    }
1895
  }
1896
  if (!thd || MyFlags & ME_NOREFRESH)
1897
    sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
1898
  return;;
1 by brian
clean slate
1899
}
1900
1901
1902
extern "C" void *my_str_malloc_mysqld(size_t size);
1903
extern "C" void my_str_free_mysqld(void *ptr);
1904
1905
void *my_str_malloc_mysqld(size_t size)
1906
{
1907
  return my_malloc(size, MYF(MY_FAE));
1908
}
1909
1910
1911
void my_str_free_mysqld(void *ptr)
1912
{
1913
  my_free((uchar*)ptr, MYF(MY_FAE));
1914
}
1915
1916
1917
static const char *load_default_groups[]= {
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1918
"mysqld","server", DRIZZLE_BASE_VERSION, 0, 0};
1 by brian
clean slate
1919
1920
1921
/**
1922
  Initialize one of the global date/time format variables.
1923
1924
  @param format_type		What kind of format should be supported
1925
  @param var_ptr		Pointer to variable that should be updated
1926
1927
  @note
1928
    The default value is taken from either opt_date_time_formats[] or
1929
    the ISO format (ANSI SQL)
1930
1931
  @retval
1932
    0 ok
1933
  @retval
1934
    1 error
1935
*/
1936
1937
static bool init_global_datetime_format(timestamp_type format_type,
1938
                                        DATE_TIME_FORMAT **var_ptr)
1939
{
1940
  /* Get command line option */
1941
  const char *str= opt_date_time_formats[format_type];
1942
1943
  if (!str)					// No specified format
1944
  {
1945
    str= get_date_time_format_str(&known_date_time_formats[ISO_FORMAT],
1946
				  format_type);
1947
    /*
1948
      Set the "command line" option to point to the generated string so
1949
      that we can set global formats back to default
1950
    */
1951
    opt_date_time_formats[format_type]= str;
1952
  }
1953
  if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str))))
1954
  {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
1955
    fprintf(stderr, _("Wrong date/time format specifier: %s\n"), str);
1 by brian
clean slate
1956
    return 1;
1957
  }
1958
  return 0;
1959
}
1960
1961
SHOW_VAR com_status_vars[]= {
1962
  {"admin_commands",       (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
1963
  {"assign_to_keycache",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1964
  {"alter_db",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
1965
  {"alter_table",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1966
  {"analyze",              (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1967
  {"begin",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
1968
  {"binlog",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS},
1969
  {"change_db",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
1970
  {"change_master",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_MASTER]), SHOW_LONG_STATUS},
1971
  {"check",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS},
1972
  {"checksum",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
1973
  {"commit",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
1974
  {"create_db",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
1975
  {"create_index",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
1976
  {"create_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
1977
  {"delete",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE]), SHOW_LONG_STATUS},
1978
  {"delete_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS},
1979
  {"drop_db",              (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
1980
  {"drop_index",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
1981
  {"drop_table",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
1982
  {"empty_query",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
1983
  {"flush",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
1984
  {"insert",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT]), SHOW_LONG_STATUS},
1985
  {"insert_select",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
1986
  {"kill",                 (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_KILL]), SHOW_LONG_STATUS},
1987
  {"load",                 (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD]), SHOW_LONG_STATUS},
1988
  {"lock_tables",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS},
1989
  {"optimize",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS},
1990
  {"purge",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE]), SHOW_LONG_STATUS},
1991
  {"purge_before_date",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BEFORE]), SHOW_LONG_STATUS},
1992
  {"release_savepoint",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
1993
  {"rename_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
1994
  {"repair",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPAIR]), SHOW_LONG_STATUS},
1995
  {"replace",              (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
1996
  {"replace_select",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
1997
  {"reset",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESET]), SHOW_LONG_STATUS},
1998
  {"rollback",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
1999
  {"rollback_to_savepoint",(char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
2000
  {"savepoint",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
2001
  {"select",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
2002
  {"set_option",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
2003
  {"show_binlog_events",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
2004
  {"show_binlogs",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
2005
  {"show_charsets",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS},
2006
  {"show_collations",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS},
2007
  {"show_create_db",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
2008
  {"show_create_table",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
2009
  {"show_databases",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
2010
  {"show_engine_status",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS},
2011
  {"show_errors",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
2012
  {"show_fields",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
2013
  {"show_keys",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
2014
  {"show_master_status",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
2015
  {"show_open_tables",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
2016
  {"show_plugins",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
2017
  {"show_processlist",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
2018
  {"show_slave_hosts",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
2019
  {"show_slave_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
2020
  {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
2021
  {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
2022
  {"show_tables",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
2023
  {"show_variables",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
2024
  {"show_warnings",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
2025
  {"slave_start",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
2026
  {"slave_stop",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS},
2027
  {"truncate",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
2028
  {"unlock_tables",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
2029
  {"update",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
2030
  {"update_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
2031
  {NullS, NullS, SHOW_LONG}
2032
};
2033
2034
static int init_common_variables(const char *conf_file_name, int argc,
2035
				 char **argv, const char **groups)
2036
{
2037
  char buff[FN_REFLEN], *s;
2038
  umask(((~my_umask) & 0666));
2039
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
2040
  tzset();			// Set tzname
2041
298 by Brian Aker
ulong conversion.
2042
  max_system_variables.pseudo_thread_id= UINT32_MAX;
1 by brian
clean slate
2043
  server_start_time= flush_status_time= my_time(0);
2044
  rpl_filter= new Rpl_filter;
2045
  binlog_filter= new Rpl_filter;
236.1.40 by Monty Taylor
A few meaningless changes.
2046
  if (!rpl_filter || !binlog_filter)
1 by brian
clean slate
2047
  {
2048
    sql_perror("Could not allocate replication and binlog filters");
2049
    exit(1);
2050
  }
2051
2052
  if (init_thread_environment())
2053
    return 1;
2054
  mysql_init_variables();
2055
2056
#ifdef HAVE_TZNAME
2057
  {
2058
    struct tm tm_tmp;
2059
    localtime_r(&server_start_time,&tm_tmp);
2060
    strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
2061
            sizeof(system_time_zone)-1);
2062
2063
 }
2064
#endif
2065
  /*
2066
    We set SYSTEM time zone as reasonable default and
2067
    also for failure of my_tz_init() and bootstrap mode.
2068
    If user explicitly set time zone with --default-time-zone
2069
    option we will change this value in my_tz_init().
2070
  */
2071
  global_system_variables.time_zone= my_tz_SYSTEM;
2072
2073
  /*
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2074
    Init mutexes for the global DRIZZLE_BIN_LOG objects.
1 by brian
clean slate
2075
    As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2076
    global DRIZZLE_BIN_LOGs in their constructors, because then they would be
1 by brian
clean slate
2077
    inited before MY_INIT(). So we do it here.
2078
  */
2079
  mysql_bin_log.init_pthread_objects();
2080
2081
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
2082
  {
2083
    strmake(glob_hostname, STRING_WITH_LEN("localhost"));
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2084
    sql_print_warning(_("gethostname failed, using '%s' as hostname"),
1 by brian
clean slate
2085
                      glob_hostname);
2086
    strmake(pidfile_name, STRING_WITH_LEN("mysql"));
2087
  }
2088
  else
2089
  strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
2090
  stpcpy(fn_ext(pidfile_name),".pid");		// Add proper extension
1 by brian
clean slate
2091
2092
  /*
2093
    Add server status variables to the dynamic list of
2094
    status variables that is shown by SHOW STATUS.
2095
    Later, in plugin_init, and mysql_install_plugin
2096
    new entries could be added to that list.
2097
  */
2098
  if (add_status_vars(status_vars))
2099
    return 1; // an error was already reported
2100
2101
  load_defaults(conf_file_name, groups, &argc, &argv);
2102
  defaults_argv=argv;
2103
  defaults_argc=argc;
2104
  get_options(&defaults_argc, defaults_argv);
2105
  set_server_version();
2106
2107
2108
  /* connections and databases needs lots of files */
2109
  {
2110
    uint files, wanted_files, max_open_files;
2111
2112
    /* MyISAM requires two file handles per table. */
2113
    wanted_files= 10+max_connections+table_cache_size*2;
2114
    /*
2115
      We are trying to allocate no less than max_connections*5 file
2116
      handles (i.e. we are trying to set the limit so that they will
2117
      be available).  In addition, we allocate no less than how much
2118
      was already allocated.  However below we report a warning and
2119
      recompute values only if we got less file handles than were
2120
      explicitly requested.  No warning and re-computation occur if we
2121
      can't get max_connections*5 but still got no less than was
2122
      requested (value of wanted_files).
2123
    */
366 by Patrick Galbraith
Ulong conversion
2124
    max_open_files= max(max((uint32_t)wanted_files, max_connections*5),
1 by brian
clean slate
2125
                        open_files_limit);
2126
    files= my_set_max_open_files(max_open_files);
2127
2128
    if (files < wanted_files)
2129
    {
2130
      if (!open_files_limit)
2131
      {
2132
        /*
2133
          If we have requested too much file handles than we bring
2134
          max_connections in supported bounds.
2135
        */
366 by Patrick Galbraith
Ulong conversion
2136
        max_connections= (uint32_t) min((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
1 by brian
clean slate
2137
                                     max_connections);
2138
        /*
2139
          Decrease table_cache_size according to max_connections, but
2140
          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
2141
          never increase table_cache_size automatically (that could
2142
          happen if max_connections is decreased above).
2143
        */
366 by Patrick Galbraith
Ulong conversion
2144
        table_cache_size= (uint32_t) min(max((files-10-max_connections)/2,
2145
                                          (uint32_t)TABLE_OPEN_CACHE_MIN),
1 by brian
clean slate
2146
                                      table_cache_size);
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2147
        if (global_system_variables.log_warnings)
2148
          sql_print_warning(_("Changed limits: max_open_files: %u  "
2149
                              "max_connections: %ld  table_cache: %ld"),
2150
                            files, max_connections, table_cache_size);
1 by brian
clean slate
2151
      }
2152
      else if (global_system_variables.log_warnings)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2153
        sql_print_warning(_("Could not increase number of max_open_files "
2154
                            "to more than %u (request: %u)"),
2155
                          files, wanted_files);
1 by brian
clean slate
2156
    }
2157
    open_files_limit= files;
2158
  }
362 by Brian Aker
No more dead special flags...
2159
  unireg_init(0); /* Set up extern variabels */
1 by brian
clean slate
2160
  if (init_errmessage())	/* Read error messages from file */
2161
    return 1;
2162
  lex_init();
2163
  if (item_create_init())
2164
    return 1;
2165
  item_init();
2166
  if (set_var_init())
2167
    return 1;
2168
  if (init_replication_sys_vars())
2169
    return 1;
2170
  /*
2171
    Process a comma-separated character set list and choose
2172
    the first available character set. This is mostly for
2173
    test purposes, to be able to start "mysqld" even if
2174
    the requested character set is not available (see bug#18743).
2175
  */
2176
  for (;;)
2177
  {
2178
    char *next_character_set_name= strchr(default_character_set_name, ',');
2179
    if (next_character_set_name)
2180
      *next_character_set_name++= '\0';
2181
    if (!(default_charset_info=
2182
          get_charset_by_csname(default_character_set_name,
2183
                                MY_CS_PRIMARY, MYF(MY_WME))))
2184
    {
2185
      if (next_character_set_name)
2186
      {
2187
        default_character_set_name= next_character_set_name;
2188
        default_collation_name= 0;          // Ignore collation
2189
      }
2190
      else
2191
        return 1;                           // Eof of the list
2192
    }
2193
    else
2194
      break;
2195
  }
2196
2197
  if (default_collation_name)
2198
  {
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
2199
    const CHARSET_INFO * const default_collation=
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2200
      get_charset_by_name(default_collation_name, MYF(0));
1 by brian
clean slate
2201
    if (!default_collation)
2202
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2203
      sql_print_error(_(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1 by brian
clean slate
2204
      return 1;
2205
    }
2206
    if (!my_charset_same(default_charset_info, default_collation))
2207
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2208
      sql_print_error(_(ER(ER_COLLATION_CHARSET_MISMATCH)),
2209
                      default_collation_name,
2210
                      default_charset_info->csname);
1 by brian
clean slate
2211
      return 1;
2212
    }
2213
    default_charset_info= default_collation;
2214
  }
2215
  /* Set collactions that depends on the default collation */
2216
  global_system_variables.collation_server=	 default_charset_info;
2217
  global_system_variables.collation_database=	 default_charset_info;
2218
  global_system_variables.collation_connection=  default_charset_info;
2219
  global_system_variables.character_set_results= default_charset_info;
2220
  global_system_variables.character_set_client= default_charset_info;
2221
2222
  global_system_variables.optimizer_use_mrr= 1;
2223
  global_system_variables.optimizer_switch= 0;
2224
236.1.40 by Monty Taylor
A few meaningless changes.
2225
  if (!(character_set_filesystem=
1 by brian
clean slate
2226
        get_charset_by_csname(character_set_filesystem_name,
2227
                              MY_CS_PRIMARY, MYF(MY_WME))))
2228
    return 1;
2229
  global_system_variables.character_set_filesystem= character_set_filesystem;
2230
2231
  if (!(my_default_lc_time_names=
2232
        my_locale_by_name(lc_time_names_name)))
2233
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2234
    sql_print_error(_("Unknown locale: '%s'"), lc_time_names_name);
1 by brian
clean slate
2235
    return 1;
2236
  }
2237
  global_system_variables.lc_time_names= my_default_lc_time_names;
236.1.40 by Monty Taylor
A few meaningless changes.
2238
1 by brian
clean slate
2239
  sys_init_connect.value_length= 0;
2240
  if ((sys_init_connect.value= opt_init_connect))
2241
    sys_init_connect.value_length= strlen(opt_init_connect);
2242
  else
2243
    sys_init_connect.value=my_strdup("",MYF(0));
2244
2245
  sys_init_slave.value_length= 0;
2246
  if ((sys_init_slave.value= opt_init_slave))
2247
    sys_init_slave.value_length= strlen(opt_init_slave);
2248
  else
2249
    sys_init_slave.value=my_strdup("",MYF(0));
2250
2251
  /* check log options and issue warnings if needed */
2252
  if (opt_log && opt_logname && !(log_output_options & LOG_FILE) &&
2253
      !(log_output_options & LOG_NONE))
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2254
    sql_print_warning(_("Although a path was specified for the "
2255
                        "--log option, log tables are used. "
2256
                        "To enable logging to files use the "
2257
                        "--log-output option."));
1 by brian
clean slate
2258
2259
  if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE)
2260
      && !(log_output_options & LOG_NONE))
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2261
    sql_print_warning(_("Although a path was specified for the "
2262
                        "--log-slow-queries option, log tables are used. "
2263
                        "To enable logging to files use the "
2264
                        "--log-output=file option."));
1 by brian
clean slate
2265
2266
  s= opt_logname ? opt_logname : make_default_log_name(buff, ".log");
2267
  sys_var_general_log_path.value= my_strdup(s, MYF(0));
2268
  sys_var_general_log_path.value_length= strlen(s);
2269
2270
  s= opt_slow_logname ? opt_slow_logname : make_default_log_name(buff, "-slow.log");
2271
  sys_var_slow_log_path.value= my_strdup(s, MYF(0));
2272
  sys_var_slow_log_path.value_length= strlen(s);
2273
2274
  if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2275
    return 1;
2276
  if (my_database_names_init())
2277
    return 1;
2278
2279
2280
  /* Reset table_alias_charset, now that lower_case_table_names is set. */
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
2281
  lower_case_table_names= 1; /* This we need to look at */
224.2.1 by Brian Aker
First pass for table name issue across platforms.
2282
  table_alias_charset= files_charset_info;
1 by brian
clean slate
2283
2284
  return 0;
2285
}
2286
2287
2288
static int init_thread_environment()
2289
{
2290
  (void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
2291
  (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
2292
  (void) pthread_mutex_init(&LOCK_open, NULL);
2293
  (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
2294
  (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2295
  (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
2296
  (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
2297
  (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2298
  (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2299
  (void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
2300
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
2301
  (void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
2302
  (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2303
  (void) my_rwlock_init(&LOCK_sys_init_connect, NULL);
2304
  (void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
2305
  (void) pthread_cond_init(&COND_thread_count,NULL);
2306
  (void) pthread_cond_init(&COND_refresh,NULL);
2307
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
2308
  (void) pthread_cond_init(&COND_thread_cache,NULL);
2309
  (void) pthread_cond_init(&COND_flush_thread_cache,NULL);
2310
  (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2311
  (void) pthread_cond_init(&COND_rpl_status, NULL);
2312
2313
  /* Parameter for threads created for connections */
2314
  (void) pthread_attr_init(&connection_attrib);
2315
  (void) pthread_attr_setdetachstate(&connection_attrib,
2316
				     PTHREAD_CREATE_DETACHED);
2317
  pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
6 by Brian Aker
Second pass on pthread cleanup
2318
  {
2319
    struct sched_param tmp_sched_param;
2320
2321
    memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
2322
    tmp_sched_param.sched_priority= WAIT_PRIOR;
2323
    (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
2324
  }
1 by brian
clean slate
2325
2326
  if (pthread_key_create(&THR_THD,NULL) ||
2327
      pthread_key_create(&THR_MALLOC,NULL))
2328
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2329
    sql_print_error(_("Can't create thread-keys"));
1 by brian
clean slate
2330
    return 1;
2331
  }
2332
  return 0;
2333
}
2334
2335
2336
static int init_server_components()
2337
{
2338
  /*
2339
    We need to call each of these following functions to ensure that
2340
    all things are initialized so that unireg_abort() doesn't fail
2341
  */
2342
  if (table_cache_init() | table_def_init())
2343
    unireg_abort(1);
2344
366 by Patrick Galbraith
Ulong conversion
2345
  randominit(&sql_rand,(uint32_t) server_start_time,(uint32_t) server_start_time/2);
1 by brian
clean slate
2346
  setup_fpu();
2347
  init_thr_lock();
2348
  init_slave_list();
2349
2350
  /* Setup logs */
2351
2352
  /*
2353
    Enable old-fashioned error log, except when the user has requested
2354
    help information. Since the implementation of plugin server
2355
    variables the help output is now written much later.
2356
  */
2357
  if (opt_error_log && !opt_help)
2358
  {
2359
    if (!log_error_file_ptr[0])
2360
      fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
2361
                MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
2362
    else
2363
      fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
2364
                MY_UNPACK_FILENAME | MY_SAFE_PATH);
2365
    if (!log_error_file[0])
2366
      opt_error_log= 1;				// Too long file name
2367
    else
2368
    {
2369
      if (freopen(log_error_file, "a+", stdout))
2370
        freopen(log_error_file, "a+", stderr);
2371
    }
2372
  }
2373
2374
  if (xid_cache_init())
2375
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2376
    sql_print_error(_("Out of memory"));
1 by brian
clean slate
2377
    unireg_abort(1);
2378
  }
2379
2380
  if (!opt_bin_log)
2381
    if (opt_binlog_format_id != BINLOG_FORMAT_UNSPEC)
92 by Brian Aker
Removed opt_update_log
2382
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2383
      sql_print_error(_("You need to use --log-bin to make "
2384
                        "--binlog-format work."));
92 by Brian Aker
Removed opt_update_log
2385
      unireg_abort(1);
2386
    }
1 by brian
clean slate
2387
    else
92 by Brian Aker
Removed opt_update_log
2388
    {
1 by brian
clean slate
2389
      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2390
    }
2391
  else
2392
    if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
2393
      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2394
    else
236.1.40 by Monty Taylor
A few meaningless changes.
2395
    {
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2396
      assert(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
2397
    }
1 by brian
clean slate
2398
2399
  /* Check that we have not let the format to unspecified at this point */
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2400
  assert((uint)global_system_variables.binlog_format <=
1 by brian
clean slate
2401
              array_elements(binlog_format_names)-1);
2402
2403
  if (opt_log_slave_updates && replicate_same_server_id)
2404
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2405
    sql_print_error(_("using --replicate-same-server-id in conjunction with "
2406
                      "--log-slave-updates is impossible, it would lead to "
2407
                      "infinite loops in this server."));
1 by brian
clean slate
2408
    unireg_abort(1);
2409
  }
2410
2411
  if (opt_bin_log)
2412
  {
2413
    char buf[FN_REFLEN];
2414
    const char *ln;
2415
    ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
2416
    if (!opt_bin_logname && !opt_binlog_index_name)
2417
    {
2418
      /*
2419
        User didn't give us info to name the binlog index file.
2420
        Picking `hostname`-bin.index like did in 4.x, causes replication to
2421
        fail if the hostname is changed later. So, we would like to instead
2422
        require a name. But as we don't want to break many existing setups, we
2423
        only give warning, not error.
2424
      */
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2425
      sql_print_warning(_("No argument was provided to --log-bin, and "
2426
                          "--log-bin-index was not used; so replication "
2427
                          "may break when this Drizzle server acts as a "
2428
                          "master and has his hostname changed!! Please "
2429
                          "use '--log-bin=%s' to avoid this problem."), ln);
1 by brian
clean slate
2430
    }
2431
    if (ln == buf)
2432
    {
2433
      my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
2434
      opt_bin_logname=my_strdup(buf, MYF(0));
2435
    }
2436
    if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
2437
    {
2438
      unireg_abort(1);
2439
    }
2440
2441
    /*
2442
      Used to specify which type of lock we need to use for queries of type
2443
      INSERT ... SELECT. This will change when we have row level logging.
2444
    */
2445
    using_update_log=1;
2446
  }
2447
2448
  /* call ha_init_key_cache() on all key caches to init them */
2449
  process_key_caches(&ha_init_key_cache);
2450
2451
  /* Allow storage engine to give real error messages */
2452
  if (ha_init_errors())
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2453
    return(1);
1 by brian
clean slate
2454
2455
  if (plugin_init(&defaults_argc, defaults_argv,
2456
                  (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
2457
                  (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
2458
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2459
    sql_print_error(_("Failed to initialize plugins."));
1 by brian
clean slate
2460
    unireg_abort(1);
2461
  }
2462
2463
  if (opt_help)
2464
    unireg_abort(0);
2465
2466
  /* we do want to exit if there are any other unknown options */
2467
  if (defaults_argc > 1)
2468
  {
2469
    int ho_error;
2470
    char **tmp_argv= defaults_argv;
2471
    struct my_option no_opts[]=
2472
    {
2473
      {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2474
    };
2475
    /*
2476
      We need to eat any 'loose' arguments first before we conclude
2477
      that there are unprocessed options.
2478
      But we need to preserve defaults_argv pointer intact for
2479
      free_defaults() to work. Thus we use a copy here.
2480
    */
2481
    my_getopt_skip_unknown= 0;
2482
2483
    if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts,
2484
                                  mysqld_get_one_option)))
2485
      unireg_abort(ho_error);
2486
2487
    if (defaults_argc)
2488
    {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
2489
      fprintf(stderr,
2490
              _("%s: Too many arguments (first extra is '%s').\n"
2491
                "Use --verbose --help to get a list of available options\n"),
1 by brian
clean slate
2492
              my_progname, *tmp_argv);
2493
      unireg_abort(1);
2494
    }
2495
  }
2496
2497
  /* We have to initialize the storage engines before CSV logging */
2498
  if (ha_init())
2499
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2500
    sql_print_error(_("Can't init databases"));
1 by brian
clean slate
2501
    unireg_abort(1);
2502
  }
2503
2504
  logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
2505
                      opt_log ? LOG_FILE:LOG_NONE);
2506
2507
  /*
2508
    Check that the default storage engine is actually available.
2509
  */
2510
  if (default_storage_engine_str)
2511
  {
2512
    LEX_STRING name= { default_storage_engine_str,
2513
                       strlen(default_storage_engine_str) };
2514
    plugin_ref plugin;
2515
    handlerton *hton;
236.1.40 by Monty Taylor
A few meaningless changes.
2516
1 by brian
clean slate
2517
    if ((plugin= ha_resolve_by_name(0, &name)))
236.1.44 by Monty Taylor
Added en_US translation file.
2518
    {
202.3.11 by Monty Taylor
Ding dong. errmsg.sys is dead.
2519
      hton= plugin_data(plugin,handlerton *);
236.1.44 by Monty Taylor
Added en_US translation file.
2520
    }
1 by brian
clean slate
2521
    else
2522
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2523
      sql_print_error(_("Unknown/unsupported table type: %s"),
1 by brian
clean slate
2524
                      default_storage_engine_str);
2525
      unireg_abort(1);
2526
    }
2527
    if (!ha_storage_engine_is_enabled(hton))
2528
    {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2529
      sql_print_error(_("Default storage engine (%s) is not available"),
228 by Brian Aker
First pass on socket cleanup.
2530
                      default_storage_engine_str);
2531
      unireg_abort(1);
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2532
      assert(global_system_variables.table_plugin);
1 by brian
clean slate
2533
    }
2534
    else
2535
    {
2536
      /*
236.1.40 by Monty Taylor
A few meaningless changes.
2537
        Need to unlock as global_system_variables.table_plugin
1 by brian
clean slate
2538
        was acquired during plugin_init()
2539
      */
2540
      plugin_unlock(0, global_system_variables.table_plugin);
2541
      global_system_variables.table_plugin= plugin;
2542
    }
2543
  }
2544
2545
  tc_log= (total_ha_2pc > 1 ? (opt_bin_log  ?
2546
                               (TC_LOG *) &mysql_bin_log :
2547
                               (TC_LOG *) &tc_log_mmap) :
2548
           (TC_LOG *) &tc_log_dummy);
2549
2550
  if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file))
2551
  {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2552
    sql_print_error(_("Can't initialize tc_log"));
1 by brian
clean slate
2553
    unireg_abort(1);
2554
  }
2555
2556
  if (ha_recover(0))
2557
  {
2558
    unireg_abort(1);
2559
  }
2560
2561
  if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
2562
                                        WRITE_CACHE, 0, max_binlog_size, 0))
2563
    unireg_abort(1);
2564
2565
  if (opt_bin_log && expire_logs_days)
2566
  {
2567
    time_t purge_time= server_start_time - expire_logs_days*24*60*60;
2568
    if (purge_time >= 0)
2569
      mysql_bin_log.purge_logs_before_date(purge_time);
2570
  }
2571
2572
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2573
  if (locked_in_memory && !getuid())
2574
  {
2575
    if (setreuid((uid_t)-1, 0) == -1)
2576
    {                        // this should never happen
2577
      sql_perror("setreuid");
2578
      unireg_abort(1);
2579
    }
2580
    if (mlockall(MCL_CURRENT))
2581
    {
2582
      if (global_system_variables.log_warnings)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2583
        sql_print_warning(_("Failed to lock memory. Errno: %d\n"),errno);
1 by brian
clean slate
2584
      locked_in_memory= 0;
2585
    }
2586
    if (user_info)
2587
      set_user(mysqld_user, user_info);
2588
  }
2589
  else
2590
#endif
2591
    locked_in_memory=0;
2592
2593
  init_update_queries();
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2594
  return(0);
1 by brian
clean slate
2595
}
2596
2597
2598
int main(int argc, char **argv)
2599
{
236.1.60 by Monty Taylor
Another stab at protecting NLS stuff.
2600
2601
#if defined(ENABLE_NLS)
2602
# if defined(HAVE_LOCALE_H)
202.3.8 by Monty Taylor
Actually turn gettext on...
2603
  setlocale(LC_ALL, "");
236.1.60 by Monty Taylor
Another stab at protecting NLS stuff.
2604
# endif
202.3.8 by Monty Taylor
Actually turn gettext on...
2605
  bindtextdomain("drizzle", LOCALEDIR);
2606
  textdomain("drizzle");
236.1.60 by Monty Taylor
Another stab at protecting NLS stuff.
2607
#endif
202.3.8 by Monty Taylor
Actually turn gettext on...
2608
1 by brian
clean slate
2609
  MY_INIT(argv[0]);		// init my_sys library & pthreads
2610
  /* nothing should come before this line ^^^ */
2611
2612
  /* Set signal used to kill MySQL */
2613
#if defined(SIGUSR2)
2614
  thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
2615
#else
2616
  thr_kill_signal= SIGINT;
2617
#endif
2618
2619
  /*
2620
    Perform basic logger initialization logger. Should be called after
2621
    MY_INIT, as it initializes mutexes. Log tables are inited later.
2622
  */
2623
  logger.init_base();
2624
2625
#ifdef _CUSTOMSTARTUPCONFIG_
2626
  if (_cust_check_startup())
2627
  {
2628
    / * _cust_check_startup will report startup failure error * /
2629
    exit(1);
2630
  }
2631
#endif
2632
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2633
  if (init_common_variables(DRIZZLE_CONFIG_NAME,
1 by brian
clean slate
2634
			    argc, argv, load_default_groups))
2635
    unireg_abort(1);				// Will do exit
2636
2637
  init_signals();
5 by Brian Aker
Removed my_pthread_setprio()
2638
1 by brian
clean slate
2639
  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
161 by Brian Aker
I had removed most of the pthread_setschedparam() calls a bit ago. This
2640
1 by brian
clean slate
2641
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
2642
  {
2643
    /* Retrieve used stack size;  Needed for checking stack overflows */
2644
    size_t stack_size= 0;
2645
    pthread_attr_getstacksize(&connection_attrib, &stack_size);
2646
    /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
2647
    if (stack_size && stack_size < my_thread_stack_size)
2648
    {
2649
      if (global_system_variables.log_warnings)
298 by Brian Aker
ulong conversion.
2650
      {
2651
        /* %zu is not yet in C++ */
2652
        unsigned long long size_tmp= (uint64_t)stack_size;
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2653
        sql_print_warning(_("Asked for %u thread stack, but got %llu"),
298 by Brian Aker
ulong conversion.
2654
                          my_thread_stack_size, size_tmp);
2655
      }
1 by brian
clean slate
2656
      my_thread_stack_size= stack_size;
2657
    }
2658
  }
2659
#endif
2660
2661
  select_thread=pthread_self();
2662
  select_thread_in_use=1;
2663
2664
  /*
2665
    We have enough space for fiddling with the argv, continue
2666
  */
2667
  check_data_home(mysql_real_data_home);
2668
  if (my_setwd(mysql_real_data_home,MYF(MY_WME)) && !opt_help)
2669
    unireg_abort(1);				/* purecov: inspected */
2670
  mysql_data_home= mysql_data_home_buff;
2671
  mysql_data_home[0]=FN_CURLIB;		// all paths are relative from here
2672
  mysql_data_home[1]=0;
2673
  mysql_data_home_len= 2;
2674
2675
  if ((user_info= check_user(mysqld_user)))
2676
  {
2677
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2678
    if (locked_in_memory) // getuid() == 0 here
2679
      set_effective_user(user_info);
2680
    else
2681
#endif
2682
      set_user(mysqld_user, user_info);
2683
  }
2684
2685
  if (opt_bin_log && !server_id)
2686
  {
2687
    server_id= 1;
2688
#ifdef EXTRA_DEBUG
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2689
    sql_print_warning(_("You have enabled the binary log, but you haven't set "
2690
                        "server-id to a non-zero value: we force server id to "
2691
                        "1; updates will be logged to the binary log, but "
2692
                        "connections from slaves will not be accepted."));
1 by brian
clean slate
2693
#endif
2694
  }
2695
2696
  if (init_server_components())
2697
    unireg_abort(1);
2698
2699
  network_init();
2700
2701
  /*
2702
   Initialize my_str_malloc() and my_str_free()
2703
  */
2704
  my_str_malloc= &my_str_malloc_mysqld;
2705
  my_str_free= &my_str_free_mysqld;
2706
2707
  /*
2708
    init signals & alarm
2709
    After this we can't quit by a simple unireg_abort
2710
  */
2711
  error_handler_hook= my_message_sql;
2712
  start_signal_handler();				// Creates pidfile
2713
228 by Brian Aker
First pass on socket cleanup.
2714
  if (mysql_rm_tmp_tables() || my_tz_init((THD *)0, default_tz_name, false))
1 by brian
clean slate
2715
  {
2716
    abort_loop=1;
2717
    select_thread_in_use=0;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2718
    (void) pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
1 by brian
clean slate
2719
228 by Brian Aker
First pass on socket cleanup.
2720
    (void) my_delete(pidfile_name,MYF(MY_WME));	// Not needed anymore
1 by brian
clean slate
2721
2722
    exit(1);
2723
  }
2724
2725
  init_status_vars();
2726
  /*
2727
    init_slave() must be called after the thread keys are created.
2728
    Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other
2729
    places) assume that active_mi != 0, so let's fail if it's 0 (out of
2730
    memory); a message has already been printed.
2731
  */
2732
  if (init_slave() && !active_mi)
2733
  {
2734
    unireg_abort(1);
2735
  }
2736
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2737
  sql_print_information(_(ER(ER_STARTUP)),my_progname,server_version,
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2738
                        "", mysqld_port, DRIZZLE_COMPILATION_COMMENT);
11 by Brian Aker
Removing old UNIX socket bits
2739
2740
2741
  handle_connections_sockets();
1 by brian
clean slate
2742
2743
  /* (void) pthread_attr_destroy(&connection_attrib); */
236.1.40 by Monty Taylor
A few meaningless changes.
2744
1 by brian
clean slate
2745
2746
#ifdef EXTRA_DEBUG2
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2747
  sql_print_error(_("Before Lock_thread_count"));
1 by brian
clean slate
2748
#endif
2749
  (void) pthread_mutex_lock(&LOCK_thread_count);
2750
  select_thread_in_use=0;			// For close_connections
2751
  (void) pthread_mutex_unlock(&LOCK_thread_count);
2752
  (void) pthread_cond_broadcast(&COND_thread_count);
2753
#ifdef EXTRA_DEBUG2
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2754
  sql_print_error(_("After lock_thread_count"));
1 by brian
clean slate
2755
#endif
2756
2757
  /* Wait until cleanup is done */
2758
  (void) pthread_mutex_lock(&LOCK_thread_count);
2759
  while (!ready_to_exit)
2760
    pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
2761
  (void) pthread_mutex_unlock(&LOCK_thread_count);
2762
2763
  clean_up(1);
2764
  mysqld_exit(0);
2765
}
2766
2767
2768
/**
2769
  Create new thread to handle incoming connection.
2770
2771
    This function will create new thread to handle the incoming
2772
    connection.  If there are idle cached threads one will be used.
2773
    'thd' will be pushed into 'threads'.
2774
2775
    In single-threaded mode (\#define ONE_THREAD) connection will be
2776
    handled inside this function.
2777
2778
  @param[in,out] thd    Thread handle of future thread.
2779
*/
2780
2781
static void create_new_thread(THD *thd)
2782
{
2783
2784
  /*
2785
    Don't allow too many connections. We roughly check here that we allow
2786
    only (max_connections + 1) connections.
2787
  */
2788
2789
  pthread_mutex_lock(&LOCK_connection_count);
2790
2791
  if (connection_count >= max_connections + 1 || abort_loop)
2792
  {
2793
    pthread_mutex_unlock(&LOCK_connection_count);
2794
2795
    close_connection(thd, ER_CON_COUNT_ERROR, 1);
2796
    delete thd;
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2797
    return;;
1 by brian
clean slate
2798
  }
2799
2800
  ++connection_count;
2801
2802
  if (connection_count > max_used_connections)
2803
    max_used_connections= connection_count;
2804
2805
  pthread_mutex_unlock(&LOCK_connection_count);
2806
2807
  /* Start a new thread to handle connection. */
2808
2809
  pthread_mutex_lock(&LOCK_thread_count);
2810
2811
  /*
2812
    The initialization of thread_id is done in create_embedded_thd() for
2813
    the embedded library.
2814
    TODO: refactor this to avoid code duplication there
2815
  */
2816
  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
2817
2818
  thread_count++;
2819
2820
  thread_scheduler.add_connection(thd);
2821
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
2822
  return;;
1 by brian
clean slate
2823
}
2824
2825
2826
#ifdef SIGNALS_DONT_BREAK_READ
2827
inline void kill_broken_server()
2828
{
2829
  /* hack to get around signals ignored in syscalls for problem OS's */
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
2830
  if ((ip_sock == -1))
1 by brian
clean slate
2831
  {
2832
    select_thread_in_use = 0;
2833
    /* The following call will never return */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
2834
    kill_server((void*) DRIZZLE_KILL_SIGNAL);
1 by brian
clean slate
2835
  }
2836
}
2837
#define MAYBE_BROKEN_SYSCALL kill_broken_server();
2838
#else
2839
#define MAYBE_BROKEN_SYSCALL
2840
#endif
2841
2842
	/* Handle new connections and spawn new process to handle them */
2843
11 by Brian Aker
Removing old UNIX socket bits
2844
void handle_connections_sockets()
1 by brian
clean slate
2845
{
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
2846
  int x;
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
2847
  int sock,new_sock;
1 by brian
clean slate
2848
  uint error_count=0;
2849
  THD *thd;
2850
  struct sockaddr_storage cAddr;
2851
  st_vio *vio_tmp;
2852
2853
  MAYBE_BROKEN_SYSCALL;
2854
  while (!abort_loop)
2855
  {
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
2856
    int number_of;
2857
2858
    if ((number_of= poll(fds, pollfd_count, -1)) == -1)
1 by brian
clean slate
2859
    {
2860
      if (socket_errno != SOCKET_EINTR)
2861
      {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
2862
        if (!select_errors++ && !abort_loop)	/* purecov: inspected */
2863
          sql_print_error(_("drizzled: Got error %d from select"),
2864
                          socket_errno); /* purecov: inspected */
1 by brian
clean slate
2865
      }
2866
      MAYBE_BROKEN_SYSCALL
2867
      continue;
2868
    }
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
2869
    if (number_of == 0)
2870
      continue;
236.1.40 by Monty Taylor
A few meaningless changes.
2871
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
2872
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
2873
    assert(number_of > 1); /* Not handling this at the moment */
2874
#endif
2875
1 by brian
clean slate
2876
    if (abort_loop)
2877
    {
2878
      MAYBE_BROKEN_SYSCALL;
2879
      break;
2880
    }
2881
229 by Brian Aker
This is the second pass through the code. Mainly to get the socket loop
2882
    for (x= 0, sock= -1; x < pollfd_count; x++)
2883
    {
2884
      if (fds[x].revents == POLLIN)
2885
      {
2886
        sock= fds[x].fd;
2887
        break;
2888
      }
2889
    }
2890
    assert(sock != -1);
1 by brian
clean slate
2891
2892
    for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2893
    {
2894
      size_socket length= sizeof(struct sockaddr_storage);
2895
      new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2896
                       &length);
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
2897
      if (new_sock != -1 || (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
1 by brian
clean slate
2898
	break;
2899
    }
228 by Brian Aker
First pass on socket cleanup.
2900
2901
268 by Brian Aker
Merging up a bunch of assert() and cleanup of my_sock typedef
2902
    if (new_sock == -1)
1 by brian
clean slate
2903
    {
2904
      if ((error_count++ & 255) == 0)		// This can happen often
2905
	sql_perror("Error in accept");
2906
      MAYBE_BROKEN_SYSCALL;
2907
      if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
2908
	sleep(1);				// Give other threads some time
2909
      continue;
2910
    }
2911
2912
    {
2913
      size_socket dummyLen;
2914
      struct sockaddr_storage dummy;
2915
      dummyLen = sizeof(dummy);
236.1.40 by Monty Taylor
A few meaningless changes.
2916
      if (  getsockname(new_sock,(struct sockaddr *)&dummy,
292 by Brian Aker
Merge
2917
                        (socklen_t *)&dummyLen) < 0  )
1 by brian
clean slate
2918
      {
292 by Brian Aker
Merge
2919
        sql_perror("Error on new connection socket");
2920
        (void) shutdown(new_sock, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
2921
        (void) close(new_sock);
292 by Brian Aker
Merge
2922
        continue;
287.1.1 by Andrew Garner
extended check for bad connections after accept
2923
      }
292 by Brian Aker
Merge
2924
      dummyLen = sizeof(dummy);
2925
      if ( getpeername(new_sock, (struct sockaddr *)&dummy,
2926
                       (socklen_t *)&dummyLen) < 0)
287.1.1 by Andrew Garner
extended check for bad connections after accept
2927
      {
292 by Brian Aker
Merge
2928
        sql_perror("Error on new connection socket");
2929
        (void) shutdown(new_sock, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
2930
        (void) close(new_sock);
287.1.1 by Andrew Garner
extended check for bad connections after accept
2931
         continue;
1 by brian
clean slate
2932
      }
2933
    }
2934
2935
    /*
2936
    ** Don't allow too many connections
2937
    */
2938
2939
    if (!(thd= new THD))
2940
    {
2941
      (void) shutdown(new_sock, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
2942
      VOID(close(new_sock));
1 by brian
clean slate
2943
      continue;
2944
    }
11 by Brian Aker
Removing old UNIX socket bits
2945
    if (!(vio_tmp=vio_new(new_sock, VIO_TYPE_TCPIP, sock == 0)) ||
1 by brian
clean slate
2946
	my_net_init(&thd->net,vio_tmp))
2947
    {
2948
      /*
2949
        Only delete the temporary vio if we didn't already attach it to the
2950
        NET object. The destructor in THD will delete any initialized net
2951
        structure.
2952
      */
2953
      if (vio_tmp && thd->net.vio != vio_tmp)
2954
        vio_delete(vio_tmp);
2955
      else
2956
      {
2957
	(void) shutdown(new_sock, SHUT_RDWR);
293 by Brian Aker
Merge + closesocket() fix
2958
	(void) close(new_sock);
1 by brian
clean slate
2959
      }
2960
      delete thd;
2961
      continue;
2962
    }
2963
2964
    create_new_thread(thd);
2965
  }
2966
}
2967
2968
2969
/****************************************************************************
2970
  Handle start options
2971
******************************************************************************/
2972
2973
enum options_mysqld
2974
{
236.1.40 by Monty Taylor
A few meaningless changes.
2975
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW,
2976
  OPT_SKIP_GRANT,
1 by brian
clean slate
2977
  OPT_ENABLE_LOCK,             OPT_USE_LOCKING,
2978
  OPT_SOCKET,                  OPT_UPDATE_LOG,
236.1.40 by Monty Taylor
A few meaningless changes.
2979
  OPT_BIN_LOG,
1 by brian
clean slate
2980
  OPT_BIN_LOG_INDEX,
2981
  OPT_BIND_ADDRESS,            OPT_PID_FILE,
245 by Brian Aker
Removed dead variables.
2982
  OPT_SKIP_PRIOR,
12.1.3 by Brian Aker
Removal of dead code/remove non-used Falcon tests.
2983
  OPT_STANDALONE,
1 by brian
clean slate
2984
  OPT_CONSOLE,                 OPT_LOW_PRIORITY_UPDATES,
2985
  OPT_SHORT_LOG_FORMAT,
2986
  OPT_FLUSH,                   OPT_SAFE,
2987
  OPT_STORAGE_ENGINE,          OPT_INIT_FILE,
2988
  OPT_DELAY_KEY_WRITE_ALL,     OPT_SLOW_QUERY_LOG,
2989
  OPT_DELAY_KEY_WRITE,	       OPT_CHARSETS_DIR,
2990
  OPT_MASTER_INFO_FILE,
2991
  OPT_MASTER_RETRY_COUNT,      OPT_LOG_TC, OPT_LOG_TC_SIZE,
2992
  OPT_SQL_BIN_UPDATE_SAME,     OPT_REPLICATE_DO_DB,
2993
  OPT_REPLICATE_IGNORE_DB,     OPT_LOG_SLAVE_UPDATES,
2994
  OPT_BINLOG_DO_DB,            OPT_BINLOG_IGNORE_DB,
2995
  OPT_BINLOG_FORMAT,
236.1.40 by Monty Taylor
A few meaningless changes.
2996
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
1 by brian
clean slate
2997
  OPT_WANT_CORE,
2998
  OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
2999
  OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
3000
  OPT_SKIP_SLAVE_START,
3001
  OPT_REPLICATE_DO_TABLE,
3002
  OPT_REPLICATE_IGNORE_TABLE,  OPT_REPLICATE_WILD_DO_TABLE,
3003
  OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
3004
  OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
3005
  OPT_ABORT_SLAVE_EVENT_COUNT,
3006
  OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
236.1.40 by Monty Taylor
A few meaningless changes.
3007
  OPT_ENGINE_CONDITION_PUSHDOWN,
1 by brian
clean slate
3008
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
3009
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
3010
  OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
3011
  OPT_SAFE_USER_CREATE,
3012
  OPT_DO_PSTACK, OPT_REPORT_HOST,
3013
  OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT,
3014
  OPT_SHOW_SLAVE_AUTH_INFO,
3015
  OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE,
3016
  OPT_RPL_RECOVERY_RANK,
3017
  OPT_RELAY_LOG, OPT_RELAY_LOG_INDEX, OPT_RELAY_LOG_INFO_FILE,
3018
  OPT_SLAVE_SKIP_ERRORS, OPT_SLAVE_ALLOW_BATCHING, OPT_DES_KEY_FILE, OPT_LOCAL_INFILE,
3019
  OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA,
3020
  OPT_SSL_CAPATH, OPT_SSL_CIPHER,
3021
  OPT_BACK_LOG, OPT_BINLOG_CACHE_SIZE,
3022
  OPT_CONNECT_TIMEOUT,
160.1.2 by mark
remove FTPARSER and last remains of full text search
3023
  OPT_FLUSH_TIME,
1 by brian
clean slate
3024
  OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
3025
  OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
3026
  OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
3027
  OPT_LONG_QUERY_TIME,
3028
  OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
3029
  OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
3030
  OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
3031
  OPT_MAX_HEP_TABLE_SIZE,
245 by Brian Aker
Removed dead variables.
3032
  OPT_MAX_JOIN_SIZE,
1 by brian
clean slate
3033
  OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH,
3034
  OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
3035
  OPT_MAX_LENGTH_FOR_SORT_DATA,
3036
  OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
3037
  OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE,
3038
  OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
3039
  OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
3040
  OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
3041
  OPT_MYISAM_STATS_METHOD,
3042
  OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
3043
  OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
3044
  OPT_OPEN_FILES_LIMIT,
3045
  OPT_PRELOAD_BUFFER_SIZE,
245 by Brian Aker
Removed dead variables.
3046
  OPT_RECORD_BUFFER,
1 by brian
clean slate
3047
  OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT,
3048
  OPT_RELAY_LOG_PURGE,
3049
  OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
3050
  OPT_SLAVE_TRANS_RETRIES, OPT_READONLY, OPT_DEBUGGING,
3051
  OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE,
3052
  OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
3053
  OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
3054
  OPT_WAIT_TIMEOUT,
3055
  OPT_ERROR_LOG_FILE,
3056
  OPT_DEFAULT_WEEK_FORMAT,
80.2.1 by mark
remove handling of suspicious UDFs
3057
  OPT_RANGE_ALLOC_BLOCK_SIZE,
1 by brian
clean slate
3058
  OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
3059
  OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
3060
  OPT_SYNC_FRM, OPT_SYNC_BINLOG,
3061
  OPT_SYNC_REPLICATION,
3062
  OPT_SYNC_REPLICATION_SLAVE_ID,
3063
  OPT_SYNC_REPLICATION_TIMEOUT,
3064
  OPT_ENABLE_SHARED_MEMORY,
3065
  OPT_SHARED_MEMORY_BASE_NAME,
3066
  OPT_OLD_ALTER_TABLE,
3067
  OPT_EXPIRE_LOGS_DAYS,
3068
  OPT_GROUP_CONCAT_MAX_LEN,
3069
  OPT_DEFAULT_COLLATION,
3070
  OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
3071
  OPT_CHARACTER_SET_FILESYSTEM,
3072
  OPT_LC_TIME_NAMES,
3073
  OPT_INIT_CONNECT,
3074
  OPT_INIT_SLAVE,
3075
  OPT_SECURE_AUTH,
3076
  OPT_DATE_FORMAT,
3077
  OPT_TIME_FORMAT,
3078
  OPT_DATETIME_FORMAT,
3079
  OPT_LOG_QUERIES_NOT_USING_INDEXES,
3080
  OPT_DEFAULT_TIME_ZONE,
3081
  OPT_SYSDATE_IS_NOW,
3082
  OPT_OPTIMIZER_SEARCH_DEPTH,
3083
  OPT_OPTIMIZER_PRUNE_LEVEL,
3084
  OPT_UPDATABLE_VIEWS_WITH_LIMIT,
3085
  OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET,
3086
  OPT_ENABLE_LARGE_PAGES,
3087
  OPT_TIMED_MUTEXES,
3088
  OPT_OLD_STYLE_USER_LIMITS,
3089
  OPT_LOG_SLOW_ADMIN_STATEMENTS,
3090
  OPT_TABLE_LOCK_WAIT_TIMEOUT,
3091
  OPT_PLUGIN_LOAD,
3092
  OPT_PLUGIN_DIR,
3093
  OPT_LOG_OUTPUT,
3094
  OPT_PORT_OPEN_TIMEOUT,
3095
  OPT_PROFILING,
3096
  OPT_KEEP_FILES_ON_CREATE,
3097
  OPT_GENERAL_LOG,
3098
  OPT_SLOW_LOG,
3099
  OPT_THREAD_HANDLING,
3100
  OPT_INNODB_ROLLBACK_ON_TIMEOUT,
3101
  OPT_SECURE_FILE_PRIV,
3102
  OPT_MIN_EXAMINED_ROW_LIMIT,
3103
  OPT_LOG_SLOW_SLAVE_STATEMENTS,
3104
  OPT_OLD_MODE,
3105
  OPT_POOL_OF_THREADS,
3106
  OPT_SLAVE_EXEC_MODE
3107
};
3108
3109
366 by Patrick Galbraith
Ulong conversion
3110
#define LONG_TIMEOUT ((uint32_t) 3600L*24L*365L)
1 by brian
clean slate
3111
3112
struct my_option my_long_options[] =
3113
{
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3114
  {"help", '?', N_("Display this help and exit."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3115
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1 by brian
clean slate
3116
   0, 0},
3117
  {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3118
   N_("Option used by mysql-test for debugging and testing of replication."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3119
   (char**) &abort_slave_event_count,  (char**) &abort_slave_event_count,
1 by brian
clean slate
3120
   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3121
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3122
   N_("Auto-increment columns are incremented by this"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3123
   (char**) &global_system_variables.auto_increment_increment,
3124
   (char**) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
1 by brian
clean slate
3125
   OPT_ARG, 1, 1, 65535, 0, 1, 0 },
3126
  {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3127
   N_("Offset added to Auto-increment columns. Used when "
3128
      "auto-increment-increment != 1"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3129
   (char**) &global_system_variables.auto_increment_offset,
3130
   (char**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
1 by brian
clean slate
3131
   1, 1, 65535, 0, 1, 0 },
3132
  {"basedir", 'b',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3133
   N_("Path to installation directory. All paths are usually resolved "
3134
      "relative to this."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3135
   (char**) &mysql_home_ptr, (char**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
3136
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3137
  {"bind-address", OPT_BIND_ADDRESS, N_("IP address to bind to."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3138
   (char**) &my_bind_addr_str, (char**) &my_bind_addr_str, 0, GET_STR,
1 by brian
clean slate
3139
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3140
  {"binlog_format", OPT_BINLOG_FORMAT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3141
   N_("Does not have any effect without '--log-bin'. "
3142
      "Tell the master the form of binary logging to use: either 'row' for "
3143
      "row-based binary logging, or 'statement' for statement-based binary "
3144
      "logging, or 'mixed'. 'mixed' is statement-based binary logging except "
3145
      "for those statements where only row-based is correct: those which "
3146
      "involve user-defined functions (i.e. UDFs) or the UUID() function; for "
3147
      "those, row-based binary logging is automatically used. ")
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3148
   ,(char**) &opt_binlog_format, (char**) &opt_binlog_format,
1 by brian
clean slate
3149
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3150
  {"binlog-do-db", OPT_BINLOG_DO_DB,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3151
   N_("Tells the master it should log updates for the specified database, and "
3152
      "exclude all others not explicitly mentioned."),
1 by brian
clean slate
3153
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3154
  {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3155
   N_("Tells the master that updates to the given database should not "
3156
      "be logged tothe binary log."),
1 by brian
clean slate
3157
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3158
  {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3159
   N_("The maximum size of a row-based binary log event in bytes. Rows will "
3160
      "be grouped into events smaller than this size if possible. "
3161
      "The value has to be a multiple of 256."),
236.1.40 by Monty Taylor
A few meaningless changes.
3162
   (char**) &opt_binlog_rows_event_max_size,
3163
   (char**) &opt_binlog_rows_event_max_size, 0,
3164
   GET_ULONG, REQUIRED_ARG,
3165
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX,
3166
   /* sub_size */     0, /* block_size */ 256,
1 by brian
clean slate
3167
   /* app_type */ 0
3168
  },
3169
  {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3170
   N_("Don't ignore client side character set value sent during handshake."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3171
   (char**) &opt_character_set_client_handshake,
3172
   (char**) &opt_character_set_client_handshake,
1 by brian
clean slate
3173
    0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
3174
  {"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3175
   N_("Set the filesystem character set."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3176
   (char**) &character_set_filesystem_name,
3177
   (char**) &character_set_filesystem_name,
1 by brian
clean slate
3178
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3179
  {"character-set-server", 'C',
3180
   N_("Set the default character set."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3181
   (char**) &default_character_set_name, (char**) &default_character_set_name,
1 by brian
clean slate
3182
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3183
  {"character-sets-dir", OPT_CHARSETS_DIR,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3184
   N_("Directory where character sets are."), (char**) &charsets_dir,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3185
   (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3186
  {"chroot", 'r',
3187
   N_("Chroot mysqld daemon during startup."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3188
   (char**) &mysqld_chroot, (char**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
3189
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3190
  {"collation-server", OPT_DEFAULT_COLLATION,
3191
   N_("Set the default collation."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3192
   (char**) &default_collation_name, (char**) &default_collation_name,
1 by brian
clean slate
3193
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3194
  {"completion-type", OPT_COMPLETION_TYPE,
3195
   N_("Default completion type."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3196
   (char**) &global_system_variables.completion_type,
3197
   (char**) &max_system_variables.completion_type, 0, GET_ULONG,
1 by brian
clean slate
3198
   REQUIRED_ARG, 0, 0, 2, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3199
  {"console", OPT_CONSOLE,
3200
   N_("Write error output on screen."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3201
   (char**) &opt_console, (char**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1 by brian
clean slate
3202
   0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3203
  {"core-file", OPT_WANT_CORE,
3204
   N_("Write core on errors."),
3205
   0, 0, 0, GET_NO_ARG,
1 by brian
clean slate
3206
   NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3207
  {"datadir", 'h',
3208
   N_("Path to the database root."),
3209
   (char**) &mysql_data_home,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3210
   (char**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3211
  {"default-character-set", 'C',
3212
   N_("Set the default character set (deprecated option, use "
3213
      "--character-set-server instead)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3214
   (char**) &default_character_set_name, (char**) &default_character_set_name,
1 by brian
clean slate
3215
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3216
  {"default-collation", OPT_DEFAULT_COLLATION,
3217
   N_("Set the default collation (deprecated option, use --collation-server "
3218
      "instead)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3219
   (char**) &default_collation_name, (char**) &default_collation_name,
1 by brian
clean slate
3220
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3221
  {"default-storage-engine", OPT_STORAGE_ENGINE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3222
   N_("Set the default storage engine (table type) for tables."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3223
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
1 by brian
clean slate
3224
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3225
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE,
3226
   N_("Set the default time zone."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3227
   (char**) &default_tz_name, (char**) &default_tz_name,
1 by brian
clean slate
3228
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3229
  {"delay-key-write", OPT_DELAY_KEY_WRITE,
3230
   N_("Type of DELAY_KEY_WRITE."),
1 by brian
clean slate
3231
   0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3232
  {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3233
   N_("Don't flush key buffers between writes for any MyISAM table "
3234
      "(Deprecated option, use --delay-key-write=all instead)."),
1 by brian
clean slate
3235
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3236
  {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3237
   N_("Option used by mysql-test for debugging and testing of replication."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3238
   (char**) &disconnect_slave_event_count,
3239
   (char**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
1 by brian
clean slate
3240
   0, 0, 0},
3241
#ifdef HAVE_STACK_TRACE_ON_SEGV
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3242
  {"enable-pstack", OPT_DO_PSTACK,
3243
   N_("Print a symbolic stack trace on failure."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3244
   (char**) &opt_do_pstack, (char**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
1 by brian
clean slate
3245
   0, 0, 0, 0},
3246
#endif /* HAVE_STACK_TRACE_ON_SEGV */
3247
  {"engine-condition-pushdown",
3248
   OPT_ENGINE_CONDITION_PUSHDOWN,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3249
   N_("Push supported query conditions to the storage engine."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3250
   (char**) &global_system_variables.engine_condition_pushdown,
3251
   (char**) &global_system_variables.engine_condition_pushdown,
1 by brian
clean slate
3252
   0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
3253
  /* See how it's handled in get_one_option() */
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3254
  {"exit-info", 'T',
3255
   N_("Used for debugging;  Use at your own risk!"),
3256
   0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
3257
  {"flush", OPT_FLUSH,
3258
   N_("Flush tables to disk between SQL commands."),
3259
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3260
  /* We must always support the next option to make scripts like mysqltest
3261
     easier to do */
3262
  {"gdb", OPT_DEBUGGING,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3263
   N_("Set up signals usable for debugging"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3264
   (char**) &opt_debugging, (char**) &opt_debugging,
1 by brian
clean slate
3265
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3266
  {"general-log", OPT_GENERAL_LOG,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3267
   N_("Enable general query log"),
3268
   (char**) &opt_log,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3269
   (char**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3270
  {"init-connect", OPT_INIT_CONNECT,
3271
   N_("Command(s) that are executed for each new connection"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3272
   (char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
1 by brian
clean slate
3273
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3274
  {"init-file", OPT_INIT_FILE,
3275
   N_("Read SQL commands from this file at startup."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3276
   (char**) &opt_init_file, (char**) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
3277
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3278
  {"init-slave", OPT_INIT_SLAVE,
3279
   N_("Command(s) that are executed when a slave connects to this master"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3280
   (char**) &opt_init_slave, (char**) &opt_init_slave, 0, GET_STR_ALLOC,
1 by brian
clean slate
3281
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3282
  {"language", 'L',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3283
   N_("(IGNORED)"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3284
   (char**) &language_ptr, (char**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
3285
   0, 0, 0, 0, 0, 0},
3286
  {"lc-time-names", OPT_LC_TIME_NAMES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3287
   N_("Set the language used for the month names and the days of the week."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3288
   (char**) &lc_time_names_name,
3289
   (char**) &lc_time_names_name,
1 by brian
clean slate
3290
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3291
  {"local-infile", OPT_LOCAL_INFILE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3292
   N_("Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3293
   (char**) &opt_local_infile,
3294
   (char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
1 by brian
clean slate
3295
   1, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3296
  {"log", 'l',
3297
   N_("Log connections and queries to file."),
3298
   (char**) &opt_logname,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3299
   (char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3300
  {"log-bin", OPT_BIN_LOG,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3301
   N_("Log update queries in binary format. Optional argument is the "
3302
      "location for the binary log files.(Strongly "
3303
      "recommended to avoid replication problems if server's hostname "
3304
      "changes)"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3305
   (char**) &opt_bin_logname, (char**) &opt_bin_logname, 0, GET_STR_ALLOC,
1 by brian
clean slate
3306
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3307
  {"log-bin-index", OPT_BIN_LOG_INDEX,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3308
   N_("File that holds the names for last binary log files."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3309
   (char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
1 by brian
clean slate
3310
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3311
  /*
3312
    This option starts with "log-bin" to emphasize that it is specific of
3313
    binary logging.
3314
  */
3315
  {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3316
   N_("If equal to 0 (the default), then when --log-bin is used, creation of "
3317
      "a stored function (or trigger) is allowed only to users having the "
3318
      "SUPER privilege and only if this stored function (trigger) may not "
3319
      "break binary logging. Note that if ALL connections to this server "
3320
      "ALWAYS use row-based binary logging, the security issues do not exist "
3321
      "and the binary logging cannot break, so you can safely set this to 1.")
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3322
   ,(char**) &trust_function_creators, (char**) &trust_function_creators, 0,
1 by brian
clean slate
3323
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3324
  {"log-error", OPT_ERROR_LOG_FILE,
3325
   N_("Error log file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3326
   (char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
1 by brian
clean slate
3327
   OPT_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3328
  {"log-isam", OPT_ISAM_LOG,
3329
   N_("Log all MyISAM changes to file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3330
   (char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
1 by brian
clean slate
3331
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3332
  {"log-long-format", '0',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3333
   N_("Log some extra information to update log. Please note that this option "
3334
      "is deprecated; see --log-queries-not-using-indexes option."),
1 by brian
clean slate
3335
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3336
#ifdef WITH_CSV_STORAGE_ENGINE
3337
  {"log-output", OPT_LOG_OUTPUT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3338
   N_("Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
3339
      "FILE or NONE."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3340
   (char**) &log_output_str, (char**) &log_output_str, 0,
1 by brian
clean slate
3341
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3342
#endif
3343
  {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3344
   N_("Log queries that are executed without benefit of any index to the "
3345
      "slow log if it is open."),
3346
   (char**) &opt_log_queries_not_using_indexes,
3347
   (char**) &opt_log_queries_not_using_indexes,
1 by brian
clean slate
3348
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3349
  {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3350
   N_("Tells the slave to log the updates from the slave thread to the binary "
3351
      "log. You will need to turn it on if you plan to "
3352
      "daisy-chain the slaves."),
3353
   (char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3354
   0, GET_BOOL,
1 by brian
clean slate
3355
   NO_ARG, 0, 0, 0, 0, 0, 0},
3356
  {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3357
   N_("Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements "
3358
      "to the slow log if it is open."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3359
   (char**) &opt_log_slow_admin_statements,
3360
   (char**) &opt_log_slow_admin_statements,
1 by brian
clean slate
3361
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3362
 {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3363
  N_("Log slow statements executed by slave thread to the slow log if it is "
3364
     "open."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3365
  (char**) &opt_log_slow_slave_statements,
3366
  (char**) &opt_log_slow_slave_statements,
1 by brian
clean slate
3367
  0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3368
  {"log-slow-queries", OPT_SLOW_QUERY_LOG,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3369
   N_("Log slow queries to a table or log file. Defaults logging to table "
3370
      "mysql.slow_log or hostname-slow.log if --log-output=file is used. "
3371
      "Must be enabled to activate other slow log options."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3372
   (char**) &opt_slow_logname, (char**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
1 by brian
clean slate
3373
   0, 0, 0, 0, 0, 0},
3374
  {"log-tc", OPT_LOG_TC,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3375
   N_("Path to transaction coordinator log (used for transactions that affect "
3376
      "more than one storage engine, when binary log is disabled)"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3377
   (char**) &opt_tc_log_file, (char**) &opt_tc_log_file, 0, GET_STR,
1 by brian
clean slate
3378
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3379
#ifdef HAVE_MMAP
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3380
  {"log-tc-size", OPT_LOG_TC_SIZE,
3381
   N_("Size of transaction coordinator log."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3382
   (char**) &opt_tc_log_size, (char**) &opt_tc_log_size, 0, GET_ULONG,
1 by brian
clean slate
3383
   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
3384
   TC_LOG_PAGE_SIZE, 0},
3385
#endif
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3386
  {"log-warnings", 'W',
3387
   N_("Log some not critical warnings to the log file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3388
   (char**) &global_system_variables.log_warnings,
3389
   (char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
1 by brian
clean slate
3390
   0, 0, 0},
3391
  {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3392
   N_("INSERT/DELETE/UPDATE has lower priority than selects."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3393
   (char**) &global_system_variables.low_priority_updates,
3394
   (char**) &max_system_variables.low_priority_updates,
1 by brian
clean slate
3395
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3396
  {"master-info-file", OPT_MASTER_INFO_FILE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3397
   N_("The location and name of the file that remembers the master and "
3398
      "where the I/O replication thread is in the master's binlogs."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3399
   (char**) &master_info_file, (char**) &master_info_file, 0, GET_STR,
1 by brian
clean slate
3400
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3401
  {"master-retry-count", OPT_MASTER_RETRY_COUNT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3402
   N_("The number of tries the slave will make to connect to the master "
3403
      "before giving up."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3404
   (char**) &master_retry_count, (char**) &master_retry_count, 0, GET_ULONG,
1 by brian
clean slate
3405
   REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
3406
  {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3407
   N_("Option used by mysql-test for debugging and testing of replication."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3408
   (char**) &max_binlog_dump_events, (char**) &max_binlog_dump_events, 0,
1 by brian
clean slate
3409
   GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3410
  {"memlock", OPT_MEMLOCK,
3411
   N_("Lock mysqld in memory."),
3412
   (char**) &locked_in_memory,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3413
   (char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3414
  {"myisam-recover", OPT_MYISAM_RECOVER,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3415
   N_("Syntax: myisam-recover[=option[,option...]], where option can be "
3416
      "DEFAULT, BACKUP, FORCE or QUICK."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3417
   (char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
1 by brian
clean slate
3418
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3419
  {"new", 'n',
3420
   N_("Use very new possible 'unsafe' functions."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3421
   (char**) &global_system_variables.new_mode,
3422
   (char**) &max_system_variables.new_mode,
1 by brian
clean slate
3423
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3424
  {"old-alter-table", OPT_OLD_ALTER_TABLE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3425
   N_("Use old, non-optimized alter table."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3426
   (char**) &global_system_variables.old_alter_table,
3427
   (char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
3428
   0, 0, 0, 0, 0, 0},
3429
  {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3430
   N_("Enable old-style user limits (before 5.0.3 user resources were counted "
3431
      "per each user+host vs. per account)"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3432
   (char**) &opt_old_style_user_limits, (char**) &opt_old_style_user_limits,
1 by brian
clean slate
3433
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3434
  {"pid-file", OPT_PID_FILE,
3435
   N_("Pid file used by safe_mysqld."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3436
   (char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
1 by brian
clean slate
3437
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3438
  {"port", 'P',
3439
   N_("Port number to use for connection or 0 for default to, in "
3440
      "order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
3441
      "built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3442
   (char**) &mysqld_port,
3443
   (char**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3444
  {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3445
   N_("Maximum time in seconds to wait for the port to become free. "
3446
      "(Default: no wait)"),
3447
   (char**) &mysqld_port_timeout,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3448
   (char**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3449
  {"relay-log", OPT_RELAY_LOG,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3450
   N_("The location and name to use for relay logs."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3451
   (char**) &opt_relay_logname, (char**) &opt_relay_logname, 0,
1 by brian
clean slate
3452
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3453
  {"relay-log-index", OPT_RELAY_LOG_INDEX,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3454
   N_("The location and name to use for the file that keeps a list of the "
3455
      "last relay logs."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3456
   (char**) &opt_relaylog_index_name, (char**) &opt_relaylog_index_name, 0,
1 by brian
clean slate
3457
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3458
  {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3459
   N_("The location and name of the file that remembers where the SQL "
3460
      "replication thread is in the relay logs."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3461
   (char**) &relay_log_info_file, (char**) &relay_log_info_file, 0, GET_STR,
1 by brian
clean slate
3462
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3463
  {"replicate-do-db", OPT_REPLICATE_DO_DB,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3464
   N_("Tells the slave thread to restrict replication to the specified "
3465
      "database. To specify more than one database, use the directive "
3466
      "multiple times, once for each database. Note that this will only work "
3467
      "if you do not use cross-database queries such as UPDATE "
3468
      "some_db.some_table SET foo='bar' while having selected a different or "
3469
      "no database. If you need cross database updates to work, use "
312.1.12 by Monty Taylor
Fixed a syntax oops.
3470
      "replicate-wild-do-table=db_name.%."),
1 by brian
clean slate
3471
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3472
  {"replicate-do-table", OPT_REPLICATE_DO_TABLE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3473
   N_("Tells the slave thread to restrict replication to the specified table. "
3474
      "To specify more than one table, use the directive multiple times, once "
3475
      "for each table. This will work for cross-database updates, in contrast "
3476
      "to replicate-do-db."),
1 by brian
clean slate
3477
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3478
  {"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3479
   N_("Tells the slave thread to not replicate to the specified database. To "
3480
      "specify more than one database to ignore, use the directive multiple "
3481
      "times, once for each database. This option will not work if you use "
3482
      "cross database updates. If you need cross database updates to work, "
3483
      "use replicate-wild-ignore-table=db_name.%. "),
1 by brian
clean slate
3484
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3485
  {"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3486
   N_("Tells the slave thread to not replicate to the specified table. To "
3487
      "specify more than one table to ignore, use the directive multiple "
3488
      "times, once for each table. This will work for cross-datbase updates, "
3489
      "in contrast to replicate-ignore-db."),
1 by brian
clean slate
3490
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3491
  {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3492
   N_("Updates to a database with a different name than the original. "
3493
      "Example: replicate-rewrite-db=master_db_name->slave_db_name."),
1 by brian
clean slate
3494
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3495
  {"replicate-same-server-id", OPT_REPLICATE_SAME_SERVER_ID,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3496
   N_("In replication, if set to 1, do not skip events having our server id. "
3497
      "Default value is 0 (to break infinite loops in circular replication). "
3498
      "Can't be set to 1 if --log-slave-updates is used."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3499
   (char**) &replicate_same_server_id,
3500
   (char**) &replicate_same_server_id,
1 by brian
clean slate
3501
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3502
  {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3503
   N_("Tells the slave thread to restrict replication to the tables that "
3504
      "match the specified wildcard pattern. To specify more than one table, "
3505
      "use the directive multiple times, once for each table. This will work "
3506
      "for cross-database updates. Example: replicate-wild-do-table=foo%.bar% "
3507
      "will replicate only updates to tables in all databases that start with "
3508
      "foo and whose table names start with bar."),
1 by brian
clean slate
3509
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3510
  {"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3511
   N_("Tells the slave thread to not replicate to the tables that match the "
3512
      "given wildcard pattern. To specify more than one table to ignore, use "
3513
      "the directive multiple times, once for each table. This will work for "
3514
      "cross-database updates. Example: replicate-wild-ignore-table=foo%.bar% "
3515
      "will not do updates to tables in databases that start with foo and "
3516
      "whose table names start with bar."),
1 by brian
clean slate
3517
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3518
  // In replication, we may need to tell the other servers how to connect
3519
  {"report-host", OPT_REPORT_HOST,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3520
   N_("Hostname or IP of the slave to be reported to to the master during "
3521
      "slave registration. Will appear in the output of SHOW SLAVE HOSTS. "
3522
      "Leave unset if you do not want the slave to register itself with the "
3523
      "master. Note that it is not sufficient for the master to simply read "
3524
      "the IP of the slave off the socket once the slave connects. Due to NAT "
3525
      "and other routing issues, that IP may not be valid for connecting to "
3526
      "the slave from the master or other hosts."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3527
   (char**) &report_host, (char**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
1 by brian
clean slate
3528
   0, 0, 0, 0},
3529
  {"report-password", OPT_REPORT_PASSWORD, "Undocumented.",
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3530
   (char**) &report_password, (char**) &report_password, 0, GET_STR,
1 by brian
clean slate
3531
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3532
  {"report-port", OPT_REPORT_PORT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3533
   N_("Port for connecting to slave reported to the master during slave "
3534
      "registration. Set it only if the slave is listening on a non-default "
3535
      "port or if you have a special tunnel from the master or other clients "
3536
      "to the slave. If not sure, leave this option unset."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3537
   (char**) &report_port, (char**) &report_port, 0, GET_UINT, REQUIRED_ARG,
301 by Brian Aker
Clean up port startup
3538
   DRIZZLE_PORT, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3539
  {"safe-mode", OPT_SAFE,
3540
   N_("Skip some optimize stages (for testing)."),
1 by brian
clean slate
3541
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3542
  {"secure-file-priv", OPT_SECURE_FILE_PRIV,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3543
   N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
3544
      "within specified directory"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3545
   (char**) &opt_secure_file_priv, (char**) &opt_secure_file_priv, 0,
1 by brian
clean slate
3546
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3547
  {"server-id",	OPT_SERVER_ID,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3548
   N_("Uniquely identifies the server instance in the community of "
3549
      "replication partners."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3550
   (char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
1 by brian
clean slate
3551
   0, 0, 0},
3552
  {"set-variable", 'O',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3553
   N_("Change the value of a variable. Please note that this option is "
3554
      "deprecated;you can set variables directly with --variable-name=value."),
1 by brian
clean slate
3555
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3556
  {"skip-new", OPT_SKIP_NEW,
3557
   N_("Don't use new, possible wrong routines."),
1 by brian
clean slate
3558
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3559
  {"skip-slave-start", OPT_SKIP_SLAVE_START,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3560
   N_("If set, slave is not autostarted."),
3561
   (char**) &opt_skip_slave_start,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3562
   (char**) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3563
  {"skip-stack-trace", OPT_SKIP_STACK_TRACE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3564
   N_("Don't print a stack trace on failure."),
3565
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
1 by brian
clean slate
3566
   0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3567
  {"skip-symlink", OPT_SKIP_SYMLINKS,
3568
   N_("Don't allow symlinking of tables. Deprecated option.  Use "
3569
      "--skip-symbolic-links instead."),
1 by brian
clean slate
3570
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3571
  {"skip-thread-priority", OPT_SKIP_PRIOR,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3572
   N_("Don't give threads different priorities."),
3573
   0, 0, 0, GET_NO_ARG, NO_ARG,
1 by brian
clean slate
3574
   DEFAULT_SKIP_THREAD_PRIORITY, 0, 0, 0, 0, 0},
3575
  {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3576
   N_("The location where the slave should put its temporary files when "
3577
      "replicating a LOAD DATA INFILE command."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3578
   (char**) &slave_load_tmpdir, (char**) &slave_load_tmpdir, 0, GET_STR_ALLOC,
1 by brian
clean slate
3579
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3580
  {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3581
   N_("Tells the slave thread to continue replication when a query event "
3582
      "returns an error from the provided list."),
1 by brian
clean slate
3583
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3584
  {"slave-exec-mode", OPT_SLAVE_EXEC_MODE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3585
   N_("Modes for how replication events should be executed.  Legal values are "
3586
      "STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, replication will "
3587
      "not stop for operations that are idempotent. In STRICT mode, "
3588
      "replication will stop on any unexpected difference between the master "
3589
      "and the slave."),
3590
   (char**) &slave_exec_mode_str, (char**) &slave_exec_mode_str,
3591
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3592
  {"slow-query-log", OPT_SLOW_LOG,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3593
   N_("Enable|disable slow query log"),
3594
   (char**) &opt_slow_log,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3595
   (char**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3596
  {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3597
   N_("(INGORED)"),
1 by brian
clean slate
3598
   0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3599
  {"symbolic-links", 's',
3600
   N_("Enable symbolic link support."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3601
   (char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
3602
   /*
3603
     The system call realpath() produces warnings under valgrind and
3604
     purify. These are not suppressed: instead we disable symlinks
3605
     option if compiled with valgrind support.
3606
   */
3607
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
3608
  {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3609
   N_("Non-default option to alias SYSDATE() to NOW() to make it "
3610
      "safe-replicable."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3611
   (char**) &global_system_variables.sysdate_is_now,
1 by brian
clean slate
3612
   0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3613
  {"tc-heuristic-recover", OPT_TC_HEURISTIC_RECOVER,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3614
   N_("Decision to use in heuristic recover process. Possible values are "
3615
      "COMMIT or ROLLBACK."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3616
   (char**) &opt_tc_heuristic_recover, (char**) &opt_tc_heuristic_recover,
1 by brian
clean slate
3617
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3618
  {"temp-pool", OPT_TEMP_POOL,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3619
   N_("Using this option will cause most temporary files created to use a "
3620
      "small set of names, rather than a unique name for each new file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3621
   (char**) &use_temp_pool, (char**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
1 by brian
clean slate
3622
   0, 0, 0, 0, 0},
3623
  {"timed_mutexes", OPT_TIMED_MUTEXES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3624
   N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
3625
      "supported)"),
236.1.40 by Monty Taylor
A few meaningless changes.
3626
   (char**) &timed_mutexes, (char**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
1 by brian
clean slate
3627
    0, 0, 0, 0, 0},
3628
  {"tmpdir", 't',
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3629
   N_("Path for temporary files. Several paths may be specified, separated "
3630
      "by a colon (:)"
3631
      ", in this case they are used in a round-robin fashion."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3632
   (char**) &opt_mysql_tmpdir,
3633
   (char**) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1 by brian
clean slate
3634
  {"transaction-isolation", OPT_TX_ISOLATION,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3635
   N_("Default transaction isolation level."),
3636
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1 by brian
clean slate
3637
   0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3638
  {"use-symbolic-links", 's',
3639
   N_("Enable symbolic link support. Deprecated option; use --symbolic-links "
3640
      "instead."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3641
   (char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
3642
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3643
  {"user", 'u',
3644
   N_("Run mysqld daemon as user."),
3645
   0, 0, 0, GET_STR, REQUIRED_ARG,
1 by brian
clean slate
3646
   0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3647
  {"version", 'V',
3648
   N_("Output version information and exit."),
3649
   0, 0, 0, GET_NO_ARG,
1 by brian
clean slate
3650
   NO_ARG, 0, 0, 0, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3651
  {"warnings", 'W',
3652
   N_("Deprecated; use --log-warnings instead."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3653
   (char**) &global_system_variables.log_warnings,
3654
   (char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
1 by brian
clean slate
3655
   1, 0, ULONG_MAX, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3656
  {"back_log", OPT_BACK_LOG,
3657
   N_("The number of outstanding connection requests MySQL can have. This "
3658
      "comes into play when the main MySQL thread gets very many connection "
3659
      "requests in a very short time."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3660
    (char**) &back_log, (char**) &back_log, 0, GET_ULONG,
1 by brian
clean slate
3661
    REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3662
  { "binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
3663
    N_("The size of the cache to hold the SQL statements for the binary log "
3664
       "during a transaction. If you often use big, multi-statement "
3665
       "transactions you can increase this to get more performance."),
3666
    (char**) &binlog_cache_size, (char**) &binlog_cache_size, 0, GET_ULONG,
3667
    REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
3668
  { "bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
3669
    N_("Size of tree cache used in bulk insert optimisation. Note that this is "
3670
       "a limit per thread!"),
3671
    (char**) &global_system_variables.bulk_insert_buff_size,
3672
    (char**) &max_system_variables.bulk_insert_buff_size,
3673
    0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
3674
  { "connect_timeout", OPT_CONNECT_TIMEOUT,
3675
    N_("The number of seconds the mysqld server is waiting for a connect "
3676
       "packet before responding with 'Bad handshake'."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3677
    (char**) &connect_timeout, (char**) &connect_timeout,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3678
    0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
1 by brian
clean slate
3679
  { "date_format", OPT_DATE_FORMAT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3680
    N_("The DATE format (For future)."),
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
3681
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
3682
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATE],
1 by brian
clean slate
3683
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3684
  { "datetime_format", OPT_DATETIME_FORMAT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3685
    N_("The DATETIME/TIMESTAMP format (for future)."),
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
3686
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
3687
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_DATETIME],
1 by brian
clean slate
3688
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3689
  { "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3690
    N_("The default week format used by WEEK() functions."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3691
    (char**) &global_system_variables.default_week_format,
3692
    (char**) &max_system_variables.default_week_format,
1 by brian
clean slate
3693
    0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3694
  { "div_precision_increment", OPT_DIV_PRECINCREMENT,
3695
   N_("Precision of the result of '/' operator will be increased on that "
3696
      "value."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3697
   (char**) &global_system_variables.div_precincrement,
3698
   (char**) &max_system_variables.div_precincrement, 0, GET_ULONG,
1 by brian
clean slate
3699
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3700
  { "expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
3701
    N_("If non-zero, binary logs will be purged after expire_logs_days "
3702
       "days; possible purges happen at startup and at binary log rotation."),
3703
    (char**) &expire_logs_days,
3704
    (char**) &expire_logs_days, 0, GET_ULONG,
3705
    REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
1 by brian
clean slate
3706
  { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3707
    N_("The maximum length of the result of function  group_concat."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3708
    (char**) &global_system_variables.group_concat_max_len,
3709
    (char**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
1 by brian
clean slate
3710
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3711
  { "interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
3712
    N_("The number of seconds the server waits for activity on an interactive "
3713
       "connection before closing it."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3714
   (char**) &global_system_variables.net_interactive_timeout,
3715
   (char**) &max_system_variables.net_interactive_timeout, 0,
1 by brian
clean slate
3716
   GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3717
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
3718
    N_("The size of the buffer that is used for full joins."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3719
   (char**) &global_system_variables.join_buff_size,
3720
   (char**) &max_system_variables.join_buff_size, 0, GET_ULONG,
1 by brian
clean slate
3721
   REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
3722
   MALLOC_OVERHEAD, IO_SIZE, 0},
3723
  {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3724
   N_("Don't overwrite stale .MYD and .MYI even if no directory is specified."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3725
   (char**) &global_system_variables.keep_files_on_create,
3726
   (char**) &max_system_variables.keep_files_on_create,
1 by brian
clean slate
3727
   0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3728
  {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3729
   N_("The size of the buffer used for index blocks for MyISAM tables. "
3730
      "Increase this to get better index handling (for all reads and multiple "
312.1.12 by Monty Taylor
Fixed a syntax oops.
3731
      "writes) to as much as you can afford;"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3732
   (char**) &dflt_key_cache_var.param_buff_size,
3733
   (char**) 0,
1 by brian
clean slate
3734
   0, (GET_ULL | GET_ASK_ADDR),
3735
   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
3736
   IO_SIZE, 0},
3737
  {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3738
   N_("This characterizes the number of hits a hot block has to be untouched "
3739
      "until it is considered aged enough to be downgraded to a warm block. "
3740
      "This specifies the percentage ratio of that number of hits to the "
3741
      "total number of blocks in key cache"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3742
   (char**) &dflt_key_cache_var.param_age_threshold,
3743
   (char**) 0,
236.1.40 by Monty Taylor
A few meaningless changes.
3744
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
1 by brian
clean slate
3745
   300, 100, ULONG_MAX, 0, 100, 0},
3746
  {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3747
   N_("The default size of key cache blocks"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3748
   (char**) &dflt_key_cache_var.param_block_size,
3749
   (char**) 0,
1 by brian
clean slate
3750
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
3751
   KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
3752
  {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3753
   N_("The minimum percentage of warm blocks in key cache"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3754
   (char**) &dflt_key_cache_var.param_division_limit,
3755
   (char**) 0,
1 by brian
clean slate
3756
   0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
3757
   1, 100, 0, 1, 0},
3758
  {"long_query_time", OPT_LONG_QUERY_TIME,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3759
   N_("Log all queries that have taken more than long_query_time seconds to "
3760
      "execute to file. The argument will be treated as a decimal value with "
3761
      "microsecond precission."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3762
   (char**) &long_query_time, (char**) &long_query_time, 0, GET_DOUBLE,
1 by brian
clean slate
3763
   REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
3764
  {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3765
   N_("Max packetlength to send/receive from to server."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3766
   (char**) &global_system_variables.max_allowed_packet,
3767
   (char**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
1 by brian
clean slate
3768
   REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
3769
  {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3770
   N_("Can be used to restrict the total size used to cache a "
3771
      "multi-transaction query."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3772
   (char**) &max_binlog_cache_size, (char**) &max_binlog_cache_size, 0,
1 by brian
clean slate
3773
   GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
3774
  {"max_binlog_size", OPT_MAX_BINLOG_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3775
   N_("Binary log will be rotated automatically when the size exceeds this "
3776
      "value. Will also apply to relay logs if max_relay_log_size is 0. "
3777
      "The minimum value for this variable is 4096."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3778
   (char**) &max_binlog_size, (char**) &max_binlog_size, 0, GET_ULONG,
1 by brian
clean slate
3779
   REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0},
3780
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3781
   N_("If there is more than this number of interrupted connections from a "
3782
      "host this host will be blocked from further connections."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3783
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_ULONG,
312.1.12 by Monty Taylor
Fixed a syntax oops.
3784
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
1 by brian
clean slate
3785
  // Default max_connections of 151 is larger than Apache's default max
3786
  // children, to avoid "too many connections" error in a common setup
3787
  {"max_connections", OPT_MAX_CONNECTIONS,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3788
   N_("The number of simultaneous clients allowed."),
3789
   (char**) &max_connections,
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3790
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
1 by brian
clean slate
3791
   0},
3792
  {"max_error_count", OPT_MAX_ERROR_COUNT,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3793
   N_("Max number of errors/warnings to store for a statement."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3794
   (char**) &global_system_variables.max_error_count,
3795
   (char**) &max_system_variables.max_error_count,
1 by brian
clean slate
3796
   0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
3797
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3798
   N_("Don't allow creation of heap tables bigger than this."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3799
   (char**) &global_system_variables.max_heap_table_size,
3800
   (char**) &max_system_variables.max_heap_table_size, 0, GET_ULL,
1 by brian
clean slate
3801
   REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE,
3802
   MALLOC_OVERHEAD, 1024, 0},
3803
  {"max_join_size", OPT_MAX_JOIN_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3804
   N_("Joins that are probably going to read more than max_join_size records "
3805
      "return an error."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3806
   (char**) &global_system_variables.max_join_size,
3807
   (char**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
1 by brian
clean slate
3808
   ~0L, 1, ~0L, 0, 1, 0},
312.1.12 by Monty Taylor
Fixed a syntax oops.
3809
  {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
3810
   N_("Max number of bytes in sorted records."),
3811
   (char**) &global_system_variables.max_length_for_sort_data,
3812
   (char**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
3813
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
1 by brian
clean slate
3814
  {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3815
   N_("If non-zero: relay log will be rotated automatically when the size "
3816
      "exceeds this value; if zero (the default): when the size exceeds "
3817
      "max_binlog_size. 0 excepted, the minimum value for this variable "
3818
      "is 4096."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3819
   (char**) &max_relay_log_size, (char**) &max_relay_log_size, 0, GET_ULONG,
1 by brian
clean slate
3820
   REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0},
3821
  { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3822
    N_("Limit assumed max number of seeks when looking up rows based on a key"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3823
    (char**) &global_system_variables.max_seeks_for_key,
3824
    (char**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
1 by brian
clean slate
3825
    REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
3826
  {"max_sort_length", OPT_MAX_SORT_LENGTH,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3827
   N_("The number of bytes to use when sorting BLOB or TEXT values "
3828
      "(only the first max_sort_length bytes of each value are used; the "
3829
      "rest are ignored)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3830
   (char**) &global_system_variables.max_sort_length,
3831
   (char**) &max_system_variables.max_sort_length, 0, GET_ULONG,
1 by brian
clean slate
3832
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
3833
  {"max_tmp_tables", OPT_MAX_TMP_TABLES,
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
3834
   N_("Maximum number of temporary tables a client can keep open at a time."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3835
   (char**) &global_system_variables.max_tmp_tables,
3836
   (char**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
1 by brian
clean slate
3837
   REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
3838
  {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3839
   N_("After this many write locks, allow some read locks to run in between."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3840
   (char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULONG,
1 by brian
clean slate
3841
   REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
3842
  {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3843
   N_("Don't log queries which examine less than min_examined_row_limit "
3844
      "rows to file."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3845
   (char**) &global_system_variables.min_examined_row_limit,
3846
   (char**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
312.1.12 by Monty Taylor
Fixed a syntax oops.
3847
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
1 by brian
clean slate
3848
  {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3849
   N_("Block size to be used for MyISAM index pages."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3850
   (char**) &opt_myisam_block_size,
3851
   (char**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
1 by brian
clean slate
3852
   MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
3853
   0, MI_MIN_KEY_BLOCK_LENGTH, 0},
3854
  {"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3855
   N_("Default pointer size to be used for MyISAM tables."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3856
   (char**) &myisam_data_pointer_size,
3857
   (char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
1 by brian
clean slate
3858
   6, 2, 7, 0, 1, 0},
3859
  {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3860
   N_("(Deprecated option)"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3861
   (char**) &global_system_variables.myisam_max_extra_sort_file_size,
3862
   (char**) &max_system_variables.myisam_max_extra_sort_file_size,
151 by Brian Aker
Ulonglong to uint64_t
3863
   0, GET_ULL, REQUIRED_ARG, (uint64_t) MI_MAX_TEMP_LENGTH,
3864
   0, (uint64_t) MAX_FILE_SIZE, 0, 1, 0},
1 by brian
clean slate
3865
  {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3866
   N_("Don't use the fast sort index method to created index if the "
3867
      "temporary file would get bigger than this."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3868
   (char**) &global_system_variables.myisam_max_sort_file_size,
3869
   (char**) &max_system_variables.myisam_max_sort_file_size, 0,
152 by Brian Aker
longlong replacement
3870
   GET_ULL, REQUIRED_ARG, (int64_t) LONG_MAX, 0, (uint64_t) MAX_FILE_SIZE,
1 by brian
clean slate
3871
   0, 1024*1024, 0},
3872
  {"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3873
   N_("Number of threads to use when repairing MyISAM tables. The value of "
3874
      "1 disables parallel repair."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3875
   (char**) &global_system_variables.myisam_repair_threads,
3876
   (char**) &max_system_variables.myisam_repair_threads, 0,
1 by brian
clean slate
3877
   GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
3878
  {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3879
   N_("The buffer that is allocated when sorting the index when doing a "
3880
      "REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3881
   (char**) &global_system_variables.myisam_sort_buff_size,
3882
   (char**) &max_system_variables.myisam_sort_buff_size, 0,
1 by brian
clean slate
3883
   GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
3884
  {"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3885
   N_("Specifies how MyISAM index statistics collection code should threat "
3886
      "NULLs. Possible values of name are 'nulls_unequal' "
3887
      "(default behavior), "
3888
      "'nulls_equal' (emulate MySQL 4.0 behavior), and 'nulls_ignored'."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3889
   (char**) &myisam_stats_method_str, (char**) &myisam_stats_method_str, 0,
1 by brian
clean slate
3890
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3891
  {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3892
   N_("Buffer length for TCP/IP and socket communication."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3893
   (char**) &global_system_variables.net_buffer_length,
3894
   (char**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
1 by brian
clean slate
3895
   REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
3896
  {"net_read_timeout", OPT_NET_READ_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3897
   N_("Number of seconds to wait for more data from a connection before "
3898
      "aborting the read."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3899
   (char**) &global_system_variables.net_read_timeout,
3900
   (char**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
1 by brian
clean slate
3901
   REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3902
  {"net_retry_count", OPT_NET_RETRY_COUNT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3903
   N_("If a read on a communication port is interrupted, retry this many "
3904
      "times before giving up."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3905
   (char**) &global_system_variables.net_retry_count,
3906
   (char**) &max_system_variables.net_retry_count,0,
1 by brian
clean slate
3907
   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
3908
  {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3909
   N_("Number of seconds to wait for a block to be written to a connection "
3910
      "before aborting the write."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3911
   (char**) &global_system_variables.net_write_timeout,
3912
   (char**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
1 by brian
clean slate
3913
   REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3914
  { "old", OPT_OLD_MODE,
3915
    N_("Use compatible behavior."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3916
    (char**) &global_system_variables.old_mode,
236.1.40 by Monty Taylor
A few meaningless changes.
3917
    (char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
3918
    0, 0, 0, 0, 0, 0},
3919
  {"open_files_limit", OPT_OPEN_FILES_LIMIT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3920
   N_("If this is not 0, then mysqld will use this value to reserve file "
3921
      "descriptors to use with setrlimit(). If this value is 0 then mysqld "
3922
      "will reserve max_connections*5 or max_connections + table_cache*2 "
3923
      "(whichever is larger) number of files."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3924
   (char**) &open_files_limit, (char**) &open_files_limit, 0, GET_ULONG,
1 by brian
clean slate
3925
   REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
3926
  {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3927
   N_("Controls the heuristic(s) applied during query optimization to prune "
3928
      "less-promising partial plans from the optimizer search space. Meaning: "
3929
      "0 - do not apply any heuristic, thus perform exhaustive search; "
3930
      "1 - prune plans based on number of retrieved rows."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3931
   (char**) &global_system_variables.optimizer_prune_level,
3932
   (char**) &max_system_variables.optimizer_prune_level,
1 by brian
clean slate
3933
   0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
3934
  {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3935
   N_("Maximum depth of search performed by the query optimizer. Values "
3936
      "larger than the number of relations in a query result in better query "
3937
      "plans, but take longer to compile a query. Smaller values than the "
3938
      "number of tables in a relation result in faster optimization, but may "
3939
      "produce very bad query plans. If set to 0, the system will "
3940
      "automatically pick a reasonable value; if set to MAX_TABLES+2, the "
3941
      "optimizer will switch to the original find_best (used for "
3942
      "testing/comparison)."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3943
   (char**) &global_system_variables.optimizer_search_depth,
3944
   (char**) &max_system_variables.optimizer_search_depth,
1 by brian
clean slate
3945
   0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
3946
  {"plugin_dir", OPT_PLUGIN_DIR,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3947
   N_("Directory for plugins."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3948
   (char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
1 by brian
clean slate
3949
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3950
  {"plugin_load", OPT_PLUGIN_LOAD,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3951
   N_("Optional comma separated list of plugins to load, where each plugin is "
3952
      "identified by the name of the shared library. "
3953
      "[for example: --plugin_load=libmd5udf.so]"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3954
   (char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
1 by brian
clean slate
3955
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3956
  {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3957
   N_("The size of the buffer that is allocated when preloading indexes"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3958
   (char**) &global_system_variables.preload_buff_size,
3959
   (char**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
1 by brian
clean slate
3960
   REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
3961
  {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3962
   N_("Allocation block size for query parsing and execution"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3963
   (char**) &global_system_variables.query_alloc_block_size,
3964
   (char**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
1 by brian
clean slate
3965
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
3966
  {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3967
   N_("Persistent buffer for query parsing and execution"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3968
   (char**) &global_system_variables.query_prealloc_size,
3969
   (char**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
1 by brian
clean slate
3970
   REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
3971
   ULONG_MAX, 0, 1024, 0},
3972
  {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3973
   N_("Allocation block size for storing ranges during optimization"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3974
   (char**) &global_system_variables.range_alloc_block_size,
3975
   (char**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
1 by brian
clean slate
3976
   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
3977
   0, 1024, 0},
3978
  {"read_buffer_size", OPT_RECORD_BUFFER,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3979
   N_("Each thread that does a sequential scan allocates a buffer of this "
3980
      "size for each table it scans. If you do many sequential scans, you may "
3981
      "want to increase this value."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3982
   (char**) &global_system_variables.read_buff_size,
3983
   (char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
163 by Brian Aker
Merge Monty's code.
3984
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT32_MAX, MALLOC_OVERHEAD, IO_SIZE,
1 by brian
clean slate
3985
   0},
3986
  {"read_only", OPT_READONLY,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3987
   N_("Make all non-temporary tables read-only, with the exception for "
3988
      "replication (slave) threads and users with the SUPER privilege"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3989
   (char**) &opt_readonly,
3990
   (char**) &opt_readonly,
1 by brian
clean slate
3991
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
3992
  {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
3993
   N_("When reading rows in sorted order after a sort, the rows are read "
3994
      "through this buffer to avoid a disk seeks. If not set, then it's set "
3995
      "to the value of record_buffer."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
3996
   (char**) &global_system_variables.read_rnd_buff_size,
3997
   (char**) &max_system_variables.read_rnd_buff_size, 0,
1 by brian
clean slate
3998
   GET_ULONG, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
163 by Brian Aker
Merge Monty's code.
3999
   INT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
1 by brian
clean slate
4000
  {"record_buffer", OPT_RECORD_BUFFER,
4001
   "Alias for read_buffer_size",
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4002
   (char**) &global_system_variables.read_buff_size,
4003
   (char**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4004
   128*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
4005
   INT32_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
1 by brian
clean slate
4006
  {"relay_log_purge", OPT_RELAY_LOG_PURGE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4007
   N_("0 = do not purge relay logs. "
4008
      "1 = purge them as soon as they are no more needed."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4009
   (char**) &relay_log_purge,
4010
   (char**) &relay_log_purge, 0, GET_BOOL, NO_ARG,
1 by brian
clean slate
4011
   1, 0, 1, 0, 1, 0},
4012
  {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4013
   N_("Maximum space to use for all relay logs."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4014
   (char**) &relay_log_space_limit,
4015
   (char**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
152 by Brian Aker
longlong replacement
4016
   (int64_t) ULONG_MAX, 0, 1, 0},
1 by brian
clean slate
4017
  {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4018
   N_("Use compression on master/slave protocol."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4019
   (char**) &opt_slave_compressed_protocol,
4020
   (char**) &opt_slave_compressed_protocol,
1 by brian
clean slate
4021
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
4022
  {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4023
   N_("Number of seconds to wait for more data from a master/slave connection "
4024
      "before aborting the read."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4025
   (char**) &slave_net_timeout, (char**) &slave_net_timeout, 0,
1 by brian
clean slate
4026
   GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
4027
  {"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4028
   N_("Number of times the slave SQL thread will retry a transaction in case "
4029
      "it failed with a deadlock or elapsed lock wait timeout, "
4030
      "before giving up and stopping."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4031
   (char**) &slave_trans_retries, (char**) &slave_trans_retries, 0,
152 by Brian Aker
longlong replacement
4032
   GET_ULONG, REQUIRED_ARG, 10L, 0L, (int64_t) ULONG_MAX, 0, 1, 0},
1 by brian
clean slate
4033
  {"slave-allow-batching", OPT_SLAVE_ALLOW_BATCHING,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4034
   N_("Allow slave to batch requests."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4035
   (char**) &slave_allow_batching, (char**) &slave_allow_batching,
1 by brian
clean slate
4036
   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
4037
  {"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4038
   N_("If creating the thread takes longer than this value (in seconds), the "
4039
      "Slow_launch_threads counter will be incremented."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4040
   (char**) &slow_launch_time, (char**) &slow_launch_time, 0, GET_ULONG,
1 by brian
clean slate
4041
   REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
4042
  {"sort_buffer_size", OPT_SORT_BUFFER,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4043
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4044
   (char**) &global_system_variables.sortbuff_size,
4045
   (char**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
1 by brian
clean slate
4046
   MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ULONG_MAX,
4047
   MALLOC_OVERHEAD, 1, 0},
4048
  {"sync-binlog", OPT_SYNC_BINLOG,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4049
   N_("Synchronously flush binary log to disk after every #th event. "
4050
      "Use 0 (default) to disable synchronous flushing."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4051
   (char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
1 by brian
clean slate
4052
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4053
  {"sync-frm", OPT_SYNC_FRM,
4054
   N_("Sync .frm to disk on create. Enabled by default."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4055
   (char**) &opt_sync_frm, (char**) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
1 by brian
clean slate
4056
   0, 0, 0, 0},
4057
  {"table_cache", OPT_TABLE_OPEN_CACHE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4058
   N_("Deprecated; use --table_open_cache instead."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4059
   (char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
1 by brian
clean slate
4060
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
4061
  {"table_definition_cache", OPT_TABLE_DEF_CACHE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4062
   N_("The number of cached table definitions."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4063
   (char**) &table_def_size, (char**) &table_def_size,
1 by brian
clean slate
4064
   0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
4065
  {"table_open_cache", OPT_TABLE_OPEN_CACHE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4066
   N_("The number of cached open tables."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4067
   (char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
1 by brian
clean slate
4068
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
4069
  {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4070
   N_("Timeout in seconds to wait for a table level lock before returning an "
4071
      "error. Used only if the connection has active cursors."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4072
   (char**) &table_lock_wait_timeout, (char**) &table_lock_wait_timeout,
1 by brian
clean slate
4073
   0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
4074
  {"thread_cache_size", OPT_THREAD_CACHE_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4075
   N_("How many threads we should keep in a cache for reuse."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4076
   (char**) &thread_cache_size, (char**) &thread_cache_size, 0, GET_ULONG,
1 by brian
clean slate
4077
   REQUIRED_ARG, 0, 0, 16384, 0, 1, 0},
4078
  {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4079
   N_("How many threads we should create to handle query requests in case of "
4080
      "'thread_handling=pool-of-threads'"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4081
   (char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULONG,
1 by brian
clean slate
4082
   REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
4083
  {"thread_stack", OPT_THREAD_STACK,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4084
   N_("The stack size for each thread."),
4085
   (char**) &my_thread_stack_size,
4086
   (char**) &my_thread_stack_size, 0, GET_ULONG,
4087
   REQUIRED_ARG,DEFAULT_THREAD_STACK,
1 by brian
clean slate
4088
   1024L*128L, ULONG_MAX, 0, 1024, 0},
4089
  { "time_format", OPT_TIME_FORMAT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4090
    N_("The TIME format (for future)."),
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
4091
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
4092
    (char**) &opt_date_time_formats[DRIZZLE_TIMESTAMP_TIME],
1 by brian
clean slate
4093
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
4094
  {"tmp_table_size", OPT_TMP_TABLE_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4095
   N_("If an internal in-memory temporary table exceeds this size, MySQL will"
4096
      " automatically convert it to an on-disk MyISAM table."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4097
   (char**) &global_system_variables.tmp_table_size,
4098
   (char**) &max_system_variables.tmp_table_size, 0, GET_ULL,
1 by brian
clean slate
4099
   REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
4100
  {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4101
   N_("Allocation block size for transactions to be stored in binary log"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4102
   (char**) &global_system_variables.trans_alloc_block_size,
4103
   (char**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
1 by brian
clean slate
4104
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
4105
  {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4106
   N_("Persistent buffer for transactions to be stored in binary log"),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4107
   (char**) &global_system_variables.trans_prealloc_size,
4108
   (char**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
1 by brian
clean slate
4109
   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
4110
  {"wait_timeout", OPT_WAIT_TIMEOUT,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4111
   N_("The number of seconds the server waits for activity on a connection "
4112
      "before closing it."),
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4113
   (char**) &global_system_variables.net_wait_timeout,
4114
   (char**) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
287.3.32 by Monty Taylor
Removed another useless define.
4115
   REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
1 by brian
clean slate
4116
   0, 1, 0},
4117
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
4118
};
4119
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4120
static int show_net_compression(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4121
                                SHOW_VAR *var,
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4122
                                char *buff __attribute__((unused)))
1 by brian
clean slate
4123
{
4124
  var->type= SHOW_MY_BOOL;
4125
  var->value= (char *)&thd->net.compress;
4126
  return 0;
4127
}
4128
77.1.45 by Monty Taylor
Warning fixes.
4129
static st_show_var_func_container
4130
show_net_compression_cont= { &show_net_compression };
4131
1 by brian
clean slate
4132
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
4133
{
4134
  var->type= SHOW_LONG;
4135
  var->value= buff;
4136
  *((long *)buff)= (long) (thd->query_start() - server_start_time);
4137
  return 0;
4138
}
4139
77.1.45 by Monty Taylor
Warning fixes.
4140
static st_show_var_func_container
4141
show_starttime_cont= { &show_starttime };
4142
1 by brian
clean slate
4143
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
4144
{
4145
  var->type= SHOW_LONG;
4146
  var->value= buff;
4147
  *((long *)buff)= (long) (thd->query_start() - flush_status_time);
4148
  return 0;
4149
}
4150
77.1.45 by Monty Taylor
Warning fixes.
4151
static st_show_var_func_container
4152
show_flushstatustime_cont= { &show_flushstatustime };
4153
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4154
static int show_slave_running(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4155
                              SHOW_VAR *var, char *buff)
1 by brian
clean slate
4156
{
4157
  var->type= SHOW_MY_BOOL;
4158
  pthread_mutex_lock(&LOCK_active_mi);
4159
  var->value= buff;
150 by Brian Aker
More bool removal. More cow bell!
4160
  *((bool *)buff)= (bool) (active_mi && active_mi->slave_running &&
1 by brian
clean slate
4161
                                 active_mi->rli.slave_running);
4162
  pthread_mutex_unlock(&LOCK_active_mi);
4163
  return 0;
4164
}
4165
77.1.45 by Monty Taylor
Warning fixes.
4166
static st_show_var_func_container
4167
show_slave_running_cont= { &show_slave_running };
4168
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4169
static int show_slave_retried_trans(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4170
                                    SHOW_VAR *var, char *buff)
1 by brian
clean slate
4171
{
4172
  /*
4173
    TODO: with multimaster, have one such counter per line in
4174
    SHOW SLAVE STATUS, and have the sum over all lines here.
4175
  */
4176
  pthread_mutex_lock(&LOCK_active_mi);
4177
  if (active_mi)
4178
  {
4179
    var->type= SHOW_LONG;
4180
    var->value= buff;
4181
    pthread_mutex_lock(&active_mi->rli.data_lock);
4182
    *((long *)buff)= (long)active_mi->rli.retried_trans;
4183
    pthread_mutex_unlock(&active_mi->rli.data_lock);
4184
  }
4185
  else
4186
    var->type= SHOW_UNDEF;
4187
  pthread_mutex_unlock(&LOCK_active_mi);
4188
  return 0;
4189
}
4190
77.1.45 by Monty Taylor
Warning fixes.
4191
static st_show_var_func_container
4192
show_slave_retried_trans_cont= { &show_slave_retried_trans };
4193
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4194
static int show_slave_received_heartbeats(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4195
                                          SHOW_VAR *var, char *buff)
1 by brian
clean slate
4196
{
4197
  pthread_mutex_lock(&LOCK_active_mi);
4198
  if (active_mi)
4199
  {
4200
    var->type= SHOW_LONGLONG;
4201
    var->value= buff;
4202
    pthread_mutex_lock(&active_mi->rli.data_lock);
152 by Brian Aker
longlong replacement
4203
    *((int64_t *)buff)= active_mi->received_heartbeats;
1 by brian
clean slate
4204
    pthread_mutex_unlock(&active_mi->rli.data_lock);
4205
  }
4206
  else
4207
    var->type= SHOW_UNDEF;
4208
  pthread_mutex_unlock(&LOCK_active_mi);
4209
  return 0;
4210
}
4211
77.1.45 by Monty Taylor
Warning fixes.
4212
static st_show_var_func_container
4213
show_slave_received_heartbeats_cont= { &show_slave_received_heartbeats };
4214
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4215
static int show_heartbeat_period(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4216
                                 SHOW_VAR *var, char *buff)
1 by brian
clean slate
4217
{
4218
  pthread_mutex_lock(&LOCK_active_mi);
4219
  if (active_mi)
4220
  {
4221
    var->type= SHOW_CHAR;
4222
    var->value= buff;
171.1.1 by Patrick Galbraith
Dar, I forgot to commit this earlier.
4223
    sprintf(buff, "%.3f",active_mi->heartbeat_period);
1 by brian
clean slate
4224
  }
4225
  else
4226
    var->type= SHOW_UNDEF;
4227
  pthread_mutex_unlock(&LOCK_active_mi);
4228
  return 0;
4229
}
4230
77.1.45 by Monty Taylor
Warning fixes.
4231
static st_show_var_func_container
4232
show_heartbeat_period_cont= { &show_heartbeat_period};
1 by brian
clean slate
4233
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4234
static int show_open_tables(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4235
                            SHOW_VAR *var, char *buff)
1 by brian
clean slate
4236
{
4237
  var->type= SHOW_LONG;
4238
  var->value= buff;
4239
  *((long *)buff)= (long)cached_open_tables();
4240
  return 0;
4241
}
4242
212.3.1 by Jay Pipes
Fix for Bug#252309 "log output to tables is enabled but ineffective".
4243
static int show_table_definitions(THD *thd __attribute__((unused)),
77.1.45 by Monty Taylor
Warning fixes.
4244
                                  SHOW_VAR *var, char *buff)
1 by brian
clean slate
4245
{
4246
  var->type= SHOW_LONG;
4247
  var->value= buff;
4248
  *((long *)buff)= (long)cached_table_definitions();
4249
  return 0;
4250
}
4251
77.1.45 by Monty Taylor
Warning fixes.
4252
static st_show_var_func_container
4253
show_open_tables_cont= { &show_open_tables };
4254
static st_show_var_func_container
4255
show_table_definitions_cont= { &show_table_definitions };
4256
1 by brian
clean slate
4257
/*
4258
  Variables shown by SHOW STATUS in alphabetical order
4259
*/
4260
4261
SHOW_VAR status_vars[]= {
4262
  {"Aborted_clients",          (char*) &aborted_threads,        SHOW_LONG},
4263
  {"Aborted_connects",         (char*) &aborted_connects,       SHOW_LONG},
4264
  {"Binlog_cache_disk_use",    (char*) &binlog_cache_disk_use,  SHOW_LONG},
4265
  {"Binlog_cache_use",         (char*) &binlog_cache_use,       SHOW_LONG},
4266
  {"Bytes_received",           (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
4267
  {"Bytes_sent",               (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
4268
  {"Com",                      (char*) com_status_vars, SHOW_ARRAY},
77.1.45 by Monty Taylor
Warning fixes.
4269
  {"Compression",              (char*) &show_net_compression_cont, SHOW_FUNC},
1 by brian
clean slate
4270
  {"Connections",              (char*) &thread_id,              SHOW_LONG_NOFLUSH},
4271
  {"Created_tmp_disk_tables",  (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
4272
  {"Created_tmp_files",	       (char*) &my_tmp_file_created,	SHOW_LONG},
4273
  {"Created_tmp_tables",       (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
4274
  {"Flush_commands",           (char*) &refresh_version,        SHOW_LONG_NOFLUSH},
4275
  {"Handler_commit",           (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
4276
  {"Handler_delete",           (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
4277
  {"Handler_discover",         (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS},
4278
  {"Handler_prepare",          (char*) offsetof(STATUS_VAR, ha_prepare_count),  SHOW_LONG_STATUS},
4279
  {"Handler_read_first",       (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
4280
  {"Handler_read_key",         (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
4281
  {"Handler_read_next",        (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
4282
  {"Handler_read_prev",        (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
4283
  {"Handler_read_rnd",         (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
4284
  {"Handler_read_rnd_next",    (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
4285
  {"Handler_rollback",         (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
4286
  {"Handler_savepoint",        (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
4287
  {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
4288
  {"Handler_update",           (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
4289
  {"Handler_write",            (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
4290
  {"Key_blocks_not_flushed",   (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
4291
  {"Key_blocks_unused",        (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
4292
  {"Key_blocks_used",          (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
4293
  {"Key_read_requests",        (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
4294
  {"Key_reads",                (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
4295
  {"Key_write_requests",       (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
4296
  {"Key_writes",               (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
4297
  {"Last_query_cost",          (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
4298
  {"Max_used_connections",     (char*) &max_used_connections,  SHOW_LONG},
4299
  {"Open_files",               (char*) &my_file_opened,         SHOW_LONG_NOFLUSH},
4300
  {"Open_streams",             (char*) &my_stream_opened,       SHOW_LONG_NOFLUSH},
77.1.45 by Monty Taylor
Warning fixes.
4301
  {"Open_table_definitions",   (char*) &show_table_definitions_cont, SHOW_FUNC},
4302
  {"Open_tables",              (char*) &show_open_tables_cont,       SHOW_FUNC},
1 by brian
clean slate
4303
  {"Opened_files",             (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
4304
  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
4305
  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
4306
  {"Questions",                (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
4307
  {"Select_full_join",         (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
4308
  {"Select_full_range_join",   (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
4309
  {"Select_range",             (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
4310
  {"Select_range_check",       (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
4311
  {"Select_scan",	       (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
4312
  {"Slave_open_temp_tables",   (char*) &slave_open_temp_tables, SHOW_LONG},
77.1.45 by Monty Taylor
Warning fixes.
4313
  {"Slave_retried_transactions",(char*) &show_slave_retried_trans_cont, SHOW_FUNC},
4314
  {"Slave_heartbeat_period",   (char*) &show_heartbeat_period_cont, SHOW_FUNC},
4315
  {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats_cont, SHOW_FUNC},
4316
  {"Slave_running",            (char*) &show_slave_running_cont,     SHOW_FUNC},
1 by brian
clean slate
4317
  {"Slow_launch_threads",      (char*) &slow_launch_threads,    SHOW_LONG},
4318
  {"Slow_queries",             (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
4319
  {"Sort_merge_passes",	       (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
4320
  {"Sort_range",	       (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
4321
  {"Sort_rows",		       (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
4322
  {"Sort_scan",		       (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
4323
  {"Table_locks_immediate",    (char*) &locks_immediate,        SHOW_LONG},
4324
  {"Table_locks_waited",       (char*) &locks_waited,           SHOW_LONG},
4325
#ifdef HAVE_MMAP
4326
  {"Tc_log_max_pages_used",    (char*) &tc_log_max_pages_used,  SHOW_LONG},
4327
  {"Tc_log_page_size",         (char*) &tc_log_page_size,       SHOW_LONG},
4328
  {"Tc_log_page_waits",        (char*) &tc_log_page_waits,      SHOW_LONG},
4329
#endif
4330
  {"Threads_cached",           (char*) &cached_thread_count,    SHOW_LONG_NOFLUSH},
4331
  {"Threads_connected",        (char*) &connection_count,       SHOW_INT},
4332
  {"Threads_created",	       (char*) &thread_created,		SHOW_LONG_NOFLUSH},
4333
  {"Threads_running",          (char*) &thread_running,         SHOW_INT},
77.1.45 by Monty Taylor
Warning fixes.
4334
  {"Uptime",                   (char*) &show_starttime_cont,         SHOW_FUNC},
4335
  {"Uptime_since_flush_status",(char*) &show_flushstatustime_cont,   SHOW_FUNC},
1 by brian
clean slate
4336
  {NullS, NullS, SHOW_LONG}
4337
};
4338
4339
static void print_version(void)
4340
{
4341
  set_server_version();
4342
  /*
4343
    Note: the instance manager keys off the string 'Ver' so it can find the
4344
    version from the output of 'mysqld --version', so don't change it!
4345
  */
4346
  printf("%s  Ver %s for %s on %s (%s)\n",my_progname,
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4347
	 server_version,SYSTEM_TYPE,MACHINE_TYPE, DRIZZLE_COMPILATION_COMMENT);
1 by brian
clean slate
4348
}
4349
4350
static void usage(void)
4351
{
4352
  if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
4353
					           MY_CS_PRIMARY,
4354
						   MYF(MY_WME))))
4355
    exit(1);
4356
  if (!default_collation_name)
4357
    default_collation_name= (char*) default_charset_info->name;
4358
  print_version();
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
4359
  puts(_("Copyright (C) 2000 MySQL AB, by Monty and others\n"
4360
         "This software comes with ABSOLUTELY NO WARRANTY. "
4361
         "This is free software,\n"
4362
         "and you are welcome to modify and redistribute it under the GPL "
4363
         "license\n\n"
4364
         "Starts the Drizzle database server\n"));
1 by brian
clean slate
4365
312.1.12 by Monty Taylor
Fixed a syntax oops.
4366
  printf(_("Usage: %s [OPTIONS]\n"), my_progname);
1 by brian
clean slate
4367
  {
259 by Brian Aker
First pass on PAM auth
4368
#ifdef FOO
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4369
  print_defaults(DRIZZLE_CONFIG_NAME,load_default_groups);
1 by brian
clean slate
4370
  puts("");
4371
  set_ports();
259 by Brian Aker
First pass on PAM auth
4372
#endif
1 by brian
clean slate
4373
4374
  /* Print out all the options including plugin supplied options */
4375
  my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
4376
312.1.11 by Monty Taylor
Added some strings from drizzled.cc.
4377
  puts(_("\nTo see what values a running Drizzle server is using, type\n"
4378
         "'drizzleadmin variables' instead of 'drizzled --help'."));
1 by brian
clean slate
4379
  }
4380
}
4381
4382
4383
/**
4384
  Initialize all MySQL global variables to default values.
4385
4386
  We don't need to set numeric variables refered to in my_long_options
4387
  as these are initialized by my_getopt.
4388
4389
  @note
4390
    The reason to set a lot of global variables to zero is to allow one to
4391
    restart the embedded server with a clean environment
4392
    It's also needed on some exotic platforms where global variables are
4393
    not set to 0 when a program starts.
4394
4395
    We don't need to set numeric variables refered to in my_long_options
4396
    as these are initialized by my_getopt.
4397
*/
4398
4399
static void mysql_init_variables(void)
4400
{
4401
  /* Things reset to zero */
4402
  opt_skip_slave_start= opt_reckless_slave = 0;
4403
  mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
4404
  opt_log= opt_slow_log= 0;
4405
  log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4406
  opt_bin_log= 0;
228 by Brian Aker
First pass on socket cleanup.
4407
  opt_skip_show_db=0;
92 by Brian Aker
Removed opt_update_log
4408
  opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
1 by brian
clean slate
4409
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
4410
  opt_secure_auth= 0;
4411
  opt_secure_file_priv= 0;
4412
  segfaulted= kill_in_progress= 0;
4413
  cleanup_done= 0;
4414
  defaults_argc= 0;
4415
  defaults_argv= 0;
4416
  server_id_supplied= 0;
4417
  test_flags= select_errors= dropping_tables= ha_open_options=0;
4418
  thread_count= thread_running= kill_cached_threads= wake_thread=0;
4419
  slave_open_temp_tables= 0;
4420
  cached_thread_count= 0;
4421
  opt_endinfo= using_udf_functions= 0;
4422
  opt_using_transactions= using_update_log= 0;
4423
  abort_loop= select_thread_in_use= signal_thread_in_use= 0;
4424
  ready_to_exit= shutdown_in_progress= 0;
4425
  aborted_threads= aborted_connects= 0;
4426
  specialflag= 0;
4427
  binlog_cache_use=  binlog_cache_disk_use= 0;
4428
  max_used_connections= slow_launch_threads = 0;
4429
  mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
11 by Brian Aker
Removing old UNIX socket bits
4430
  opt_mysql_tmpdir= my_bind_addr_str= NullS;
212.6.6 by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove().
4431
  memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4432
  memset(&global_status_var, 0, sizeof(global_status_var));
1 by brian
clean slate
4433
  key_map_full.set_all();
4434
4435
  /* Character sets */
4436
  system_charset_info= &my_charset_utf8_general_ci;
4437
  files_charset_info= &my_charset_utf8_general_ci;
4438
  national_charset_info= &my_charset_utf8_general_ci;
4439
  table_alias_charset= &my_charset_bin;
4440
  character_set_filesystem= &my_charset_bin;
4441
4442
  opt_date_time_formats[0]= opt_date_time_formats[1]= opt_date_time_formats[2]= 0;
4443
4444
  /* Things with default values that are not zero */
4445
  delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
4446
  slave_exec_mode_options= 0;
4447
  slave_exec_mode_options= (uint)
4448
    find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
4449
  mysql_home_ptr= mysql_home;
4450
  pidfile_name_ptr= pidfile_name;
4451
  log_error_file_ptr= log_error_file;
4452
  language_ptr= language;
4453
  mysql_data_home= mysql_real_data_home;
4454
  thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4455
                        OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
4456
  protocol_version= PROTOCOL_VERSION;
4457
  what_to_log= ~ (1L << (uint) COM_TIME);
4458
  refresh_version= 1L;	/* Increments on each reload */
4459
  global_query_id= thread_id= 1L;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4460
  stpcpy(server_version, DRIZZLE_SERVER_VERSION);
1 by brian
clean slate
4461
  myisam_recover_options_str= "OFF";
4462
  myisam_stats_method_str= "nulls_unequal";
4463
  threads.empty();
4464
  thread_cache.empty();
4465
  key_caches.empty();
4466
  if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
4467
                                                default_key_cache_base.length)))
4468
    exit(1);
4469
  /* set key_cache_hash.default_value = dflt_key_cache */
4470
  multi_keycache_init();
4471
4472
  /* Set directory paths */
4473
  strmake(language, LANGUAGE, sizeof(language)-1);
4474
  strmake(mysql_real_data_home, get_relative_path(DATADIR),
4475
	  sizeof(mysql_real_data_home)-1);
4476
  mysql_data_home_buff[0]=FN_CURLIB;	// all paths are relative from here
4477
  mysql_data_home_buff[1]=0;
4478
  mysql_data_home_len= 2;
4479
4480
  /* Replication parameters */
4481
  master_info_file= (char*) "master.info",
4482
    relay_log_info_file= (char*) "relay-log.info";
4483
  report_user= report_password = report_host= 0;	/* TO BE DELETED */
4484
  opt_relay_logname= opt_relaylog_index_name= 0;
4485
4486
  /* Variables in libraries */
4487
  charsets_dir= 0;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4488
  default_character_set_name= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
1 by brian
clean slate
4489
  default_collation_name= compiled_default_collation_name;
10 by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs
4490
  sys_charset_system.set((char*) system_charset_info->csname);
1 by brian
clean slate
4491
  character_set_filesystem_name= (char*) "binary";
4492
  lc_time_names_name= (char*) "en_US";
4493
  /* Set default values for some option variables */
201 by Brian Aker
Convert default engine to Innodb
4494
  default_storage_engine_str= (char*) "innodb";
1 by brian
clean slate
4495
  global_system_variables.table_plugin= NULL;
4496
  global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
151 by Brian Aker
Ulonglong to uint64_t
4497
  global_system_variables.select_limit= (uint64_t) HA_POS_ERROR;
4498
  max_system_variables.select_limit=    (uint64_t) HA_POS_ERROR;
4499
  global_system_variables.max_join_size= (uint64_t) HA_POS_ERROR;
4500
  max_system_variables.max_join_size=   (uint64_t) HA_POS_ERROR;
1 by brian
clean slate
4501
  global_system_variables.old_alter_table= 0;
4502
  global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
4503
  /*
4504
    Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
4505
    when collecting index statistics for MyISAM tables.
4506
  */
4507
  global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4508
4509
  /* Variables that depends on compile options */
287.3.32 by Monty Taylor
Removed another useless define.
4510
  opt_error_log= 0;
1 by brian
clean slate
4511
#ifdef HAVE_BROKEN_REALPATH
4512
  have_symlink=SHOW_OPTION_NO;
4513
#else
4514
  have_symlink=SHOW_OPTION_YES;
4515
#endif
4516
#ifdef HAVE_COMPRESS
4517
  have_compress= SHOW_OPTION_YES;
4518
#else
4519
  have_compress= SHOW_OPTION_NO;
4520
#endif
4521
4522
  const char *tmpenv;
4523
  if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4524
    tmpenv = DEFAULT_DRIZZLE_HOME;
1 by brian
clean slate
4525
  (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
4526
}
4527
4528
143 by Brian Aker
Bool cleanup.
4529
bool
1 by brian
clean slate
4530
mysqld_get_one_option(int optid,
4531
                      const struct my_option *opt __attribute__((unused)),
4532
                      char *argument)
4533
{
4534
  switch(optid) {
4535
  case '#':
4536
    opt_endinfo=1;				/* unireg: memory allocation */
4537
    break;
4538
  case 'a':
4539
    global_system_variables.tx_isolation= ISO_SERIALIZABLE;
4540
    break;
4541
  case 'b':
4542
    strmake(mysql_home,argument,sizeof(mysql_home)-1);
4543
    break;
4544
  case 'C':
4545
    if (default_collation_name == compiled_default_collation_name)
4546
      default_collation_name= 0;
4547
    break;
4548
  case 'l':
4549
    opt_log=1;
4550
    break;
4551
  case 'h':
4552
    strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
4553
    /* Correct pointer set by my_getopt (for embedded library) */
4554
    mysql_data_home= mysql_real_data_home;
4555
    mysql_data_home_len= strlen(mysql_data_home);
4556
    break;
4557
  case 'u':
4558
    if (!mysqld_user || !strcmp(mysqld_user, argument))
4559
      mysqld_user= argument;
4560
    else
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
4561
      sql_print_warning(_("Ignoring user change to '%s' because the user was "
4562
                          "set to '%s' earlier on the command line\n"),
4563
                        argument, mysqld_user);
1 by brian
clean slate
4564
    break;
4565
  case 'L':
4566
    strmake(language, argument, sizeof(language)-1);
4567
    break;
4568
  case OPT_SLAVE_SKIP_ERRORS:
4569
    init_slave_skip_errors(argument);
4570
    break;
4571
  case OPT_SLAVE_EXEC_MODE:
4572
    slave_exec_mode_options= (uint)
4573
      find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "");
4574
    break;
4575
  case 'V':
4576
    print_version();
4577
    exit(0);
4578
  case 'W':
4579
    if (!argument)
4580
      global_system_variables.log_warnings++;
4581
    else if (argument == disabled_my_option)
4582
      global_system_variables.log_warnings= 0L;
4583
    else
4584
      global_system_variables.log_warnings= atoi(argument);
4585
    break;
4586
  case 'T':
4587
    test_flags= argument ? (uint) atoi(argument) : 0;
4588
    opt_endinfo=1;
4589
    break;
4590
  case (int) OPT_BIN_LOG:
4591
    opt_bin_log= test(argument != disabled_my_option);
4592
    break;
4593
  case (int) OPT_ERROR_LOG_FILE:
4594
    opt_error_log= 1;
4595
    break;
4596
  case (int)OPT_REPLICATE_IGNORE_DB:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4597
    {
4598
      rpl_filter->add_ignore_db(argument);
4599
      break;
4600
    }
1 by brian
clean slate
4601
  case (int)OPT_REPLICATE_DO_DB:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4602
    {
4603
      rpl_filter->add_do_db(argument);
4604
      break;
4605
    }
1 by brian
clean slate
4606
  case (int)OPT_REPLICATE_REWRITE_DB:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4607
    {
4608
      char* key = argument,*p, *val;
4609
4610
      if (!(p= strstr(argument, "->")))
4611
      {
4612
        fprintf(stderr,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4613
                _("Bad syntax in replicate-rewrite-db - missing '->'!\n"));
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4614
        exit(1);
4615
      }
4616
      val= p--;
4617
      while (my_isspace(mysqld_charset, *p) && p > argument)
4618
        *p-- = 0;
4619
      if (p == argument)
4620
      {
4621
        fprintf(stderr,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4622
                _("Bad syntax in replicate-rewrite-db - empty FROM db!\n"));
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4623
        exit(1);
4624
      }
4625
      *val= 0;
4626
      val+= 2;
4627
      while (*val && my_isspace(mysqld_charset, *val))
4628
        *val++;
4629
      if (!*val)
4630
      {
4631
        fprintf(stderr,
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4632
                _("Bad syntax in replicate-rewrite-db - empty TO db!\n"));
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4633
        exit(1);
4634
      }
4635
4636
      rpl_filter->add_db_rewrite(key, val);
4637
      break;
4638
    }
1 by brian
clean slate
4639
4640
  case (int)OPT_BINLOG_IGNORE_DB:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4641
    {
4642
      binlog_filter->add_ignore_db(argument);
4643
      break;
4644
    }
1 by brian
clean slate
4645
  case OPT_BINLOG_FORMAT:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4646
    {
4647
      int id;
4648
      id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
4649
      global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
4650
      break;
4651
    }
1 by brian
clean slate
4652
  case (int)OPT_BINLOG_DO_DB:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4653
    {
4654
      binlog_filter->add_do_db(argument);
4655
      break;
4656
    }
1 by brian
clean slate
4657
  case (int)OPT_REPLICATE_DO_TABLE:
4658
    {
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4659
      if (rpl_filter->add_do_table(argument))
4660
      {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4661
        fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4662
        exit(1);
4663
      }
4664
      break;
1 by brian
clean slate
4665
    }
4666
  case (int)OPT_REPLICATE_WILD_DO_TABLE:
4667
    {
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4668
      if (rpl_filter->add_wild_do_table(argument))
4669
      {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4670
        fprintf(stderr, _("Could not add do table rule '%s'!\n"), argument);
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4671
        exit(1);
4672
      }
4673
      break;
1 by brian
clean slate
4674
    }
4675
  case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
4676
    {
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4677
      if (rpl_filter->add_wild_ignore_table(argument))
4678
      {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4679
        fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4680
        exit(1);
4681
      }
4682
      break;
1 by brian
clean slate
4683
    }
4684
  case (int)OPT_REPLICATE_IGNORE_TABLE:
4685
    {
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4686
      if (rpl_filter->add_ignore_table(argument))
4687
      {
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
4688
        fprintf(stderr, _("Could not add ignore table rule '%s'!\n"), argument);
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4689
        exit(1);
4690
      }
4691
      break;
1 by brian
clean slate
4692
    }
4693
  case (int) OPT_SLOW_QUERY_LOG:
4694
    opt_slow_log= 1;
4695
    break;
4696
#ifdef WITH_CSV_STORAGE_ENGINE
4697
  case  OPT_LOG_OUTPUT:
4698
    {
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4699
      if (!argument || !argument[0])
4700
      {
4701
        log_output_options= LOG_FILE;
4702
        log_output_str= log_output_typelib.type_names[1];
4703
      }
4704
      else
4705
      {
4706
        log_output_str= argument;
4707
        log_output_options=
4708
          find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
4709
      }
4710
      break;
1 by brian
clean slate
4711
    }
4712
#endif
4713
  case (int) OPT_WANT_CORE:
4714
    test_flags |= TEST_CORE_ON_SIGNAL;
4715
    break;
4716
  case (int) OPT_SKIP_STACK_TRACE:
4717
    test_flags|=TEST_NO_STACKTRACE;
4718
    break;
4719
  case (int) OPT_SKIP_SYMLINKS:
4720
    my_use_symdir=0;
4721
    break;
4722
  case (int) OPT_BIND_ADDRESS:
4723
    {
236.1.40 by Monty Taylor
A few meaningless changes.
4724
      struct addrinfo *res_lst, hints;
1 by brian
clean slate
4725
212.6.1 by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file.
4726
      memset(&hints, 0, sizeof(struct addrinfo));
1 by brian
clean slate
4727
      hints.ai_socktype= SOCK_STREAM;
4728
      hints.ai_protocol= IPPROTO_TCP;
4729
236.1.40 by Monty Taylor
A few meaningless changes.
4730
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
1 by brian
clean slate
4731
      {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
4732
        sql_print_error(_("Can't start server: cannot resolve hostname!"));
1 by brian
clean slate
4733
        exit(1);
4734
      }
4735
4736
      if (res_lst->ai_next)
4737
      {
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
4738
        sql_print_error(_("Can't start server: bind-address refers to "
4739
                          "multiple interfaces!"));
1 by brian
clean slate
4740
        exit(1);
4741
      }
4742
      freeaddrinfo(res_lst);
4743
    }
4744
    break;
4745
  case (int) OPT_PID_FILE:
4746
    strmake(pidfile_name, argument, sizeof(pidfile_name)-1);
4747
    break;
4748
  case OPT_CONSOLE:
4749
    if (opt_console)
4750
      opt_error_log= 0;			// Force logs to stdout
4751
    break;
4752
  case OPT_LOW_PRIORITY_UPDATES:
4753
    thr_upgraded_concurrent_insert_lock= TL_WRITE_LOW_PRIORITY;
4754
    global_system_variables.low_priority_updates=1;
4755
    break;
4756
  case OPT_SERVER_ID:
4757
    server_id_supplied = 1;
4758
    break;
4759
  case OPT_DELAY_KEY_WRITE_ALL:
4760
    if (argument != disabled_my_option)
4761
      argument= (char*) "ALL";
4762
    /* Fall through */
4763
  case OPT_DELAY_KEY_WRITE:
4764
    if (argument == disabled_my_option)
4765
      delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
4766
    else if (! argument)
4767
      delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
4768
    else
4769
    {
4770
      int type;
4771
      type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name);
4772
      delay_key_write_options= (uint) type-1;
4773
    }
4774
    break;
4775
  case OPT_CHARSETS_DIR:
4776
    strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1);
4777
    charsets_dir = mysql_charsets_dir;
4778
    break;
4779
  case OPT_TX_ISOLATION:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4780
    {
4781
      int type;
4782
      type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
4783
      global_system_variables.tx_isolation= (type-1);
4784
      break;
4785
    }
1 by brian
clean slate
4786
  case OPT_MYISAM_RECOVER:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4787
    {
4788
      if (!argument)
4789
      {
4790
        myisam_recover_options=    HA_RECOVER_DEFAULT;
4791
        myisam_recover_options_str= myisam_recover_typelib.type_names[0];
4792
      }
4793
      else if (!argument[0])
4794
      {
4795
        myisam_recover_options= HA_RECOVER_NONE;
4796
        myisam_recover_options_str= "OFF";
4797
      }
4798
      else
4799
      {
4800
        myisam_recover_options_str=argument;
4801
        myisam_recover_options=
4802
          find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
4803
      }
4804
      ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
4805
      break;
4806
    }
1 by brian
clean slate
4807
  case OPT_TC_HEURISTIC_RECOVER:
4808
    tc_heuristic_recover= find_type_or_exit(argument,
4809
                                            &tc_heuristic_recover_typelib,
4810
                                            opt->name);
4811
    break;
4812
  case OPT_MYISAM_STATS_METHOD:
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4813
    {
366 by Patrick Galbraith
Ulong conversion
4814
      uint32_t method_conv;
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4815
      int method;
1 by brian
clean slate
4816
224.2.2 by Brian Aker
Second pass cleanup around filesystem type.
4817
      myisam_stats_method_str= argument;
4818
      method= find_type_or_exit(argument, &myisam_stats_method_typelib,
4819
                                opt->name);
4820
      switch (method-1) {
4821
      case 2:
4822
        method_conv= MI_STATS_METHOD_IGNORE_NULLS;
4823
        break;
4824
      case 1:
4825
        method_conv= MI_STATS_METHOD_NULLS_EQUAL;
4826
        break;
4827
      case 0:
4828
      default:
4829
        method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
4830
        break;
4831
      }
4832
      global_system_variables.myisam_stats_method= method_conv;
1 by brian
clean slate
4833
      break;
4834
    }
4835
  }
4836
  return 0;
4837
}
4838
4839
4840
/** Handle arguments for multiple key caches. */
4841
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4842
extern "C" char **mysql_getopt_value(const char *keyname, uint key_length,
1 by brian
clean slate
4843
                                      const struct my_option *option);
4844
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4845
char**
1 by brian
clean slate
4846
mysql_getopt_value(const char *keyname, uint key_length,
4847
		   const struct my_option *option)
4848
{
4849
  switch (option->id) {
4850
  case OPT_KEY_BUFFER_SIZE:
4851
  case OPT_KEY_CACHE_BLOCK_SIZE:
4852
  case OPT_KEY_CACHE_DIVISION_LIMIT:
4853
  case OPT_KEY_CACHE_AGE_THRESHOLD:
4854
  {
4855
    KEY_CACHE *key_cache;
4856
    if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
4857
      exit(1);
4858
    switch (option->id) {
4859
    case OPT_KEY_BUFFER_SIZE:
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4860
      return (char**) &key_cache->param_buff_size;
1 by brian
clean slate
4861
    case OPT_KEY_CACHE_BLOCK_SIZE:
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4862
      return (char**) &key_cache->param_block_size;
1 by brian
clean slate
4863
    case OPT_KEY_CACHE_DIVISION_LIMIT:
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4864
      return (char**) &key_cache->param_division_limit;
1 by brian
clean slate
4865
    case OPT_KEY_CACHE_AGE_THRESHOLD:
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4866
      return (char**) &key_cache->param_age_threshold;
1 by brian
clean slate
4867
    }
4868
  }
4869
  }
77.1.77 by Monty Taylor
A crapton more warning cleanups (I turned on more warnings)
4870
  return (char **)option->value;
1 by brian
clean slate
4871
}
4872
4873
4874
extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
4875
4876
void option_error_reporter(enum loglevel level, const char *format, ...)
4877
{
4878
  va_list args;
4879
  va_start(args, format);
4880
4881
  /* Don't print warnings for --loose options during bootstrap */
228 by Brian Aker
First pass on socket cleanup.
4882
  if (level == ERROR_LEVEL || global_system_variables.log_warnings)
1 by brian
clean slate
4883
  {
4884
    vprint_msg_to_log(level, format, args);
4885
  }
4886
  va_end(args);
4887
}
4888
4889
4890
/**
4891
  @todo
4892
  - FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code?
4893
*/
4894
static void get_options(int *argc,char **argv)
4895
{
4896
  int ho_error;
4897
4898
  my_getopt_register_get_addr(mysql_getopt_value);
4899
  my_getopt_error_reporter= option_error_reporter;
4900
4901
  /* Skip unknown options so that they may be processed later by plugins */
163 by Brian Aker
Merge Monty's code.
4902
  my_getopt_skip_unknown= true;
1 by brian
clean slate
4903
4904
  if ((ho_error= handle_options(argc, &argv, my_long_options,
4905
                                mysqld_get_one_option)))
4906
    exit(ho_error);
4907
  (*argc)++; /* add back one for the progname handle_options removes */
4908
             /* no need to do this for argv as we are discarding it. */
4909
4910
  if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
4911
       opt_log_slow_slave_statements) &&
4912
      !opt_slow_log)
312.1.10 by Monty Taylor
Added some strings from drizzled.cc.
4913
    sql_print_warning(_("options --log-slow-admin-statements, "
4914
                        "--log-queries-not-using-indexes and "
4915
                        "--log-slow-slave-statements have no effect if "
4916
                        "--log-slow-queries is not set"));
1 by brian
clean slate
4917
4918
#if defined(HAVE_BROKEN_REALPATH)
4919
  my_use_symdir=0;
4920
  my_disable_symlinks=1;
4921
  have_symlink=SHOW_OPTION_NO;
4922
#else
4923
  if (!my_use_symdir)
4924
  {
4925
    my_disable_symlinks=1;
4926
    have_symlink=SHOW_OPTION_DISABLED;
4927
  }
4928
#endif
4929
  if (opt_debugging)
4930
  {
4931
    /* Allow break with SIGINT, no core or stack trace */
4932
    test_flags|= TEST_SIGINT | TEST_NO_STACKTRACE;
4933
    test_flags&= ~TEST_CORE_ON_SIGNAL;
4934
  }
4935
  /* Set global MyISAM variables from delay_key_write_options */
4936
  fix_delay_key_write((THD*) 0, OPT_GLOBAL);
4937
  /* Set global slave_exec_mode from its option */
4938
  fix_slave_exec_mode(OPT_GLOBAL);
4939
4940
  if (mysqld_chroot)
4941
    set_root(mysqld_chroot);
4942
  fix_paths();
4943
4944
  /*
4945
    Set some global variables from the global_system_variables
4946
    In most cases the global variables will not be used
4947
  */
4948
  my_default_record_cache_size=global_system_variables.read_buff_size;
4949
  myisam_max_temp_length=
4950
    (my_off_t) global_system_variables.myisam_max_sort_file_size;
4951
4952
  /* Set global variables based on startup options */
4953
  myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
4954
4955
  /* long_query_time is in microseconds */
4956
  global_system_variables.long_query_time= max_system_variables.long_query_time=
152 by Brian Aker
longlong replacement
4957
    (int64_t) (long_query_time * 1000000.0);
1 by brian
clean slate
4958
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
4959
  if (init_global_datetime_format(DRIZZLE_TIMESTAMP_DATE,
1 by brian
clean slate
4960
				  &global_system_variables.date_format) ||
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
4961
      init_global_datetime_format(DRIZZLE_TIMESTAMP_TIME,
1 by brian
clean slate
4962
				  &global_system_variables.time_format) ||
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
4963
      init_global_datetime_format(DRIZZLE_TIMESTAMP_DATETIME,
1 by brian
clean slate
4964
				  &global_system_variables.datetime_format))
4965
    exit(1);
4966
12.1.3 by Brian Aker
Removal of dead code/remove non-used Falcon tests.
4967
  pool_of_threads_scheduler(&thread_scheduler);  /* purecov: tested */
1 by brian
clean slate
4968
}
4969
4970
4971
/*
4972
  Create version name for running mysqld version
4973
  We automaticly add suffixes -debug, -embedded and -log to the version
4974
  name to make the version more descriptive.
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4975
  (DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
1 by brian
clean slate
4976
*/
4977
4978
static void set_server_version(void)
4979
{
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4980
  char *end= strxmov(server_version, DRIZZLE_SERVER_VERSION,
4981
                     DRIZZLE_SERVER_SUFFIX_STR, NullS);
92 by Brian Aker
Removed opt_update_log
4982
  if (opt_log || opt_slow_log || opt_bin_log)
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
4983
    stpcpy(end, "-log");                        // This may slow down system
1 by brian
clean slate
4984
}
4985
4986
4987
static char *get_relative_path(const char *path)
4988
{
4989
  if (test_if_hard_path(path) &&
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4990
      is_prefix(path,DEFAULT_DRIZZLE_HOME) &&
4991
      strcmp(DEFAULT_DRIZZLE_HOME,FN_ROOTDIR))
1 by brian
clean slate
4992
  {
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4993
    path+=(uint) strlen(DEFAULT_DRIZZLE_HOME);
1 by brian
clean slate
4994
    while (*path == FN_LIBCHAR)
4995
      path++;
4996
  }
4997
  return (char*) path;
4998
}
4999
5000
5001
/**
5002
  Fix filename and replace extension where 'dir' is relative to
5003
  mysql_real_data_home.
5004
  @return
5005
    1 if len(path) > FN_REFLEN
5006
*/
5007
5008
bool
5009
fn_format_relative_to_data_home(char * to, const char *name,
5010
				const char *dir, const char *extension)
5011
{
5012
  char tmp_path[FN_REFLEN];
5013
  if (!test_if_hard_path(dir))
5014
  {
5015
    strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home,
5016
	     dir, NullS);
5017
    dir=tmp_path;
5018
  }
5019
  return !fn_format(to, name, dir, extension,
5020
		    MY_APPEND_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH);
5021
}
5022
5023
5024
static void fix_paths(void)
5025
{
5026
  char buff[FN_REFLEN],*pos;
5027
  convert_dirname(mysql_home,mysql_home,NullS);
5028
  /* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
5029
  my_realpath(mysql_home,mysql_home,MYF(0));
5030
  /* Ensure that mysql_home ends in FN_LIBCHAR */
5031
  pos=strend(mysql_home);
5032
  if (pos[-1] != FN_LIBCHAR)
5033
  {
5034
    pos[0]= FN_LIBCHAR;
5035
    pos[1]= 0;
5036
  }
5037
  convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
5038
  (void) fn_format(buff, mysql_real_data_home, "", "",
5039
                   (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
5040
  (void) unpack_dirname(mysql_unpacked_real_data_home, buff);
5041
  convert_dirname(language,language,NullS);
5042
  (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
5043
  (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
5044
  (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
5045
  (void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr ? opt_plugin_dir_ptr :
5046
                                      get_relative_path(PLUGINDIR), mysql_home);
5047
  opt_plugin_dir_ptr= opt_plugin_dir;
5048
5049
  char *sharedir=get_relative_path(SHAREDIR);
5050
  if (test_if_hard_path(sharedir))
5051
    strmake(buff,sharedir,sizeof(buff)-1);		/* purecov: tested */
5052
  else
5053
    strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
5054
  convert_dirname(buff,buff,NullS);
5055
  (void) my_load_path(language,language,buff);
5056
5057
  /* If --character-sets-dir isn't given, use shared library dir */
5058
  if (charsets_dir != mysql_charsets_dir)
5059
  {
5060
    strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
5061
	     CHARSET_DIR, NullS);
5062
  }
5063
  (void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
5064
  convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
5065
  charsets_dir=mysql_charsets_dir;
5066
5067
  if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
5068
    exit(1);
5069
  if (!slave_load_tmpdir)
5070
  {
5071
    if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
5072
      exit(1);
5073
  }
5074
  /*
5075
    Convert the secure-file-priv option to system format, allowing
5076
    a quick strcmp to check if read or write is in an allowed dir
5077
   */
5078
  if (opt_secure_file_priv)
5079
  {
5080
    convert_dirname(buff, opt_secure_file_priv, NullS);
5081
    my_free(opt_secure_file_priv, MYF(0));
5082
    opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
5083
  }
5084
}
5085
5086
366 by Patrick Galbraith
Ulong conversion
5087
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
1 by brian
clean slate
5088
                                   const char *option)
5089
{
366 by Patrick Galbraith
Ulong conversion
5090
  uint32_t res;
1 by brian
clean slate
5091
5092
  const char **ptr;
236.1.40 by Monty Taylor
A few meaningless changes.
5093
366 by Patrick Galbraith
Ulong conversion
5094
  if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
1 by brian
clean slate
5095
  {
5096
    ptr= bit_lib->type_names;
5097
    if (!*x)
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
5098
      fprintf(stderr, _("No option given to %s\n"), option);
1 by brian
clean slate
5099
    else
312.1.15 by Monty Taylor
Finished marking strings in drizzled.cc.
5100
      fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
5101
              option, x);
5102
    fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
1 by brian
clean slate
5103
    while (*++ptr)
5104
      fprintf(stderr, ",'%s'", *ptr);
5105
    fprintf(stderr, "\n");
5106
    exit(1);
5107
  }
5108
  return res;
5109
}
5110
5111
5112
/**
5113
  @return
5114
    a bitfield from a string of substrings separated by ','
5115
    or
366 by Patrick Galbraith
Ulong conversion
5116
    ~(uint32_t) 0 on error.
1 by brian
clean slate
5117
*/
5118
366 by Patrick Galbraith
Ulong conversion
5119
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
1 by brian
clean slate
5120
{
5121
  bool found_end;
5122
  int  found_count;
5123
  const char *end,*i,*j;
5124
  const char **array, *pos;
366 by Patrick Galbraith
Ulong conversion
5125
  uint32_t found,found_int,bit;
1 by brian
clean slate
5126
5127
  found=0;
5128
  found_end= 0;
5129
  pos=(char *) x;
5130
  while (*pos == ' ') pos++;
5131
  found_end= *pos == 0;
5132
  while (!found_end)
5133
  {
266.1.14 by Monty Taylor
Removed strcend.
5134
    if ((end=strrchr(pos,',')) != NULL)		/* Let end point at fieldend */
1 by brian
clean slate
5135
    {
5136
      while (end > pos && end[-1] == ' ')
5137
	end--;					/* Skip end-space */
5138
      found_end=1;
5139
    }
266.1.18 by Monty Taylor
Merged. Plus a few fixes.
5140
    else
5141
    {
5142
        end=pos+strlen(pos);
5143
        found_end=1;
5144
    }
1 by brian
clean slate
5145
    found_int=0; found_count=0;
5146
    for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
5147
    {
5148
      j=pos;
5149
      while (j != end)
5150
      {
5151
	if (my_toupper(mysqld_charset,*i++) !=
5152
            my_toupper(mysqld_charset,*j++))
5153
	  goto skip;
5154
      }
5155
      found_int=bit;
5156
      if (! *i)
5157
      {
5158
	found_count=1;
5159
	break;
5160
      }
5161
      else if (j != pos)			// Half field found
5162
      {
5163
	found_count++;				// Could be one of two values
5164
      }
5165
skip: ;
5166
    }
5167
    if (found_count != 1)
366 by Patrick Galbraith
Ulong conversion
5168
      return(~(uint32_t) 0);				// No unique value
1 by brian
clean slate
5169
    found|=found_int;
5170
    pos=end+1;
5171
  }
5172
51.2.1 by Patrick Galbraith
Removed DBUG_PRINTs, DBUG_ASSERTs, DBUG_EXECUTE_IFs from
5173
  return(found);
1 by brian
clean slate
5174
} /* find_bit_type */
5175
5176
5177
/**
5178
  Create file to store pid number.
5179
*/
5180
static void create_pid_file()
5181
{
5182
  File file;
5183
  if ((file = my_create(pidfile_name,0664,
5184
			O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
5185
  {
5186
    char buff[21], *end;
5187
    end= int10_to_str((long) getpid(), buff, 10);
5188
    *end++= '\n';
5189
    if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
5190
    {
5191
      (void) my_close(file, MYF(0));
5192
      return;
5193
    }
5194
    (void) my_close(file, MYF(0));
5195
  }
5196
  sql_perror("Can't start server: can't create PID file");
5197
  exit(1);
5198
}
5199
5200
/** Clear most status variables. */
5201
void refresh_status(THD *thd)
5202
{
5203
  pthread_mutex_lock(&LOCK_status);
5204
5205
  /* Add thread's status variabes to global status */
5206
  add_to_status(&global_status_var, &thd->status_var);
5207
5208
  /* Reset thread's status variables */
212.6.6 by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove().
5209
  memset(&thd->status_var, 0, sizeof(thd->status_var));
1 by brian
clean slate
5210
5211
  /* Reset some global variables */
5212
  reset_status_vars();
5213
5214
  /* Reset the counters of all key caches (default and named). */
5215
  process_key_caches(reset_key_cache_counters);
5216
  flush_status_time= time((time_t*) 0);
5217
  pthread_mutex_unlock(&LOCK_status);
5218
5219
  /*
5220
    Set max_used_connections to the number of currently open
5221
    connections.  Lock LOCK_thread_count out of LOCK_status to avoid
5222
    deadlocks.  Status reset becomes not atomic, but status data is
5223
    not exact anyway.
5224
  */
5225
  pthread_mutex_lock(&LOCK_thread_count);
5226
  max_used_connections= thread_count;
5227
  pthread_mutex_unlock(&LOCK_thread_count);
5228
}
5229
5230
5231
/*****************************************************************************
5232
  Instantiate templates
5233
*****************************************************************************/
5234
5235
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
5236
/* Used templates */
5237
template class I_List<THD>;
5238
template class I_List_iterator<THD>;
5239
template class I_List<i_string>;
5240
template class I_List<i_string_pair>;
5241
template class I_List<NAMED_LIST>;
5242
template class I_List<Statement>;
5243
template class I_List_iterator<Statement>;
5244
#endif