~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "rpl_mi.h"
20
20
#include "sql_repl.h"
21
21
#include "rpl_filter.h"
22
 
#include "repl_failsafe.h"
23
22
#include "stacktrace.h"
24
 
#include "mysqld_suffix.h"
25
23
#include <mysys/mysys_err.h>
26
24
#include <sys/poll.h>
27
25
#include <netinet/tcp.h>
28
26
#include <drizzled/drizzled_error_messages.h>
29
27
 
 
28
#if TIME_WITH_SYS_TIME
 
29
# include <sys/time.h>
 
30
# include <time.h>
 
31
#else
 
32
# if HAVE_SYS_TIME_H
 
33
#  include <sys/time.h>
 
34
# else
 
35
#  include <time.h>
 
36
# endif
 
37
#endif
 
38
 
30
39
#include <storage/myisam/ha_myisam.h>
31
40
 
32
41
#ifdef HAVE_SYS_PRCTL_H
154
163
extern "C" int gethostname(char *name, int namelen);
155
164
#endif
156
165
 
157
 
extern "C" sig_handler handle_segfault(int sig);
 
166
extern "C" RETSIGTYPE handle_segfault(int sig);
158
167
 
159
168
/* Constants */
160
169
 
167
176
static const char *optimizer_switch_names[]=
168
177
{
169
178
  "no_materialization", "no_semijoin",
170
 
  NullS
 
179
  NULL
171
180
};
172
181
 
173
182
/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */
183
192
 
184
193
static const char *tc_heuristic_recover_names[]=
185
194
{
186
 
  "COMMIT", "ROLLBACK", NullS
 
195
  "COMMIT", "ROLLBACK", NULL
187
196
};
188
197
static TYPELIB tc_heuristic_recover_typelib=
189
198
{
211
220
 {&Arg_comparator::compare_row,        &Arg_comparator::compare_e_row},
212
221
 {&Arg_comparator::compare_decimal,    &Arg_comparator::compare_e_decimal}};
213
222
 
214
 
const char *log_output_names[] = { "NONE", "FILE", NullS};
 
223
const char *log_output_names[] = { "NONE", "FILE", NULL};
215
224
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
216
225
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
217
226
                             log_output_names,
223
232
static bool volatile select_thread_in_use, signal_thread_in_use;
224
233
static bool volatile ready_to_exit;
225
234
static bool opt_debugging= 0, opt_console= 0;
226
 
static uint kill_cached_threads, wake_thread;
 
235
static uint32_t kill_cached_threads, wake_thread;
227
236
static uint32_t killed_threads, thread_created;
228
237
static uint32_t max_used_connections;
229
238
static volatile uint32_t cached_thread_count= 0;
244
253
/* Global variables */
245
254
 
246
255
bool opt_bin_log;
247
 
bool opt_log;
248
 
bool opt_slow_log;
249
256
ulong log_output_options;
250
257
bool opt_log_queries_not_using_indexes= false;
251
258
bool opt_error_log= 0;
291
298
bool opt_noacl;
292
299
 
293
300
ulong opt_binlog_rows_event_max_size;
294
 
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
 
301
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NULL};
295
302
TYPELIB binlog_format_typelib=
296
303
  { array_elements(binlog_format_names) - 1, "",
297
304
    binlog_format_names, NULL };
300
307
#ifdef HAVE_INITGROUPS
301
308
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
302
309
#endif
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;
 
310
uint32_t mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
 
311
uint32_t mysqld_port_timeout;
 
312
uint32_t delay_key_write_options, protocol_version;
 
313
uint32_t lower_case_table_names= 1;
 
314
uint32_t tc_heuristic_recover= 0;
 
315
uint32_t volatile thread_count, thread_running;
309
316
uint64_t thd_startup_options;
310
317
ulong back_log, connect_timeout, server_id;
311
318
ulong table_cache_size, table_def_size;
332
339
ulong binlog_cache_disk_use= 0;
333
340
ulong max_connections;
334
341
ulong max_connect_errors;
335
 
uint  max_user_connections= 0;
 
342
uint32_t  max_user_connections= 0;
336
343
ulong thread_id=1L;
337
344
ulong current_pid;
338
345
ulong slow_launch_threads = 0;
384
391
     language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
385
392
     *opt_init_file, *opt_tc_log_file;
386
393
char mysql_unpacked_real_data_home[FN_REFLEN];
387
 
uint reg_ext_length;
 
394
uint32_t reg_ext_length;
388
395
const key_map key_map_empty(0);
389
396
key_map key_map_full(0);                        // Will be initialized later
390
397
 
391
398
const char *opt_date_time_formats[3];
392
399
 
393
 
uint mysql_data_home_len;
 
400
uint32_t mysql_data_home_len;
394
401
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
395
402
char server_version[SERVER_VERSION_LENGTH];
396
403
char *opt_mysql_tmpdir;
454
461
pthread_cond_t  COND_server_started;
455
462
 
456
463
/* replication parameters, if master_host is not NULL, we are a slave */
457
 
uint report_port= DRIZZLE_PORT;
 
464
uint32_t report_port= DRIZZLE_PORT;
458
465
uint32_t master_retry_count= 0;
459
466
char *master_info_file;
460
467
char *relay_log_info_file, *report_user, *report_password, *report_host;
461
468
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
462
 
char *opt_logname, *opt_slow_logname;
 
469
char *opt_logname;
463
470
 
464
471
/* Static variables */
465
472
 
480
487
 
481
488
struct passwd *user_info;
482
489
static pthread_t select_thread;
483
 
static uint thr_kill_signal;
 
490
static uint32_t thr_kill_signal;
484
491
 
485
492
/* OS specific variables */
486
493
 
492
499
  Number of currently active user connections. The variable is protected by
493
500
  LOCK_connection_count.
494
501
*/
495
 
uint connection_count= 0;
 
502
uint32_t connection_count= 0;
496
503
 
497
504
/* Function declarations */
498
505
 
547
554
      break;                                    // allready dead
548
555
#endif
549
556
    set_timespec(abstime, 2);
550
 
    for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
 
557
    for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
