~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Lee Bieber
  • Date: 2010-10-22 16:47:38 UTC
  • mfrom: (1841.1.7 drizzle_pbms)
  • Revision ID: kalebral@gmail.com-20101022164738-vv8w22b8towpb307
Merge Barry - fix bug 657830: PBMS build failure in GCC 4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 */
19
19
 
20
20
#include "config.h"
21
 
 
22
 
#include <drizzled/configmake.h>
23
 
#include <drizzled/atomics.h>
24
 
#include <drizzled/data_home.h>
 
21
#include "drizzled/configmake.h"
 
22
#include "drizzled/atomics.h"
 
23
#include "drizzled/data_home.h"
25
24
 
26
25
#include <netdb.h>
27
26
#include <sys/types.h>
32
31
#include <stdexcept>
33
32
 
34
33
#include <boost/program_options.hpp>
35
 
#include <drizzled/program_options/config_file.h>
 
34
#include "drizzled/program_options/config_file.h"
36
35
#include <boost/thread/recursive_mutex.hpp>
37
36
#include <boost/thread/mutex.hpp>
38
37
#include <boost/thread/shared_mutex.hpp>
39
38
#include <boost/thread/condition_variable.hpp>
40
39
#include <boost/filesystem.hpp>
41
 
#include <boost/detail/atomic_count.hpp>
42
40
 
43
 
#include <drizzled/cached_directory.h>
44
 
#include <drizzled/charset.h>
45
 
#include <drizzled/data_home.h>
46
 
#include <drizzled/debug.h>
47
 
#include <drizzled/definition/cache.h>
48
 
#include <drizzled/drizzled.h>
 
41
#include "drizzled/internal/my_sys.h"
 
42
#include "drizzled/internal/my_bit.h"
 
43
#include <drizzled/my_hash.h>
 
44
#include <drizzled/error.h>
49
45
#include <drizzled/errmsg_print.h>
50
 
#include <drizzled/error.h>
51
 
#include <drizzled/global_buffer.h>
52
 
#include <drizzled/internal/my_bit.h>
53
 
#include <drizzled/internal/my_sys.h>
 
46
#include <drizzled/tztime.h>
 
47
#include <drizzled/sql_base.h>
 
48
#include <drizzled/show.h>
 
49
#include <drizzled/sql_parse.h>
54
50
#include <drizzled/item/cmpfunc.h>
 
51
#include <drizzled/session.h>
55
52
#include <drizzled/item/create.h>
56
 
#include <drizzled/message/cache.h>
57
 
#include <drizzled/module/load_list.h>
58
 
#include <drizzled/module/registry.h>
59
 
#include <drizzled/my_hash.h>
60
 
#include <drizzled/plugin/client.h>
61
 
#include <drizzled/plugin/error_message.h>
62
 
#include <drizzled/plugin/event_observer.h>
63
 
#include <drizzled/plugin/listen.h>
64
 
#include <drizzled/plugin/monitored_in_transaction.h>
65
 
#include <drizzled/plugin/scheduler.h>
66
 
#include <drizzled/plugin/storage_engine.h>
67
 
#include <drizzled/plugin/xa_resource_manager.h>
68
 
#include <drizzled/probes.h>
69
 
#include <drizzled/replication_services.h> /* For ReplicationServices::evaluateRegisteredPlugins() */
70
 
#include <drizzled/session.h>
71
 
#include <drizzled/session/cache.h>
72
 
#include <drizzled/show.h>
73
 
#include <drizzled/sql_base.h>
74
 
#include <drizzled/sql_parse.h>
75
 
#include <drizzled/temporal_format.h> /* For init_temporal_formats() */
76
 
#include <drizzled/tztime.h>
77
53
#include <drizzled/unireg.h>
78
 
#include <plugin/myisam/myisam.h>
 
54
#include "drizzled/temporal_format.h" /* For init_temporal_formats() */
 
55
#include "drizzled/plugin/listen.h"
 
56
#include "drizzled/plugin/error_message.h"
 
57
#include "drizzled/plugin/client.h"
 
58
#include "drizzled/plugin/scheduler.h"
 
59
#include "drizzled/plugin/xa_resource_manager.h"
 
60
#include "drizzled/plugin/monitored_in_transaction.h"
 
61
#include "drizzled/replication_services.h" /* For ReplicationServices::evaluateRegisteredPlugins() */
 
62
#include "drizzled/probes.h"
 
63
#include "drizzled/session_list.h"
 
64
#include "drizzled/charset.h"
 
65
#include "plugin/myisam/myisam.h"
 
66
#include "drizzled/drizzled.h"
 
67
#include "drizzled/module/registry.h"
 
68
#include "drizzled/module/load_list.h"
79
69
 
80
 
#include "drizzled/visibility.h"
 
70
#include "drizzled/plugin/event_observer.h"
81
71
 
82
72
#include <google/protobuf/stubs/common.h>
83
73
 
84
 
#include <drizzled/refresh_version.h>
85
 
 
86
74
#if TIME_WITH_SYS_TIME
87
75
# include <sys/time.h>
88
76
# include <time.h>
158
146
namespace po=boost::program_options;
159
147
namespace dpo=drizzled::program_options;
160
148
 
161
 
bool opt_daemon= false;
162
149
 
