1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2000-2003 MySQL AB
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.
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.
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 */
21
16
#include <drizzled/server_includes.h>
17
#include <mysys/my_bit.h>
21
#include "rpl_filter.h"
22
#include "repl_failsafe.h"
23
#include "stacktrace.h"
24
#include "mysqld_suffix.h"
25
#include <mysys/mysys_err.h>
24
26
#include <sys/poll.h>
25
27
#include <netinet/tcp.h>
28
#include <mysys/my_bit.h>
29
#include <drizzled/slave.h>
30
#include <drizzled/rpl_mi.h>
31
#include <drizzled/sql_repl.h>
32
#include <drizzled/rpl_filter.h>
33
#include <drizzled/stacktrace.h>
34
#include <mysys/mysys_err.h>
35
#include <drizzled/error.h>
36
#include <drizzled/tztime.h>
38
#if TIME_WITH_SYS_TIME
39
# include <sys/time.h>
43
# include <sys/time.h>
28
#include <drizzled/drizzled_error_messages.h>
49
30
#include <storage/myisam/ha_myisam.h>
219
211
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
220
212
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
222
const char *log_output_names[] = { "NONE", "FILE", NULL};
214
const char *log_output_names[] = { "NONE", "FILE", NullS};
223
215
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
224
216
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
225
217
log_output_names,
231
223
static bool volatile select_thread_in_use, signal_thread_in_use;
232
224
static bool volatile ready_to_exit;
233
225
static bool opt_debugging= 0, opt_console= 0;
234
static uint32_t wake_thread;
226
static uint kill_cached_threads, wake_thread;
235
227
static uint32_t killed_threads, thread_created;
236
228
static uint32_t max_used_connections;
237
static char *drizzled_user, *drizzled_chroot, *log_error_file_ptr;
229
static volatile uint32_t cached_thread_count= 0;
230
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
238
231
static char *opt_init_slave, *language_ptr, *opt_init_connect;
239
232
static char *default_character_set_name;
240
233
static char *character_set_filesystem_name;
290
293
ulong opt_binlog_rows_event_max_size;
291
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NULL};
294
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
292
295
TYPELIB binlog_format_typelib=
293
296
{ array_elements(binlog_format_names) - 1, "",
294
297
binlog_format_names, NULL };
297
300
#ifdef HAVE_INITGROUPS
298
301
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
300
uint32_t drizzled_port, test_flags, select_errors, dropping_tables, ha_open_options;
301
uint32_t drizzled_port_timeout;
302
uint32_t delay_key_write_options, protocol_version;
303
uint32_t lower_case_table_names= 1;
304
uint32_t tc_heuristic_recover= 0;
305
uint32_t volatile thread_count, thread_running;
306
uint64_t session_startup_options;
307
ulong back_log, connect_timeout;
303
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
304
uint mysqld_port_timeout;
305
uint delay_key_write_options, protocol_version;
306
uint lower_case_table_names= 1;
307
uint tc_heuristic_recover= 0;
308
uint volatile thread_count, thread_running;
309
uint64_t thd_startup_options;
310
ulong back_log, connect_timeout, server_id;
309
311
ulong table_cache_size, table_def_size;
310
312
ulong what_to_log;
311
313
ulong slow_launch_time, slave_open_temp_tables;
381
384
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
382
385
*opt_init_file, *opt_tc_log_file;
383
386
char mysql_unpacked_real_data_home[FN_REFLEN];
384
uint32_t reg_ext_length;
385
388
const key_map key_map_empty(0);
386
389
key_map key_map_full(0); // Will be initialized later
388
391
const char *opt_date_time_formats[3];
390
uint32_t mysql_data_home_len;
393
uint mysql_data_home_len;
391
394
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
392
395
char server_version[SERVER_VERSION_LENGTH];
393
396
char *opt_mysql_tmpdir;
435
438
/* Thread specific variables */
437
pthread_key_t THR_MALLOC;
438
pthread_key_t THR_Session;
440
pthread_key(MEM_ROOT**,THR_MALLOC);
441
pthread_key(THD*, THR_THD);
439
442
pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
441
LOCK_global_read_lock,
443
LOCK_global_system_variables,
443
LOCK_status, LOCK_global_read_lock,
444
LOCK_error_log, LOCK_uuid_generator,
445
LOCK_global_system_variables,
446
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
446
447
LOCK_connection_count;
448
449
rw_lock_t LOCK_sys_init_connect, LOCK_sys_init_slave;
453
454
pthread_cond_t COND_server_started;
455
456
/* replication parameters, if master_host is not NULL, we are a slave */
456
uint32_t report_port= DRIZZLE_PORT;
457
uint report_port= DRIZZLE_PORT;
457
458
uint32_t master_retry_count= 0;
458
459
char *master_info_file;
459
char *relay_log_info_file;
460
char *relay_log_info_file, *report_user, *report_password, *report_host;
461
461
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
462
char *opt_logname, *opt_slow_logname;
464
464
/* Static variables */
471
471
static uint32_t opt_myisam_block_size;
472
472
static char *opt_binlog_index_name;
473
473
static char *opt_tc_heuristic_recover;
474
static char *drizzle_home_ptr, *pidfile_name_ptr;
474
static char *mysql_home_ptr, *pidfile_name_ptr;
475
475
static int defaults_argc;
476
476
static char **defaults_argv;
477
477
static char *opt_bin_logname;
479
struct rand_struct sql_rand; ///< used by sql_class.cc:Session::Session()
479
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
481
481
struct passwd *user_info;
482
482
static pthread_t select_thread;
483
static uint32_t thr_kill_signal;
483
static uint thr_kill_signal;
485
485
/* OS specific variables */
492
492
Number of currently active user connections. The variable is protected by
493
493
LOCK_connection_count.
495
uint32_t connection_count= 0;
495
uint connection_count= 0;
497
497
/* Function declarations */
499
499
pthread_handler_t signal_hand(void *arg);
500
static void drizzle_init_variables(void);
500
static void mysql_init_variables(void);
501
501
static void get_options(int *argc,char **argv);
502
502
extern "C" bool mysqld_get_one_option(int, const struct my_option *, char *);
503
503
static void set_server_version(void);
836
846
xid_cache_free();
837
delete_elements(&key_caches, (void (*)(const char*, unsigned char*)) free_key_cache);
847
delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
838
848
multi_keycache_free();
839
849
free_status_vars();
840
850
end_thr_alarm(1); /* Free allocated memory */
841
851
my_free_open_file_info();
842
free((char*) global_system_variables.date_format);
843
free((char*) global_system_variables.time_format);
844
free((char*) global_system_variables.datetime_format);
852
my_free((char*) global_system_variables.date_format,
853
MYF(MY_ALLOW_ZERO_PTR));
854
my_free((char*) global_system_variables.time_format,
855
MYF(MY_ALLOW_ZERO_PTR));
856
my_free((char*) global_system_variables.datetime_format,
857
MYF(MY_ALLOW_ZERO_PTR));
845
858
if (defaults_argv)
846
859
free_defaults(defaults_argv);
847
free(sys_init_connect.value);
848
free(sys_init_slave.value);
860
my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR));
861
my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR));
862
my_free(sys_var_general_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
863
my_free(sys_var_slow_log_path.value, MYF(MY_ALLOW_ZERO_PTR));
849
864
free_tmpdir(&mysql_tmpdir_list);
850
free(slave_load_tmpdir);
852
free(opt_bin_logname);
853
if (opt_relay_logname)
854
free(opt_relay_logname);
855
if (opt_secure_file_priv)
856
free(opt_secure_file_priv);
865
my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
866
x_free(opt_bin_logname);
867
x_free(opt_relay_logname);
868
x_free(opt_secure_file_priv);
857
869
bitmap_free(&temp_pool);
858
871
delete binlog_filter;
859
872
delete rpl_filter;
912
925
(void) pthread_mutex_destroy(&LOCK_thread_count);
913
926
(void) pthread_mutex_destroy(&LOCK_status);
914
927
(void) pthread_mutex_destroy(&LOCK_error_log);
928
(void) pthread_mutex_destroy(&LOCK_user_conn);
915
929
(void) pthread_mutex_destroy(&LOCK_connection_count);
930
(void) pthread_mutex_destroy(&LOCK_rpl_status);
931
(void) pthread_cond_destroy(&COND_rpl_status);
916
932
(void) pthread_mutex_destroy(&LOCK_active_mi);
917
933
(void) rwlock_destroy(&LOCK_sys_init_connect);
918
934
(void) rwlock_destroy(&LOCK_sys_init_slave);
919
935
(void) pthread_mutex_destroy(&LOCK_global_system_variables);
920
936
(void) rwlock_destroy(&LOCK_system_variables_hash);
921
937
(void) pthread_mutex_destroy(&LOCK_global_read_lock);
938
(void) pthread_mutex_destroy(&LOCK_uuid_generator);
922
939
(void) pthread_cond_destroy(&COND_thread_count);
923
940
(void) pthread_cond_destroy(&COND_refresh);
924
941
(void) pthread_cond_destroy(&COND_global_read_lock);
942
(void) pthread_cond_destroy(&COND_thread_cache);
943
(void) pthread_cond_destroy(&COND_flush_thread_cache);
1173
1192
on busy Linux systems. Retry to bind the address at these intervals:
1174
1193
Sleep intervals: 1, 2, 4, 6, 9, 13, 17, 22, ...
1175
1194
Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ...
1176
Limit the sequence by drizzled_port_timeout (set --port-open-timeout=#).
1195
Limit the sequence by mysqld_port_timeout (set --port-open-timeout=#).
1178
1197
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1180
1199
if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1181
(errno != EADDRINUSE) ||
1182
(waited >= drizzled_port_timeout))
1200
(socket_errno != SOCKET_EADDRINUSE) ||
1201
(waited >= mysqld_port_timeout))
1184
sql_print_information(_("Retrying bind on TCP/IP port %u"), drizzled_port);
1203
sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
1185
1204
this_wait= retry * retry / 3 + 1;
1186
1205
sleep(this_wait);
1209
1228
Close a connection.
1211
@param session Thread handle
1230
@param thd Thread handle
1212
1231
@param errcode Error code to print to console
1213
1232
@param lock 1 if we have have to lock LOCK_thread_count
1216
1235
For the connection that is doing shutdown, this is called twice
1218
void close_connection(Session *session, uint32_t errcode, bool lock)
1237
void close_connection(THD *thd, uint errcode, bool lock)
1222
1241
(void) pthread_mutex_lock(&LOCK_thread_count);
1223
session->killed= Session::KILL_CONNECTION;
1224
if ((vio= session->net.vio) != 0)
1242
thd->killed= THD::KILL_CONNECTION;
1243
if ((vio= thd->net.vio) != 0)
1227
net_send_error(session, errcode, ER(errcode)); /* purecov: inspected */
1228
net_close(&(session->net)); /* vio is freed in delete session */
1246
net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
1247
net_close(&(thd->net)); /* vio is freed in delete thd */
1231
1250
(void) pthread_mutex_unlock(&LOCK_thread_count);
1236
1255
/** Called when a thread is aborted. */
1238
extern "C" RETSIGTYPE end_thread_signal(int sig __attribute__((unused)))
1257
extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
1240
Session *session=current_session;
1259
THD *thd=current_thd;
1260
if (thd && ! thd->bootstrap)
1243
1262
statistic_increment(killed_threads, &LOCK_status);
1244
thread_scheduler.end_thread(session,0); /* purecov: inspected */
1263
thread_scheduler.end_thread(thd,0); /* purecov: inspected */
1246
1265
return;; /* purecov: deadcode */
1251
Unlink session from global list of available connections and free session
1270
Unlink thd from global list of available connections and free thd
1255
session Thread handler
1258
1277
LOCK_thread_count is locked and left locked
1261
void unlink_session(Session *session)
1280
void unlink_thd(THD *thd)
1265
1284
pthread_mutex_lock(&LOCK_connection_count);
1266
1285
--connection_count;
1269
1288
(void) pthread_mutex_lock(&LOCK_thread_count);
1270
1289
thread_count--;
1296
Store thread in cache for reuse by new connections
1302
LOCK_thread_count has to be locked
1305
0 Thread was not put in cache
1306
1 Thread is to be reused by new connection.
1307
(ie, caller should return, not abort with pthread_exit())
1311
static bool cache_thread()
1313
safe_mutex_assert_owner(&LOCK_thread_count);
1314
if (cached_thread_count < thread_cache_size &&
1315
! abort_loop && !kill_cached_threads)
1317
/* Don't kill the thread, just put it in cache for reuse */
1318
cached_thread_count++;
1319
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
1320
(void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
1321
cached_thread_count--;
1322
if (kill_cached_threads)
1323
pthread_cond_signal(&COND_flush_thread_cache);
1328
thd= thread_cache.get();
1329
thd->thread_stack= (char*) &thd; // For store_globals
1330
(void) thd->store_globals();
1332
THD::mysys_var::abort is associated with physical thread rather
1333
than with THD object. So we need to reset this flag before using
1334
this thread for handling of new THD object/connection.
1336
thd->mysys_var->abort= 0;
1337
thd->thr_create_utime= my_micro_time();
1338
threads.append(thd);
1347
End thread for the current connection
1350
one_thread_per_connection_end()
1352
put_in_cache Store thread in cache, if there is room in it
1353
Normally this is true in all cases except when we got
1354
out of resources initializing the current thread
1357
If thread is cached, we will wait until thread is scheduled to be
1358
reused and then we will return.
1359
If thread is not cached, we end the thread.
1362
0 Signal to handle_one_connection to reuse connection
1365
bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
1369
put_in_cache= cache_thread();
1370
pthread_mutex_unlock(&LOCK_thread_count);
1372
return(0); // Thread is reused
1374
/* It's safe to broadcast outside a lock (COND... is not deleted here) */
1376
(void) pthread_cond_broadcast(&COND_thread_count);
1379
return(0); // Impossible
1383
void flush_thread_cache()
1385
(void) pthread_mutex_lock(&LOCK_thread_count);
1386
kill_cached_threads++;
1387
while (cached_thread_count)
1389
pthread_cond_broadcast(&COND_thread_cache);
1390
pthread_cond_wait(&COND_flush_thread_cache,&LOCK_thread_count);
1392
kill_cached_threads--;
1393
(void) pthread_mutex_unlock(&LOCK_thread_count);
1276
1397
#ifdef THREAD_SPECIFIC_SIGPIPE
1278
1399
Aborts a thread nicely. Comes here on SIGPIPE.
1350
1471
(global_system_variables.read_buff_size +
1351
1472
global_system_variables.sortbuff_size) *
1352
1473
thread_scheduler.max_threads +
1353
max_connections * sizeof(Session)) / 1024);
1474
max_connections * sizeof(THD)) / 1024);
1355
1476
#ifdef HAVE_STACKTRACE
1356
Session *session= current_session;
1477
THD *thd= current_thd;
1358
1479
if (!(test_flags & TEST_NO_STACKTRACE))
1360
fprintf(stderr,"session: 0x%lx\n",(long) session);
1481
fprintf(stderr,"thd: 0x%lx\n",(long) thd);
1361
1482
fprintf(stderr,_("Attempting backtrace. You can use the following "
1362
1483
"information to find out\n"
1363
1484
"where mysqld died. If you see no messages after this, "
1364
1485
"something went\n"
1365
1486
"terribly wrong...\n"));
1366
print_stacktrace(session ? (unsigned char*) session->thread_stack : (unsigned char*) 0,
1487
print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
1367
1488
my_thread_stack_size);
1371
1492
const char *kreason= "UNKNOWN";
1372
switch (session->killed) {
1373
case Session::NOT_KILLED:
1493
switch (thd->killed) {
1494
case THD::NOT_KILLED:
1374
1495
kreason= "NOT_KILLED";
1376
case Session::KILL_BAD_DATA:
1497
case THD::KILL_BAD_DATA:
1377
1498
kreason= "KILL_BAD_DATA";
1379
case Session::KILL_CONNECTION:
1500
case THD::KILL_CONNECTION:
1380
1501
kreason= "KILL_CONNECTION";
1382
case Session::KILL_QUERY:
1503
case THD::KILL_QUERY:
1383
1504
kreason= "KILL_QUERY";
1385
case Session::KILLED_NO_VALUE:
1506
case THD::KILLED_NO_VALUE:
1386
1507
kreason= "KILLED_NO_VALUE";
1389
1510
fprintf(stderr, _("Trying to get some variables.\n"
1390
1511
"Some pointers may be invalid and cause the "
1391
1512
"dump to abort...\n"));
1392
safe_print_str("session->query", session->query, 1024);
1393
fprintf(stderr, "session->thread_id=%"PRIu32"\n", (uint32_t) session->thread_id);
1394
fprintf(stderr, "session->killed=%s\n", kreason);
1513
safe_print_str("thd->query", thd->query, 1024);
1514
fprintf(stderr, "thd->thread_id=%"PRIu32"\n", (uint32_t) thd->thread_id);
1515
fprintf(stderr, "thd->killed=%s\n", kreason);
1396
1517
fflush(stderr);
1397
1518
#endif /* HAVE_STACKTRACE */
1671
1794
if (!abort_loop)
1674
reload_cache((Session*) 0,
1797
reload_cache((THD*) 0,
1675
1798
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
1800
REFRESH_THREADS | REFRESH_HOSTS),
1677
1801
(TableList*) 0, ¬_used); // Flush logs
1803
logger.set_handlers(LOG_FILE,
1804
opt_slow_log ? log_output_options : LOG_NONE,
1805
opt_log ? log_output_options : LOG_NONE);
1680
1807
#ifdef USE_ONE_SIGNAL_HAND
1681
1808
case THR_SERVER_ALARM:
1703
1830
for the client.
1706
extern "C" void my_message_sql(uint32_t error, const char *str, myf MyFlags);
1833
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
1708
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
1835
void my_message_sql(uint error, const char *str, myf MyFlags)
1712
1839
Put here following assertion when situation with EE_* error codes
1715
if ((session= current_session))
1842
if ((thd= current_thd))
1717
1844
if (MyFlags & ME_FATALERROR)
1718
session->is_fatal_error= 1;
1845
thd->is_fatal_error= 1;
1847
#ifdef BUG_36098_FIXED
1848
mysql_audit_general(thd,DRIZZLE_AUDIT_GENERAL_ERROR,error,my_time(0),
1849
0,0,str,str ? strlen(str) : 0,
1850
thd->query,thd->query_length,
1851
thd->variables.character_set_client,
1721
TODO: There are two exceptions mechanism (Session and sp_rcontext),
1857
TODO: There are two exceptions mechanism (THD and sp_rcontext),
1722
1858
this could be improved by having a common stack of handlers.
1724
if (session->handle_error(error, str,
1860
if (thd->handle_error(error, str,
1725
1861
DRIZZLE_ERROR::WARN_LEVEL_ERROR))
1728
session->is_slave_error= 1; // needed to catch query errors during replication
1864
thd->is_slave_error= 1; // needed to catch query errors during replication
1731
session->lex->current_select == 0 if lex structure is not inited
1867
thd->lex->current_select == 0 if lex structure is not inited
1732
1868
(not query command (COM_QUERY))
1734
if (! (session->lex->current_select &&
1735
session->lex->current_select->no_error && !session->is_fatal_error))
1870
if (! (thd->lex->current_select &&
1871
thd->lex->current_select->no_error && !thd->is_fatal_error))
1737
if (! session->main_da.is_error()) // Return only first message
1873
if (! thd->main_da.is_error()) // Return only first message
1739
1875
if (error == 0)
1740
1876
error= ER_UNKNOWN_ERROR;
1741
1877
if (str == NULL)
1742
1878
str= ER(error);
1743
session->main_da.set_error_status(session, error, str);
1879
thd->main_da.set_error_status(thd, error, str);
1747
if (!session->no_warnings_for_error && !session->is_fatal_error)
1883
if (!thd->no_warnings_for_error && !thd->is_fatal_error)
1750
1886
Suppress infinite recursion if there a memory allocation error
1751
1887
inside push_warning.
1753
session->no_warnings_for_error= true;
1754
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
1755
session->no_warnings_for_error= false;
1889
thd->no_warnings_for_error= true;
1890
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
1891
thd->no_warnings_for_error= false;
1758
if (!session || MyFlags & ME_NOREFRESH)
1894
if (!thd || MyFlags & ME_NOREFRESH)
1759
1895
sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
1862
1998
{"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1863
1999
{"select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1864
2000
{"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
2001
{"show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
1865
2002
{"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
2003
{"show_charsets", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS},
2004
{"show_collations", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS},
1866
2005
{"show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1867
2006
{"show_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1868
2007
{"show_databases", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
1874
2013
{"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
1875
2014
{"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
1876
2015
{"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
2016
{"show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
1877
2017
{"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
1878
2018
{"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1879
2019
{"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1886
2026
{"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1887
2027
{"update", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1888
2028
{"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1889
{NULL, NULL, SHOW_LONG}
2029
{NullS, NullS, SHOW_LONG}
1892
2032
static int init_common_variables(const char *conf_file_name, int argc,
1893
2033
char **argv, const char **groups)
2035
char buff[FN_REFLEN], *s;
1895
2036
umask(((~my_umask) & 0666));
1896
2037
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1897
2038
tzset(); // Set tzname
1990
2131
If we have requested too much file handles than we bring
1991
2132
max_connections in supported bounds.
1993
max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
2134
max_connections= (uint32_t) min((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
1994
2135
max_connections);
1996
2137
Decrease table_cache_size according to max_connections, but
1997
not below TABLE_OPEN_CACHE_MIN. Outer cmin() ensures that we
2138
not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
1998
2139
never increase table_cache_size automatically (that could
1999
2140
happen if max_connections is decreased above).
2001
table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
2142
table_cache_size= (uint32_t) min(max((files-10-max_connections)/2,
2002
2143
(uint32_t)TABLE_OPEN_CACHE_MIN),
2003
2144
table_cache_size);
2004
2145
if (global_system_variables.log_warnings)
2106
2247
sys_init_slave.value=my_strdup("",MYF(0));
2249
/* check log options and issue warnings if needed */
2250
if (opt_log && opt_logname && !(log_output_options & LOG_FILE) &&
2251
!(log_output_options & LOG_NONE))
2252
sql_print_warning(_("Although a path was specified for the "
2253
"--log option, log tables are used. "
2254
"To enable logging to files use the "
2255
"--log-output option."));
2257
if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE)
2258
&& !(log_output_options & LOG_NONE))
2259
sql_print_warning(_("Although a path was specified for the "
2260
"--log-slow-queries option, log tables are used. "
2261
"To enable logging to files use the "
2262
"--log-output=file option."));
2264
s= opt_logname ? opt_logname : make_default_log_name(buff, ".log");
2265
sys_var_general_log_path.value= my_strdup(s, MYF(0));
2266
sys_var_general_log_path.value_length= strlen(s);
2268
s= opt_slow_logname ? opt_slow_logname : make_default_log_name(buff, "-slow.log");
2269
sys_var_slow_log_path.value= my_strdup(s, MYF(0));
2270
sys_var_slow_log_path.value_length= strlen(s);
2108
2272
if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2110
2274
if (my_database_names_init())
2127
2291
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
2128
2292
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2129
2293
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
2294
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
2130
2295
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2131
2296
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2132
2297
(void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
2133
2298
(void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
2299
(void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
2134
2300
(void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2135
2301
(void) my_rwlock_init(&LOCK_sys_init_connect, NULL);
2136
2302
(void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
2137
2303
(void) pthread_cond_init(&COND_thread_count,NULL);
2138
2304
(void) pthread_cond_init(&COND_refresh,NULL);
2139
2305
(void) pthread_cond_init(&COND_global_read_lock,NULL);
2306
(void) pthread_cond_init(&COND_thread_cache,NULL);
2307
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
2308
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2309
(void) pthread_cond_init(&COND_rpl_status, NULL);
2141
2311
/* Parameter for threads created for connections */
2142
2312
(void) pthread_attr_init(&connection_attrib);
2193
2364
opt_error_log= 1; // Too long file name
2196
if (freopen(log_error_file, "a+", stdout)==NULL)
2197
sql_print_error(_("Unable to reopen stdout"));
2199
if(freopen(log_error_file, "a+", stderr)==NULL)
2200
sql_print_error(_("Unable to reopen stderr"));
2367
if (freopen(log_error_file, "a+", stdout))
2368
freopen(log_error_file, "a+", stderr);
2475
2647
if (global_system_variables.log_warnings)
2477
2649
/* %zu is not yet in C++ */
2478
uint64_t size_tmp= (uint64_t)stack_size;
2479
sql_print_warning(_("Asked for %u thread stack, but got %"PRIu64),
2650
unsigned long long size_tmp= (uint64_t)stack_size;
2651
sql_print_warning(_("Asked for %u thread stack, but got %llu"),
2480
2652
my_thread_stack_size, size_tmp);
2482
2654
my_thread_stack_size= stack_size;
2597
2769
This function will create new thread to handle the incoming
2598
2770
connection. If there are idle cached threads one will be used.
2599
'session' will be pushed into 'threads'.
2771
'thd' will be pushed into 'threads'.
2601
2773
In single-threaded mode (\#define ONE_THREAD) connection will be
2602
2774
handled inside this function.
2604
@param[in,out] session Thread handle of future thread.
2776
@param[in,out] thd Thread handle of future thread.
2607
static void create_new_thread(Session *session)
2779
static void create_new_thread(THD *thd)
2729
2901
if ((error_count++ & 255) == 0) // This can happen often
2730
2902
sql_perror("Error in accept");
2731
2903
MAYBE_BROKEN_SYSCALL;
2732
if (errno == ENFILE || errno == EMFILE)
2904
if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
2733
2905
sleep(1); // Give other threads some time
2738
SOCKET_SIZE_TYPE dummyLen;
2910
size_socket dummyLen;
2739
2911
struct sockaddr_storage dummy;
2740
2912
dummyLen = sizeof(dummy);
2741
2913
if ( getsockname(new_sock,(struct sockaddr *)&dummy,
2815
2987
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
2816
2988
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
2817
2989
OPT_ABORT_SLAVE_EVENT_COUNT,
2990
OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
2818
2991
OPT_ENGINE_CONDITION_PUSHDOWN,
2819
2992
OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
2820
2993
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
2938
3116
{"basedir", 'b',
2939
3117
N_("Path to installation directory. All paths are usually resolved "
2940
3118
"relative to this."),
2941
(char**) &drizzle_home_ptr, (char**) &drizzle_home_ptr, 0, GET_STR, REQUIRED_ARG,
3119
(char**) &mysql_home_ptr, (char**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
2942
3120
0, 0, 0, 0, 0, 0},
2943
3121
{"bind-address", OPT_BIND_ADDRESS, N_("IP address to bind to."),
2944
3122
(char**) &my_bind_addr_str, (char**) &my_bind_addr_str, 0, GET_STR,
2991
3169
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2992
3170
{"chroot", 'r',
2993
3171
N_("Chroot mysqld daemon during startup."),
2994
(char**) &drizzled_chroot, (char**) &drizzled_chroot, 0, GET_STR, REQUIRED_ARG,
3172
(char**) &mysqld_chroot, (char**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
2995
3173
0, 0, 0, 0, 0, 0},
2996
3174
{"collation-server", OPT_DEFAULT_COLLATION,
2997
3175
N_("Set the default collation."),
3014
3192
N_("Path to the database root."),
3015
3193
(char**) &mysql_data_home,
3016
3194
(char**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3195
{"default-character-set", 'C',
3196
N_("Set the default character set (deprecated option, use "
3197
"--character-set-server instead)."),
3198
(char**) &default_character_set_name, (char**) &default_character_set_name,
3199
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3200
{"default-collation", OPT_DEFAULT_COLLATION,
3201
N_("Set the default collation (deprecated option, use --collation-server "
3203
(char**) &default_collation_name, (char**) &default_collation_name,
3204
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3017
3205
{"default-storage-engine", OPT_STORAGE_ENGINE,
3018
3206
N_("Set the default storage engine (table type) for tables."),
3019
3207
(char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
3025
3213
{"delay-key-write", OPT_DELAY_KEY_WRITE,
3026
3214
N_("Type of DELAY_KEY_WRITE."),
3027
3215
0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3216
{"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
3217
N_("Don't flush key buffers between writes for any MyISAM table "
3218
"(Deprecated option, use --delay-key-write=all instead)."),
3219
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3028
3220
{"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
3029
3221
N_("Option used by mysql-test for debugging and testing of replication."),
3030
3222
(char**) &disconnect_slave_event_count,
3041
3233
N_("Push supported query conditions to the storage engine."),
3042
3234
(char**) &global_system_variables.engine_condition_pushdown,
3043
3235
(char**) &global_system_variables.engine_condition_pushdown,
3044
0, GET_BOOL, NO_ARG, false, 0, 0, 0, 0, 0},
3236
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
3045
3237
/* See how it's handled in get_one_option() */
3046
3238
{"exit-info", 'T',
3047
3239
N_("Used for debugging; Use at your own risk!"),
3055
3247
N_("Set up signals usable for debugging"),
3056
3248
(char**) &opt_debugging, (char**) &opt_debugging,
3057
3249
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3250
{"general-log", OPT_GENERAL_LOG,
3251
N_("Enable general query log"),
3253
(char**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3058
3254
{"init-connect", OPT_INIT_CONNECT,
3059
3255
N_("Command(s) that are executed for each new connection"),
3060
3256
(char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
3096
3292
N_("File that holds the names for last binary log files."),
3097
3293
(char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
3098
3294
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3296
This option starts with "log-bin" to emphasize that it is specific of
3299
{"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
3300
N_("If equal to 0 (the default), then when --log-bin is used, creation of "
3301
"a stored function (or trigger) is allowed only to users having the "
3302
"SUPER privilege and only if this stored function (trigger) may not "
3303
"break binary logging. Note that if ALL connections to this server "
3304
"ALWAYS use row-based binary logging, the security issues do not exist "
3305
"and the binary logging cannot break, so you can safely set this to 1.")
3306
,(char**) &trust_function_creators, (char**) &trust_function_creators, 0,
3307
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3099
3308
{"log-error", OPT_ERROR_LOG_FILE,
3100
3309
N_("Error log file."),
3101
3310
(char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
3104
3313
N_("Log all MyISAM changes to file."),
3105
3314
(char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3106
3315
OPT_ARG, 0, 0, 0, 0, 0, 0},
3316
{"log-long-format", '0',
3317
N_("Log some extra information to update log. Please note that this option "
3318
"is deprecated; see --log-queries-not-using-indexes option."),
3319
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3320
#ifdef WITH_CSV_STORAGE_ENGINE
3321
{"log-output", OPT_LOG_OUTPUT,
3322
N_("Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
3324
(char**) &log_output_str, (char**) &log_output_str, 0,
3325
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3327
{"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
3328
N_("Log queries that are executed without benefit of any index to the "
3329
"slow log if it is open."),
3330
(char**) &opt_log_queries_not_using_indexes,
3331
(char**) &opt_log_queries_not_using_indexes,
3332
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3107
3333
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
3108
3334
N_("Tells the slave to log the updates from the slave thread to the binary "
3109
3335
"log. You will need to turn it on if you plan to "
3111
3337
(char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3113
3339
NO_ARG, 0, 0, 0, 0, 0, 0},
3340
{"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
3341
N_("Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements "
3342
"to the slow log if it is open."),
3343
(char**) &opt_log_slow_admin_statements,
3344
(char**) &opt_log_slow_admin_statements,
3345
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3346
{"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
3347
N_("Log slow statements executed by slave thread to the slow log if it is "
3349
(char**) &opt_log_slow_slave_statements,
3350
(char**) &opt_log_slow_slave_statements,
3351
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3352
{"log-slow-queries", OPT_SLOW_QUERY_LOG,
3353
N_("Log slow queries to a table or log file. Defaults logging to table "
3354
"mysql.slow_log or hostname-slow.log if --log-output=file is used. "
3355
"Must be enabled to activate other slow log options."),
3356
(char**) &opt_slow_logname, (char**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
3114
3358
{"log-tc", OPT_LOG_TC,
3115
3359
N_("Path to transaction coordinator log (used for transactions that affect "
3116
3360
"more than one storage engine, when binary log is disabled)"),
3166
3410
(char**) &global_system_variables.old_alter_table,
3167
3411
(char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
3168
3412
0, 0, 0, 0, 0, 0},
3413
{"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS,
3414
N_("Enable old-style user limits (before 5.0.3 user resources were counted "
3415
"per each user+host vs. per account)"),
3416
(char**) &opt_old_style_user_limits, (char**) &opt_old_style_user_limits,
3417
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3169
3418
{"pid-file", OPT_PID_FILE,
3170
3419
N_("Pid file used by safe_mysqld."),
3171
3420
(char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
3172
3421
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3174
3423
N_("Port number to use for connection or 0 for default to, in "
3175
"order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
3424
"order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
3176
3425
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
3177
(char**) &drizzled_port,
3178
(char**) &drizzled_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3426
(char**) &mysqld_port,
3427
(char**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3179
3428
{"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
3180
3429
N_("Maximum time in seconds to wait for the port to become free. "
3181
3430
"(Default: no wait)"),
3182
(char**) &drizzled_port_timeout,
3183
(char**) &drizzled_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3431
(char**) &mysqld_port_timeout,
3432
(char**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3184
3433
{"relay-log", OPT_RELAY_LOG,
3185
3434
N_("The location and name to use for relay logs."),
3186
3435
(char**) &opt_relay_logname, (char**) &opt_relay_logname, 0,
3261
3510
"the slave from the master or other hosts."),
3262
3511
(char**) &report_host, (char**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
3513
{"report-password", OPT_REPORT_PASSWORD, "Undocumented.",
3514
(char**) &report_password, (char**) &report_password, 0, GET_STR,
3515
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3516
{"report-port", OPT_REPORT_PORT,
3517
N_("Port for connecting to slave reported to the master during slave "
3518
"registration. Set it only if the slave is listening on a non-default "
3519
"port or if you have a special tunnel from the master or other clients "
3520
"to the slave. If not sure, leave this option unset."),
3521
(char**) &report_port, (char**) &report_port, 0, GET_UINT, REQUIRED_ARG,
3522
DRIZZLE_PORT, 0, 0, 0, 0, 0},
3264
3523
{"safe-mode", OPT_SAFE,
3265
3524
N_("Skip some optimize stages (for testing)."),
3266
3525
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3274
3533
"replication partners."),
3275
3534
(char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
3536
{"set-variable", 'O',
3537
N_("Change the value of a variable. Please note that this option is "
3538
"deprecated;you can set variables directly with --variable-name=value."),
3539
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3277
3540
{"skip-new", OPT_SKIP_NEW,
3278
3541
N_("Don't use new, possible wrong routines."),
3279
3542
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3285
3548
N_("Don't print a stack trace on failure."),
3286
3549
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
3551
{"skip-symlink", OPT_SKIP_SYMLINKS,
3552
N_("Don't allow symlinking of tables. Deprecated option. Use "
3553
"--skip-symbolic-links instead."),
3554
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3288
3555
{"skip-thread-priority", OPT_SKIP_PRIOR,
3289
3556
N_("Don't give threads different priorities."),
3290
3557
0, 0, 0, GET_NO_ARG, NO_ARG,
3306
3573
"and the slave."),
3307
3574
(char**) &slave_exec_mode_str, (char**) &slave_exec_mode_str,
3308
3575
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3576
{"slow-query-log", OPT_SLOW_LOG,
3577
N_("Enable|disable slow query log"),
3578
(char**) &opt_slow_log,
3579
(char**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3309
3580
{"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
3310
3581
N_("(INGORED)"),
3311
3582
0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
3348
3619
N_("Default transaction isolation level."),
3349
3620
0, 0, 0, GET_STR, REQUIRED_ARG, 0,
3350
3621
0, 0, 0, 0, 0},
3622
{"use-symbolic-links", 's',
3623
N_("Enable symbolic link support. Deprecated option; use --symbolic-links "
3625
(char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
3626
IF_PURIFY(0,1), 0, 0, 0, 0, 0},
3352
N_("Run drizzled daemon as user."),
3628
N_("Run mysqld daemon as user."),
3353
3629
0, 0, 0, GET_STR, REQUIRED_ARG,
3354
3630
0, 0, 0, 0, 0, 0},
3355
3631
{"version", 'V',
3356
3632
N_("Output version information and exit."),
3357
3633
0, 0, 0, GET_NO_ARG,
3358
3634
NO_ARG, 0, 0, 0, 0, 0, 0},
3636
N_("Deprecated; use --log-warnings instead."),
3637
(char**) &global_system_variables.log_warnings,
3638
(char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
3639
1, 0, ULONG_MAX, 0, 0, 0},
3359
3640
{"back_log", OPT_BACK_LOG,
3360
3641
N_("The number of outstanding connection requests MySQL can have. This "
3361
3642
"comes into play when the main MySQL thread gets very many connection "
3459
3740
0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
3460
3741
1, 100, 0, 1, 0},
3742
{"long_query_time", OPT_LONG_QUERY_TIME,
3743
N_("Log all queries that have taken more than long_query_time seconds to "
3744
"execute to file. The argument will be treated as a decimal value with "
3745
"microsecond precission."),
3746
(char**) &long_query_time, (char**) &long_query_time, 0, GET_DOUBLE,
3747
REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
3461
3748
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
3462
3749
N_("Max packetlength to send/receive from to server."),
3463
3750
(char**) &global_system_variables.max_allowed_packet,
3553
3840
(char**) &myisam_data_pointer_size,
3554
3841
(char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
3555
3842
6, 2, 7, 0, 1, 0},
3843
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
3844
N_("(Deprecated option)"),
3845
(char**) &global_system_variables.myisam_max_extra_sort_file_size,
3846
(char**) &max_system_variables.myisam_max_extra_sort_file_size,
3847
0, GET_ULL, REQUIRED_ARG, (uint64_t) MI_MAX_TEMP_LENGTH,
3848
0, (uint64_t) MAX_FILE_SIZE, 0, 1, 0},
3556
3849
{"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
3557
3850
N_("Don't use the fast sort index method to created index if the "
3558
3851
"temporary file would get bigger than this."),
3639
3932
(char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
3640
3933
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3641
3934
{"plugin_load", OPT_PLUGIN_LOAD,
3642
N_("Optional colon (or semicolon) separated list of plugins to load,"
3643
"where each plugin is identified by the name of the shared library. "
3644
"[for example: --plugin_load=libmd5udf.so:libauth_pam.so]"),
3935
N_("Optional comma separated list of plugins to load, where each plugin is "
3936
"identified by the name of the shared library. "
3937
"[for example: --plugin_load=libmd5udf.so]"),
3645
3938
(char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
3646
3939
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3647
3940
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
3741
4034
"Use 0 (default) to disable synchronous flushing."),
3742
4035
(char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
3743
4036
REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
4037
{"table_cache", OPT_TABLE_OPEN_CACHE,
4038
N_("Deprecated; use --table_open_cache instead."),
4039
(char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
4040
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
3744
4041
{"table_definition_cache", OPT_TABLE_DEF_CACHE,
3745
4042
N_("The number of cached table definitions."),
3746
4043
(char**) &table_def_size, (char**) &table_def_size,
3762
4059
N_("How many threads we should create to handle query requests in case of "
3763
4060
"'thread_handling=pool-of-threads'"),
3764
4061
(char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULONG,
3765
REQUIRED_ARG, 8, 1, 16384, 0, 1, 0},
4062
REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
3766
4063
{"thread_stack", OPT_THREAD_STACK,
3767
4064
N_("The stack size for each thread."),
3768
4065
(char**) &my_thread_stack_size,
3800
4097
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
3803
static int show_net_compression(Session *session __attribute__((unused)),
4100
static int show_net_compression(THD *thd __attribute__((unused)),
3805
4102
char *buff __attribute__((unused)))
3807
4104
var->type= SHOW_MY_BOOL;
3808
var->value= (char *)&session->net.compress;
4105
var->value= (char *)&thd->net.compress;
3812
4109
static st_show_var_func_container
3813
4110
show_net_compression_cont= { &show_net_compression };
3815
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
4112
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
3817
4114
var->type= SHOW_LONG;
3818
4115
var->value= buff;
3819
*((long *)buff)= (long) (session->query_start() - server_start_time);
4116
*((long *)buff)= (long) (thd->query_start() - server_start_time);
3823
4120
static st_show_var_func_container
3824
4121
show_starttime_cont= { &show_starttime };
3826
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
4123
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
3828
4125
var->type= SHOW_LONG;
3829
4126
var->value= buff;
3830
*((long *)buff)= (long) (session->query_start() - flush_status_time);
4127
*((long *)buff)= (long) (thd->query_start() - flush_status_time);
3834
4131
static st_show_var_func_container
3835
4132
show_flushstatustime_cont= { &show_flushstatustime };
3837
static int show_slave_running(Session *session __attribute__((unused)),
4134
static int show_slave_running(THD *thd __attribute__((unused)),
3838
4135
SHOW_VAR *var, char *buff)
3840
4137
var->type= SHOW_MY_BOOL;
4010
4307
{"Tc_log_page_size", (char*) &tc_log_page_size, SHOW_LONG},
4011
4308
{"Tc_log_page_waits", (char*) &tc_log_page_waits, SHOW_LONG},
4310
{"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH},
4013
4311
{"Threads_connected", (char*) &connection_count, SHOW_INT},
4014
4312
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
4015
4313
{"Threads_running", (char*) &thread_running, SHOW_INT},
4016
4314
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
4017
4315
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
4018
{NULL, NULL, SHOW_LONG}
4316
{NullS, NullS, SHOW_LONG}
4021
4319
static void print_version(void)
4078
4376
as these are initialized by my_getopt.
4081
static void drizzle_init_variables(void)
4379
static void mysql_init_variables(void)
4083
4381
/* Things reset to zero */
4084
4382
opt_skip_slave_start= opt_reckless_slave = 0;
4085
4383
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
4384
opt_log= opt_slow_log= 0;
4086
4385
log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4087
4386
opt_bin_log= 0;
4088
4387
opt_skip_show_db=0;
4089
opt_logname= opt_binlog_index_name= 0;
4388
opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
4090
4389
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
4091
4391
opt_secure_file_priv= 0;
4092
4392
segfaulted= kill_in_progress= 0;
4093
4393
cleanup_done= 0;
4105
4406
specialflag= 0;
4106
4407
binlog_cache_use= binlog_cache_disk_use= 0;
4107
4408
max_used_connections= slow_launch_threads = 0;
4108
drizzled_user= drizzled_chroot= opt_init_file= opt_bin_logname = 0;
4109
opt_mysql_tmpdir= my_bind_addr_str= NULL;
4409
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4410
opt_mysql_tmpdir= my_bind_addr_str= NullS;
4110
4411
memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4111
4412
memset(&global_status_var, 0, sizeof(global_status_var));
4112
4413
key_map_full.set_all();
4125
4426
slave_exec_mode_options= 0;
4126
4427
slave_exec_mode_options= (uint)
4127
4428
find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
4128
drizzle_home_ptr= mysql_home;
4429
mysql_home_ptr= mysql_home;
4129
4430
pidfile_name_ptr= pidfile_name;
4130
4431
log_error_file_ptr= log_error_file;
4131
4432
language_ptr= language;
4132
4433
mysql_data_home= mysql_real_data_home;
4133
session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4434
thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4134
4435
OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
4135
4436
protocol_version= PROTOCOL_VERSION;
4136
4437
what_to_log= ~ (1L << (uint) COM_TIME);
4137
4438
refresh_version= 1L; /* Increments on each reload */
4139
my_stpcpy(server_version, VERSION);
4439
global_query_id= thread_id= 1L;
4440
stpcpy(server_version, DRIZZLE_SERVER_VERSION);
4140
4441
myisam_recover_options_str= "OFF";
4141
4442
myisam_stats_method_str= "nulls_unequal";
4142
4443
threads.empty();
4159
4460
/* Replication parameters */
4160
4461
master_info_file= (char*) "master.info",
4161
4462
relay_log_info_file= (char*) "relay-log.info";
4162
report_host= 0; /* TO BE DELETED */
4463
report_user= report_password = report_host= 0; /* TO BE DELETED */
4163
4464
opt_relay_logname= opt_relaylog_index_name= 0;
4165
4466
/* Variables in libraries */
4166
4467
charsets_dir= 0;
4167
4468
default_character_set_name= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
4168
4469
default_collation_name= compiled_default_collation_name;
4470
sys_charset_system.set((char*) system_charset_info->csname);
4169
4471
character_set_filesystem_name= (char*) "binary";
4170
4472
lc_time_names_name= (char*) "en_US";
4171
4473
/* Set default values for some option variables */
4230
4535
mysql_data_home_len= strlen(mysql_data_home);
4233
if (!drizzled_user || !strcmp(drizzled_user, argument))
4234
drizzled_user= argument;
4538
if (!mysqld_user || !strcmp(mysqld_user, argument))
4539
mysqld_user= argument;
4236
4541
sql_print_warning(_("Ignoring user change to '%s' because the user was "
4237
4542
"set to '%s' earlier on the command line\n"),
4238
argument, drizzled_user);
4543
argument, mysqld_user);
4241
4546
strmake(language, argument, sizeof(language)-1);
4495
4820
/** Handle arguments for multiple key caches. */
4497
extern "C" char **mysql_getopt_value(const char *keyname, uint32_t key_length,
4822
extern "C" char **mysql_getopt_value(const char *keyname, uint key_length,
4498
4823
const struct my_option *option);
4501
mysql_getopt_value(const char *keyname, uint32_t key_length,
4826
mysql_getopt_value(const char *keyname, uint key_length,
4502
4827
const struct my_option *option)
4504
4829
switch (option->id) {
4562
4887
(*argc)++; /* add back one for the progname handle_options removes */
4563
4888
/* no need to do this for argv as we are discarding it. */
4890
if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
4891
opt_log_slow_slave_statements) &&
4893
sql_print_warning(_("options --log-slow-admin-statements, "
4894
"--log-queries-not-using-indexes and "
4895
"--log-slow-slave-statements have no effect if "
4896
"--log-slow-queries is not set"));
4565
4898
#if defined(HAVE_BROKEN_REALPATH)
4566
4899
my_use_symdir=0;
4567
4900
my_disable_symlinks=1;
4618
4955
(DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
4621
#ifdef DRIZZLE_SERVER_SUFFIX
4622
#define DRIZZLE_SERVER_SUFFIX_STR STRINGIFY_ARG(DRIZZLE_SERVER_SUFFIX)
4624
#define DRIZZLE_SERVER_SUFFIX_STR ""
4627
4958
static void set_server_version(void)
4629
char *end= strxmov(server_version, VERSION,
4630
DRIZZLE_SERVER_SUFFIX_STR, NULL);
4632
my_stpcpy(end, "-log"); // This may slow down system
4960
char *end= strxmov(server_version, DRIZZLE_SERVER_VERSION,
4961
DRIZZLE_SERVER_SUFFIX_STR, NullS);
4962
if (opt_log || opt_slow_log || opt_bin_log)
4963
stpcpy(end, "-log"); // This may slow down system
4982
Fix filename and replace extension where 'dir' is relative to
4983
mysql_real_data_home.
4985
1 if len(path) > FN_REFLEN
4989
fn_format_relative_to_data_home(char * to, const char *name,
4990
const char *dir, const char *extension)
4992
char tmp_path[FN_REFLEN];
4993
if (!test_if_hard_path(dir))
4995
strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home,
4999
return !fn_format(to, name, dir, extension,
5000
MY_APPEND_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH);
4650
5004
static void fix_paths(void)
4652
5006
char buff[FN_REFLEN],*pos;
4653
convert_dirname(mysql_home,mysql_home,NULL);
5007
convert_dirname(mysql_home,mysql_home,NullS);
4654
5008
/* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
4655
5009
my_realpath(mysql_home,mysql_home,MYF(0));
4656
5010
/* Ensure that mysql_home ends in FN_LIBCHAR */
4660
5014
pos[0]= FN_LIBCHAR;
4663
convert_dirname(mysql_real_data_home,mysql_real_data_home,NULL);
5017
convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
4664
5018
(void) fn_format(buff, mysql_real_data_home, "", "",
4665
5019
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
4666
5020
(void) unpack_dirname(mysql_unpacked_real_data_home, buff);
4667
convert_dirname(language,language,NULL);
5021
convert_dirname(language,language,NullS);
4668
5022
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
4669
5023
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
4670
5024
(void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
4675
5029
char *sharedir=get_relative_path(SHAREDIR);
4676
5030
if (test_if_hard_path(sharedir))
4677
strncpy(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
5031
strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
4680
strcpy(buff, mysql_home);
4681
strncat(buff, sharedir, sizeof(buff)-strlen(mysql_home)-1);
4683
convert_dirname(buff,buff,NULL);
5033
strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
5034
convert_dirname(buff,buff,NullS);
4684
5035
(void) my_load_path(language,language,buff);
4686
5037
/* If --character-sets-dir isn't given, use shared library dir */
4687
5038
if (charsets_dir != mysql_charsets_dir)
4689
strcpy(mysql_charsets_dir, buff);
4690
strncat(mysql_charsets_dir, CHARSET_DIR,
4691
sizeof(mysql_charsets_dir)-strlen(buff)-1);
5040
strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
5041
CHARSET_DIR, NullS);
4693
5043
(void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
4694
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NULL);
5044
convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
4695
5045
charsets_dir=mysql_charsets_dir;
4697
5047
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
4830
5180
/** Clear most status variables. */
4831
void refresh_status(Session *session)
5181
void refresh_status(THD *thd)
4833
5183
pthread_mutex_lock(&LOCK_status);
4835
5185
/* Add thread's status variabes to global status */
4836
add_to_status(&global_status_var, &session->status_var);
5186
add_to_status(&global_status_var, &thd->status_var);
4838
5188
/* Reset thread's status variables */
4839
memset(&session->status_var, 0, sizeof(session->status_var));
5189
memset(&thd->status_var, 0, sizeof(thd->status_var));
4841
5191
/* Reset some global variables */
4842
5192
reset_status_vars();