551
558
    {
552
559
      error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count,
553
560
                                   &abstime);
760
767
#endif
761
768
 
762
769
 
763
 
extern "C" sig_handler print_signal_warning(int sig)
 
770
extern "C" RETSIGTYPE print_signal_warning(int sig)
764
771
{
765
772
  if (global_system_variables.log_warnings)
766
 
    sql_print_warning(_("Got signal %d from thread %ld"), sig,my_thread_id());
767
 
#ifdef DONT_REMEMBER_SIGNAL
 
773
    sql_print_warning(_("Got signal %d from thread %lud"), sig,my_thread_id());
 
774
#ifndef HAVE_BSD_SIGNALS
768
775
  my_sigset(sig,print_signal_warning);          /* int. thread system calls */
769
776
#endif
770
777
  if (sig == SIGALRM)
819
826
  if (cleanup_done++)
820
827
    return; /* purecov: inspected */
821
828
 
822
 
  /*
823
 
    make sure that handlers finish up
824
 
    what they have that is dependent on the binlog
825
 
  */
826
 
  ha_binlog_end(current_thd);
827
 
 
828
829
  logger.cleanup_base();
829
830
 
830
831
  mysql_bin_log.cleanup();
844
845
  if (tc_log)
845
846
    tc_log->close();
846
847
  xid_cache_free();
847
 
  delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
 
848
  delete_elements(&key_caches, (void (*)(const char*, unsigned char*)) free_key_cache);
848
849
  multi_keycache_free();
849
850
  free_status_vars();
850
851
  end_thr_alarm(1);                     /* Free allocated memory */
851
852
  my_free_open_file_info();
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));
 
853
  free((char*) global_system_variables.date_format);
 
854
  free((char*) global_system_variables.time_format);
 
855
  free((char*) global_system_variables.datetime_format);
858
856
  if (defaults_argv)
859
857
    free_defaults(defaults_argv);
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));
 
858
  free(sys_init_connect.value);
 
859
  free(sys_init_slave.value);
864
860
  free_tmpdir(&mysql_tmpdir_list);
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);
 
861
  free(slave_load_tmpdir);
 
862
  if (opt_bin_logname)
 
863
    free(opt_bin_logname);
 
864
  if (opt_relay_logname)
 
865
    free(opt_relay_logname);
 
866
  if (opt_secure_file_priv)
 
867
    free(opt_secure_file_priv);
869
868
  bitmap_free(&temp_pool);
870
 
  end_slave_list();
871
869
  delete binlog_filter;
872
870
  delete rpl_filter;
873
 
  vio_end();
874
871
 
875
872
  (void) my_delete(pidfile_name,MYF(0));        // This may not always exist
876
873
 
882
879
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
883
880
  // TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
884
881
/*  if (freeme != NULL)
885
 
    my_free(freeme, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));  */
 
882
    free(freeme);  */
886
883
  /* Tell main we are ready */
887
884
  logger.cleanup_end();
888
885
  (void) pthread_mutex_lock(&LOCK_thread_count);
904
901
*/
905
902
static void wait_for_signal_thread_to_end()
906
903
{
907
 
  uint i;
 
904
  uint32_t i;
908
905
  /*
909
906
    Wait up to 10 seconds for signal thread to die. We use this mainly to
910
907
    avoid getting warnings that my_thread_end has not been called
928
925
  (void) pthread_mutex_destroy(&LOCK_error_log);
929
926
  (void) pthread_mutex_destroy(&LOCK_user_conn);
930
927
  (void) pthread_mutex_destroy(&LOCK_connection_count);
931
 
  (void) pthread_mutex_destroy(&LOCK_rpl_status);
932
 
  (void) pthread_cond_destroy(&COND_rpl_status);
933
928
  (void) pthread_mutex_destroy(&LOCK_active_mi);
934
929
  (void) rwlock_destroy(&LOCK_sys_init_connect);
935
930
  (void) rwlock_destroy(&LOCK_sys_init_slave);
1101
1096
static void network_init(void)
1102
1097
{
1103
1098
  int   ret;
1104
 
  uint  waited;
1105
 
  uint  this_wait;
1106
 
  uint  retry;
 
1099
  uint32_t  waited;
 
1100
  uint32_t  this_wait;
 
1101
  uint32_t  retry;
1107
1102
  char port_buf[NI_MAXSERV];
1108
1103
  struct addrinfo *ai;
1109
1104
  struct addrinfo *next;
1198
1193
    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1199
1194
    {
1200
1195
      if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1201
 
          (socket_errno != SOCKET_EADDRINUSE) ||
 
1196
          (errno != EADDRINUSE) ||
1202
1197
          (waited >= mysqld_port_timeout))
1203
1198
        break;
1204
1199
      sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
1216
1211
    {
1217
1212
      sql_perror(_("Can't start server: listen() on TCP/IP port"));
1218
1213
      sql_print_error(_("listen() on TCP/IP failed with error %d"),
1219
 
                      socket_errno);
 
1214
                      errno);
1220
1215
      unireg_abort(1);
1221
1216
    }
1222
1217
  }
1235
1230
  @note
1236
1231
    For the connection that is doing shutdown, this is called twice
1237
1232
*/
1238
 
void close_connection(THD *thd, uint errcode, bool lock)
 
1233
void close_connection(THD *thd, uint32_t errcode, bool lock)
1239
1234
{
1240
1235
  st_vio *vio;
1241
1236
  if (lock)
1245
1240
  {
1246
1241
    if (errcode)
1247
1242
      net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
1248
 
    vio_close(vio);                     /* vio is freed in delete thd */
 
1243
    net_close(&(thd->net));             /* vio is freed in delete thd */
1249
1244
  }
1250
1245
  if (lock)
1251
1246
    (void) pthread_mutex_unlock(&LOCK_thread_count);
1255
1250
 
1256
1251
/** Called when a thread is aborted. */
1257
1252
/* ARGSUSED */
1258
 
extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
 
1253
extern "C" RETSIGTYPE end_thread_signal(int sig __attribute__((unused)))
1259
1254
{
1260
1255
  THD *thd=current_thd;
1261
1256
  if (thd && ! thd->bootstrap)
1402
1397
  @todo
1403
1398
    One should have to fix that thr_alarm know about this thread too.
1404
1399
*/
1405
 
extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
 
1400
extern "C" RETSIGTYPE abort_thread(int sig __attribute__((unused)))
1406
1401
{
1407
1402
  THD *thd=current_thd;
1408
1403
  if (thd)
1420
1415
#endif
1421
1416
 
1422
1417
 
1423
 
extern "C" sig_handler handle_segfault(int sig)
 
1418
extern "C" RETSIGTYPE handle_segfault(int sig)
1424
1419
{
1425
1420
  time_t curr_time;
1426
1421
  struct tm tm;
1485
1480
                     "where mysqld died. If you see no messages after this, "
1486
1481
                     "something went\n"
1487
1482
                     "terribly wrong...\n"));
1488
 
    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
 
1483
    print_stacktrace(thd ? (unsigned char*) thd->thread_stack : (unsigned char*) 0,
1489
1484
                     my_thread_stack_size);
1490
1485
  }
1491
1486
  if (thd)
1769
1764
      sql_print_information(_("Got signal %d to shutdown mysqld"),sig);
1770
1765
#endif
1771
1766
      /* switch to the old log message processing */
1772
 
      logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
1773
 
                          opt_log ? LOG_FILE:LOG_NONE);
1774
1767
      if (!abort_loop)
1775
1768
      {
1776
1769
        abort_loop=1;                           // mark abort for threads
1801
1794
                      REFRESH_THREADS | REFRESH_HOSTS),
1802
1795
                     (TableList*) 0, &not_used); // Flush logs