163
150
namespace drizzled
164
151
{
165
152
 
 
153
#define mysqld_charset &my_charset_utf8_general_ci
166
154
inline void setup_fpu()
167
155
{
168
156
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
234
222
 
235
223
/* Global variables */
236
224
 
 
225
bool volatile ready_to_exit;
237
226
char *drizzled_user;
238
227
bool volatile select_thread_in_use;
239
228
bool volatile abort_loop;
240
 
DRIZZLED_API bool volatile shutdown_in_progress;
 
229
bool volatile shutdown_in_progress;
241
230
char *opt_scheduler_default;
242
231
const char *opt_scheduler= NULL;
243
232
 
244
 
DRIZZLED_API size_t my_thread_stack_size= 0;
 
233
size_t my_thread_stack_size= 0;
245
234
 
246
235
/*
247
236
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
252
241
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
253
242
 
254
243
uint32_t drizzled_bind_timeout;
 
244
std::bitset<12> test_flags;
255
245
uint32_t dropping_tables, ha_open_options;
256
246
uint32_t tc_heuristic_recover= 0;
257
247
uint64_t session_startup_options;
258
248
back_log_constraints back_log(50);
259
 
DRIZZLED_API uint32_t server_id;
 
249
uint32_t server_id;
260
250
uint64_t table_cache_size;
261
251
size_t table_def_size;
 
252
uint64_t max_connect_errors;
262
253
uint32_t global_thread_id= 1UL;
263
254
pid_t current_pid;
264
255
 
310
301
 
311
302
char system_time_zone[30];
312
303
char *default_tz_name;
313
 
DRIZZLED_API char glob_hostname[FN_REFLEN];
 
304
char glob_hostname[FN_REFLEN];
314
305
 
315
306
char *opt_tc_log_file;
316
307
const key_map key_map_empty(0);
325
316
const char *in_additional_cond= "<IN COND>";
326
317
const char *in_having_cond= "<IN HAVING>";
327
318
 
 
319
my_decimal decimal_zero;
328
320
/* classes for comparation parsing/processing */
329
321
 
330
322
FILE *stderror_file=0;
331
323
 
332
 
drizzle_system_variables global_system_variables;
333
 
drizzle_system_variables max_system_variables;
334
 
global_counters current_global_counters;
 
324
struct system_variables global_system_variables;
 
325
struct system_variables max_system_variables;
 
326
struct global_counters current_global_counters;
335
327
 
336
 
DRIZZLED_API const CHARSET_INFO *system_charset_info;
337
 
const CHARSET_INFO *files_charset_info;
 
328
const CHARSET_INFO *system_charset_info, *files_charset_info ;
338
329
const CHARSET_INFO *table_alias_charset;
339
330
const CHARSET_INFO *character_set_filesystem;
340
331
 
342
333
 
343
334
SHOW_COMP_OPTION have_symlink;
344
335
 
 
336
/* Thread specific variables */
 
337
 
 
338
boost::mutex LOCK_open;
 
339
boost::mutex LOCK_global_system_variables;
 
340
boost::mutex LOCK_thread_count;
 
341
 
345
342
boost::condition_variable_any COND_refresh;
346
343
boost::condition_variable COND_thread_count;
347
344
pthread_t signal_thread;
 
345
boost::condition_variable COND_server_end;
348
346
 
349
347
/* Static variables */
350
348
 
352
350
 
353
351
passwd *user_info;
354
352
 
355
 
boost::detail::atomic_count connection_count(0);
356
 
 
357
 
global_buffer_constraint<uint64_t> global_sort_buffer(0);
358
 
global_buffer_constraint<uint64_t> global_join_buffer(0);
359
 
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
360
 
global_buffer_constraint<uint64_t> global_read_buffer(0);
361
 
 
362
 
DRIZZLED_API size_t transaction_message_threshold;
 
353
atomic<uint32_t> connection_count;
 
354
 
 
355
/** 
 
356
  Refresh value. We use to test this to find out if a refresh even has happened recently.
 
357
*/
 
358
uint64_t refresh_version;  /* Increments on each reload */
363
359
 
364
360
/* Function declarations */
365
361
bool drizzle_rm_tmp_tables();
383
379
vector<string> defaults_file_list;
384
380
po::variables_map vm;
385
381
 
 
382
fs::path data_home(LOCALSTATEDIR);
 
383
fs::path full_data_home(LOCALSTATEDIR);
 
384
 
386
385
po::variables_map &getVariablesMap()
387
386
{
388
387
  return vm;
389
388
}
390
389
 
391
 
 
 
390
fs::path& getDataHome()
 
391
{
 
392
  return data_home;
 
393
}
 
394
 
 
395
fs::path& getDataHomeCatalog()
 
396
{
 
397
  static fs::path data_home_catalog(getDataHome());
 
398
  return data_home_catalog;
 
399
}
 
400
 
 
401
 
392
402
/****************************************************************************
393
403
** Code to end drizzled
394
404
****************************************************************************/
400
410
 
401
411
  /* kill connection thread */
402
412
  {
403
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
413
    boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
404
414
 
405
415
    while (select_thread_in_use)
406
416
    {
424
434
    statements and inform their clients that the server is about to die.
425
435
  */
426
436
 
 
437
  Session *tmp;
 
438
 
427
439
  {
428
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
429
 
    session::Cache::list list= session::Cache::singleton().getCache();
430
 
 
431
 
    for (session::Cache::list::iterator it= list.begin(); it != list.end(); ++it )
 
440
    boost::mutex::scoped_lock scoped(LOCK_thread_count);
 
441
    for( SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
432
442
    {
433
 
      Session::shared_ptr tmp(*it);
434
 
 
435
 
      tmp->setKilled(Session::KILL_CONNECTION);
436
 
      tmp->scheduler->killSession(tmp.get());
 
443
      tmp= *it;
 
444
      tmp->killed= Session::KILL_CONNECTION;
 
445
      tmp->scheduler->killSession(tmp);
437
446
      DRIZZLE_CONNECTION_DONE(tmp->thread_id);
438
 
 
439
447
      tmp->lockOnSys();
440
448
    }
441
449
  }
442
450
 
443
 
  if (session::Cache::singleton().count())
 
451
  if (connection_count)
444
452
    sleep(2);                                   // Give threads time to die
445
453
 
446
454
  /*
450
458
  */
451
459
  for (;;)
452
460
  {
453
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
454
 
    session::Cache::list list= session::Cache::singleton().getCache();
455
 
 
456
 
    if (list.empty())
 
461
    boost::mutex::scoped_lock scoped(LOCK_thread_count);
 
462
    if (getSessionList().empty())
457
463
    {
458
464
      break;
459
465
    }
 
466
    tmp= getSessionList().front();
460
467
    /* Close before unlock, avoiding crash. See LP bug#436685 */
461
 
    list.front()->getClient()->close();
 
468
    tmp->client->close();
462
469
  }
463
470
}
464
471
 
467
474
{
468
475
 
469
476
  if (exit_code)
470
 
  {
471
 
    errmsg_printf(error::ERROR, _("Aborting"));
472
 
  }
 
477
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
473
478
  else if (opt_help)
474
 
  {
475
479
    usage();
476
 
  }
477
 
 
478
480
  clean_up(!opt_help && (exit_code));
479
481
  internal::my_end();
480
482
  exit(exit_code);
501
503
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
502
504
 
503
505
  if (print_message && server_start_time)
504
 
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
505
 
 
506
 
  session::Cache::singleton().shutdownFirst();
 
506
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
507
  LOCK_thread_count.lock();
 
508
  ready_to_exit=1;
 
509
  /* do the broadcast inside the lock to ensure that my_end() is not called */
 
510
  COND_server_end.notify_all();
 
511
  LOCK_thread_count.unlock();
507
512
 
508
513
  /*
509
514
    The following lines may never be executed as the main thread may have
528
533
      tmp_user_info= getpwnam(user);
529
534
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
530
535
          global_system_variables.log_warnings)
531
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
536
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
532
537
                            "if running as root\n"));
533
538
    }
534
539
    return NULL;
535
540
  }
536
 
  if (not user)
 
541
  if (!user)
537
542
  {
538
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
539
 
                                    "the manual to find out how to run drizzled as root"));
 
543
      errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
544
                      "the manual to find out how to run drizzled as root!\n"));
540
545
    unireg_abort(1);
541
546
  }
542
 
 
543
 
  if (not strcmp(user, "root"))
 
547
  if (!strcmp(user,"root"))
544
548
    return NULL;                        // Avoid problem with dynamic libraries
545
549
 
546
550
  if (!(tmp_user_info= getpwnam(user)))
547
551
  {
548
552
    // Allow a numeric uid to be used
549
553
    const char *pos;
550
 
    for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
 
554
    for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
551
555
    if (*pos)                                   // Not numeric id
552
556
      goto err;
553
557
    if (!(tmp_user_info= getpwuid(atoi(user))))
556
560
  return tmp_user_info;
557
561
 
558
562
err:
559
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
563
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
560
564
                    "Please check that the user exists!\n"),user);
561
565
  unireg_abort(1);
562
566
 
563
567
#ifdef PR_SET_DUMPABLE
564
 
  if (getDebug().test(debug::CORE_ON_SIGNAL))
 
568
  if (test_flags.test(TEST_CORE_ON_SIGNAL))
565
569
  {
566
570
    /* inform kernel that process is dumpable */
567
571
    (void) prctl(PR_SET_DUMPABLE, 1);
581
585
  initgroups((char*) user, user_info_arg->pw_gid);
582
586
  if (setgid(user_info_arg->pw_gid) == -1)
583
587
  {
584
 
    sql_perror(_("Set process group ID failed"));
 
588
    sql_perror(N_("Set process group ID failed"));
585
589
    unireg_abort(1);
586
590
  }
587
591
  if (setuid(user_info_arg->pw_uid) == -1)
588
592
  {
589
 
    sql_perror(_("Set process user ID failed"));
 
593
    sql_perror(N_("Set process user ID failed"));
590
594
    unireg_abort(1);
591
595
  }
592
596
}
598
602
{
599
603
  if ((chroot(path) == -1) || !chdir("/"))
600
604
  {
601
 
    sql_perror(_("Process chroot failed"));
 
605
    sql_perror(N_("Process chroot failed"));
602
606
    unireg_abort(1);
603
607
  }
604
608
}
610
614
  SYNOPSIS
611
615
    Session::unlink()
612
616
    session              Thread handler
 
617
 
 
618
  NOTES
 
619
    LOCK_thread_count is locked and left locked
613
620
*/
614
621
 
615
 
void drizzled::Session::unlink(session_id_t &session_id)
616
 
{
617
 
  Session::shared_ptr session= session::Cache::singleton().find(session_id);
618
 
 
619
 
  if (session)
620
 
    unlink(session);
621
 
}
622
 
 
623
 
void drizzled::Session::unlink(Session::shared_ptr &session)
624
 
{
625
 
  --connection_count;
 
622
void Session::unlink(Session *session)
 
623
{
 
624
  connection_count.decrement();
626
625
 
627
626
  session->cleanup();
628
627
 
629
 
  boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
628
  boost::mutex::scoped_lock scoped(LOCK_thread_count);
 
629
  session->lockForDelete();
630
630
 
 
631
  getSessionList().erase(remove(getSessionList().begin(),
 
632
                         getSessionList().end(),
 
633
                         session));
631
634
  if (unlikely(plugin::EventObserver::disconnectSession(*session)))
632
635
  {
633
636
    // We should do something about an error...
634
637
  }
635
 
  session::Cache::singleton().erase(session);
 
638
 
 
639
  delete session;
636
640
}
637
641
 
638
642
 
718
722
  global_system_variables.auto_increment_increment= 1;
719
723
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
720
724
  {
721
 
    cout << _("Error: Invalid Value for auto_increment_increment");
 
725
    cout << N_("Error: Invalid Value for auto_increment_increment");
722
726
    exit(-1);
723
727
  }
724
728
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
729
733
  global_system_variables.auto_increment_offset= 1;
730
734
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
731
735
  {
732
 
    cout << _("Error: Invalid Value for auto_increment_offset");
 
736
    cout << N_("Error: Invalid Value for auto_increment_offset");
733
737
    exit(-1);
734
738
  }
735
739
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
740
744
  global_system_variables.completion_type= 0;
741
745
  if (in_completion_type > 2)
742
746
  {
743
 
    cout << _("Error: Invalid Value for completion_type");
 
747
    cout << N_("Error: Invalid Value for completion_type");
744
748
    exit(-1);
745
749
  }
746
750
  global_system_variables.completion_type= in_completion_type;
752
756
  global_system_variables.div_precincrement= 4;
753
757
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
754
758
  {
755
 
    cout << _("Error: Invalid Value for div-precision-increment");
 
759
    cout << N_("Error: Invalid Value for div-precision-increment");
756
760
    exit(-1);
757
761
  }
758
762
  global_system_variables.div_precincrement= in_div_precincrement;
763
767
  global_system_variables.group_concat_max_len= 1024;
764
768
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
765
769
  {
766
 
    cout << _("Error: Invalid Value for group_concat_max_len");
 
770
    cout << N_("Error: Invalid Value for group_concat_max_len");
767
771
    exit(-1);
768
772
  }
769
773
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
774
778
  global_system_variables.join_buff_size= (128*1024L);
775
779
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
776
780
  {
777
 
    cout << _("Error: Invalid Value for join_buffer_size");
 
781
    cout << N_("Error: Invalid Value for join_buffer_size");
778
782
    exit(-1);
779
783
  }
780
784
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
783
787
 
784
788
static void check_limits_map(uint32_t in_max_allowed_packet)
785
789
{
786
 
  global_system_variables.max_allowed_packet= (64*1024*1024L);
 
790
  global_system_variables.max_allowed_packet= (1024*1024L);
787
791
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
788
792
  {
789
 
    cout << _("Error: Invalid Value for max_allowed_packet");
 
793
    cout << N_("Error: Invalid Value for max_allowed_packet");
790
794
    exit(-1);
791
795
  }
792
796
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
793
797
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
794
798
}
795
799
 
 
800
static void check_limits_mce(uint64_t in_max_connect_errors)
 
801
{
 
802
  max_connect_errors= MAX_CONNECT_ERRORS;
 
803
  if (in_max_connect_errors < 1 || in_max_connect_errors > ULONG_MAX)
 
804
  {
 
805
    cout << N_("Error: Invalid Value for max_connect_errors");
 
806
    exit(-1);
 
807
  }
 
808
  max_connect_errors= in_max_connect_errors;
 
809
}
 
810
 
796
811
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
797
812
{
798
813
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
799
814
  if (in_max_error_count > 65535)
800
815
  {
801
 
    cout << _("Error: Invalid Value for max_error_count");
 
816
    cout << N_("Error: Invalid Value for max_error_count");
802
817
    exit(-1);
803
818
  }
804
819
  global_system_variables.max_error_count= in_max_error_count;
809
824
  global_system_variables.max_heap_table_size= (16*1024*1024L);
810
825
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
811
826
  {
812
 
    cout << _("Error: Invalid Value for max_heap_table_size");
 
827
    cout << N_("Error: Invalid Value for max_heap_table_size");
813
828
    exit(-1);
814
829
  }
815
830
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
821
836
  global_system_variables.min_examined_row_limit= 0;
822
837
  if (in_min_examined_row_limit > ULONG_MAX)
823
838
  {
824
 
    cout << _("Error: Invalid Value for min_examined_row_limit");
 
839
    cout << N_("Error: Invalid Value for min_examined_row_limit");
825
840
    exit(-1);
826
841
  }
827
842
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
832
847
  global_system_variables.max_join_size= INT32_MAX;
833
848
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
834
849
  {
835
 
    cout << _("Error: Invalid Value for max_join_size");
 
850
    cout << N_("Error: Invalid Value for max_join_size");
836
851
    exit(-1);
837
852
  }
838
853
  global_system_variables.max_join_size= in_max_join_size;
843
858
  global_system_variables.max_length_for_sort_data= 1024;
844
859
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
845
860
  {
846
 
    cout << _("Error: Invalid Value for max_length_for_sort_data");
 
861
    cout << N_("Error: Invalid Value for max_length_for_sort_data");
847
862
    exit(-1);
848
863
  }
849
864
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
854
869
  global_system_variables.max_seeks_for_key= ULONG_MAX;
855
870
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
856
871
  {
857
 
    cout << _("Error: Invalid Value for max_seeks_for_key");
 
872
    cout << N_("Error: Invalid Value for max_seeks_for_key");
858
873
    exit(-1);
859
874
  }
860
875
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
865
880
  global_system_variables.max_sort_length= 1024;
866
881
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
867
882
  {
868
 
    cout << _("Error: Invalid Value for max_sort_length");
 
883
    cout << N_("Error: Invalid Value for max_sort_length");
869
884
    exit(-1);
870
885
  }
871
886
  global_system_variables.max_sort_length= in_max_sort_length;
876
891
  global_system_variables.optimizer_search_depth= 0;
877
892
  if (in_optimizer_search_depth > MAX_TABLES + 2)
878
893
  {
879
 
    cout << _("Error: Invalid Value for optimizer_search_depth");
 
894
    cout << N_("Error: Invalid Value for optimizer_search_depth");
880
895
    exit(-1);
881
896
  }
882
897
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
887
902
  global_system_variables.preload_buff_size= (32*1024L);
888
903
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
889
904
  {
890
 
    cout << _("Error: Invalid Value for preload_buff_size");
 
905
    cout << N_("Error: Invalid Value for preload_buff_size");
891
906
    exit(-1);
892
907
  }
893
908
  global_system_variables.preload_buff_size= in_preload_buff_size;
898
913
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
899
914
  if (in_query_alloc_block_size < 1024)
900
915
  {
901
 
    cout << _("Error: Invalid Value for query_alloc_block_size");
 
916
    cout << N_("Error: Invalid Value for query_alloc_block_size");
902
917
    exit(-1);
903
918
  }
904
919
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
910
925
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
911
926
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
912
927
  {
913
 
    cout << _("Error: Invalid Value for query_prealloc_size");
 
928
    cout << N_("Error: Invalid Value for query_prealloc_size");
914
929
    exit(-1);
915
930
  }
916
931
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
922
937
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
923
938
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
924
939
  {
925
 
    cout << _("Error: Invalid Value for range_alloc_block_size");
 
940
    cout << N_("Error: Invalid Value for range_alloc_block_size");
926
941
    exit(-1);
927
942
  }
928
943
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
934
949
  global_system_variables.read_buff_size= (128*1024L);
935
950
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
936
951
  {
937
 
    cout << _("Error: Invalid Value for read_buff_size");
 
952
    cout << N_("Error: Invalid Value for read_buff_size");
938
953
    exit(-1);
939
954
  }
940
955
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
946
961
  global_system_variables.read_rnd_buff_size= (256*1024L);
947
962
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
948
963
  {
949
 
    cout << _("Error: Invalid Value for read_rnd_buff_size");
 
964
    cout << N_("Error: Invalid Value for read_rnd_buff_size");
950
965
    exit(-1);
951
966
  }
952
967
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
957
972
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
958
973
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
959
974
  {
960
 
    cout << _("Error: Invalid Value for sort_buff_size");
 
975
    cout << N_("Error: Invalid Value for sort_buff_size");
961
976
    exit(-1);
962
977
  }
963
978
  global_system_variables.sortbuff_size= in_sortbuff_size;
968
983
  table_def_size= 128;
969
984
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
970
985
  {
971
 
    cout << _("Error: Invalid Value for table_def_size");
 
986
    cout << N_("Error: Invalid Value for table_def_size");
972
987
    exit(-1);
973
988
  }
974
989
  table_def_size= in_table_def_size;
979
994
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
980
995
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
981
996
  {
982
 
    cout << _("Error: Invalid Value for table_cache_size");
 
997
    cout << N_("Error: Invalid Value for table_cache_size");
983
998
    exit(-1);
984
999
  }
985
1000
  table_cache_size= in_table_cache_size;
990
1005
  table_lock_wait_timeout= 50;
991
1006
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
992
1007
  {
993
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1008
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
994
1009
    exit(-1);
995
1010
  }
996
1011
  table_lock_wait_timeout= in_table_lock_wait_timeout;
1006
1021
  global_system_variables.tmp_table_size= 16*1024*1024L;
1007
1022
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1008
1023
  {
1009
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1024
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
1010
1025
    exit(-1);
1011
1026
  }
1012
1027
  global_system_variables.tmp_table_size= in_tmp_table_size;
1014
1029
 
1015
1030
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1016
1031
{
1017
 
  transaction_message_threshold= 1024*1024;
 
1032
  global_system_variables.transaction_message_threshold= 1024*1024;
1018
1033
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1019
1034
  {
1020
 
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
 
1035
    cout << N_("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1021
1036
    exit(-1);
1022
1037
  }
1023
 
  transaction_message_threshold= in_transaction_message_threshold;
 
1038
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
 
1039
}
 
1040
 
 
1041
static pair<string, string> parse_size_suffixes(string s)
 
1042
{
 
1043
  size_t equal_pos= s.find("=");
 
1044
  if (equal_pos != string::npos)
 
1045
  {
 
1046
    string arg_key(s.substr(0, equal_pos));
 
1047
    string arg_val(s.substr(equal_pos+1));
 
1048
 
 
1049
    try
 
1050
    {
 
1051
      size_t size_suffix_pos= arg_val.find_last_of("kmgKMG");
 
1052
      if (size_suffix_pos == arg_val.size()-1)
 
1053
      {
 
1054
        char suffix= arg_val[size_suffix_pos];
 
1055
        string size_val(arg_val.substr(0, size_suffix_pos));
 
1056
 
 
1057
        uint64_t base_size= boost::lexical_cast<uint64_t>(size_val);
 
1058
        uint64_t new_size= 0;
 
1059
 
 
1060
        switch (suffix)
 
1061
        {
 
1062
        case 'K':
 
1063
        case 'k':
 
1064
          new_size= base_size * 1024;
 
1065
          break;
 
1066
        case 'M':
 
1067
        case 'm':
 
1068
          new_size= base_size * 1024 * 1024;
 
1069
          break;
 
1070
        case 'G':
 
1071
        case 'g':
 
1072
          new_size= base_size * 1024 * 1024 * 1024;
 
1073
          break;
 
1074
        }
 
1075
        return make_pair(arg_key,
 
1076
                         boost::lexical_cast<string>(new_size));
 
1077
      }
 
1078
    }
 
1079
    catch (...)
 
1080
    {
 
1081
      /* Screw it, let the normal parser take over */
 
1082
    }
 
1083
  }
 
1084
 
 
1085
  return make_pair(string(""), string(""));
 
1086
}
 
1087
 
 
1088
static pair<string, string> parse_size_arg(string s)
 
1089
{
 
1090
  if (s.find("--") == 0)
 
1091
  {
 
1092
    return parse_size_suffixes(s.substr(2));
 
1093
  }
 
1094
  return make_pair(string(""), string(""));
1024
1095
}
1025
1096
 
1026
1097
static void process_defaults_files()
1029
1100
       iter != defaults_file_list.end();
1030
1101
       ++iter)
1031
1102
  {
1032
 
    fs::path file_location= *iter;
 
1103
    fs::path file_location(system_config_dir);
 
1104
    if ((*iter)[0] != '/')
 
1105
    {
 
1106
      /* Relative path - add config dir */
 
1107
      file_location /= *iter;
 
1108
    }
 
1109
    else
 
1110
    {
 
1111
      file_location= *iter;
 
1112
    }
1033
1113
 
1034
1114
    ifstream input_defaults_file(file_location.file_string().c_str());
1035
1115
    
1069
1149
       it != in_options.end();
1070
1150
       ++it)
1071
1151
  {
1072
 
    fs::path p(*it);
1073
 
    if (fs::is_regular_file(p))
1074
 
      defaults_file_list.push_back(*it);
1075
 
    else
1076
 
    {
1077
 
      errmsg_printf(error::ERROR,
1078
 
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1079
 
      unireg_abort(1);
1080
 
    }
1081
 
 
 
1152
    defaults_file_list.push_back(*it);
1082
1153
  }
1083
1154
}
1084
1155
 
1085
 
int init_basic_variables(int argc, char **argv)
 
1156
int init_common_variables(int argc, char **argv, module::Registry &plugins)
1086
1157
{
1087
1158
  time_t curr_time;
1088
1159
  umask(((~internal::my_umask) & 0666));
1089
 
  decimal_zero.set_zero(); // set decimal_zero constant;
 
1160
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1090
1161
  tzset();                      // Set tzname
1091
1162
 
1092
1163
  curr_time= time(NULL);
1117
1188
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1118
1189
  {
1119
1190
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1120
 
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
 
1191
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1121
1192
                  glob_hostname);
1122
1193
    pid_file= "drizzle";
1123
1194
  }
1128
1199
  pid_file.replace_extension(".pid");
1129
1200
 
1130
1201
  system_config_dir /= "drizzle";
 
1202
  std::string system_config_file_drizzle("drizzled.cnf");
1131
1203
 
1132
1204
  config_options.add_options()
1133
1205
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1134
 
  _("Display this help and exit."))
1135
 
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1136
 
  _("Run as a daemon."))
 
1206
  N_("Display this help and exit."))
1137
1207
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1138
 
  _("Configuration file defaults are not used if no-defaults is set"))
 
1208
  N_("Configuration file defaults are not used if no-defaults is set"))
1139
1209
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1140
 
  _("Configuration file to use"))
 
