~posulliv/drizzle/memcached_applier

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2008-08-03 22:27:54 UTC
  • mfrom: (236.1.66 codestyle)
  • Revision ID: brian@tangent.org-20080803222754-yhkw8plul06oqvhe
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <mysys/mysys_err.h>
26
26
#include <sys/poll.h>
27
27
#include <netinet/tcp.h>
 
28
#include <drizzled/drizzled_error_messages.h>
28
29
 
29
30
#include <storage/myisam/ha_myisam.h>
30
31
 
38
39
 
39
40
#include <mysys/thr_alarm.h>
40
41
#include <libdrizzle/errmsg.h>
 
42
#include <locale.h>
 
43
#include <libdrizzle/gettext.h>
41
44
 
42
45
#define mysqld_charset &my_charset_latin1
43
46
 
93
96
#endif
94
97
 
95
98
#define SIGNAL_FMT "signal %d"
96
 
  
 
99
 
97
100
 
98
101
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
99
102
#include <ieeefp.h>
210
213
const char *log_output_names[] = { "NONE", "FILE", NullS};
211
214
static const unsigned int log_output_names_len[]= { 4, 4, 0 };
212
215
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
213
 
                             log_output_names, 
 
216
                             log_output_names,
214
217
                             (unsigned int *) log_output_names_len};
215
218
 
216
219
/* static variables */
230
233
static char *character_set_filesystem_name;
231
234
static char *lc_time_names_name;
232
235
static char *my_bind_addr_str;
233
 
static char *default_collation_name; 
 
236
static char *default_collation_name;
234
237
static char *default_storage_engine_str;
235
238
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
236
239
static I_List<THD> thread_cache;
241
244
/* Global variables */
242
245
 
243
246
bool opt_bin_log;
244
 
bool opt_log; 
 
247
bool opt_log;
245
248
bool opt_slow_log;
246
249
ulong log_output_options;
247
250
bool opt_log_queries_not_using_indexes= false;
382
385
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
383
386
char server_version[SERVER_VERSION_LENGTH];
384
387
char *opt_mysql_tmpdir;
385
 
const char **errmesg;                   /**< Error messages */
386
388
const char *myisam_recover_options_str="OFF";
387
389
const char *myisam_stats_method_str="nulls_unequal";
388
390
 
556
558
  /* Abort listening to new connections */
