~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2010-12-26 01:32:11 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101226013211-c1tx52h7evovmijg
fixed dict and eval.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
79
 
 
80
 
#include "drizzled/visibility.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/cache.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"
 
69
#include "drizzled/global_buffer.h"
 
70
 
 
71
#include "drizzled/definition/cache.h"
 
72
 
 
73
#include "drizzled/plugin/event_observer.h"
 
74
 
 
75
#include "drizzled/message/cache.h"
81
76
 
82
77
#include <google/protobuf/stubs/common.h>
83
78
 
84
 
#include <drizzled/refresh_version.h>
85
 
 
86
79
#if TIME_WITH_SYS_TIME
87
80
# include <sys/time.h>
88
81
# include <time.h>
158
151
namespace po=boost::program_options;
159
152
namespace dpo=drizzled::program_options;
160
153
 
161
 
bool opt_daemon= false;
162
154
 
163
155
namespace drizzled
164
156
{
165
157
 
 
158
#define mysqld_charset &my_charset_utf8_general_ci
166
159
inline void setup_fpu()
167
160
{
168
161
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
234
227
 
235
228
/* Global variables */
236
229
 
 
230
bool volatile ready_to_exit;
237
231
char *drizzled_user;
238
232
bool volatile select_thread_in_use;
239
233
bool volatile abort_loop;
240
 
DRIZZLED_API bool volatile shutdown_in_progress;
 
234
bool volatile shutdown_in_progress;
241
235
char *opt_scheduler_default;
242
236
const char *opt_scheduler= NULL;
243
237
 
244
 
DRIZZLED_API size_t my_thread_stack_size= 0;
 
238
size_t my_thread_stack_size= 0;
245
239
 
246
240
/*
247
241
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
252
246
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
253
247
 
254
248
uint32_t drizzled_bind_timeout;
 
249
std::bitset<12> test_flags;
255
250
uint32_t dropping_tables, ha_open_options;
256
251
uint32_t tc_heuristic_recover= 0;
257
252
uint64_t session_startup_options;
258
253
back_log_constraints back_log(50);
259
 
DRIZZLED_API uint32_t server_id;
 
254
uint32_t server_id;
260
255
uint64_t table_cache_size;
261
256
size_t table_def_size;
 
257
uint64_t max_connect_errors;
262
258
uint32_t global_thread_id= 1UL;
263
259
pid_t current_pid;
264
260
 
310
306
 
311
307
char system_time_zone[30];
312
308
char *default_tz_name;
313
 
DRIZZLED_API char glob_hostname[FN_REFLEN];
 
309
char glob_hostname[FN_REFLEN];
314
310
 
315
311
char *opt_tc_log_file;
316
312
const key_map key_map_empty(0);
325
321
const char *in_additional_cond= "<IN COND>";
326
322
const char *in_having_cond= "<IN HAVING>";
327
323
 
 
324
my_decimal decimal_zero;
328
325
/* classes for comparation parsing/processing */
329
326
 
330
327
FILE *stderror_file=0;
331
328
 
332
 
drizzle_system_variables global_system_variables;
333
 
drizzle_system_variables max_system_variables;
334
 
global_counters current_global_counters;
 
329
struct drizzle_system_variables global_system_variables;
 
330
struct drizzle_system_variables max_system_variables;
 
331
struct global_counters current_global_counters;
335
332
 
336
 
DRIZZLED_API const CHARSET_INFO *system_charset_info;
337
 
const CHARSET_INFO *files_charset_info;
 
333
const CHARSET_INFO *system_charset_info, *files_charset_info ;
338
334
const CHARSET_INFO *table_alias_charset;
339
335
const CHARSET_INFO *character_set_filesystem;
340
336
 
342
338
 
343
339
SHOW_COMP_OPTION have_symlink;
344
340
 
 
341
/* Thread specific variables */
 
342
boost::mutex LOCK_global_system_variables;
 
343
 
345
344
boost::condition_variable_any COND_refresh;
346
345
boost::condition_variable COND_thread_count;
347
346
pthread_t signal_thread;
 
347
boost::condition_variable COND_server_end;
348
348
 
349
349
/* Static variables */
350
350
 
352
352
 
353
353
passwd *user_info;
354
354
 
355
 
boost::detail::atomic_count connection_count(0);
 
355
atomic<uint32_t> connection_count;
356
356
 
357
357
global_buffer_constraint<uint64_t> global_sort_buffer(0);
358
358
global_buffer_constraint<uint64_t> global_join_buffer(0);
359
359
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
360
360
global_buffer_constraint<uint64_t> global_read_buffer(0);
361
361
 
362
 
DRIZZLED_API size_t transaction_message_threshold;
 
362
/** 
 
363
  Refresh value. We use to test this to find out if a refresh even has happened recently.
 
364
*/
 
365
uint64_t refresh_version;  /* Increments on each reload */
363
366
 
364
367
/* Function declarations */
365
368
bool drizzle_rm_tmp_tables();
383
386
vector<string> defaults_file_list;
384
387
po::variables_map vm;
385
388
 
 
389
fs::path data_home(LOCALSTATEDIR);
 
390
fs::path full_data_home(LOCALSTATEDIR);
 
391
 
386
392
po::variables_map &getVariablesMap()
387
393
{
388
394
  return vm;
389
395
}
390
396
 
391
 
 
 
397
fs::path& getDataHome()
 
398
{
 
399
  return data_home;
 
400
}
 
401
 
 
402
fs::path& getDataHomeCatalog()
 
403
{
 
404
  static fs::path data_home_catalog(getDataHome());
 
405
  return data_home_catalog;
 
406
}
 
407
 
 
408
 
392
409
/****************************************************************************
393
410
** Code to end drizzled
394
411
****************************************************************************/
458
475
      break;
459
476
    }
460
477
    /* Close before unlock, avoiding crash. See LP bug#436685 */
461
 
    list.front()->getClient()->close();
 
478
    list.front()->client->close();
462
479
  }