1210
   N_("Configuration file to use"))
1141
1211
  ("config-dir", po::value<fs::path>(&system_config_dir),
1142
 
  _("Base location for config files"))
 
1212
   N_("Base location for config files"))
1143
1213
  ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
1144
 
  _("Directory for plugins."))
 
1214
  N_("Directory for plugins."))
1145
1215
  ;
1146
1216
 
1147
1217
  plugin_load_options.add_options()
1148
1218
  ("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1149
 
  _("Optional comma separated list of plugins to load at startup in addition "
 
1219
  N_("Optional comma separated list of plugins to load at startup in addition "
1150
1220
     "to the default list of plugins. "
1151
1221
     "[for example: --plugin_add=crc32,logger_gearman]"))    
1152
1222
  ("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1153
 
  _("Optional comma separated list of plugins to not load at startup. Effectively "
 
1223
  N_("Optional comma separated list of plugins to not load at startup. Effectively "
1154
1224
     "removes a plugin from the list of plugins to be loaded. "
1155
1225
     "[for example: --plugin_remove=crc32,logger_gearman]"))
1156
1226
  ("plugin-load", po::value<string>()->notifier(&notify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1157
 
  _("Optional comma separated list of plugins to load at starup instead of "
 
1227
  N_("Optional comma separated list of plugins to load at starup instead of "
1158
1228
     "the default plugin load list. "
1159
1229
     "[for example: --plugin_load=crc32,logger_gearman]"))
1160
1230
  ;
1161
1231
 
1162
1232
  long_options.add_options()
1163
1233
  ("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1164
 
  _("Auto-increment columns are incremented by this"))
 
1234
  N_("Auto-increment columns are incremented by this"))
1165
1235
  ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1166
 
  _("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
 
1236
  N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1167
1237
  ("basedir,b", po::value<fs::path>(&basedir),
1168
 
  _("Path to installation directory. All paths are usually resolved "
 
1238
  N_("Path to installation directory. All paths are usually resolved "
1169
1239
     "relative to this."))
1170
1240
  ("chroot,r", po::value<string>(),
1171
 
  _("Chroot drizzled daemon during startup."))
 
1241
  N_("Chroot drizzled daemon during startup."))
1172
1242
  ("collation-server", po::value<string>(),
1173
 
  _("Set the default collation."))      
 
1243
  N_("Set the default collation."))      
1174
1244
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1175
 
  _("Default completion type."))
1176
 
  ("core-file",  _("Write core on errors."))
1177
 
  ("datadir", po::value<fs::path>(&getDataHome()),
1178
 
  _("Path to the database root."))
 
1245
  N_("Default completion type."))
 
1246
  ("core-file",  N_("Write core on errors."))
 
1247
  ("datadir", po::value<fs::path>(&data_home),
 
1248
  N_("Path to the database root."))
1179
1249
  ("default-storage-engine", po::value<string>(),
1180
 
  _("Set the default storage engine for tables."))
 
1250
  N_("Set the default storage engine for tables."))