557
559
  {
558
560
    int x;
559
 
    
 
561
 
560
562
    for (x= 0; x < pollfd_count; x++)
561
563
    {
562
564
      if (fds[x].fd != INVALID_SOCKET)
650
652
#ifdef HAVE_CLOSE_SERVER_SOCK
651
653
  {
652
654
    int x;
653
 
    
 
655
 
654
656
    for (x= 0; x < pollfd_count; x++)
655
657
    {
656
658
      if (fds[x].fd != INVALID_SOCKET)
718
720
    sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname);
719
721
  else
720
722
    sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
721
 
  
 
723
 
722
724
  close_connections();
723
725
  if (sig != MYSQL_KILL_SIGNAL &&
724
726
      sig != 0)
864
866
 
865
867
  (void) my_delete(pidfile_name,MYF(0));        // This may not always exist
866
868
 
867
 
  if (print_message && errmesg && server_start_time)
 
869
  if (print_message && server_start_time)
868
870
    sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname);
869
871
  thread_scheduler.end();
870
872
  finish_client_errs();
871
 
  my_free((uchar*) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
872
 
          MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
 
873
  /* Returns NULL on globerrs, we don't want to try to free that */
 
874
  //void *freeme=
 
875
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
 
876
  // TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
 
877
/*  if (freeme != NULL)
 
878
    my_free(freeme, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));  */
873
879
  /* Tell main we are ready */
874
880
  logger.cleanup_end();
875
881
  (void) pthread_mutex_lock(&LOCK_thread_count);
1434
1440
    fprintf(stderr,"\
1435
1441
Attempting backtrace. You can use the following information to find out\n\
1436
1442
where mysqld died. If you see no messages after this, something went\n\
1437
 
terribly wrong...\n");  
 
1443
terribly wrong...\n");
1438
1444
    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
1439
1445
                     my_thread_stack_size);
1440
1446
  }
1488
1494
You should either build a dynamically-linked binary, or force LinuxThreads\n\
1489
1495
to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
1490
1496
the documentation for your distribution on how to do that.\n");
1491
 
  
 
1497
 
1492
1498
  if (locked_in_memory)
1493
1499
  {
1494
1500
    fprintf(stderr, "\n\
1982
1988
  server_start_time= flush_status_time= my_time(0);
1983
1989
  rpl_filter= new Rpl_filter;
1984
1990
  binlog_filter= new Rpl_filter;
1985
 
  if (!rpl_filter || !binlog_filter) 
 
1991
  if (!rpl_filter || !binlog_filter)
1986
1992
  {
1987
1993
    sql_perror("Could not allocate replication and binlog filters");
1988
1994
    exit(1);
2159
2165
  global_system_variables.optimizer_use_mrr= 1;
2160
2166
  global_system_variables.optimizer_switch= 0;
2161
2167
 
2162
 
  if (!(character_set_filesystem= 
 
2168
  if (!(character_set_filesystem=
2163
2169
        get_charset_by_csname(character_set_filesystem_name,
2164
2170
                              MY_CS_PRIMARY, MYF(MY_WME))))
2165
2171
    return 1;
2172
2178
    return 1;
2173
2179
  }
2174
2180
  global_system_variables.lc_time_names= my_default_lc_time_names;
2175
 
  
 
2181
 
2176
2182
  sys_init_connect.value_length= 0;
2177
2183
  if ((sys_init_connect.value= opt_init_connect))
2178
2184
    sys_init_connect.value_length= strlen(opt_init_connect);
2329
2335
    if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
2330
2336
      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
2331
2337
    else
2332
 
    { 
 
2338
    {
2333
2339
      assert(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
2334
2340
    }
2335
2341
 
2431
2437
    }
2432
2438
  }
2433
2439
 
2434
 
  /* if the errmsg.sys is not loaded, terminate to maintain behaviour */
2435
 
  if (!errmesg[0][0])
2436
 
    unireg_abort(1);
2437
 
 
2438
2440
  /* We have to initialize the storage engines before CSV logging */
2439
2441
  if (ha_init())
2440
2442
  {
2454
2456
                       strlen(default_storage_engine_str) };
2455
2457
    plugin_ref plugin;
2456
2458
    handlerton *hton;
2457
 
    
 
2459
 
2458
2460
    if ((plugin= ha_resolve_by_name(0, &name)))
2459
 
      hton= plugin_data(plugin, handlerton*);
 
2461
    {
 
2462
      hton= plugin_data(plugin,handlerton *);
 
2463
    }
2460
2464
    else
2461
2465
    {
2462
2466
      sql_print_error("Unknown/unsupported table type: %s",
2473
2477
    else
2474
2478
    {
2475
2479
      /*
2476
 
        Need to unlock as global_system_variables.table_plugin 
 
2480
        Need to unlock as global_system_variables.table_plugin
2477
2481
        was acquired during plugin_init()
2478
2482
      */
2479
2483
      plugin_unlock(0, global_system_variables.table_plugin);
2539
2543
 
2540
2544
int main(int argc, char **argv)
2541
2545
{
 
2546
 
 
2547
#if defined(ENABLE_NLS)
 
2548
# if defined(HAVE_LOCALE_H)
 
2549
  setlocale(LC_ALL, "");
 
2550
# endif
 
2551
  bindtextdomain("drizzle", LOCALEDIR);
 
2552
  textdomain("drizzle");
 
2553
#endif
 
2554
 
2542
2555
  MY_INIT(argv[0]);             // init my_sys library & pthreads
2543
2556
  /* nothing should come before this line ^^^ */
2544
2557
 
2670
2683
  handle_connections_sockets();
2671
2684
 
2672
2685
  /* (void) pthread_attr_destroy(&connection_attrib); */
2673
 
  
 
2686
 
2674
2687
 
2675
2688
#ifdef EXTRA_DEBUG2
2676
2689
  sql_print_error("Before Lock_thread_count");
2796
2809
    }
2797
2810
    if (number_of == 0)
2798
2811
      continue;
2799
 
    
 
2812
 
2800
2813
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
2801
2814
    assert(number_of > 1); /* Not handling this at the moment */
2802
2815
#endif
2841
2854
      size_socket dummyLen;
2842
2855
      struct sockaddr_storage dummy;
2843
2856
      dummyLen = sizeof(dummy);
2844
 
      if (  getsockname(new_sock,(struct sockaddr *)&dummy, 
 
2857
      if (  getsockname(new_sock,(struct sockaddr *)&dummy,
2845
2858
                  (socklen_t *)&dummyLen) < 0  )
2846
2859
      {
2847
2860
        sql_perror("Error on new connection socket");
2891
2904
 
2892
2905
enum options_mysqld
2893
2906
{
2894
 
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW, 
2895
 
  OPT_SKIP_GRANT,              
 
2907
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW,
 
2908
  OPT_SKIP_GRANT,
2896
2909
  OPT_ENABLE_LOCK,             OPT_USE_LOCKING,
2897
2910
  OPT_SOCKET,                  OPT_UPDATE_LOG,
2898
 
  OPT_BIN_LOG,                 
 
2911
  OPT_BIN_LOG,
2899
2912
  OPT_BIN_LOG_INDEX,
2900
2913
  OPT_BIND_ADDRESS,            OPT_PID_FILE,
2901
2914
  OPT_SKIP_PRIOR,
2912
2925
  OPT_REPLICATE_IGNORE_DB,     OPT_LOG_SLAVE_UPDATES,
2913
2926
  OPT_BINLOG_DO_DB,            OPT_BINLOG_IGNORE_DB,
2914
2927
  OPT_BINLOG_FORMAT,
2915
 
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 
 
2928
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
2916
2929
  OPT_WANT_CORE,
2917
2930
  OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
2918
2931
  OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
2923
2936
  OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
2924
2937
  OPT_ABORT_SLAVE_EVENT_COUNT,
2925
2938
  OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
2926
 
  OPT_ENGINE_CONDITION_PUSHDOWN, 
 
2939
  OPT_ENGINE_CONDITION_PUSHDOWN,
2927
2940
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
2928
2941
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
2929
2942
  OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
3030
3043
 
3031
3044
struct my_option my_long_options[] =
3032
3045
{
3033
 
  {"help", '?', "Display this help and exit.", 
 
3046
  {"help", '?', "Display this help and exit.",
3034
3047
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
3035
3048
   0, 0},
3036
3049
  {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT,
3074
3087
   "The maximum size of a row-based binary log event in bytes. Rows will be "
3075
3088
   "grouped into events smaller than this size if possible. "
3076
3089
   "The value has to be a multiple of 256.",
3077
 
   (char**) &opt_binlog_rows_event_max_size, 
3078
 
   (char**) &opt_binlog_rows_event_max_size, 0, 
3079
 
   GET_ULONG, REQUIRED_ARG, 
3080
 
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
3081
 
   /* sub_size */     0, /* block_size */ 256, 
 
3090
   (char**) &opt_binlog_rows_event_max_size,
 
3091
   (char**) &opt_binlog_rows_event_max_size, 0,
 
3092
   GET_ULONG, REQUIRED_ARG,
 
3093
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX,
 
3094
   /* sub_size */     0, /* block_size */ 256,
3082
3095
   /* app_type */ 0
3083
3096
  },
3084
3097
  {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
3172
3185
   (char**) &opt_init_slave, (char**) &opt_init_slave, 0, GET_STR_ALLOC,
3173
3186
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3174
3187
  {"language", 'L',
3175
 
   "Client error messages in given language. May be given as a full path.",
 
3188
   "Client error messages in given language. May be given as a full path. (IGNORED)",
3176
3189
   (char**) &language_ptr, (char**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
3177
3190
   0, 0, 0, 0, 0, 0},
3178
3191
  {"lc-time-names", OPT_LC_TIME_NAMES,
3217
3230
   (char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
3218
3231
   OPT_ARG, 0, 0, 0, 0, 0, 0},
3219
3232
  {"log-long-format", '0',
3220
 
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 
 
3233
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.",
3221
3234
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
3222
3235
#ifdef WITH_CSV_STORAGE_ENGINE
3223
3236
  {"log-output", OPT_LOG_OUTPUT,
3439
3452
   0, 0, 0, 0, 0},
3440
3453
  {"timed_mutexes", OPT_TIMED_MUTEXES,
3441
3454
   "Specify whether to time mutexes (only InnoDB mutexes are currently supported)",
3442
 
   (char**) &timed_mutexes, (char**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 
 
3455
   (char**) &timed_mutexes, (char**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
3443
3456
    0, 0, 0, 0, 0},
3444
3457
  {"tmpdir", 't',
3445
3458
   "Path for temporary files. Several paths may be specified, separated by a "
3536
3549
   "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
3537
3550
   (char**) &dflt_key_cache_var.param_age_threshold,
3538
3551
   (char**) 0,
3539
 
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 
 
3552
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
3540
3553
   300, 100, ULONG_MAX, 0, 100, 0},
3541
3554
  {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
3542
3555
   "The default size of key cache blocks",
3688
3701
   (char**) &global_system_variables.net_write_timeout,
3689
3702
   (char**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
3690
3703
   REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
3691
 
  { "old", OPT_OLD_MODE, "Use compatible behavior.", 
 
3704
  { "old", OPT_OLD_MODE, "Use compatible behavior.",
3692
3705
    (char**) &global_system_variables.old_mode,
3693
 
    (char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 
 
3706
    (char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
3694
3707
    0, 0, 0, 0, 0, 0},
3695
3708
  {"open_files_limit", OPT_OPEN_FILES_LIMIT,
3696
3709
   "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
4176
4189
  binlog_cache_use=  binlog_cache_disk_use= 0;
4177
4190
  max_used_connections= slow_launch_threads = 0;
4178
4191
  mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4179
 
  errmesg= 0;
4180
4192
  opt_mysql_tmpdir= my_bind_addr_str= NullS;
4181
4193
  memset((uchar*) &mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4182
4194
  memset((char *) &global_status_var, 0, sizeof(global_status_var));
4476
4488
    break;
4477
4489
  case (int) OPT_BIND_ADDRESS:
4478
4490
    {
4479
 
      struct addrinfo *res_lst, hints;    
 
4491
      struct addrinfo *res_lst, hints;
4480
4492
 
4481
4493
      memset(&hints, 0, sizeof(struct addrinfo));
4482
4494
      hints.ai_socktype= SOCK_STREAM;
4483
4495
      hints.ai_protocol= IPPROTO_TCP;
4484
4496
 
4485
 
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0) 
 
4497
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
4486
4498
      {
4487
4499
        sql_print_error("Can't start server: cannot resolve hostname!");
4488
4500
        exit(1);
4844
4856
  ulong res;
4845
4857
 
4846
4858
  const char **ptr;
4847
 
  
 
4859
 
4848
4860
  if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
4849
4861
  {
4850
4862
    ptr= bit_lib->type_names;