463
480
}
464
481
 
467
484
{
468
485
 
469
486
  if (exit_code)
470
 
  {
471
 
    errmsg_printf(error::ERROR, _("Aborting"));
472
 
  }
 
487
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
473
488
  else if (opt_help)
474
 
  {
475
489
    usage();
476
 
  }
477
 
 
478
490
  clean_up(!opt_help && (exit_code));
479
491
  internal::my_end();
480
492
  exit(exit_code);
501
513
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
502
514
 
503
515
  if (print_message && server_start_time)
504
 
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
516
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
517
  {
 
518
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
519
    ready_to_exit= true;
505
520
 
506
 
  session::Cache::singleton().shutdownFirst();
 
521
    /* do the broadcast inside the lock to ensure that my_end() is not called */
 
522
    COND_server_end.notify_all();
 
523
  }
507
524
 
508
525
  /*
509
526
    The following lines may never be executed as the main thread may have
528
545
      tmp_user_info= getpwnam(user);
529
546
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
530
547
          global_system_variables.log_warnings)
531
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
548
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
532
549
                            "if running as root\n"));
533
550
    }
534
551
    return NULL;
535
552
  }
536
553
  if (not user)
537
554
  {
538
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
539
 
                                    "the manual to find out how to run drizzled as root"));
 
555
      errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
556
                      "the manual to find out how to run drizzled as root!\n"));
540
557
    unireg_abort(1);
541
558
  }
542
 
 
543
 
  if (not strcmp(user, "root"))
 
559
  if (!strcmp(user,"root"))
544
560
    return NULL;                        // Avoid problem with dynamic libraries
545
561
 
546
562
  if (!(tmp_user_info= getpwnam(user)))
547
563
  {
548
564
    // Allow a numeric uid to be used
549
565
    const char *pos;
550
 
    for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
 
566
    for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
551
567
    if (*pos)                                   // Not numeric id
552
568
      goto err;
553
569
    if (!(tmp_user_info= getpwuid(atoi(user))))
556
572
  return tmp_user_info;
557
573
 
558
574
err:
559
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
575
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
560
576
                    "Please check that the user exists!\n"),user);
561
577
  unireg_abort(1);
562
578
 
563
579
#ifdef PR_SET_DUMPABLE
564
 
  if (getDebug().test(debug::CORE_ON_SIGNAL))
 
580
  if (test_flags.test(TEST_CORE_ON_SIGNAL))
565
581
  {
566
582
    /* inform kernel that process is dumpable */
567
583
    (void) prctl(PR_SET_DUMPABLE, 1);
581
597
  initgroups((char*) user, user_info_arg->pw_gid);
582
598
  if (setgid(user_info_arg->pw_gid) == -1)
583
599
  {
584
 
    sql_perror(_("Set process group ID failed"));
 
600
    sql_perror(N_("Set process group ID failed"));
585
601
    unireg_abort(1);
586
602
  }
587
603
  if (setuid(user_info_arg->pw_uid) == -1)
588
604
  {
589
 
    sql_perror(_("Set process user ID failed"));
 
605
    sql_perror(N_("Set process user ID failed"));
590
606
    unireg_abort(1);
591
607
  }
592
608
}
598
614
{
599
615
  if ((chroot(path) == -1) || !chdir("/"))
600
616
  {
601
 
    sql_perror(_("Process chroot failed"));
 
617
    sql_perror(N_("Process chroot failed"));
602
618
    unireg_abort(1);
603
619
  }
604
620
}
612
628
    session              Thread handler
613
629
*/
614
630
 
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
631
void drizzled::Session::unlink(Session::shared_ptr &session)
624
632
{
625
 
  --connection_count;
 
633
  connection_count.decrement();
626
634
 
627
635
  session->cleanup();
628
636
 
718
726
  global_system_variables.auto_increment_increment= 1;
719
727
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
720
728
  {
721
 
    cout << _("Error: Invalid Value for auto_increment_increment");
 
729
    cout << N_("Error: Invalid Value for auto_increment_increment");
722
730
    exit(-1);
723
731
  }
724
732
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
729
737
  global_system_variables.auto_increment_offset= 1;
730
738
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
731
739
  {
732
 
    cout << _("Error: Invalid Value for auto_increment_offset");
 
740
    cout << N_("Error: Invalid Value for auto_increment_offset");
733
741
    exit(-1);
734
742
  }
735
743
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
740
748
  global_system_variables.completion_type= 0;
741
749
  if (in_completion_type > 2)
742
750
  {
743
 
    cout << _("Error: Invalid Value for completion_type");
 
751
    cout << N_("Error: Invalid Value for completion_type");
744
752
    exit(-1);
745
753
  }
746
754
  global_system_variables.completion_type= in_completion_type;
752
760
  global_system_variables.div_precincrement= 4;
753
761
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
754
762
  {
755
 
    cout << _("Error: Invalid Value for div-precision-increment");
 
763
    cout << N_("Error: Invalid Value for div-precision-increment");
756
764
    exit(-1);
757
765
  }
758
766
  global_system_variables.div_precincrement= in_div_precincrement;
763
771
  global_system_variables.group_concat_max_len= 1024;
764
772
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
765
773
  {
766
 
    cout << _("Error: Invalid Value for group_concat_max_len");
 
774
    cout << N_("Error: Invalid Value for group_concat_max_len");
767
775
    exit(-1);
768
776
  }
769
777
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
774
782
  global_system_variables.join_buff_size= (128*1024L);
775
783
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
776
784
  {
777
 
    cout << _("Error: Invalid Value for join_buffer_size");
 
785
    cout << N_("Error: Invalid Value for join_buffer_size");
778
786
    exit(-1);
779
787
  }
780
788
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
786
794
  global_system_variables.max_allowed_packet= (64*1024*1024L);
787
795
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
788
796
  {
789
 
    cout << _("Error: Invalid Value for max_allowed_packet");
 
797
    cout << N_("Error: Invalid Value for max_allowed_packet");
790
798
    exit(-1);
791
799
  }
792
800
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
793
801
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
794
802
}
795
803
 
 
804
static void check_limits_mce(uint64_t in_max_connect_errors)
 