1181
1251
  ("default-time-zone", po::value<string>(),
1182
 
  _("Set the default time zone."))
 
1252
  N_("Set the default time zone."))
1183
1253
  ("exit-info,T", po::value<long>(),
1184
 
  _("Used for debugging;  Use at your own risk!"))
 
1254
  N_("Used for debugging;  Use at your own risk!"))
1185
1255
  ("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1186
 
  _("Set up signals usable for debugging"))
 
1256
  N_("Set up signals usable for debugging"))
1187
1257
  ("lc-time-name", po::value<string>(),
1188
 
  _("Set the language used for the month names and the days of the week."))
 
1258
  N_("Set the language used for the month names and the days of the week."))
1189
1259
  ("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
1190
 
  _("Log some not critical warnings to the log file."))  
 
1260
  N_("Log some not critical warnings to the log file."))  
1191
1261
  ("pid-file", po::value<fs::path>(&pid_file),
1192
 
  _("Pid file used by drizzled."))
 
1262
  N_("Pid file used by drizzled."))
1193
1263
  ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1194
 
  _("Maximum time in seconds to wait for the port to become free. "))
1195
 
  ("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1196
 
  _("Include the SQL query in replicated protobuf messages."))
 
1264
  N_("Maximum time in seconds to wait for the port to become free. "))