1803
1796
      }
1804
 
      logger.set_handlers(LOG_FILE,
1805
 
                          opt_slow_log ? log_output_options : LOG_NONE,
1806
 
                          opt_log ? log_output_options : LOG_NONE);
1807
1797
      break;
1808
1798
#ifdef USE_ONE_SIGNAL_HAND
1809
1799
    case THR_SERVER_ALARM:
1831
1821
  for the client.
1832
1822
*/
1833
1823
/* ARGSUSED */
1834
 
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
 
1824
extern "C" void my_message_sql(uint32_t error, const char *str, myf MyFlags);
1835
1825
 
1836
 
void my_message_sql(uint error, const char *str, myf MyFlags)
 
1826
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
1837
1827
{
1838
1828
  THD *thd;
1839
1829
  /*
1845
1835
    if (MyFlags & ME_FATALERROR)
1846
1836
      thd->is_fatal_error= 1;
1847
1837
 
1848
 
#ifdef BUG_36098_FIXED
1849
 
    mysql_audit_general(thd,DRIZZLE_AUDIT_GENERAL_ERROR,error,my_time(0),
1850
 
                        0,0,str,str ? strlen(str) : 0,
1851
 
                        thd->query,thd->query_length,
1852
 
                        thd->variables.character_set_client,
1853
 
                        thd->row_count);
1854
 
#endif
1855
 
 
1856
 
 
1857
1838
    /*
1858
1839
      TODO: There are two exceptions mechanism (THD and sp_rcontext),
1859
1840
      this could be improved by having a common stack of handlers.
1909
1890
 
1910
1891
void my_str_free_mysqld(void *ptr)
1911
1892
{
1912
 
  my_free((uchar*)ptr, MYF(MY_FAE));
 
1893
  free((unsigned char*)ptr);
1913
1894
}
1914
1895
 
1915
1896
 
1933
1914
    1 error
1934
1915
*/
1935
1916
 
1936
 
static bool init_global_datetime_format(timestamp_type format_type,
 
1917
static bool init_global_datetime_format(enum enum_drizzle_timestamp_type format_type,
1937
1918
                                        DATE_TIME_FORMAT **var_ptr)
1938
1919
{
1939
1920
  /* Get command line option */
2014
1995
  {"show_open_tables",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
2015
1996
  {"show_plugins",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
2016
1997
  {"show_processlist",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
2017
 
  {"show_slave_hosts",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
2018
1998
  {"show_slave_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
2019
1999
  {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
2020
2000
  {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
2027
2007
  {"unlock_tables",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
2028
2008
  {"update",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
2029
2009
  {"update_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
2030
 
  {NullS, NullS, SHOW_LONG}
 
2010
  {NULL, NULL, SHOW_LONG}
2031
2011
};
2032
2012
 
2033
2013
static int init_common_variables(const char *conf_file_name, int argc,
2034
2014
                                 char **argv, const char **groups)
2035
2015
{
2036
 
  char buff[FN_REFLEN], *s;
2037
2016
  umask(((~my_umask) & 0666));
2038
2017
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
2039
2018
  tzset();                      // Set tzname
2086
2065
  }
2087
2066
  else
2088
2067
  strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
2089
 
  stpcpy(fn_ext(pidfile_name),".pid");          // Add proper extension
 
2068
  my_stpcpy(fn_ext(pidfile_name),".pid");               // Add proper extension
2090
2069
 
2091
2070
  /*
2092
2071
    Add server status variables to the dynamic list of
2106
2085
 
2107
2086
  /* connections and databases needs lots of files */
2108
2087
  {
2109
 
    uint files, wanted_files, max_open_files;
 
2088
    uint32_t files, wanted_files, max_open_files;
2110
2089
 
2111
2090
    /* MyISAM requires two file handles per table. */
2112
2091
    wanted_files= 10+max_connections+table_cache_size*2;
2120
2099
      can't get max_connections*5 but still got no less than was
2121
2100
      requested (value of wanted_files).
2122
2101
    */
2123
 
    max_open_files= max(max((uint32_t)wanted_files, max_connections*5),
2124
 
                        open_files_limit);
 
2102
    max_open_files= cmax(cmax((uint32_t)wanted_files, max_connections*5),
 
2103
                         open_files_limit);
2125
2104
    files= my_set_max_open_files(max_open_files);
2126
2105
 
2127
2106
    if (files < wanted_files)
2132
2111
          If we have requested too much file handles than we bring
2133
2112
          max_connections in supported bounds.
2134
2113
        */
2135
 
        max_connections= (uint32_t) min((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
 
2114
        max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
2136
2115
                                     max_connections);
2137
2116
        /*
2138
2117
          Decrease table_cache_size according to max_connections, but
2139
 
          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
 
2118
          not below TABLE_OPEN_CACHE_MIN.  Outer cmin() ensures that we
2140
2119
          never increase table_cache_size automatically (that could
2141
2120
          happen if max_connections is decreased above).
2142
2121
        */
2143
 
        table_cache_size= (uint32_t) min(max((files-10-max_connections)/2,
 
2122
        table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
2144
2123
                                          (uint32_t)TABLE_OPEN_CACHE_MIN),
2145
2124
                                      table_cache_size);
2146
2125
        if (global_system_variables.log_warnings)
2247
2226
  else
2248
2227
    sys_init_slave.value=my_strdup("",MYF(0));
2249
2228
 
2250
 
  /* check log options and issue warnings if needed */
2251
 
  if (opt_log && opt_logname && !(log_output_options & LOG_FILE) &&
2252
 
      !(log_output_options & LOG_NONE))
2253
 
    sql_print_warning(_("Although a path was specified for the "
2254
 
                        "--log option, log tables are used. "
2255
 
                        "To enable logging to files use the "
2256
 
                        "--log-output option."));
2257
 
 
2258
 
  if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE)
2259
 
      && !(log_output_options & LOG_NONE))
2260
 
    sql_print_warning(_("Although a path was specified for the "
2261
 
                        "--log-slow-queries option, log tables are used. "
2262
 
                        "To enable logging to files use the "
2263
 
                        "--log-output=file option."));
2264
 
 
2265
 
  s= opt_logname ? opt_logname : make_default_log_name(buff, ".log");
2266
 
  sys_var_general_log_path.value= my_strdup(s, MYF(0));
2267
 
  sys_var_general_log_path.value_length= strlen(s);
2268
 
 
2269
 
  s= opt_slow_logname ? opt_slow_logname : make_default_log_name(buff, "-slow.log");
2270
 
  sys_var_slow_log_path.value= my_strdup(s, MYF(0));
2271
 
  sys_var_slow_log_path.value_length= strlen(s);
2272
 
 
2273
2229
  if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
2274
2230
    return 1;
2275
2231
  if (my_database_names_init())
2306
2262
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
2307
2263
  (void) pthread_cond_init(&COND_thread_cache,NULL);
2308
2264
  (void) pthread_cond_init(&COND_flush_thread_cache,NULL);
2309
 
  (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2310
 
  (void) pthread_cond_init(&COND_rpl_status, NULL);
2311
2265
 
2312
2266
  /* Parameter for threads created for connections */
2313
2267
  (void) pthread_attr_init(&connection_attrib);
2344
2298
  randominit(&sql_rand,(uint32_t) server_start_time,(uint32_t) server_start_time/2);
2345
2299
  setup_fpu();
2346
2300
  init_thr_lock();
2347
 
  init_slave_list();
2348
2301
 
2349
2302
  /* Setup logs */
2350
2303
 
2429
2382
    }
2430
2383
    if (ln == buf)
2431
2384
    {
2432
 
      my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
 
2385
      free(opt_bin_logname);
2433
2386
      opt_bin_logname=my_strdup(buf, MYF(0));
2434
2387
    }
2435
2388
    if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
2500
2453
    unireg_abort(1);
2501
2454
  }
2502
2455
 
2503
 
  logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
2504
 
                      opt_log ? LOG_FILE:LOG_NONE);
2505
 
 
2506
2456
  /*
2507
2457
    Check that the default storage engine is actually available.
2508
2458
  */
2596
2546
 
2597
2547
int main(int argc, char **argv)
2598
2548
{
2599
 
 
2600
2549
#if defined(ENABLE_NLS)
2601
2550
# if defined(HAVE_LOCALE_H)
2602
2551
  setlocale(LC_ALL, "");
2648
2597
      if (global_system_variables.log_warnings)
2649
2598
      {
2650
2599
        /* %zu is not yet in C++ */
2651
 
        unsigned long long size_tmp= (uint64_t)stack_size;
2652
 
        sql_print_warning(_("Asked for %u thread stack, but got %llu"),
 
2600
        uint64_t size_tmp= (uint64_t)stack_size;
 
2601
        sql_print_warning(_("Asked for %u thread stack, but got %"PRIu64),
2653
2602
                          my_thread_stack_size, size_tmp);
2654
2603
      }
2655
2604
      my_thread_stack_size= stack_size;
2844
2793
{
2845
2794
  int x;
2846
2795
  int sock,new_sock;
2847
 
  uint error_count=0;
 
2796
  uint32_t error_count=0;
2848
2797
  THD *thd;
2849
2798
  struct sockaddr_storage cAddr;
2850
 
  st_vio *vio_tmp;
2851
2799
 
2852
2800
  MAYBE_BROKEN_SYSCALL;
2853
2801
  while (!abort_loop)
2856
2804
 
2857
2805
    if ((number_of= poll(fds, pollfd_count, -1)) == -1)
2858
2806
    {
2859
 
      if (socket_errno != SOCKET_EINTR)
 
2807
      if (errno != EINTR)
2860
2808
      {
2861
2809
        if (!select_errors++ && !abort_loop)    /* purecov: inspected */
2862
2810
          sql_print_error(_("drizzled: Got error %d from select"),
2863
 
                          socket_errno); /* purecov: inspected */
 
2811
                          errno); /* purecov: inspected */
2864
2812
      }
2865
2813
      MAYBE_BROKEN_SYSCALL
2866
2814
      continue;
2888
2836
    }
2889
2837
    assert(sock != -1);
2890
2838
 
2891
 
    for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
 
2839
    for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
2892
2840
    {
2893
 
      size_socket length= sizeof(struct sockaddr_storage);
 
2841
      SOCKET_SIZE_TYPE length= sizeof(struct sockaddr_storage);
2894
2842
      new_sock= accept(sock, (struct sockaddr *)(&cAddr),
2895
2843
                       &length);
2896
 
      if (new_sock != -1 || (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
 
2844
      if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
2897
2845
        break;
2898
2846
    }
2899
2847
 
2903
2851
      if ((error_count++ & 255) == 0)           // This can happen often
2904
2852
        sql_perror("Error in accept");
2905
2853
      MAYBE_BROKEN_SYSCALL;
2906
 
      if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
 
2854
      if (errno == ENFILE || errno == EMFILE)
2907
2855
        sleep(1);                               // Give other threads some time
2908
2856
      continue;
2909
2857
    }
2910
2858
 
2911
2859
    {
2912
 
      size_socket dummyLen;
 
2860
      SOCKET_SIZE_TYPE dummyLen;
2913
2861
      struct sockaddr_storage dummy;
2914
2862
      dummyLen = sizeof(dummy);
2915
2863
      if (  getsockname(new_sock,(struct sockaddr *)&dummy,
2938
2886
    if (!(thd= new THD))
2939
2887
    {
2940
2888
      (void) shutdown(new_sock, SHUT_RDWR);
2941
 
      VOID(close(new_sock));
 
2889
      close(new_sock);
2942
2890
      continue;
2943
2891
    }
2944
 
    if (!(vio_tmp=vio_new(new_sock, VIO_TYPE_TCPIP, sock == 0)) ||
2945
 
        my_net_init(&thd->net,vio_tmp))
 
2892
    if (net_init_sock(&thd->net, new_sock, sock == 0))
2946
2893
    {
2947
 
      /*
2948
 
        Only delete the temporary vio if we didn't already attach it to the
2949
 
        NET object. The destructor in THD will delete any initialized net
2950
 
        structure.
2951
 
      */
2952
 
      if (vio_tmp && thd->net.vio != vio_tmp)
2953
 
        vio_delete(vio_tmp);
2954
 
      else
2955
 
      {
2956
 
        (void) shutdown(new_sock, SHUT_RDWR);
2957
 
        (void) close(new_sock);
2958
 
      }
2959
2894
      delete thd;
2960
2895
      continue;
2961
2896
    }
2984
2919
  OPT_SHORT_LOG_FORMAT,
2985
2920
  OPT_FLUSH,                   OPT_SAFE,
2986
2921
  OPT_STORAGE_ENGINE,          OPT_INIT_FILE,
2987
 
  OPT_DELAY_KEY_WRITE_ALL,     OPT_SLOW_QUERY_LOG,
 
2922
  OPT_DELAY_KEY_WRITE_ALL,
2988
2923
  OPT_DELAY_KEY_WRITE,         OPT_CHARSETS_DIR,
2989
2924
  OPT_MASTER_INFO_FILE,
2990
2925
  OPT_MASTER_RETRY_COUNT,      OPT_LOG_TC, OPT_LOG_TC_SIZE,
3002
2937
  OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
3003
2938
  OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
3004
2939
  OPT_ABORT_SLAVE_EVENT_COUNT,
3005
 
  OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
3006
2940
  OPT_ENGINE_CONDITION_PUSHDOWN,
3007
2941
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
3008
2942
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
3075
3009
  OPT_DATE_FORMAT,
3076
3010
  OPT_TIME_FORMAT,
3077
3011
  OPT_DATETIME_FORMAT,
3078
 
  OPT_LOG_QUERIES_NOT_USING_INDEXES,
3079
3012
  OPT_DEFAULT_TIME_ZONE,
3080
3013
  OPT_SYSDATE_IS_NOW,
3081
3014
  OPT_OPTIMIZER_SEARCH_DEPTH,
3085
3018
  OPT_ENABLE_LARGE_PAGES,
3086
3019
  OPT_TIMED_MUTEXES,
3087
3020
  OPT_OLD_STYLE_USER_LIMITS,
3088
 
  OPT_LOG_SLOW_ADMIN_STATEMENTS,
3089
3021
  OPT_TABLE_LOCK_WAIT_TIMEOUT,
3090
3022
  OPT_PLUGIN_LOAD,
3091
3023
  OPT_PLUGIN_DIR,
3092
 
  OPT_LOG_OUTPUT,
3093
3024
  OPT_PORT_OPEN_TIMEOUT,
3094
3025
  OPT_PROFILING,
3095
3026
  OPT_KEEP_FILES_ON_CREATE,
3096
3027
  OPT_GENERAL_LOG,
3097
 
  OPT_SLOW_LOG,
3098
3028
  OPT_THREAD_HANDLING,
3099
3029
  OPT_INNODB_ROLLBACK_ON_TIMEOUT,
3100
3030
  OPT_SECURE_FILE_PRIV,
3101
3031
  OPT_MIN_EXAMINED_ROW_LIMIT,
3102
 
  OPT_LOG_SLOW_SLAVE_STATEMENTS,
3103
3032
  OPT_OLD_MODE,
3104
3033
  OPT_POOL_OF_THREADS,
3105
3034
  OPT_SLAVE_EXEC_MODE
3207
3136
   N_("Path to the database root."),
3208
3137
   (char**) &mysql_data_home,
3209
3138
   (char**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3210
 
  {"default-character-set", 'C',
3211
 
   N_("Set the default character set (deprecated option, use "
3212
 
      "--character-set-server instead)."),
3213
 
   (char**) &default_character_set_name, (char**) &default_character_set_name,
3214
 
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3215
 
  {"default-collation", OPT_DEFAULT_COLLATION,
3216
 
   N_("Set the default collation (deprecated option, use --collation-server "
3217
 
      "instead)."),
3218
 
   (char**) &default_collation_name, (char**) &default_collation_name,
3219
 
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
3220
3139
  {"default-storage-engine", OPT_STORAGE_ENGINE,
3221
3140
   N_("Set the default storage engine (table type) for tables."),
3222
3141
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
3228
3147
  {"delay-key-write", OPT_DELAY_KEY_WRITE,
3229
3148
   N_("Type of DELAY_KEY_WRITE."),
3230
3149
   0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3231
 
  {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
3232
 
   N_("Don't flush key buffers between writes for any MyISAM table "
3233
 
      "(Deprecated option, use --delay-key-write=all instead)."),
3234
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3235
3150
  {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
3236
3151
   N_("Option used by mysql-test for debugging and testing of replication."),
3237
3152
   (char**) &disconnect_slave_event_count,
3262
3177
   N_("Set up signals usable for debugging"),
3263
3178
   (char**) &opt_debugging, (char**) &opt_debugging,
3264
3179
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3265
 
  {"general-log", OPT_GENERAL_LOG,
3266
 
   N_("Enable general query log"),
3267
 
   (char**) &opt_log,
3268
 
   (char**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3269
3180
  {"init-connect", OPT_INIT_CONNECT,
3270
3181
   N_("Command(s) that are executed for each new connection"),
3271
3182
   (char**) &opt_init_connect, (char**) &opt_init_connect, 0, GET_STR_ALLOC,
3307
3218
   N_("File that holds the names for last binary log files."),
3308
3219
   (char**) &opt_binlog_index_name, (char**) &opt_binlog_index_name, 0, GET_STR,
3309
3220
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3310
 
  /*
3311
 
    This option starts with "log-bin" to emphasize that it is specific of
3312
 
    binary logging.
3313
 
  */
3314
 
  {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
3315
 
   N_("If equal to 0 (the default), then when --log-bin is used, creation of "
3316
 
      "a stored function (or trigger) is allowed only to users having the "
3317
 
      "SUPER privilege and only if this stored function (trigger) may not "
3318
 
      "break binary logging. Note that if ALL connections to this server "
3319
 
      "ALWAYS use row-based binary logging, the security issues do not exist "
3320
 
      "and the binary logging cannot break, so you can safely set this to 1.")
3321
 
   ,(char**) &trust_function_creators, (char**) &trust_function_creators, 0,
3322
 
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3323
3221
  {"log-error", OPT_ERROR_LOG_FILE,
3324
3222
   N_("Error log file."),
3325
3223
   (char**) &log_error_file_ptr, (char**) &log_error_file_ptr, 0, GET_STR,
3328
3226
   N_("Log all MyISAM changes to file."),
3329
3227
   (char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3330
3228
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3331
 
  {"log-long-format", '0',
3332
 
   N_("Log some extra information to update log. Please note that this option "
3333
 
      "is deprecated; see --log-queries-not-using-indexes option."),
3334
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3335
 
#ifdef WITH_CSV_STORAGE_ENGINE
3336
 
  {"log-output", OPT_LOG_OUTPUT,
3337
 
   N_("Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
3338
 
      "FILE or NONE."),
3339
 
   (char**) &log_output_str, (char**) &log_output_str, 0,
3340
 
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
3341
 
#endif
3342
 
  {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
3343
 
   N_("Log queries that are executed without benefit of any index to the "
3344
 
      "slow log if it is open."),
3345
 
   (char**) &opt_log_queries_not_using_indexes,
3346
 
   (char**) &opt_log_queries_not_using_indexes,
3347
 
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3348
3229
  {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
3349
3230
   N_("Tells the slave to log the updates from the slave thread to the binary "
3350
3231
      "log. You will need to turn it on if you plan to "
3352
3233
   (char**) &opt_log_slave_updates, (char**) &opt_log_slave_updates,
3353
3234
   0, GET_BOOL,
3354
3235
   NO_ARG, 0, 0, 0, 0, 0, 0},
3355
 
  {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
3356
 
   N_("Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements "
3357
 
      "to the slow log if it is open."),
3358
 
   (char**) &opt_log_slow_admin_statements,
3359
 
   (char**) &opt_log_slow_admin_statements,
3360
 
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3361
 
 {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
3362
 
  N_("Log slow statements executed by slave thread to the slow log if it is "
3363
 
     "open."),
3364
 
  (char**) &opt_log_slow_slave_statements,
3365
 
  (char**) &opt_log_slow_slave_statements,
3366
 
  0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
3367
 
  {"log-slow-queries", OPT_SLOW_QUERY_LOG,
3368
 
   N_("Log slow queries to a table or log file. Defaults logging to table "
3369
 
      "mysql.slow_log or hostname-slow.log if --log-output=file is used. "
3370
 
      "Must be enabled to activate other slow log options."),
3371
 
   (char**) &opt_slow_logname, (char**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
3372
 
   0, 0, 0, 0, 0, 0},
3373
3236
  {"log-tc", OPT_LOG_TC,
3374
3237
   N_("Path to transaction coordinator log (used for transactions that affect "
3375
3238
      "more than one storage engine, when binary log is disabled)"),
3548
3411
      "replication partners."),
3549
3412
   (char**) &server_id, (char**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
3550
3413
   0, 0, 0},
3551
 
  {"set-variable", 'O',
3552
 
   N_("Change the value of a variable. Please note that this option is "
3553
 
      "deprecated;you can set variables directly with --variable-name=value."),
3554
 
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3555
3414
  {"skip-new", OPT_SKIP_NEW,
3556
3415
   N_("Don't use new, possible wrong routines."),
3557
3416
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3563
3422
   N_("Don't print a stack trace on failure."),
3564
3423
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
3565
3424
   0, 0, 0, 0},
3566
 
  {"skip-symlink", OPT_SKIP_SYMLINKS,
3567
 
   N_("Don't allow symlinking of tables. Deprecated option.  Use "
3568
 
      "--skip-symbolic-links instead."),
3569
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3570
3425
  {"skip-thread-priority", OPT_SKIP_PRIOR,
3571
3426
   N_("Don't give threads different priorities."),
3572
3427
   0, 0, 0, GET_NO_ARG, NO_ARG,
3588
3443
      "and the slave."),
3589
3444
   (char**) &slave_exec_mode_str, (char**) &slave_exec_mode_str,
3590
3445
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3591
 
  {"slow-query-log", OPT_SLOW_LOG,
3592
 
   N_("Enable|disable slow query log"),
3593
 
   (char**) &opt_slow_log,
3594
 
   (char**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
3595
3446
  {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
3596
3447
   N_("(INGORED)"),
3597
3448
   0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
3634
3485
   N_("Default transaction isolation level."),
3635
3486
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
3636
3487
   0, 0, 0, 0, 0},
3637
 
  {"use-symbolic-links", 's',
3638
 
   N_("Enable symbolic link support. Deprecated option; use --symbolic-links "
3639
 
      "instead."),
3640
 
   (char**) &my_use_symdir, (char**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
3641
 
   IF_PURIFY(0,1), 0, 0, 0, 0, 0},
3642
3488
  {"user", 'u',
3643
3489
   N_("Run mysqld daemon as user."),
3644
3490
   0, 0, 0, GET_STR, REQUIRED_ARG,
3647
3493
   N_("Output version information and exit."),
3648
3494
   0, 0, 0, GET_NO_ARG,
3649
3495
   NO_ARG, 0, 0, 0, 0, 0, 0},
3650
 
  {"warnings", 'W',
3651
 
   N_("Deprecated; use --log-warnings instead."),
3652
 
   (char**) &global_system_variables.log_warnings,
3653
 
   (char**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
3654
 
   1, 0, ULONG_MAX, 0, 0, 0},
3655
3496
  {"back_log", OPT_BACK_LOG,
3656
3497
   N_("The number of outstanding connection requests MySQL can have. This "
3657
3498
      "comes into play when the main MySQL thread gets very many connection "
3855
3696
   (char**) &myisam_data_pointer_size,
3856
3697
   (char**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
3857
3698
   6, 2, 7, 0, 1, 0},
3858
 
  {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
3859
 
   N_("(Deprecated option)"),
3860
 
   (char**) &global_system_variables.myisam_max_extra_sort_file_size,
3861
 
   (char**) &max_system_variables.myisam_max_extra_sort_file_size,
3862
 
   0, GET_ULL, REQUIRED_ARG, (uint64_t) MI_MAX_TEMP_LENGTH,
3863
 
   0, (uint64_t) MAX_FILE_SIZE, 0, 1, 0},
3864
3699
  {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
3865
3700
   N_("Don't use the fast sort index method to created index if the "
3866
3701
      "temporary file would get bigger than this."),
4049
3884
      "Use 0 (default) to disable synchronous flushing."),
4050
3885
   (char**) &sync_binlog_period, (char**) &sync_binlog_period, 0, GET_ULONG,
4051
3886
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
4052
 
  {"table_cache", OPT_TABLE_OPEN_CACHE,
4053
 
   N_("Deprecated; use --table_open_cache instead."),
4054
 
   (char**) &table_cache_size, (char**) &table_cache_size, 0, GET_ULONG,
4055
 
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
4056
3887
  {"table_definition_cache", OPT_TABLE_DEF_CACHE,
4057
3888
   N_("The number of cached table definitions."),
4058
3889
   (char**) &table_def_size, (char**) &table_def_size,
4328
4159
  {"Threads_running",          (char*) &thread_running,         SHOW_INT},
4329
4160
  {"Uptime",                   (char*) &show_starttime_cont,         SHOW_FUNC},
4330
4161
  {"Uptime_since_flush_status",(char*) &show_flushstatustime_cont,   SHOW_FUNC},
4331
 
  {NullS, NullS, SHOW_LONG}
 
4162
  {NULL, NULL, SHOW_LONG}
4332
4163
};
4333
4164
 
4334
4165
static void print_version(void)
4396
4227
  /* Things reset to zero */
4397
4228
  opt_skip_slave_start= opt_reckless_slave = 0;
4398
4229
  mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
4399
 
  opt_log= opt_slow_log= 0;
4400
4230
  log_output_options= find_bit_type(log_output_str, &log_output_typelib);
4401
4231
  opt_bin_log= 0;
4402
4232
  opt_skip_show_db=0;
4403
 
  opt_logname= opt_binlog_index_name= opt_slow_logname= 0;
 
4233
  opt_logname= opt_binlog_index_name= 0;
4404
4234
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
4405
4235
  opt_secure_auth= 0;
4406
4236
  opt_secure_file_priv= 0;
4422
4252
  binlog_cache_use=  binlog_cache_disk_use= 0;
4423
4253
  max_used_connections= slow_launch_threads = 0;
4424
4254
  mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4425
 
  opt_mysql_tmpdir= my_bind_addr_str= NullS;
 
4255
  opt_mysql_tmpdir= my_bind_addr_str= NULL;
4426
4256
  memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4427
4257
  memset(&global_status_var, 0, sizeof(global_status_var));
4428
4258
  key_map_full.set_all();
4452
4282
  what_to_log= ~ (1L << (uint) COM_TIME);
4453
4283
  refresh_version= 1L;  /* Increments on each reload */
4454
4284
  global_query_id= thread_id= 1L;
4455
 
  stpcpy(server_version, DRIZZLE_SERVER_VERSION);
 
4285
  my_stpcpy(server_version, DRIZZLE_SERVER_VERSION);
4456
4286
  myisam_recover_options_str= "OFF";
4457
4287
  myisam_stats_method_str= "nulls_unequal";
4458
4288
  threads.empty();
4540
4370
    if (default_collation_name == compiled_default_collation_name)
4541
4371
      default_collation_name= 0;
4542
4372
    break;
4543
 
  case 'l':
4544
 
    opt_log=1;
4545
 
    break;
4546
4373
  case 'h':
4547
4374
    strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
4548
4375
    /* Correct pointer set by my_getopt (for embedded library) */
4685
4512
      }
4686
4513
      break;
4687
4514
    }
4688
 
  case (int) OPT_SLOW_QUERY_LOG:
4689
 
    opt_slow_log= 1;
4690
 
    break;
4691
 
#ifdef WITH_CSV_STORAGE_ENGINE
4692
 
  case  OPT_LOG_OUTPUT:
4693
 
    {
4694
 
      if (!argument || !argument[0])
4695
 
      {
4696
 
        log_output_options= LOG_FILE;
4697
 
        log_output_str= log_output_typelib.type_names[1];
4698
 
      }
4699
 
      else
4700
 
      {
4701
 
        log_output_str= argument;
4702
 
        log_output_options=
4703
 
          find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
4704
 
      }
4705
 
      break;
4706
 
    }
4707
 
#endif
4708
4515
  case (int) OPT_WANT_CORE:
4709
4516
    test_flags |= TEST_CORE_ON_SIGNAL;
4710
4517
    break;
4834
4641
 
4835
4642
/** Handle arguments for multiple key caches. */
4836
4643
 
4837
 
extern "C" char **mysql_getopt_value(const char *keyname, uint key_length,
 
4644
extern "C" char **mysql_getopt_value(const char *keyname, uint32_t key_length,
4838
4645
                                      const struct my_option *option);
4839
4646
 
4840
4647
char**
4841
 
mysql_getopt_value(const char *keyname, uint key_length,
 
4648
mysql_getopt_value(const char *keyname, uint32_t key_length,
4842
4649
                   const struct my_option *option)
4843
4650
{
4844
4651
  switch (option->id) {
4902
4709
  (*argc)++; /* add back one for the progname handle_options removes */
4903
4710
             /* no need to do this for argv as we are discarding it. */
4904
4711
 
4905
 
  if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
4906
 
       opt_log_slow_slave_statements) &&
4907
 
      !opt_slow_log)
4908
 
    sql_print_warning(_("options --log-slow-admin-statements, "
4909
 
                        "--log-queries-not-using-indexes and "
4910
 
                        "--log-slow-slave-statements have no effect if "
4911
 
                        "--log-slow-queries is not set"));
4912
 
 
4913
4712
#if defined(HAVE_BROKEN_REALPATH)
4914
4713
  my_use_symdir=0;
4915
4714
  my_disable_symlinks=1;
4970
4769
  (DRIZZLE_SERVER_SUFFIX is set by the compilation environment)
4971
4770
*/
4972
4771
 
 
4772
#ifdef DRIZZLE_SERVER_SUFFIX
 
4773
#define DRIZZLE_SERVER_SUFFIX_STR STRINGIFY_ARG(DRIZZLE_SERVER_SUFFIX)
 
4774
#else
 
4775
#define DRIZZLE_SERVER_SUFFIX_STR DRIZZLE_SERVER_SUFFIX_DEF
 
4776
#endif
 
4777
 
4973
4778
static void set_server_version(void)
4974
4779
{
4975
4780
  char *end= strxmov(server_version, DRIZZLE_SERVER_VERSION,
4976
 
                     DRIZZLE_SERVER_SUFFIX_STR, NullS);
4977
 
  if (opt_log || opt_slow_log || opt_bin_log)
4978
 
    stpcpy(end, "-log");                        // This may slow down system
 
4781
                     DRIZZLE_SERVER_SUFFIX_STR, NULL);
 
4782
  if (opt_bin_log)
 
4783
    my_stpcpy(end, "-log");                        // This may slow down system
4979
4784
}
4980
4785
 
4981
4786
 
5008
4813
  if (!test_if_hard_path(dir))
5009
4814
  {
5010
4815
    strxnmov(tmp_path,sizeof(tmp_path)-1, mysql_real_data_home,
5011
 
             dir, NullS);
 
4816
             dir, NULL);
5012
4817
    dir=tmp_path;
5013
4818
  }
5014
4819
  return !fn_format(to, name, dir, extension,
5019
4824
static void fix_paths(void)
5020
4825
{
5021
4826
  char buff[FN_REFLEN],*pos;
5022
 
  convert_dirname(mysql_home,mysql_home,NullS);
 
4827
  convert_dirname(mysql_home,mysql_home,NULL);
5023
4828
  /* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
5024
4829
  my_realpath(mysql_home,mysql_home,MYF(0));
5025
4830
  /* Ensure that mysql_home ends in FN_LIBCHAR */
5029
4834
    pos[0]= FN_LIBCHAR;
5030
4835
    pos[1]= 0;
5031
4836
  }
5032
 
  convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
 
4837
  convert_dirname(mysql_real_data_home,mysql_real_data_home,NULL);
5033
4838
  (void) fn_format(buff, mysql_real_data_home, "", "",
5034
4839
                   (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
5035
4840
  (void) unpack_dirname(mysql_unpacked_real_data_home, buff);
5036
 
  convert_dirname(language,language,NullS);
 
4841
  convert_dirname(language,language,NULL);
5037
4842
  (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
5038
4843
  (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
5039
4844
  (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
5045
4850
  if (test_if_hard_path(sharedir))
5046
4851
    strmake(buff,sharedir,sizeof(buff)-1);              /* purecov: tested */
5047
4852
  else
5048
 
    strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS);
5049
 
  convert_dirname(buff,buff,NullS);
 
4853
    strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NULL);
 
4854
  convert_dirname(buff,buff,NULL);
5050
4855
  (void) my_load_path(language,language,buff);
5051
4856
 
5052
4857
  /* If --character-sets-dir isn't given, use shared library dir */
5053
4858
  if (charsets_dir != mysql_charsets_dir)
5054
4859
  {
5055
4860
    strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff,
5056
 
             CHARSET_DIR, NullS);
 
4861
             CHARSET_DIR, NULL);
5057
4862
  }
5058
4863
  (void) my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff);
5059
 
  convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS);
 
4864
  convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NULL);
5060
4865
  charsets_dir=mysql_charsets_dir;
5061
4866
 
5062
4867
  if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
5072
4877
   */
5073
4878
  if (opt_secure_file_priv)
5074
4879
  {
5075
 
    convert_dirname(buff, opt_secure_file_priv, NullS);
5076
 
    my_free(opt_secure_file_priv, MYF(0));
 
4880
    convert_dirname(buff, opt_secure_file_priv, NULL);
 
4881
    free(opt_secure_file_priv);
5077
4882
    opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
5078
4883
  }
5079
4884
}
5181
4986
    char buff[21], *end;
5182
4987
    end= int10_to_str((long) getpid(), buff, 10);
5183
4988
    *end++= '\n';
5184
 
    if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
 
4989
    if (!my_write(file, (unsigned char*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
5185
4990
    {
5186
4991
      (void) my_close(file, MYF(0));
5187
4992
      return;