805
{
 
806
  max_connect_errors= MAX_CONNECT_ERRORS;
 
807
  if (in_max_connect_errors < 1 || in_max_connect_errors > ULONG_MAX)
 
808
  {
 
809
    cout << N_("Error: Invalid Value for max_connect_errors");
 
810
    exit(-1);
 
811
  }
 
812
  max_connect_errors= in_max_connect_errors;
 
813
}
 
814
 
796
815
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
797
816
{
798
817
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
799
818
  if (in_max_error_count > 65535)
800
819
  {
801
 
    cout << _("Error: Invalid Value for max_error_count");
 
820
    cout << N_("Error: Invalid Value for max_error_count");
802
821
    exit(-1);
803
822
  }
804
823
  global_system_variables.max_error_count= in_max_error_count;
809
828
  global_system_variables.max_heap_table_size= (16*1024*1024L);
810
829
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
811
830
  {
812
 
    cout << _("Error: Invalid Value for max_heap_table_size");
 
831
    cout << N_("Error: Invalid Value for max_heap_table_size");
813
832
    exit(-1);
814
833
  }
815
834
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
821
840
  global_system_variables.min_examined_row_limit= 0;
822
841
  if (in_min_examined_row_limit > ULONG_MAX)
823
842
  {
824
 
    cout << _("Error: Invalid Value for min_examined_row_limit");
 
843
    cout << N_("Error: Invalid Value for min_examined_row_limit");
825
844
    exit(-1);
826
845
  }
827
846
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
832
851
  global_system_variables.max_join_size= INT32_MAX;
833
852
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
834
853
  {
835
 
    cout << _("Error: Invalid Value for max_join_size");
 
854
    cout << N_("Error: Invalid Value for max_join_size");
836
855
    exit(-1);
837
856
  }
838
857
  global_system_variables.max_join_size= in_max_join_size;
843
862
  global_system_variables.max_length_for_sort_data= 1024;
844
863
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
845
864
  {
846
 
    cout << _("Error: Invalid Value for max_length_for_sort_data");
 
865
    cout << N_("Error: Invalid Value for max_length_for_sort_data");
847
866
    exit(-1);
848
867
  }
849
868
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
854
873
  global_system_variables.max_seeks_for_key= ULONG_MAX;
855
874
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
856
875
  {
857
 
    cout << _("Error: Invalid Value for max_seeks_for_key");
 
876
    cout << N_("Error: Invalid Value for max_seeks_for_key");
858
877
    exit(-1);
859
878
  }
860
879
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
865
884
  global_system_variables.max_sort_length= 1024;
866
885
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
867
886
  {
868
 
    cout << _("Error: Invalid Value for max_sort_length");
 
887
    cout << N_("Error: Invalid Value for max_sort_length");
869
888
    exit(-1);
870
889
  }
871
890
  global_system_variables.max_sort_length= in_max_sort_length;
876
895
  global_system_variables.optimizer_search_depth= 0;
877
896
  if (in_optimizer_search_depth > MAX_TABLES + 2)
878
897
  {
879
 
    cout << _("Error: Invalid Value for optimizer_search_depth");
 
898
    cout << N_("Error: Invalid Value for optimizer_search_depth");
880
899
    exit(-1);
881
900
  }
882
901
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
887
906
  global_system_variables.preload_buff_size= (32*1024L);
888
907
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
889
908
  {
890
 
    cout << _("Error: Invalid Value for preload_buff_size");
 
909
    cout << N_("Error: Invalid Value for preload_buff_size");
891
910
    exit(-1);
892
911
  }
893
912
  global_system_variables.preload_buff_size= in_preload_buff_size;
898
917
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
899
918
  if (in_query_alloc_block_size < 1024)
900
919
  {
901
 
    cout << _("Error: Invalid Value for query_alloc_block_size");
 
920
    cout << N_("Error: Invalid Value for query_alloc_block_size");
902
921
    exit(-1);
903
922
  }
904
923
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
910
929
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
911
930
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
912
931
  {
913
 
    cout << _("Error: Invalid Value for query_prealloc_size");
 
932
    cout << N_("Error: Invalid Value for query_prealloc_size");
914
933
    exit(-1);
915
934
  }
916
935
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
922
941
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
923
942
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
924
943
  {
925
 
    cout << _("Error: Invalid Value for range_alloc_block_size");
 
944
    cout << N_("Error: Invalid Value for range_alloc_block_size");
926
945
    exit(-1);
927
946
  }
928
947
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
934
953
  global_system_variables.read_buff_size= (128*1024L);
935
954
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
936
955
  {
937
 
    cout << _("Error: Invalid Value for read_buff_size");
 
956
    cout << N_("Error: Invalid Value for read_buff_size");
938
957
    exit(-1);
939
958
  }
940
959
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
946
965
  global_system_variables.read_rnd_buff_size= (256*1024L);
947
966
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
948
967
  {
949
 
    cout << _("Error: Invalid Value for read_rnd_buff_size");
 
968
    cout << N_("Error: Invalid Value for read_rnd_buff_size");
950
969
    exit(-1);
951
970
  }
952
971
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
957
976
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
958
977
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
959
978
  {
960
 
    cout << _("Error: Invalid Value for sort_buff_size");
 
979
    cout << N_("Error: Invalid Value for sort_buff_size");
961
980
    exit(-1);
962
981
  }
963
982
  global_system_variables.sortbuff_size= in_sortbuff_size;
968
987
  table_def_size= 128;
969
988
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
970
989
  {
971
 
    cout << _("Error: Invalid Value for table_def_size");
 
990
    cout << N_("Error: Invalid Value for table_def_size");
972
991
    exit(-1);
973
992
  }
974
993
  table_def_size= in_table_def_size;
979
998
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
980
999
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
981
1000
  {
982
 
    cout << _("Error: Invalid Value for table_cache_size");
 
1001
    cout << N_("Error: Invalid Value for table_cache_size");
983
1002
    exit(-1);
984
1003
  }
985
1004
  table_cache_size= in_table_cache_size;
990
1009
  table_lock_wait_timeout= 50;
991
1010
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
992
1011
  {
993
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1012
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
994
1013
    exit(-1);
995
1014
  }
996
1015
  table_lock_wait_timeout= in_table_lock_wait_timeout;
1006
1025
  global_system_variables.tmp_table_size= 16*1024*1024L;
1007
1026
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1008
1027
  {
1009
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1028
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
1010
1029
    exit(-1);
1011
1030
  }
1012
1031
  global_system_variables.tmp_table_size= in_tmp_table_size;
1014
1033
 
1015
1034
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1016
1035
{
1017
 
  transaction_message_threshold= 1024*1024;
 
1036
  global_system_variables.transaction_message_threshold= 1024*1024;
1018
1037
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1019
1038
  {
1020
 
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
 
1039
    cout << N_("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1021
1040
    exit(-1);
1022
1041
  }
1023
 
  transaction_message_threshold= in_transaction_message_threshold;
 
1042
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
1024
1043
}
1025
1044
 
1026
1045
static void process_defaults_files()
1074
1093
      defaults_file_list.push_back(*it);
1075
1094
    else
1076
1095
    {
1077
 
      errmsg_printf(error::ERROR,
 
1096
      errmsg_printf(ERRMSG_LVL_ERROR,
1078
1097
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1079
1098
      unireg_abort(1);
1080
1099
    }
1082
1101
  }
1083
1102
}
1084
1103
 
1085
 
int init_basic_variables(int argc, char **argv)
 
1104
int init_common_variables(int argc, char **argv, module::Registry &plugins)
1086
1105
{
1087
1106
  time_t curr_time;
1088
1107
  umask(((~internal::my_umask) & 0666));
1089
 
  decimal_zero.set_zero(); // set decimal_zero constant;
 
1108
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1090
1109
  tzset();                      // Set tzname
1091
1110
 
1092
1111
  curr_time= time(NULL);
1117
1136
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1118
1137
  {
1119
1138
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1120
 
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
 
1139
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1121
1140
                  glob_hostname);
1122
1141
    pid_file= "drizzle";
1123
1142
  }
1131
1150
 
1132
1151
  config_options.add_options()
1133
1152
  ("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."))
 
1153
  N_("Display this help and exit."))