1197
1265
  ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1198
 
  _("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
 
1266
  N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1199
1267
     "within specified directory"))
1200
1268
  ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1201
 
  _("Uniquely identifies the server instance in the community of "
 
1269
  N_("Uniquely identifies the server instance in the community of "
1202
1270
     "replication partners."))
1203
1271
  ("skip-stack-trace",  
1204
 
  _("Don't print a stack trace on failure."))
 
1272
  N_("Don't print a stack trace on failure."))
1205
1273
  ("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1206
 
  _("Enable symbolic link support."))
 
1274
  N_("Enable symbolic link support."))
1207
1275
  ("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1208
 
  _("Specify whether to time mutexes (only InnoDB mutexes are currently "
 
1276
  N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1209
1277
     "supported)")) 
1210
1278
  ("tmpdir,t", po::value<string>(),
1211
 
  _("Path for temporary files."))
 
1279
  N_("Path for temporary files."))
1212
1280
  ("transaction-isolation", po::value<string>(),
1213
 
  _("Default transaction isolation level."))
1214
 
  ("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1215
 
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
 
1281
  N_("Default transaction isolation level."))
 
1282
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
 
1283
  N_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1216
1284
  ("user,u", po::value<string>(),
1217
 
  _("Run drizzled daemon as user."))  
 
1285
  N_("Run drizzled daemon as user."))  
1218
1286
  ("version,V", 
1219
 
  _("Output version information and exit."))
 
1287
  N_("Output version information and exit."))
1220
1288
  ("back-log", po::value<back_log_constraints>(&back_log),
1221
 
  _("The number of outstanding connection requests Drizzle can have. This "
 
1289
  N_("The number of outstanding connection requests Drizzle can have. This "
1222
1290
     "comes into play when the main Drizzle thread gets very many connection "
1223
1291
     "requests in a very short time."))
1224
1292
  ("bulk-insert-buffer-size", 
1225
1293
  po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1226
 
  _("Size of tree cache used in bulk insert optimization. Note that this is "
 
1294
  N_("Size of tree cache used in bulk insert optimization. Note that this is "
1227
1295
     "a limit per thread!"))
1228
1296
  ("div-precision-increment",  po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1229
 
  _("Precision of the result of '/' operator will be increased on that "
 
1297
  N_("Precision of the result of '/' operator will be increased on that "
1230
1298
     "value."))
1231
1299
  ("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1232
 
  _("The maximum length of the result of function  group_concat."))
 
1300
  N_("The maximum length of the result of function  group_concat."))
1233
1301
  ("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1234
 
  _("The size of the buffer that is used for full joins."))
1235
 
  ("join-heap-threshold",
1236
 
  po::value<uint64_t>()->default_value(0),
1237
 
  _("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1238
 
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1239
 
  _("Max packetlength to send/receive from to server."))
 
1302
  N_("The size of the buffer that is used for full joins."))
 
1303
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(1024*1024L)->notifier(&check_limits_map),
 
1304
  N_("Max packetlength to send/receive from to server."))
 
1305
  ("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
 
1306
  N_("If there is more than this number of interrupted connections from a "
 
1307
     "host this host will be blocked from further connections."))
1240
1308
  ("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1241
 
  _("Max number of errors/warnings to store for a statement."))
 
1309
  N_("Max number of errors/warnings to store for a statement."))
1242
1310
  ("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1243
 
  _("Don't allow creation of heap tables bigger than this."))
 
1311
  N_("Don't allow creation of heap tables bigger than this."))
1244
1312
  ("max-join-size", po::value<drizzled::ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1245
 
  _("Joins that are probably going to read more than max_join_size records "
 
1313
  N_("Joins that are probably going to read more than max_join_size records "
1246
1314
     "return an error."))
1247
1315
  ("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1248
 
  _("Max number of bytes in sorted records."))
 
1316
  N_("Max number of bytes in sorted records."))
1249
1317
  ("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1250
 
  _("Limit assumed max number of seeks when looking up rows based on a key"))
 
1318
  N_("Limit assumed max number of seeks when looking up rows based on a key"))
1251
1319
  ("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),  
1252
 
  _("The number of bytes to use when sorting BLOB or TEXT values "
 
1320
  N_("The number of bytes to use when sorting BLOB or TEXT values "
1253
1321
     "(only the first max_sort_length bytes of each value are used; the "
1254
1322
     "rest are ignored)."))
1255
1323
  ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1256
 
  _("After this many write locks, allow some read locks to run in between."))
 
1324
  N_("After this many write locks, allow some read locks to run in between."))
1257
1325
  ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1258
 
  _("Don't log queries which examine less than min_examined_row_limit "
 
1326
  N_("Don't log queries which examine less than min_examined_row_limit "
1259
1327
     "rows to file."))
1260
1328
  ("disable-optimizer-prune",
1261
 
  _("Do not apply any heuristic(s) during query optimization to prune, "
 
1329
  N_("Do not apply any heuristic(s) during query optimization to prune, "
1262
1330
     "thus perform an exhaustive search from the optimizer search space."))
1263
1331
  ("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1264
 
  _("Maximum depth of search performed by the query optimizer. Values "
 
1332
  N_("Maximum depth of search performed by the query optimizer. Values "
1265
1333
     "larger than the number of relations in a query result in better query "
1266
1334
     "plans, but take longer to compile a query. Smaller values than the "
1267
1335
     "number of tables in a relation result in faster optimization, but may "
1270
1338
     "optimizer will switch to the original find_best (used for "
1271
1339
     "testing/comparison)."))
1272
1340
  ("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1273
 
  _("The size of the buffer that is allocated when preloading indexes"))
 
1341
  N_("The size of the buffer that is allocated when preloading indexes"))
1274
1342
  ("query-alloc-block-size", 
1275
1343
  po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1276
 
  _("Allocation block size for query parsing and execution"))
 
1344
  N_("Allocation block size for query parsing and execution"))
1277
1345
  ("query-prealloc-size",
1278
1346
  po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1279
 
  _("Persistent buffer for query parsing and execution"))
 