1137
1154
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1138
 
  _("Configuration file defaults are not used if no-defaults is set"))
 
1155
  N_("Configuration file defaults are not used if no-defaults is set"))
1139
1156
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1140
 
  _("Configuration file to use"))
 
1157
   N_("Configuration file to use"))
1141
1158
  ("config-dir", po::value<fs::path>(&system_config_dir),
1142
 
  _("Base location for config files"))
 
1159
   N_("Base location for config files"))
1143
1160
  ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
1144
 
  _("Directory for plugins."))
 
1161
  N_("Directory for plugins."))
1145
1162
  ;
1146
1163
 
1147
1164
  plugin_load_options.add_options()
1148
1165
  ("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1149
 
  _("Optional comma separated list of plugins to load at startup in addition "
 
1166
  N_("Optional comma separated list of plugins to load at startup in addition "
1150
1167
     "to the default list of plugins. "
1151
1168
     "[for example: --plugin_add=crc32,logger_gearman]"))    
1152
1169
  ("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1153
 
  _("Optional comma separated list of plugins to not load at startup. Effectively "
 
1170
  N_("Optional comma separated list of plugins to not load at startup. Effectively "
1154
1171
     "removes a plugin from the list of plugins to be loaded. "
1155
1172
     "[for example: --plugin_remove=crc32,logger_gearman]"))
1156
1173
  ("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 "
 
1174
  N_("Optional comma separated list of plugins to load at starup instead of "
1158
1175
     "the default plugin load list. "
1159
1176
     "[for example: --plugin_load=crc32,logger_gearman]"))
1160
1177
  ;
1161
1178
 
1162
1179
  long_options.add_options()
1163
1180
  ("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"))
 
1181
  N_("Auto-increment columns are incremented by this"))
1165
1182
  ("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"))
 
1183
  N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1167
1184
  ("basedir,b", po::value<fs::path>(&basedir),
1168
 
  _("Path to installation directory. All paths are usually resolved "
 
1185
  N_("Path to installation directory. All paths are usually resolved "
1169
1186
     "relative to this."))
1170
1187
  ("chroot,r", po::value<string>(),
1171
 
  _("Chroot drizzled daemon during startup."))
 
1188
  N_("Chroot drizzled daemon during startup."))
1172
1189
  ("collation-server", po::value<string>(),
1173
 
  _("Set the default collation."))      
 
1190
  N_("Set the default collation."))      
1174
1191
  ("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."))
 
1192
  N_("Default completion type."))
 
1193
  ("core-file",  N_("Write core on errors."))
 
1194
  ("datadir", po::value<fs::path>(&data_home),
 
1195
  N_("Path to the database root."))
1179
1196
  ("default-storage-engine", po::value<string>(),
1180
 
  _("Set the default storage engine for tables."))
 
1197
  N_("Set the default storage engine for tables."))
1181
1198
  ("default-time-zone", po::value<string>(),
1182
 
  _("Set the default time zone."))
 
1199
  N_("Set the default time zone."))
1183
1200
  ("exit-info,T", po::value<long>(),
1184
 
  _("Used for debugging;  Use at your own risk!"))
 
1201
  N_("Used for debugging;  Use at your own risk!"))
1185
1202
  ("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1186
 
  _("Set up signals usable for debugging"))
 
1203
  N_("Set up signals usable for debugging"))
1187
1204
  ("lc-time-name", po::value<string>(),
1188
 
  _("Set the language used for the month names and the days of the week."))
 
1205
  N_("Set the language used for the month names and the days of the week."))
1189
1206
  ("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."))  
 
1207
  N_("Log some not critical warnings to the log file."))  
1191
1208
  ("pid-file", po::value<fs::path>(&pid_file),
1192
 
  _("Pid file used by drizzled."))
 
1209
  N_("Pid file used by drizzled."))
1193
1210
  ("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. "))
 
1211
  N_("Maximum time in seconds to wait for the port to become free. "))
1195
1212
  ("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1196
 
  _("Include the SQL query in replicated protobuf messages."))
 
1213
  N_("Include the SQL query in replicated protobuf messages."))
1197
1214
  ("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 "
 
1215
  N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1199
1216
     "within specified directory"))
1200
1217
  ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1201
 
  _("Uniquely identifies the server instance in the community of "
 
1218
  N_("Uniquely identifies the server instance in the community of "
1202
1219
     "replication partners."))
1203
1220
  ("skip-stack-trace",  
1204
 
  _("Don't print a stack trace on failure."))
 
1221
  N_("Don't print a stack trace on failure."))
1205
1222
  ("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1206
 
  _("Enable symbolic link support."))
 
1223
  N_("Enable symbolic link support."))
1207
1224
  ("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1208
 
  _("Specify whether to time mutexes (only InnoDB mutexes are currently "
 
1225
  N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1209
1226
     "supported)")) 
1210
1227
  ("tmpdir,t", po::value<string>(),
1211
 
  _("Path for temporary files."))
 
1228
  N_("Path for temporary files."))
1212
1229
  ("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."))
 
1230
  N_("Default transaction isolation level."))
 
1231
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
 
1232
  N_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1216
1233
  ("user,u", po::value<string>(),
1217
 
  _("Run drizzled daemon as user."))  
 
1234
  N_("Run drizzled daemon as user."))  
1218
1235
  ("version,V", 
1219
 
  _("Output version information and exit."))
 
1236
  N_("Output version information and exit."))
1220
1237
  ("back-log", po::value<back_log_constraints>(&back_log),
1221
 
  _("The number of outstanding connection requests Drizzle can have. This "
 
1238
  N_("The number of outstanding connection requests Drizzle can have. This "
1222
1239
     "comes into play when the main Drizzle thread gets very many connection "
1223
1240
     "requests in a very short time."))
1224
1241
  ("bulk-insert-buffer-size", 
1225
1242
  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 "
 
1243
  N_("Size of tree cache used in bulk insert optimization. Note that this is "
1227
1244
     "a limit per thread!"))
1228
1245
  ("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 "
 
1246
  N_("Precision of the result of '/' operator will be increased on that "
1230
1247
     "value."))
1231
1248
  ("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."))
 
1249
  N_("The maximum length of the result of function  group_concat."))
1233
1250
  ("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."))
 
1251
  N_("The size of the buffer that is used for full joins."))
1235
1252
  ("join-heap-threshold",
1236
1253
  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)"))
 
1254
  N_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1238
1255
  ("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."))
 
1256
  N_("Max packetlength to send/receive from to server."))
 
1257
  ("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
 
1258
  N_("If there is more than this number of interrupted connections from a "
 
1259
     "host this host will be blocked from further connections."))
1240
1260
  ("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."))
 
1261
  N_("Max number of errors/warnings to store for a statement."))
1242
1262
  ("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."))
 
1263
  N_("Don't allow creation of heap tables bigger than this."))
1244
1264
  ("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 "
 
1265
  N_("Joins that are probably going to read more than max_join_size records "
1246
1266
     "return an error."))
1247
1267
  ("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."))
 
1268
  N_("Max number of bytes in sorted records."))
1249
1269
  ("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"))
 
1270
  N_("Limit assumed max number of seeks when looking up rows based on a key"))
1251
1271
  ("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 "
 
1272
  N_("The number of bytes to use when sorting BLOB or TEXT values "
1253
1273
     "(only the first max_sort_length bytes of each value are used; the "
1254
1274
     "rest are ignored)."))
1255
1275
  ("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."))
 
1276
  N_("After this many write locks, allow some read locks to run in between."))
1257
1277
  ("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 "
 
1278
  N_("Don't log queries which examine less than min_examined_row_limit "
1259
1279
     "rows to file."))
1260
1280
  ("disable-optimizer-prune",
1261
 
  _("Do not apply any heuristic(s) during query optimization to prune, "
 
1281
  N_("Do not apply any heuristic(s) during query optimization to prune, "
1262
1282
     "thus perform an exhaustive search from the optimizer search space."))
1263
1283
  ("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 "
 
1284
  N_("Maximum depth of search performed by the query optimizer. Values "
1265
1285
     "larger than the number of relations in a query result in better query "
1266
1286
     "plans, but take longer to compile a query. Smaller values than the "
1267
1287
     "number of tables in a relation result in faster optimization, but may "
1270
1290
     "optimizer will switch to the original find_best (used for "
1271
1291
     "testing/comparison)."))
1272
1292
  ("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"))
 
1293
  N_("The size of the buffer that is allocated when preloading indexes"))
1274
1294
  ("query-alloc-block-size", 
1275
1295
  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"))
 
1296
  N_("Allocation block size for query parsing and execution"))