1347
  N_("Persistent buffer for query parsing and execution"))
1280
1348
  ("range-alloc-block-size",
1281
1349
  po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1282
 
  _("Allocation block size for storing ranges during optimization"))
 
1350
  N_("Allocation block size for storing ranges during optimization"))
1283
1351
  ("read-buffer-size",
1284
1352
  po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1285
 
  _("Each thread that does a sequential scan allocates a buffer of this "
 
1353
  N_("Each thread that does a sequential scan allocates a buffer of this "
1286
1354
      "size for each table it scans. If you do many sequential scans, you may "
1287
1355
      "want to increase this value."))
1288
 
  ("read-buffer-threshold",
1289
 
  po::value<uint64_t>()->default_value(0),
1290
 
  _("A global cap on the size of read-buffer-size (0 means unlimited)"))
1291
1356
  ("read-rnd-buffer-size",
1292
1357
  po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1293
 
  _("When reading rows in sorted order after a sort, the rows are read "
 
1358
  N_("When reading rows in sorted order after a sort, the rows are read "
1294
1359
     "through this buffer to avoid a disk seeks. If not set, then it's set "
1295
1360
     "to the value of record_buffer."))
1296
 
  ("read-rnd-threshold",
1297
 
  po::value<uint64_t>()->default_value(0),
1298
 
  _("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1299
1361
  ("scheduler", po::value<string>(),
1300
 
  _("Select scheduler to be used (by default multi-thread)."))
 
1362
  N_("Select scheduler to be used (by default multi-thread)."))
1301
1363
  ("sort-buffer-size",
1302
1364
  po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1303
 
  _("Each thread that needs to do a sort allocates a buffer of this size."))
1304
 
  ("sort-heap-threshold",
1305
 
  po::value<uint64_t>()->default_value(0),
1306
 
  _("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
 
1365
  N_("Each thread that needs to do a sort allocates a buffer of this size."))
1307
1366
  ("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1308
 
  _("The number of cached table definitions."))
 
1367
  N_("The number of cached table definitions."))
1309
1368
  ("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1310
 
  _("The number of cached open tables."))
 
1369
  N_("The number of cached open tables."))
1311
1370
  ("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1312
 
  _("Timeout in seconds to wait for a table level lock before returning an "
 
1371
  N_("Timeout in seconds to wait for a table level lock before returning an "
1313
1372
     "error. Used only if the connection has active cursors."))
1314
1373
  ("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1315
 
  _("The stack size for each thread."))
 
1374
  N_("The stack size for each thread."))
1316
1375
  ("tmp-table-size", 
1317
1376
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1318
 
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
 
1377
  N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1319
1378
     " automatically convert it to an on-disk MyISAM table."))
1320
1379
  ;
1321
1380
 
1336
1395
  {
1337
1396
    po::store(parsed, vm);
1338
1397
  }
1339
 
  catch (std::exception&)
 
1398
  catch (...)
1340
1399
  {
1341
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
 
1400
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1342
1401
    unireg_abort(1);
1343
1402
  }
1344
1403
 
1345
1404
  if (not vm["no-defaults"].as<bool>())
1346
1405
  {
1347
 
    fs::path system_config_file_drizzle(system_config_dir);
1348
 
    system_config_file_drizzle /= "drizzled.cnf";
1349
1406
    defaults_file_list.insert(defaults_file_list.begin(),
1350
 
                              system_config_file_drizzle.file_string());
1351
 
 
1352
 
    fs::path config_conf_d_location(system_config_dir);
1353
 
    config_conf_d_location /= "conf.d";
1354
 
 
1355
 
 
1356
 
    CachedDirectory config_conf_d(config_conf_d_location.file_string());
1357
 
    if (not config_conf_d.fail())
 
1407
                              system_config_file_drizzle);
 
1408
  }
 
1409
 
 
1410
  fs::path config_conf_d_location(system_config_dir);
 
1411
  config_conf_d_location /= "conf.d";
 
1412
 
 
1413
  CachedDirectory config_conf_d(config_conf_d_location.file_string());
 
1414
  if (not config_conf_d.fail())
 
1415
  {
 
1416
 
 
1417
    for (CachedDirectory::Entries::const_iterator iter= config_conf_d.getEntries().begin();
 
1418
         iter != config_conf_d.getEntries().end();
 
1419
         ++iter)
1358
1420
    {
1359
 
 
1360
 
      for (CachedDirectory::Entries::const_iterator iter= config_conf_d.getEntries().begin();
1361
 
           iter != config_conf_d.getEntries().end();
1362
 
           ++iter)
 
1421
      string file_entry((*iter)->filename);
 
1422
          
 
1423
      if (not file_entry.empty()
 
1424
          && file_entry != "."
 
1425
          && file_entry != "..")
1363
1426
      {
1364
 
        string file_entry((*iter)->filename);
1365
 
 
1366
 
        if (not file_entry.empty()
1367
 
            && file_entry != "."
1368
 
            && file_entry != "..")
1369
 
        {
1370
 
          fs::path the_entry(config_conf_d_location);
1371
 
          the_entry /= file_entry;
1372
 
          defaults_file_list.push_back(the_entry.file_string());
1373
 
        }
 
1427
        fs::path the_entry(config_conf_d_location);
 
1428
        the_entry /= file_entry;
 
1429
        defaults_file_list.push_back(the_entry.file_string());
1374
1430
      }
1375
1431
    }
1376
1432
  }
1377
1433
 
 
1434
  process_defaults_files();
1378
1435
  /* TODO: here is where we should add a process_env_vars */
1379
1436
 
1380
1437
  /* We need a notify here so that plugin_init will work properly */
1384
1441
  }
1385
1442
  catch (po::validation_error &err)
1386
1443
  {
1387
 
    errmsg_printf(error::ERROR,  
1388
 
                  _("%s: %s.\n"
1389
 
                    "Use --help to get a list of available options\n"),
1390
 
                  internal::my_progname, err.what());
1391
 
    unireg_abort(1);
1392
 
  }
1393
 
 
1394
 
  process_defaults_files();
1395
 
 
1396
 
  /* Process with notify a second time because a config file may contain
1397
 
     plugin loader options */
1398
 
 
1399
 
  try
1400
 
  {
1401
 
    po::notify(vm);
1402
 
  }
1403
 
  catch (po::validation_error &err)
1404
 
  {
1405
 
    errmsg_printf(error::ERROR,
1406
 
                  _("%s: %s.\n"
1407
 
                    "Use --help to get a list of available options\n"),
1408
 
                  internal::my_progname, err.what());
1409
 
    unireg_abort(1);
1410
 
  }
1411
 
 
1412
 
  return 0;
1413
 
}
1414
 
 
1415
 
int init_remaining_variables(module::Registry &plugins)
1416
 
{
1417
 
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1418
 
 
1419
 
  current_pid= getpid();                /* Save for later ref */
1420
 
 
 
1444
    errmsg_printf(ERRMSG_LVL_ERROR,  
 
1445
                  _("%s: %s.\n"
 
1446
                    "Use --help to get a list of available options\n"),
 
1447
                  internal::my_progname, err.what());
 
1448
    unireg_abort(1);
 
1449
  }
1421
1450
  /* At this point, we've read all the options we need to read from files and
1422
1451
     collected most of them into unknown options - now let's load everything
1423
1452
  */
1424
1453
 
1425
1454
  if (plugin_init(plugins, plugin_options))
1426
1455
  {
1427
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
 
1456
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1428
1457
    unireg_abort(1);
1429
1458
  }
1430
1459
 
1435
1464
  {
1436
1465
    po::parsed_options final_parsed=
1437
1466
      po::command_line_parser(unknown_options).style(style).
1438
 
      options(full_options).extra_parser(dpo::parse_size_arg).run();
 
1467
      options(full_options).extra_parser(parse_size_arg).run();
1439
1468
 
1440
1469
    final_unknown_options=
1441
1470
      po::collect_unrecognized(final_parsed.options, po::include_positional);
1445
1474
  }
1446
1475
  catch (po::validation_error &err)