1277
1297
  ("query-prealloc-size",
1278
1298
  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"))
 
1299
  N_("Persistent buffer for query parsing and execution"))
1280
1300
  ("range-alloc-block-size",
1281
1301
  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"))
 
1302
  N_("Allocation block size for storing ranges during optimization"))
1283
1303
  ("read-buffer-size",
1284
1304
  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 "
 
1305
  N_("Each thread that does a sequential scan allocates a buffer of this "
1286
1306
      "size for each table it scans. If you do many sequential scans, you may "
1287
1307
      "want to increase this value."))
1288
1308
  ("read-buffer-threshold",
1289
1309
  po::value<uint64_t>()->default_value(0),
1290
 
  _("A global cap on the size of read-buffer-size (0 means unlimited)"))
 
1310
  N_("A global cap on the size of read-buffer-size (0 means unlimited)"))
1291
1311
  ("read-rnd-buffer-size",
1292
1312
  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 "
 
1313
  N_("When reading rows in sorted order after a sort, the rows are read "
1294
1314
     "through this buffer to avoid a disk seeks. If not set, then it's set "
1295
1315
     "to the value of record_buffer."))
1296
1316
  ("read-rnd-threshold",
1297
1317
  po::value<uint64_t>()->default_value(0),
1298
 
  _("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
 
1318
  N_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1299
1319
  ("scheduler", po::value<string>(),
1300
 
  _("Select scheduler to be used (by default multi-thread)."))
 
1320
  N_("Select scheduler to be used (by default multi-thread)."))
1301
1321
  ("sort-buffer-size",
1302
1322
  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."))
 
1323
  N_("Each thread that needs to do a sort allocates a buffer of this size."))
1304
1324
  ("sort-heap-threshold",
1305
1325
  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)"))
 
1326
  N_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1307
1327
  ("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1308
 
  _("The number of cached table definitions."))
 
1328
  N_("The number of cached table definitions."))
1309
1329
  ("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."))
 
1330
  N_("The number of cached open tables."))
1311
1331
  ("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 "
 
1332
  N_("Timeout in seconds to wait for a table level lock before returning an "
1313
1333
     "error. Used only if the connection has active cursors."))
1314
1334
  ("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."))
 
1335
  N_("The stack size for each thread."))
1316
1336
  ("tmp-table-size", 
1317
1337
  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"
 
1338
  N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1319
1339
     " automatically convert it to an on-disk MyISAM table."))
1320
1340
  ;
1321
1341
 
1338
1358
  }
1339
1359
  catch (std::exception&)
1340
1360
  {
1341
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
 
1361
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1342
1362
    unireg_abort(1);
1343
1363
  }
1344
1364
 
1384
1404
  }
1385
1405
  catch (po::validation_error &err)
1386
1406
  {
1387
 
    errmsg_printf(error::ERROR,  
 
1407
    errmsg_printf(ERRMSG_LVL_ERROR,  
1388
1408
                  _("%s: %s.\n"
1389
1409
                    "Use --help to get a list of available options\n"),
1390
1410
                  internal::my_progname, err.what());
1402
1422
  }
1403
1423
  catch (po::validation_error &err)
1404
1424
  {
1405
 
    errmsg_printf(error::ERROR,
 
1425
    errmsg_printf(ERRMSG_LVL_ERROR,
1406
1426
                  _("%s: %s.\n"
1407
1427
                    "Use --help to get a list of available options\n"),
1408
1428
                  internal::my_progname, err.what());
1409
1429
    unireg_abort(1);
1410
1430
  }
1411
1431
 
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
 
 
1421
1432
  /* At this point, we've read all the options we need to read from files and
1422
1433
     collected most of them into unknown options - now let's load everything
1423
1434
  */
1424
1435
 
1425
1436
  if (plugin_init(plugins, plugin_options))
1426
1437
  {
1427
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
 
1438
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1428
1439
    unireg_abort(1);
1429
1440
  }
1430
1441
 
1445
1456
  }
1446
1457
  catch (po::validation_error &err)
1447
1458
  {
1448
 
    errmsg_printf(error::ERROR,
 
1459
    errmsg_printf(ERRMSG_LVL_ERROR,
1449
1460
                  _("%s: %s.\n"
1450
1461
                    "Use --help to get a list of available options\n"),
1451
1462
                  internal::my_progname, err.what());
1453
1464
  }
1454
1465
  catch (po::invalid_command_line_syntax &err)
1455
1466
  {
1456
 
    errmsg_printf(error::ERROR,
 
1467
    errmsg_printf(ERRMSG_LVL_ERROR,
1457
1468
                  _("%s: %s.\n"
1458
1469
                    "Use --help to get a list of available options\n"),
1459
1470
                  internal::my_progname, err.what());
1461
1472
  }
1462
1473
  catch (po::unknown_option &err)
1463
1474
  {
1464
 
    errmsg_printf(error::ERROR,
 
1475
    errmsg_printf(ERRMSG_LVL_ERROR,
1465
1476
                  _("%s\nUse --help to get a list of available options\n"),
1466
1477
                  err.what());
1467
1478
    unireg_abort(1);
1473
1484
  }
1474
1485
  catch (po::validation_error &err)
1475
1486
  {
1476
 
    errmsg_printf(error::ERROR,  
 
1487
    errmsg_printf(ERRMSG_LVL_ERROR,  
1477
1488
                  _("%s: %s.\n"
1478
1489
                    "Use --help to get a list of available options\n"),
1479
1490
                  internal::my_progname, err.what());
1497
1508
 
1498
1509
  fix_paths();
1499
1510
 
 
1511
  current_pid= getpid();                /* Save for later ref */
1500
1512
  init_time();                          /* Init time-functions (read zone) */
1501
1513
 
1502
1514
  if (item_create_init())
1510
1522
  if (!(default_charset_info=
1511
1523
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1512
1524
  {
1513
 
    errmsg_printf(error::ERROR, _("Error getting default charset"));
 
1525
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1514
1526
    return 1;                           // Eof of the list
1515
1527
  }
1516
1528
 
1522
1534
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1523
1535
    if (not default_collation)
1524
1536
    {
1525
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1537
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1526
1538
      return 1;
1527
1539
    }
1528
1540
    if (not my_charset_same(default_charset_info, default_collation))
1529
1541
    {
1530
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1542
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1531
1543
                    default_collation_name,
1532
1544
                    default_charset_info->csname);
1533
1545
      return 1;
1540
1552
  if (not (character_set_filesystem=
1541
1553
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1542
1554
  {
1543
 
    errmsg_printf(error::ERROR, _("Error setting collation"));
 
1555
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
1544
1556
    return 1;
1545
1557
  }
1546
1558
  global_system_variables.character_set_filesystem= character_set_filesystem;
1548
1560
  if (!(my_default_lc_time_names=
1549
1561
        my_locale_by_name(lc_time_names_name)))
1550
1562
  {
1551
 
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1563
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1552
1564
    return 1;
1553
1565
  }
1554
1566
  global_system_variables.lc_time_names= my_default_lc_time_names;
1568
1580
  */
1569
1581
  if (table_cache_init())
1570
1582
  {
1571
 
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
 
1583
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
1572
1584
    unireg_abort(1);
1573
1585
  }
1574
1586
 
1583
1595
 
1584
1596
  if (xid_cache_init())
1585
1597
  {
1586
 
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1598
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1587
1599
    unireg_abort(1);
1588
1600
  }
1589
1601
 
1612
1624
 
1613
1625
  if (plugin::Scheduler::setPlugin(scheduler_name))
1614
1626
  {
1615
 
      errmsg_printf(error::ERROR,
 
1627
      errmsg_printf(ERRMSG_LVL_ERROR,
1616
1628
                   _("No scheduler found, cannot continue!\n"));
1617
1629
      unireg_abort(1);
1618
1630
  }
1637
1649
    engine= plugin::StorageEngine::findByName(name);
1638
1650
    if (engine == NULL)
1639
1651
    {
1640
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1652
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1641
1653
                    default_storage_engine_str);
1642
1654
      unireg_abort(1);
1643
1655
    }
1678
1690
  OPT_BACK_LOG,
1679
1691
  OPT_JOIN_BUFF_SIZE,
1680
1692
  OPT_MAX_ALLOWED_PACKET,
 
1693
  OPT_MAX_CONNECT_ERRORS,
1681
1694
  OPT_MAX_HEP_TABLE_SIZE,
1682
1695
  OPT_MAX_JOIN_SIZE,
1683
1696
  OPT_MAX_SORT_LENGTH,
1731
1744
  {"help", '?', N_("Display this help and exit."),
1732
1745
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1733
1746
   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
1747
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1738
1748
   N_("Auto-increment columns are incremented by this"),
1739
1749
   (char**) &global_system_variables.auto_increment_increment,
1770
1780
  {"datadir", 'h',
1771
1781
   N_("Path to the database root."),
1772
1782
   NULL, NULL, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1783
  {"default-storage-engine", OPT_STORAGE_ENGINE,
 
1784
   N_("Set the default storage engine (table type) for tables."),
 
1785
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
 
1786
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1787
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE,
 
1788
   N_("Set the default time zone."),
 
1789
   (char**) &default_tz_name, (char**) &default_tz_name,
 
1790
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1773
1791
  /* See how it's handled in get_one_option() */
1774
1792
  {"exit-info", 'T',
1775
1793
   N_("Used for debugging;  Use at your own risk!"),
1780
1798
   N_("Set up signals usable for debugging"),
1781
1799
   (char**) &opt_debugging, (char**) &opt_debugging,
1782
1800
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
1801
  {"lc-time-names", OPT_LC_TIME_NAMES,
 
1802
   N_("Set the language used for the month names and the days of the week."),
 
1803
   (char**) &lc_time_names_name,
 
1804
   (char**) &lc_time_names_name,
 
1805
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1783
1806
  {"log-warnings", 'W',
1784
1807
   N_("Log some not critical warnings to the log file."),
1785
1808
   (char**) &global_system_variables.log_warnings,
1822
1845
      "supported)"),
1823
1846
   (char**) &internal::timed_mutexes, (char**) &internal::timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
1824
1847
    0, 0, 0, 0, 0},
 
1848
  {"tmpdir", 't',
 
1849
   N_("Path for temporary files."),
 
1850
   (char**) &opt_drizzle_tmpdir,
 
1851
   (char**) &opt_drizzle_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1825
1852
  {"transaction-isolation", OPT_TX_ISOLATION,
1826
1853
   N_("Default transaction isolation level."),
1827
1854
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1830
1857
   N_("Run drizzled daemon as user."),
1831
1858
   0, 0, 0, GET_STR, REQUIRED_ARG,
1832
1859
   0, 0, 0, 0, 0, 0},
 
1860
  {"version", 'V',
 
1861
   N_("Output version information and exit."),
 
1862
   0, 0, 0, GET_NO_ARG,
 
1863
   NO_ARG, 0, 0, 0, 0, 0, 0},
1833
1864
  {"back_log", OPT_BACK_LOG,
1834
1865
   N_("The number of outstanding connection requests Drizzle can have. This "
1835
1866
      "comes into play when the main Drizzle thread gets very many connection "
1848
1879
   (char**) &global_system_variables.div_precincrement,
1849
1880
   (char**) &max_system_variables.div_precincrement, 0, GET_UINT,
1850
1881
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
 
1882
  { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
 
1883
    N_("The maximum length of the result of function  group_concat."),
 
1884
    (char**) &global_system_variables.group_concat_max_len,
 
1885
    (char**) &max_system_variables.group_concat_max_len, 0, GET_UINT64,
 
1886
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
1851
1887
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1852
1888
    N_("The size of the buffer that is used for full joins."),
1853
1889
   (char**) &global_system_variables.join_buff_size,
1859
1895
   (char**) &global_system_variables.max_allowed_packet,
1860
1896
   (char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1861
1897
   REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
1898
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
 
1899
   N_("If there is more than this number of interrupted connections from a "
 
1900
      "host this host will be blocked from further connections."),
 
1901
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
 
1902
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
 
1903
  {"max_error_count", OPT_MAX_ERROR_COUNT,
 
1904
   N_("Max number of errors/warnings to store for a statement."),
 
1905
   (char**) &global_system_variables.max_error_count,
 
1906
   (char**) &max_system_variables.max_error_count,
 
1907
   0, GET_UINT64, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
1862
1908
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1863
1909
   N_("Don't allow creation of heap tables bigger than this."),
1864
1910
   (char**) &global_system_variables.max_heap_table_size,
1978
2024
   (char**) &max_system_variables.read_rnd_buff_size, 0,
1979
2025
   GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
1980
2026
   UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
 
2027
  {"scheduler", OPT_SCHEDULER,
 
2028
   N_("Select scheduler to be used (by default multi-thread)."),
 
2029
   (char**)&opt_scheduler, (char**)&opt_scheduler,
 
2030
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1981
2031
  /* x8 compared to MySQL's x2. We have UTF8 to consider. */
1982
2032
  {"sort_buffer_size", OPT_SORT_BUFFER,
1983
2033
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
2071
2121
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
2072
2122
  cleanup_done= 0;
2073
2123
  dropping_tables= ha_open_options=0;
2074
 
  getDebug().reset();
 
2124
  test_flags.reset();
2075
2125
  wake_thread=0;
2076
2126
  abort_loop= select_thread_in_use= false;
2077
 
  shutdown_in_progress= 0;
 
2127
  ready_to_exit= shutdown_in_progress= 0;
2078
2128
  drizzled_user= drizzled_chroot= 0;
2079
2129
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2080
2130
  key_map_full.set();
2139
2189
#else
2140
2190
  have_symlink=SHOW_OPTION_YES;
2141
2191
#endif
 
2192
 
 
2193
  connection_count= 0;
2142
2194
}
2143
2195
 
2144
2196
 
2159
2211
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2160
2212
 
2161
2213
    else
2162
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2214
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2163
2215
                                       "set to '%s' earlier on the command line\n"),
2164
2216
                    vm["user"].as<string>().c_str(), drizzled_user);
2165
2217
  }
2176
2228
      (vm["sort-heap-threshold"].as<uint64_t>() < 
2177
2229
      global_system_variables.sortbuff_size))
2178
2230
    {
2179
 
      cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
 
2231
      cout << N_("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2180
2232
      exit(-1);
2181
2233
    }
2182
2234
 
2189
2241
      (vm["join-heap-threshold"].as<uint64_t>() <
2190
2242
      global_system_variables.join_buff_size))
2191
2243
    {
2192
 
      cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
 
2244
      cout << N_("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2193
2245
      exit(-1);
2194
2246
    }
2195
2247
 
2202
2254
      (vm["read-rnd-threshold"].as<uint64_t>() <
2203
2255
      global_system_variables.read_rnd_buff_size))
2204
2256
    {
2205
 
      cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
 
2257
      cout << N_("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2206
2258
      exit(-1);
2207
2259
    }
2208
2260
 
2215
2267
      (vm["read-buffer-threshold"].as<uint64_t>() <
2216
2268
      global_system_variables.read_buff_size))
2217
2269
    {
2218
 
      cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
 
2270
      cout << N_("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2219
2271
      exit(-1);
2220
2272
    }
2221
2273
 
2226
2278
  {
2227
2279
    if (vm["exit-info"].as<long>())
2228
2280
    {
2229
 
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
 
2281
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
2230
2282
    }
2231
2283
  }
2232
2284
 
2233
2285
  if (vm.count("want-core"))
2234
2286
  {
2235
 
    getDebug().set(debug::CORE_ON_SIGNAL);
 
2287
    test_flags.set(TEST_CORE_ON_SIGNAL);
2236
2288
  }
2237
2289
 
2238
2290
  if (vm.count("skip-stack-trace"))
2239
2291
  {
2240
 
    getDebug().set(debug::NO_STACKTRACE);
 
2292
    test_flags.set(TEST_NO_STACKTRACE);
2241
2293
  }
2242
2294
 
2243
2295
  if (vm.count("skip-symlinks"))
2247
2299
 
2248
2300
  if (vm.count("transaction-isolation"))
2249
2301
  {
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;
 
2302
    int type;
 
2303
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2304
    global_system_variables.tx_isolation= (type-1);
2252
2305
  }
2253
2306
 
2254
2307
  /* @TODO Make this all strings */
2275
2328
  if (opt_debugging)
2276
2329
  {
2277
2330
    /* 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);
 
2331
    test_flags.set(TEST_SIGINT);
 
2332
    test_flags.set(TEST_NO_STACKTRACE);
 
2333
    test_flags.reset(TEST_CORE_ON_SIGNAL);
2281
2334
  }
2282
2335
 
2283
2336
  if (drizzled_chroot)
2329
2382
    {
2330
2383
      if (errno != EEXIST)
2331
2384
      {
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());
 
2385
        perror(drizzle_tmpdir.c_str());
2333
2386
        exit(1);
2334
2387
      }
2335
2388
    }
2336
2389
 
2337
2390
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2338
2391
    {
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());
 
2392
      perror(drizzle_tmpdir.c_str());
2340
2393
      exit(1);
2341
2394
    }
2342
2395
  }