1447
1476
  {
1448
 
    errmsg_printf(error::ERROR,
 
1477
    errmsg_printf(ERRMSG_LVL_ERROR,
1449
1478
                  _("%s: %s.\n"
1450
1479
                    "Use --help to get a list of available options\n"),
1451
1480
                  internal::my_progname, err.what());
1453
1482
  }
1454
1483
  catch (po::invalid_command_line_syntax &err)
1455
1484
  {
1456
 
    errmsg_printf(error::ERROR,
 
1485
    errmsg_printf(ERRMSG_LVL_ERROR,
1457
1486
                  _("%s: %s.\n"
1458
1487
                    "Use --help to get a list of available options\n"),
1459
1488
                  internal::my_progname, err.what());
1461
1490
  }
1462
1491
  catch (po::unknown_option &err)
1463
1492
  {
1464
 
    errmsg_printf(error::ERROR,
 
1493
    errmsg_printf(ERRMSG_LVL_ERROR,
1465
1494
                  _("%s\nUse --help to get a list of available options\n"),
1466
1495
                  err.what());
1467
1496
    unireg_abort(1);
1473
1502
  }
1474
1503
  catch (po::validation_error &err)
1475
1504
  {
1476
 
    errmsg_printf(error::ERROR,  
 
1505
    errmsg_printf(ERRMSG_LVL_ERROR,  
1477
1506
                  _("%s: %s.\n"
1478
1507
                    "Use --help to get a list of available options\n"),
1479
1508
                  internal::my_progname, err.what());
1497
1526
 
1498
1527
  fix_paths();
1499
1528
 
 
1529
  current_pid= getpid();                /* Save for later ref */
1500
1530
  init_time();                          /* Init time-functions (read zone) */
1501
1531
 
1502
1532
  if (item_create_init())
1503
1533
    return 1;
1504
 
  if (sys_var_init())
 
1534
  if (set_var_init())
1505
1535
    return 1;
1506
1536
  /* Creates static regex matching for temporal values */
1507
1537
  if (! init_temporal_formats())
1510
1540
  if (!(default_charset_info=
1511
1541
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1512
1542
  {
1513
 
    errmsg_printf(error::ERROR, _("Error getting default charset"));
 
1543
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1514
1544
    return 1;                           // Eof of the list
1515
1545
  }
1516
1546
 
1522
1552
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1523
1553
    if (not default_collation)
1524
1554
    {
1525
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1555
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1526
1556
      return 1;
1527
1557
    }
1528
1558
    if (not my_charset_same(default_charset_info, default_collation))
1529
1559
    {
1530
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1560
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1531
1561
                    default_collation_name,
1532
1562
                    default_charset_info->csname);
1533
1563
      return 1;
1540
1570
  if (not (character_set_filesystem=
1541
1571
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1542
1572
  {
1543
 
    errmsg_printf(error::ERROR, _("Error setting collation"));
 
1573
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
1544
1574
    return 1;
1545
1575
  }
1546
1576
  global_system_variables.character_set_filesystem= character_set_filesystem;
1548
1578
  if (!(my_default_lc_time_names=
1549
1579
        my_locale_by_name(lc_time_names_name)))
1550
1580
  {
1551
 
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1581
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1552
1582
    return 1;
1553
1583
  }
1554
1584
  global_system_variables.lc_time_names= my_default_lc_time_names;
1568
1598
  */
1569
1599
  if (table_cache_init())
1570
1600
  {
1571
 
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
 
1601
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
1572
1602
    unireg_abort(1);
1573
1603
  }
1574
 
 
1575
 
  // Resize the definition Cache at startup
1576
 
  table::Cache::singleton().rehash(table_def_size);
1577
 
  definition::Cache::singleton().rehash(table_def_size);
1578
 
  message::Cache::singleton().rehash(table_def_size);
 
1604
  TableShare::cacheStart();
1579
1605
 
1580
1606
  setup_fpu();
1581
1607
 
1583
1609
 
1584
1610
  if (xid_cache_init())
1585
1611
  {
1586
 
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1612
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1587
1613
    unireg_abort(1);
1588
1614
  }
1589
1615
 
1612
1638
 
1613
1639
  if (plugin::Scheduler::setPlugin(scheduler_name))
1614
1640
  {
1615
 
      errmsg_printf(error::ERROR,
 
1641
      errmsg_printf(ERRMSG_LVL_ERROR,
1616
1642
                   _("No scheduler found, cannot continue!\n"));
1617
1643
      unireg_abort(1);
1618
1644
  }
1637
1663
    engine= plugin::StorageEngine::findByName(name);
1638
1664
    if (engine == NULL)
1639
1665
    {
1640
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1666
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1641
1667
                    default_storage_engine_str);
1642
1668
      unireg_abort(1);
1643
1669
    }
1678
1704
  OPT_BACK_LOG,
1679
1705
  OPT_JOIN_BUFF_SIZE,
1680
1706
  OPT_MAX_ALLOWED_PACKET,
 
1707
  OPT_MAX_CONNECT_ERRORS,
1681
1708
  OPT_MAX_HEP_TABLE_SIZE,
1682
1709
  OPT_MAX_JOIN_SIZE,
1683
1710
  OPT_MAX_SORT_LENGTH,
1731
1758
  {"help", '?', N_("Display this help and exit."),
1732
1759
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1733
1760
   0, 0},
1734
 
  {"daemon", 'd', N_("Run as daemon."),
1735
 
   (char**) &opt_daemon, (char**) &opt_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1736
 
   0, 0},
1737
1761
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1738
1762
   N_("Auto-increment columns are incremented by this"),
1739
1763
   (char**) &global_system_variables.auto_increment_increment,
1770
1794
  {"datadir", 'h',
1771
1795
   N_("Path to the database root."),
1772
1796
   NULL, NULL, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1797
  {"default-storage-engine", OPT_STORAGE_ENGINE,
 
1798
   N_("Set the default storage engine (table type) for tables."),
 
1799
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
 
1800
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1801
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE,
 
1802
   N_("Set the default time zone."),
 
1803
   (char**) &default_tz_name, (char**) &default_tz_name,
 
1804
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1773
1805
  /* See how it's handled in get_one_option() */
1774
1806
  {"exit-info", 'T',
1775
1807
   N_("Used for debugging;  Use at your own risk!"),
1780
1812
   N_("Set up signals usable for debugging"),
1781
1813
   (char**) &opt_debugging, (char**) &opt_debugging,
1782
1814
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
1815
  {"lc-time-names", OPT_LC_TIME_NAMES,
 
1816
   N_("Set the language used for the month names and the days of the week."),
 
1817
   (char**) &lc_time_names_name,
 
1818
   (char**) &lc_time_names_name,
 
1819
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1783
1820
  {"log-warnings", 'W',
1784
1821
   N_("Log some not critical warnings to the log file."),
1785
1822
   (char**) &global_system_variables.log_warnings,
1822
1859
      "supported)"),
1823
1860
   (char**) &internal::timed_mutexes, (char**) &internal::timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
1824
1861
    0, 0, 0, 0, 0},
 
1862
  {"tmpdir", 't',
 
1863
   N_("Path for temporary files."),
 
1864
   (char**) &opt_drizzle_tmpdir,
 
1865
   (char**) &opt_drizzle_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1825
1866
  {"transaction-isolation", OPT_TX_ISOLATION,
1826
1867
   N_("Default transaction isolation level."),
1827
1868
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1830
1871
   N_("Run drizzled daemon as user."),
1831
1872
   0, 0, 0, GET_STR, REQUIRED_ARG,
1832
1873
   0, 0, 0, 0, 0, 0},
 
1874
  {"version", 'V',
 
1875
   N_("Output version information and exit."),
 
1876
   0, 0, 0, GET_NO_ARG,
 
1877
   NO_ARG, 0, 0, 0, 0, 0, 0},
1833
1878
  {"back_log", OPT_BACK_LOG,
1834
1879
   N_("The number of outstanding connection requests Drizzle can have. This "
1835
1880
      "comes into play when the main Drizzle thread gets very many connection "
1848
1893
   (char**) &global_system_variables.div_precincrement,
1849
1894
   (char**) &max_system_variables.div_precincrement, 0, GET_UINT,
1850
1895
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
 
1896
  { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
 
1897
    N_("The maximum length of the result of function  group_concat."),
 
1898
    (char**) &global_system_variables.group_concat_max_len,
 
1899
    (char**) &max_system_variables.group_concat_max_len, 0, GET_UINT64,
 
1900
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
1851
1901
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1852
1902
    N_("The size of the buffer that is used for full joins."),
1853
1903
   (char**) &global_system_variables.join_buff_size,
1858
1908
   N_("Max packetlength to send/receive from to server."),
1859
1909
   (char**) &global_system_variables.max_allowed_packet,
1860
1910
   (char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1861
 
   REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
1911
   REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
1912
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
 
1913
   N_("If there is more than this number of interrupted connections from a "
 
1914
      "host this host will be blocked from further connections."),
 
1915
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
 
1916
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
 
1917
  {"max_error_count", OPT_MAX_ERROR_COUNT,
 
1918
   N_("Max number of errors/warnings to store for a statement."),
 
1919
   (char**) &global_system_variables.max_error_count,
 
1920
   (char**) &max_system_variables.max_error_count,
 
1921
   0, GET_UINT64, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
1862
1922
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1863
1923
   N_("Don't allow creation of heap tables bigger than this."),
1864
1924
   (char**) &global_system_variables.max_heap_table_size,
1978
2038
   (char**) &max_system_variables.read_rnd_buff_size, 0,
1979
2039
   GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
1980
2040
   UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
 
2041
  {"scheduler", OPT_SCHEDULER,
 
2042
   N_("Select scheduler to be used (by default multi-thread)."),
 
2043
   (char**)&opt_scheduler, (char**)&opt_scheduler,
 
2044
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1981
2045
  /* x8 compared to MySQL's x2. We have UTF8 to consider. */
1982
2046
  {"sort_buffer_size", OPT_SORT_BUFFER,
1983
2047
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
2071
2135
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
2072
2136
  cleanup_done= 0;
2073
2137
  dropping_tables= ha_open_options=0;
2074
 
  getDebug().reset();
 
2138
  test_flags.reset();
2075
2139
  wake_thread=0;
2076
2140
  abort_loop= select_thread_in_use= false;
2077
 
  shutdown_in_progress= 0;
 
2141
  ready_to_exit= shutdown_in_progress= 0;
2078
2142
  drizzled_user= drizzled_chroot= 0;
2079
2143
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2080
2144
  key_map_full.set();
2089
2153
  session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2090
2154
  refresh_version= 1L;  /* Increments on each reload */
2091
2155
  global_thread_id= 1UL;
2092
 
  session::Cache::singleton().getCache().clear();
 
2156
  getSessionList().clear();
2093
2157
 
2094
2158
  /* Variables in libraries */
2095
2159
  default_character_set_name= "utf8";
2139
2203
#else
2140
2204
  have_symlink=SHOW_OPTION_YES;
2141
2205
#endif
 
2206
 
 
2207
  connection_count= 0;
2142
2208
}
2143
2209
 
2144
2210
 
2159
2225
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2160
2226
 
2161
2227
    else
2162
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2228
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2163
2229
                                       "set to '%s' earlier on the command line\n"),
2164
2230
                    vm["user"].as<string>().c_str(), drizzled_user);
2165
2231
  }
2170
2236
    exit(0);
2171
2237
  }
2172
2238
 
2173
 
  if (vm.count("sort-heap-threshold"))
2174
 
  {
2175
 
    if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2176
 
      (vm["sort-heap-threshold"].as<uint64_t>() < 
2177
 
      global_system_variables.sortbuff_size))
2178
 
    {
2179
 
      cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2180
 
      exit(-1);
2181
 
    }
2182
 
 
2183
 
    global_sort_buffer.setMaxSize(vm["sort-heap-threshold"].as<uint64_t>());
2184
 
  }
2185
 
 
2186
 
  if (vm.count("join-heap-threshold"))
2187
 
  {
2188
 
    if ((vm["join-heap-threshold"].as<uint64_t>() > 0) and
2189
 
      (vm["join-heap-threshold"].as<uint64_t>() <
2190
 
      global_system_variables.join_buff_size))
2191
 
    {
2192
 
      cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2193
 
      exit(-1);
2194
 
    }
2195
 
 
2196
 
    global_join_buffer.setMaxSize(vm["join-heap-threshold"].as<uint64_t>());
2197
 
  }
2198
 
 
2199
 
  if (vm.count("read-rnd-threshold"))
2200
 
  {
2201
 
    if ((vm["read-rnd-threshold"].as<uint64_t>() > 0) and
2202
 
      (vm["read-rnd-threshold"].as<uint64_t>() <
2203
 
      global_system_variables.read_rnd_buff_size))
2204
 
    {
2205
 
      cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2206
 
      exit(-1);
2207
 
    }
2208
 
 
2209
 
    global_read_rnd_buffer.setMaxSize(vm["read-rnd-threshold"].as<uint64_t>());
2210
 
  }
2211
 
 
2212
 
  if (vm.count("read-buffer-threshold"))
2213
 
  {
2214
 
    if ((vm["read-buffer-threshold"].as<uint64_t>() > 0) and
2215
 
      (vm["read-buffer-threshold"].as<uint64_t>() <
2216
 
      global_system_variables.read_buff_size))
2217
 
    {
2218
 
      cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2219
 
      exit(-1);
2220
 
    }
2221
 
 
2222
 
    global_read_buffer.setMaxSize(vm["read-buffer-threshold"].as<uint64_t>());
2223
 
  }
2224
 
 
2225
2239
  if (vm.count("exit-info"))
2226
2240
  {
2227
2241
    if (vm["exit-info"].as<long>())
2228
2242
    {
2229
 
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
 
2243
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
2230
2244
    }
2231
2245
  }
2232
2246
 
2233
2247
  if (vm.count("want-core"))
2234
2248
  {
2235
 
    getDebug().set(debug::CORE_ON_SIGNAL);
 
2249
    test_flags.set(TEST_CORE_ON_SIGNAL);
2236
2250
  }
2237
2251
 
2238
2252
  if (vm.count("skip-stack-trace"))
2239
2253
  {
2240
 
    getDebug().set(debug::NO_STACKTRACE);
 
2254
    test_flags.set(TEST_NO_STACKTRACE);
2241
2255
  }
2242
2256
 
2243
2257
  if (vm.count("skip-symlinks"))
2247
2261
 
2248
2262
  if (vm.count("transaction-isolation"))
2249
2263
  {
2250
 
    int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
2251
 
    global_system_variables.tx_isolation= type - 1;
 
2264
    int type;
 
2265
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2266
    global_system_variables.tx_isolation= (type-1);
2252
2267
  }
2253
2268
 
2254
2269
  /* @TODO Make this all strings */
2275
2290
  if (opt_debugging)
2276
2291
  {
2277
2292
    /* Allow break with SIGINT, no core or stack trace */
2278
 
    getDebug().set(debug::ALLOW_SIGINT);
2279
 
    getDebug().set(debug::NO_STACKTRACE);
2280
 
    getDebug().reset(debug::CORE_ON_SIGNAL);
 
2293
    test_flags.set(TEST_SIGINT);
 
2294
    test_flags.set(TEST_NO_STACKTRACE);
 
2295
    test_flags.reset(TEST_CORE_ON_SIGNAL);
2281
2296
  }
2282
2297
 
2283
2298
  if (drizzled_chroot)
2299
2314
    pid_file_path= getDataHome();
2300
2315
    pid_file_path /= pid_file;
2301
2316
  }
2302
 
  pid_file= fs::system_complete(pid_file_path);
 
2317
  pid_file= pid_file_path;
2303
2318
 
2304
2319
  if (not opt_help)
2305
2320
  {
2329
2344
    {
2330
2345
      if (errno != EEXIST)
2331
2346
      {
2332
 
        errmsg_printf(error::ERROR, _("There was an error creating the '%s' part of the path '%s'.  Please check the path exists and is writable.\n"), fs::path(drizzle_tmpdir).leaf().c_str(), drizzle_tmpdir.c_str());
 
2347
        perror(drizzle_tmpdir.c_str());
2333
2348
        exit(1);
2334
2349
      }
2335
2350
    }
2336
2351
 
2337
2352
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2338
2353
    {
2339
 
      errmsg_printf(error::ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
 
2354
      perror(drizzle_tmpdir.c_str());
2340
2355
      exit(1);
2341
2356
    }
2342
2357
  }