~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include "drizzled/configmake.h"
22
 
#include "drizzled/atomics.h"
23
 
#include "drizzled/data_home.h"
 
20
#include <config.h>
 
21
 
 
22
#include <drizzled/configmake.h>
 
23
#include <drizzled/atomics.h>
 
24
#include <drizzled/data_home.h>
24
25
 
25
26
#include <netdb.h>
26
27
#include <sys/types.h>
31
32
#include <stdexcept>
32
33
 
33
34
#include <boost/program_options.hpp>
34
 
#include "drizzled/program_options/config_file.h"
 
35
#include <drizzled/program_options/config_file.h>
35
36
#include <boost/thread/recursive_mutex.hpp>
36
37
#include <boost/thread/mutex.hpp>
37
38
#include <boost/thread/shared_mutex.hpp>
38
39
#include <boost/thread/condition_variable.hpp>
39
40
#include <boost/filesystem.hpp>
 
41
#include <boost/detail/atomic_count.hpp>
40
42
 
41
 
#include "drizzled/internal/my_sys.h"
42
 
#include "drizzled/internal/my_bit.h"
43
 
#include <drizzled/my_hash.h>
 
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>
 
49
#include <drizzled/errmsg_print.h>
44
50
#include <drizzled/error.h>
45
 
#include <drizzled/errmsg_print.h>
46
 
#include <drizzled/tztime.h>
 
51
#include <drizzled/global_buffer.h>
 
52
#include <drizzled/internal/my_bit.h>
 
53
#include <drizzled/internal/my_sys.h>
 
54
#include <drizzled/item/cmpfunc.h>
 
55
#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/plugin/client.h>
 
60
#include <drizzled/plugin/error_message.h>
 
61
#include <drizzled/plugin/event_observer.h>
 
62
#include <drizzled/plugin/listen.h>
 
63
#include <drizzled/plugin/monitored_in_transaction.h>
 
64
#include <drizzled/plugin/scheduler.h>
 
65
#include <drizzled/plugin/storage_engine.h>
 
66
#include <drizzled/plugin/xa_resource_manager.h>
 
67
#include <drizzled/probes.h>
 
68
#include <drizzled/replication_services.h> /* For ReplicationServices::evaluateRegisteredPlugins() */
 
69
#include <drizzled/session.h>
 
70
#include <drizzled/session/cache.h>
 
71
#include <drizzled/show.h>
47
72
#include <drizzled/sql_base.h>
48
 
#include <drizzled/show.h>
49
73
#include <drizzled/sql_parse.h>
50
 
#include <drizzled/item/cmpfunc.h>
51
 
#include <drizzled/session.h>
52
 
#include <drizzled/item/create.h>
 
74
#include <drizzled/statistics_variables.h>
 
75
#include <drizzled/temporal_format.h> /* For init_temporal_formats() */
 
76
#include <drizzled/tztime.h>
53
77
#include <drizzled/unireg.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"
 
78
#include <plugin/myisam/myisam.h>
 
79
#include <drizzled/typelib.h>
 
80
#include <drizzled/visibility.h>
 
81
#include <drizzled/system_variables.h>
76
82
 
77
83
#include <google/protobuf/stubs/common.h>
78
84
 
 
85
#include <drizzled/refresh_version.h>
 
86
 
79
87
#if TIME_WITH_SYS_TIME
80
88
# include <sys/time.h>
81
89
# include <time.h>
95
103
 
96
104
#include <errno.h>
97
105
#include <sys/stat.h>
98
 
#include "drizzled/option.h"
 
106
#include <drizzled/option.h>
99
107
#ifdef HAVE_SYSENT_H
100
108
#include <sysent.h>
101
109
#endif
129
137
#include <sys/fpu.h>
130
138
#endif
131
139
 
132
 
#include "drizzled/internal/my_pthread.h"                       // For thr_setconcurency()
133
 
#include "drizzled/constrained_value.h"
 
140
#include <drizzled/internal/my_pthread.h>                       // For thr_setconcurency()
 
141
#include <drizzled/constrained_value.h>
134
142
 
135
143
#include <drizzled/gettext.h>
136
144
 
151
159
namespace po=boost::program_options;
152
160
namespace dpo=drizzled::program_options;
153
161
 
 
162
bool opt_daemon= false;
154
163
 
155
164
namespace drizzled
156
165
{
157
166
 
158
 
#define mysqld_charset &my_charset_utf8_general_ci
159
167
inline void setup_fpu()
160
168
{
161
169
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
227
235
 
228
236
/* Global variables */
229
237
 
230
 
bool volatile ready_to_exit;
231
238
char *drizzled_user;
232
239
bool volatile select_thread_in_use;
233
240
bool volatile abort_loop;
234
 
bool volatile shutdown_in_progress;
 
241
DRIZZLED_API bool volatile shutdown_in_progress;
235
242
char *opt_scheduler_default;
236
243
const char *opt_scheduler= NULL;
237
244
 
238
 
size_t my_thread_stack_size= 0;
 
245
DRIZZLED_API size_t my_thread_stack_size= 0;
239
246
 
240
247
/*
241
248
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
246
253
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
247
254
 
248
255
uint32_t drizzled_bind_timeout;
249
 
std::bitset<12> test_flags;
250
256
uint32_t dropping_tables, ha_open_options;
251
257
uint32_t tc_heuristic_recover= 0;
252
258
uint64_t session_startup_options;
253
259
back_log_constraints back_log(50);
254
 
uint32_t server_id;
 
260
DRIZZLED_API uint32_t server_id;
255
261
uint64_t table_cache_size;
256
262
size_t table_def_size;
257
 
uint64_t max_connect_errors;
258
263
uint32_t global_thread_id= 1UL;
259
264
pid_t current_pid;
260
265
 
304
309
fs::path system_config_dir(SYSCONFDIR);
305
310
 
306
311
 
307
 
char system_time_zone[30];
308
 
char *default_tz_name;
309
 
char glob_hostname[FN_REFLEN];
310
 
 
311
312
char *opt_tc_log_file;
312
313
const key_map key_map_empty(0);
313
314
key_map key_map_full(0);                        // Will be initialized later
321
322
const char *in_additional_cond= "<IN COND>";
322
323
const char *in_having_cond= "<IN HAVING>";
323
324
 
324
 
my_decimal decimal_zero;
325
325
/* classes for comparation parsing/processing */
326
326
 
327
327
FILE *stderror_file=0;
328
328
 
329
 
struct drizzle_system_variables global_system_variables;
330
 
struct drizzle_system_variables max_system_variables;
331
 
struct global_counters current_global_counters;
 
329
drizzle_system_variables global_system_variables;
 
330
drizzle_system_variables max_system_variables;
 
331
global_counters current_global_counters;
332
332
 
333
 
const CHARSET_INFO *system_charset_info, *files_charset_info ;
334
 
const CHARSET_INFO *table_alias_charset;
335
 
const CHARSET_INFO *character_set_filesystem;
 
333
DRIZZLED_API const charset_info_st *system_charset_info;
 
334
const charset_info_st *files_charset_info;
 
335
const charset_info_st *table_alias_charset;
 
336
const charset_info_st *character_set_filesystem;
336
337
 
337
338
MY_LOCALE *my_default_lc_time_names;
338
339
 
339
340
SHOW_COMP_OPTION have_symlink;
340
341
 
341
 
/* Thread specific variables */
342
 
boost::mutex LOCK_global_system_variables;
343
 
 
344
342
boost::condition_variable_any COND_refresh;
345
343
boost::condition_variable COND_thread_count;
346
344
pthread_t signal_thread;
347
 
boost::condition_variable COND_server_end;
348
345
 
349
346
/* Static variables */
350
347
 
352
349
 
353
350
passwd *user_info;
354
351
 
355
 
atomic<uint32_t> connection_count;
 
352
boost::detail::atomic_count connection_count(0);
356
353
 
357
354
global_buffer_constraint<uint64_t> global_sort_buffer(0);
358
355
global_buffer_constraint<uint64_t> global_join_buffer(0);
359
356
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
360
357
global_buffer_constraint<uint64_t> global_read_buffer(0);
361
358
 
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 */
366
 
 
367
 
/* Function declarations */
368
 
bool drizzle_rm_tmp_tables();
 
359
DRIZZLED_API size_t transaction_message_threshold;
369
360
 
370
361
static void drizzle_init_variables(void);
371
362
static void get_options();
376
367
 
377
368
fs::path base_plugin_dir(PKGPLUGINDIR);
378
369
 
379
 
po::options_description config_options("Config File Options");
380
 
po::options_description long_options("Kernel Options");
381
 
po::options_description plugin_load_options("Plugin Loading Options");
382
 
po::options_description plugin_options("Plugin Options");
383
 
po::options_description initial_options("Config and Plugin Loading");
384
 
po::options_description full_options("Kernel and Plugin Loading and Plugin");
 
370
po::options_description config_options(_("Config File Options"));
 
371
po::options_description long_options(_("Kernel Options"));
 
372
po::options_description plugin_load_options(_("Plugin Loading Options"));
 
373
po::options_description plugin_options(_("Plugin Options"));
 
374
po::options_description initial_options(_("Config and Plugin Loading"));
 
375
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
385
376
vector<string> unknown_options;
386
377
vector<string> defaults_file_list;
387
378
po::variables_map vm;
388
379
 
389
 
fs::path data_home(LOCALSTATEDIR);
390
 
fs::path full_data_home(LOCALSTATEDIR);
391
 
 
392
380
po::variables_map &getVariablesMap()
393
381
{
394
382
  return vm;
395
383
}
396
384
 
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
 
 
 
385
namespace
 
386
{
 
387
 
 
388
std::string &getGlobHostname()
 
389
{
 
390
  static std::string glob_hostname("localhost");
 
391
  return glob_hostname;
 
392
}
 
393
 
 
394
void setServerHostname(const std::string &hostname)
 
395
{
 
396
  getGlobHostname()= hostname;
 
397
}
 
398
}
 
399
 
 
400
const std::string &getServerHostname()
 
401
{
 
402
  return getGlobHostname();
 
403
}
 
404
 
409
405
/****************************************************************************
410
406
** Code to end drizzled
411
407
****************************************************************************/
421
417
 
422
418
    while (select_thread_in_use)
423
419
    {
424
 
      boost::xtime xt; 
425
 
      xtime_get(&xt, boost::TIME_UTC); 
426
 
      xt.sec += 2; 
 
420
      boost::xtime xt;
 
421
      xtime_get(&xt, boost::TIME_UTC);
 
422
      xt.sec += 2;
427
423
 
428
424
      for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
429
425
      {
445
441
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
446
442
    session::Cache::list list= session::Cache::singleton().getCache();
447
443
 
448
 
    for (session::Cache::list::iterator it= list.begin(); it != list.end(); ++it )
 
444
    BOOST_FOREACH(session::Cache::list::reference tmp, list)
449
445
    {
450
 
      Session::shared_ptr tmp(*it);
451
 
 
452
446
      tmp->setKilled(Session::KILL_CONNECTION);
453
447
      tmp->scheduler->killSession(tmp.get());
454
448
      DRIZZLE_CONNECTION_DONE(tmp->thread_id);
475
469
      break;
476
470
    }
477
471
    /* Close before unlock, avoiding crash. See LP bug#436685 */
478
 
    list.front()->client->close();
 
472
    list.front()->getClient()->close();
479
473
  }
480
474
}
481
475
 
484
478
{
485
479
 
486
480
  if (exit_code)
487
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
 
481
  {
 
482
    errmsg_printf(error::ERROR, _("Aborting"));
 
483
  }
488
484
  else if (opt_help)
 
485
  {
489
486
    usage();
 
487
  }
 
488
 
490
489
  clean_up(!opt_help && (exit_code));
491
490
  internal::my_end();
492
491
  exit(exit_code);
502
501
  free_charsets();
503
502
  module::Registry &modules= module::Registry::singleton();
504
503
  modules.shutdownModules();
505
 
  xid_cache_free();
506
504
 
507
505
  deinit_temporal_formats();
508
506
 
513
511
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
514
512
 
515
513
  if (print_message && server_start_time)
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;
 
514
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
520
515
 
521
 
    /* do the broadcast inside the lock to ensure that my_end() is not called */
522
 
    COND_server_end.notify_all();
523
 
  }
 
516
  session::Cache::singleton().shutdownFirst();
524
517
 
525
518
  /*
526
519
    The following lines may never be executed as the main thread may have
545
538
      tmp_user_info= getpwnam(user);
546
539
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
547
540
          global_system_variables.log_warnings)
548
 
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
 
541
            errmsg_printf(error::WARN, _("One can only use the --user switch "
549
542
                            "if running as root\n"));
550
543
    }
551
544
    return NULL;
552
545
  }
553
546
  if (not user)
554
547
  {
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"));
 
548
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
 
549
                                    "the manual to find out how to run drizzled as root"));
557
550
    unireg_abort(1);
558
551
  }
559
 
  if (!strcmp(user,"root"))
 
552
 
 
553
  if (not strcmp(user, "root"))
560
554
    return NULL;                        // Avoid problem with dynamic libraries
561
555
 
562
556
  if (!(tmp_user_info= getpwnam(user)))
563
557
  {
564
558
    // Allow a numeric uid to be used
565
559
    const char *pos;
566
 
    for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
 
560
    for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
567
561
    if (*pos)                                   // Not numeric id
568
562
      goto err;
569
563
    if (!(tmp_user_info= getpwuid(atoi(user))))
572
566
  return tmp_user_info;
573
567
 
574
568
err:
575
 
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
569
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
576
570
                    "Please check that the user exists!\n"),user);
577
571
  unireg_abort(1);
578
572
 
579
573
#ifdef PR_SET_DUMPABLE
580
 
  if (test_flags.test(TEST_CORE_ON_SIGNAL))
 
574
  if (getDebug().test(debug::CORE_ON_SIGNAL))
581
575
  {
582
576
    /* inform kernel that process is dumpable */
583
577
    (void) prctl(PR_SET_DUMPABLE, 1);
597
591
  initgroups((char*) user, user_info_arg->pw_gid);
598
592
  if (setgid(user_info_arg->pw_gid) == -1)
599
593
  {
600
 
    sql_perror(N_("Set process group ID failed"));
 
594
    sql_perror(_("Set process group ID failed"));
601
595
    unireg_abort(1);
602
596
  }
603
597
  if (setuid(user_info_arg->pw_uid) == -1)
604
598
  {
605
 
    sql_perror(N_("Set process user ID failed"));
 
599
    sql_perror(_("Set process user ID failed"));
606
600
    unireg_abort(1);
607
601
  }
608
602
}
614
608
{
615
609
  if ((chroot(path) == -1) || !chdir("/"))
616
610
  {
617
 
    sql_perror(N_("Process chroot failed"));
 
611
    sql_perror(_("Process chroot failed"));
618
612
    unireg_abort(1);
619
613
  }
620
614
}
628
622
    session              Thread handler
629
623
*/
630
624
 
631
 
void drizzled::Session::unlink(Session::shared_ptr &session)
632
 
{
633
 
  connection_count.decrement();
 
625
void Session::unlink(session_id_t &session_id)
 
626
{
 
627
  Session::shared_ptr session= session::Cache::singleton().find(session_id);
 
628
 
 
629
  if (session)
 
630
    unlink(session);
 
631
}
 
632
 
 
633
void Session::unlink(Session::shared_ptr &session)
 
634
{
 
635
  --connection_count;
634
636
 
635
637
  session->cleanup();
636
638
 
654
656
 
655
657
 
656
658
 
657
 
const char *load_default_groups[]= 
 
659
const char *load_default_groups[]=
658
660
{
659
661
  DRIZZLE_CONFIG_NAME, "server", 0, 0
660
662
};
661
663
 
662
664
static void find_plugin_dir(string progname)
663
665
{
664
 
  if (progname[0] != FN_LIBCHAR)
665
 
  {
666
 
    /* We have a relative path and need to find the absolute */
667
 
    char working_dir[FN_REFLEN];
668
 
    char *working_dir_ptr= working_dir;
669
 
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
670
 
    string new_path(working_dir);
671
 
    if (*(new_path.end()-1) != '/')
672
 
      new_path.push_back('/');
673
 
    if (progname[0] == '.' && progname[1] == '/')
674
 
      new_path.append(progname.substr(2));
675
 
    else
676
 
      new_path.append(progname);
677
 
    progname.swap(new_path);
678
 
  }
679
 
 
680
 
  /* Now, trim off the exe name */
681
 
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
682
 
  if (progdir.rfind(".libs/") != string::npos)
683
 
  {
684
 
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
685
 
  }
686
 
  string testlofile(progdir);
687
 
  testlofile.append("drizzled.lo");
688
 
  string testofile(progdir);
689
 
  testofile.append("drizzled.o");
690
 
  struct stat testfile_stat;
691
 
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
 
666
  fs::path full_progname(fs::system_complete(progname));
 
667
 
 
668
  fs::path progdir(full_progname.parent_path());
 
669
  if (progdir.filename() == ".libs")
 
670
  {
 
671
    progdir= progdir.parent_path();
 
672
  }
 
673
 
 
674
  if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
692
675
  {
693
676
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
694
 
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
695
 
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
 
677
    base_plugin_dir= progdir.parent_path();
696
678
    base_plugin_dir /= "plugin";
697
679
    base_plugin_dir /= ".libs";
698
680
  }
726
708
  global_system_variables.auto_increment_increment= 1;
727
709
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
728
710
  {
729
 
    cout << N_("Error: Invalid Value for auto_increment_increment");
 
711
    cout << _("Error: Invalid Value for auto_increment_increment");
730
712
    exit(-1);
731
713
  }
732
714
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
737
719
  global_system_variables.auto_increment_offset= 1;
738
720
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
739
721
  {
740
 
    cout << N_("Error: Invalid Value for auto_increment_offset");
 
722
    cout << _("Error: Invalid Value for auto_increment_offset");
741
723
    exit(-1);
742
724
  }
743
725
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
748
730
  global_system_variables.completion_type= 0;
749
731
  if (in_completion_type > 2)
750
732
  {
751
 
    cout << N_("Error: Invalid Value for completion_type");
 
733
    cout << _("Error: Invalid Value for completion_type");
752
734
    exit(-1);
753
735
  }
754
736
  global_system_variables.completion_type= in_completion_type;
760
742
  global_system_variables.div_precincrement= 4;
761
743
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
762
744
  {
763
 
    cout << N_("Error: Invalid Value for div-precision-increment");
 
745
    cout << _("Error: Invalid Value for div-precision-increment");
764
746
    exit(-1);
765
747
  }
766
748
  global_system_variables.div_precincrement= in_div_precincrement;
771
753
  global_system_variables.group_concat_max_len= 1024;
772
754
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
773
755
  {
774
 
    cout << N_("Error: Invalid Value for group_concat_max_len");
 
756
    cout << _("Error: Invalid Value for group_concat_max_len");
775
757
    exit(-1);
776
758
  }
777
759
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
782
764
  global_system_variables.join_buff_size= (128*1024L);
783
765
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
784
766
  {
785
 
    cout << N_("Error: Invalid Value for join_buffer_size");
 
767
    cout << _("Error: Invalid Value for join_buffer_size");
786
768
    exit(-1);
787
769
  }
788
770
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
794
776
  global_system_variables.max_allowed_packet= (64*1024*1024L);
795
777
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
796
778
  {
797
 
    cout << N_("Error: Invalid Value for max_allowed_packet");
 
779
    cout << _("Error: Invalid Value for max_allowed_packet");
798
780
    exit(-1);
799
781
  }
800
782
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
801
783
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
802
784
}
803
785
 
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
 
 
815
786
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
816
787
{
817
788
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
818
789
  if (in_max_error_count > 65535)
819
790
  {
820
 
    cout << N_("Error: Invalid Value for max_error_count");
 
791
    cout << _("Error: Invalid Value for max_error_count");
821
792
    exit(-1);
822
793
  }
823
794
  global_system_variables.max_error_count= in_max_error_count;
828
799
  global_system_variables.max_heap_table_size= (16*1024*1024L);
829
800
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
830
801
  {
831
 
    cout << N_("Error: Invalid Value for max_heap_table_size");
 
802
    cout << _("Error: Invalid Value for max_heap_table_size");
832
803
    exit(-1);
833
804
  }
834
805
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
840
811
  global_system_variables.min_examined_row_limit= 0;
841
812
  if (in_min_examined_row_limit > ULONG_MAX)
842
813
  {
843
 
    cout << N_("Error: Invalid Value for min_examined_row_limit");
 
814
    cout << _("Error: Invalid Value for min_examined_row_limit");
844
815
    exit(-1);
845
816
  }
846
817
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
847
818
}
848
819
 
849
 
static void check_limits_max_join_size(drizzled::ha_rows in_max_join_size)
 
820
static void check_limits_max_join_size(ha_rows in_max_join_size)
850
821
{
851
822
  global_system_variables.max_join_size= INT32_MAX;
852
823
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
853
824
  {
854
 
    cout << N_("Error: Invalid Value for max_join_size");
 
825
    cout << _("Error: Invalid Value for max_join_size");
855
826
    exit(-1);
856
827
  }
857
828
  global_system_variables.max_join_size= in_max_join_size;
862
833
  global_system_variables.max_length_for_sort_data= 1024;
863
834
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
864
835
  {
865
 
    cout << N_("Error: Invalid Value for max_length_for_sort_data");
 
836
    cout << _("Error: Invalid Value for max_length_for_sort_data");
866
837
    exit(-1);
867
838
  }
868
839
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
873
844
  global_system_variables.max_seeks_for_key= ULONG_MAX;
874
845
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
875
846
  {
876
 
    cout << N_("Error: Invalid Value for max_seeks_for_key");
 
847
    cout << _("Error: Invalid Value for max_seeks_for_key");
877
848
    exit(-1);
878
849
  }
879
850
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
884
855
  global_system_variables.max_sort_length= 1024;
885
856
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
886
857
  {
887
 
    cout << N_("Error: Invalid Value for max_sort_length");
 
858
    cout << _("Error: Invalid Value for max_sort_length");
888
859
    exit(-1);
889
860
  }
890
861
  global_system_variables.max_sort_length= in_max_sort_length;
895
866
  global_system_variables.optimizer_search_depth= 0;
896
867
  if (in_optimizer_search_depth > MAX_TABLES + 2)
897
868
  {
898
 
    cout << N_("Error: Invalid Value for optimizer_search_depth");
 
869
    cout << _("Error: Invalid Value for optimizer_search_depth");
899
870
    exit(-1);
900
871
  }
901
872
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
906
877
  global_system_variables.preload_buff_size= (32*1024L);
907
878
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
908
879
  {
909
 
    cout << N_("Error: Invalid Value for preload_buff_size");
 
880
    cout << _("Error: Invalid Value for preload_buff_size");
910
881
    exit(-1);
911
882
  }
912
883
  global_system_variables.preload_buff_size= in_preload_buff_size;
917
888
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
918
889
  if (in_query_alloc_block_size < 1024)
919
890
  {
920
 
    cout << N_("Error: Invalid Value for query_alloc_block_size");
 
891
    cout << _("Error: Invalid Value for query_alloc_block_size");
921
892
    exit(-1);
922
893
  }
923
894
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
929
900
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
930
901
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
931
902
  {
932
 
    cout << N_("Error: Invalid Value for query_prealloc_size");
 
903
    cout << _("Error: Invalid Value for query_prealloc_size");
933
904
    exit(-1);
934
905
  }
935
906
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
941
912
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
942
913
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
943
914
  {
944
 
    cout << N_("Error: Invalid Value for range_alloc_block_size");
 
915
    cout << _("Error: Invalid Value for range_alloc_block_size");
945
916
    exit(-1);
946
917
  }
947
918
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
953
924
  global_system_variables.read_buff_size= (128*1024L);
954
925
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
955
926
  {
956
 
    cout << N_("Error: Invalid Value for read_buff_size");
 
927
    cout << _("Error: Invalid Value for read_buff_size");
957
928
    exit(-1);
958
929
  }
959
930
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
965
936
  global_system_variables.read_rnd_buff_size= (256*1024L);
966
937
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
967
938
  {
968
 
    cout << N_("Error: Invalid Value for read_rnd_buff_size");
 
939
    cout << _("Error: Invalid Value for read_rnd_buff_size");
969
940
    exit(-1);
970
941
  }
971
942
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
976
947
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
977
948
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
978
949
  {
979
 
    cout << N_("Error: Invalid Value for sort_buff_size");
 
950
    cout << _("Error: Invalid Value for sort_buff_size");
980
951
    exit(-1);
981
952
  }
982
953
  global_system_variables.sortbuff_size= in_sortbuff_size;
987
958
  table_def_size= 128;
988
959
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
989
960
  {
990
 
    cout << N_("Error: Invalid Value for table_def_size");
 
961
    cout << _("Error: Invalid Value for table_def_size");
991
962
    exit(-1);
992
963
  }
993
964
  table_def_size= in_table_def_size;
998
969
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
999
970
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
1000
971
  {
1001
 
    cout << N_("Error: Invalid Value for table_cache_size");
 
972
    cout << _("Error: Invalid Value for table_cache_size");
1002
973
    exit(-1);
1003
974
  }
1004
975
  table_cache_size= in_table_cache_size;
1009
980
  table_lock_wait_timeout= 50;
1010
981
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
1011
982
  {
1012
 
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
 
983
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
1013
984
    exit(-1);
1014
985
  }
1015
986
  table_lock_wait_timeout= in_table_lock_wait_timeout;
1025
996
  global_system_variables.tmp_table_size= 16*1024*1024L;
1026
997
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1027
998
  {
1028
 
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
 
999
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
1029
1000
    exit(-1);
1030
1001
  }
1031
1002
  global_system_variables.tmp_table_size= in_tmp_table_size;
1033
1004
 
1034
1005
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1035
1006
{
1036
 
  global_system_variables.transaction_message_threshold= 1024*1024;
 
1007
  transaction_message_threshold= 1024*1024;
1037
1008
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1038
1009
  {
1039
 
    cout << N_("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
 
1010
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1040
1011
    exit(-1);
1041
1012
  }
1042
 
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
 
1013
  transaction_message_threshold= in_transaction_message_threshold;
1043
1014
}
1044
1015
 
1045
1016
static void process_defaults_files()
1046
1017
{
1047
 
  for (vector<string>::iterator iter= defaults_file_list.begin();
1048
 
       iter != defaults_file_list.end();
1049
 
       ++iter)
 
1018
        BOOST_FOREACH(vector<string>::reference iter, defaults_file_list)
1050
1019
  {
1051
 
    fs::path file_location= *iter;
 
1020
    fs::path file_location= iter;
1052
1021
 
1053
1022
    ifstream input_defaults_file(file_location.file_string().c_str());
1054
 
    
 
1023
 
1055
1024
    po::parsed_options file_parsed=
1056
1025
      dpo::parse_config_file(input_defaults_file, full_options, true);
1057
 
    vector<string> file_unknown= 
 
1026
    vector<string> file_unknown=
1058
1027
      po::collect_unrecognized(file_parsed.options, po::include_positional);
1059
1028
 
1060
1029
    for (vector<string>::iterator it= file_unknown.begin();
1064
1033
      string new_unknown_opt("--");
1065
1034
      new_unknown_opt.append(*it);
1066
1035
      ++it;
1067
 
      if (it != file_unknown.end())
1068
 
      {
1069
 
        if ((*it) != "true")
1070
 
        {
1071
 
          new_unknown_opt.push_back('=');
1072
 
          new_unknown_opt.append(*it);
1073
 
        }
1074
 
      }
1075
 
      else
1076
 
      {
1077
 
        break;
 
1036
      if (it == file_unknown.end())
 
1037
                                break;
 
1038
      if ((*it) != "true")
 
1039
      {
 
1040
        new_unknown_opt.push_back('=');
 
1041
        new_unknown_opt.append(*it);
1078
1042
      }
1079
1043
      unknown_options.push_back(new_unknown_opt);
1080
1044
    }
1084
1048
 
1085
1049
static void compose_defaults_file_list(vector<string> in_options)
1086
1050
{
1087
 
  for (vector<string>::iterator it= in_options.begin();
1088
 
       it != in_options.end();
1089
 
       ++it)
 
1051
        BOOST_FOREACH(vector<string>::reference it, in_options)
1090
1052
  {
1091
 
    fs::path p(*it);
 
1053
    fs::path p(it);
1092
1054
    if (fs::is_regular_file(p))
1093
 
      defaults_file_list.push_back(*it);
 
1055
      defaults_file_list.push_back(it);
1094
1056
    else
1095
1057
    {
1096
 
      errmsg_printf(ERRMSG_LVL_ERROR,
1097
 
                  _("Defaults file '%s' not found\n"), (*it).c_str());
 
1058
      errmsg_printf(error::ERROR, _("Defaults file '%s' not found\n"), it.c_str());
1098
1059
      unireg_abort(1);
1099
1060
    }
1100
 
 
1101
1061
  }
1102
1062
}
1103
1063
 
1104
 
int init_common_variables(int argc, char **argv, module::Registry &plugins)
 
1064
int init_basic_variables(int argc, char **argv)
1105
1065
{
1106
1066
  time_t curr_time;
1107
1067
  umask(((~internal::my_umask) & 0666));
1108
 
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
 
1068
  decimal_zero.set_zero(); // set decimal_zero constant;
1109
1069
  tzset();                      // Set tzname
1110
1070
 
1111
1071
  curr_time= time(NULL);
1118
1078
  drizzle_init_variables();
1119
1079
 
1120
1080
  find_plugin_dir(argv[0]);
1121
 
  {
1122
 
    struct tm tm_tmp;
1123
 
    localtime_r(&server_start_time,&tm_tmp);
1124
 
    strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
1125
 
            sizeof(system_time_zone)-1);
1126
1081
 
1127
 
  }
1128
1082
  /*
1129
1083
    We set SYSTEM time zone as reasonable default and
1130
1084
    also for failure of my_tz_init() and bootstrap mode.
1133
1087
  */
1134
1088
  global_system_variables.time_zone= my_tz_SYSTEM;
1135
1089
 
1136
 
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
 
1090
  char ret_hostname[FN_REFLEN];
 
1091
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
1137
1092
  {
1138
 
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1139
 
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1140
 
                  glob_hostname);
 
1093
    errmsg_printf(error::WARN,
 
1094
                  _("gethostname failed, using '%s' as hostname"),
 
1095
                  getServerHostname().c_str());
1141
1096
    pid_file= "drizzle";
1142
1097
  }
1143
1098
  else
1144
1099
  {
1145
 
    pid_file= glob_hostname;
 
1100
    setServerHostname(ret_hostname);
 
1101
    pid_file= getServerHostname();
1146
1102
  }
1147
1103
  pid_file.replace_extension(".pid");
1148
1104
 
1150
1106
 
1151
1107
  config_options.add_options()
1152
1108
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1153
 
  N_("Display this help and exit."))
 
1109
  _("Display this help and exit."))
 
1110
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
 
1111
  _("Run as a daemon."))
1154
1112
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1155
 
  N_("Configuration file defaults are not used if no-defaults is set"))
 
1113
  _("Configuration file defaults are not used if no-defaults is set"))
1156
1114
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1157
 
   N_("Configuration file to use"))
 
1115
  _("Configuration file to use"))
1158
1116
  ("config-dir", po::value<fs::path>(&system_config_dir),
1159
 
   N_("Base location for config files"))
 
1117
  _("Base location for config files"))
1160
1118
  ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
1161
 
  N_("Directory for plugins."))
 
1119
  _("Directory for plugins."))
1162
1120
  ;
1163
1121
 
1164
1122
  plugin_load_options.add_options()
1165
1123
  ("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1166
 
  N_("Optional comma separated list of plugins to load at startup in addition "
 
1124
  _("Optional comma separated list of plugins to load at startup in addition "
1167
1125
     "to the default list of plugins. "
1168
 
     "[for example: --plugin_add=crc32,logger_gearman]"))    
 
1126
     "[for example: --plugin_add=crc32,logger_gearman]"))
1169
1127
  ("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1170
 
  N_("Optional comma separated list of plugins to not load at startup. Effectively "
 
1128
  _("Optional comma separated list of plugins to not load at startup. Effectively "
1171
1129
     "removes a plugin from the list of plugins to be loaded. "
1172
1130
     "[for example: --plugin_remove=crc32,logger_gearman]"))
1173
1131
  ("plugin-load", po::value<string>()->notifier(&notify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1174
 
  N_("Optional comma separated list of plugins to load at starup instead of "
 
1132
  _("Optional comma separated list of plugins to load at starup instead of "
1175
1133
     "the default plugin load list. "
1176
1134
     "[for example: --plugin_load=crc32,logger_gearman]"))
1177
1135
  ;
1178
1136
 
1179
1137
  long_options.add_options()
1180
1138
  ("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1181
 
  N_("Auto-increment columns are incremented by this"))
 
1139
  _("Auto-increment columns are incremented by this"))
1182
1140
  ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1183
 
  N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
 
1141
  _("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1184
1142
  ("basedir,b", po::value<fs::path>(&basedir),
1185
 
  N_("Path to installation directory. All paths are usually resolved "
 
1143
  _("Path to installation directory. All paths are usually resolved "
1186
1144
     "relative to this."))
1187
1145
  ("chroot,r", po::value<string>(),
1188
 
  N_("Chroot drizzled daemon during startup."))
 
1146
  _("Chroot drizzled daemon during startup."))
1189
1147
  ("collation-server", po::value<string>(),
1190
 
  N_("Set the default collation."))      
 
1148
  _("Set the default collation."))
1191
1149
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
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."))
 
1150
  _("Default completion type."))
 
1151
  ("core-file",  _("Write core on errors."))
 
1152
  ("datadir", po::value<fs::path>(&getDataHome()),
 
1153
  _("Path to the database root."))
1196
1154
  ("default-storage-engine", po::value<string>(),
1197
 
  N_("Set the default storage engine for tables."))
 
1155
  _("Set the default storage engine for tables."))
1198
1156
  ("default-time-zone", po::value<string>(),
1199
 
  N_("Set the default time zone."))
 
1157
  _("Set the default time zone."))
1200
1158
  ("exit-info,T", po::value<long>(),
1201
 
  N_("Used for debugging;  Use at your own risk!"))
 
1159
  _("Used for debugging;  Use at your own risk!"))
1202
1160
  ("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1203
 
  N_("Set up signals usable for debugging"))
 
1161
  _("Set up signals usable for debugging"))
1204
1162
  ("lc-time-name", po::value<string>(),
1205
 
  N_("Set the language used for the month names and the days of the week."))
 
1163
  _("Set the language used for the month names and the days of the week."))
1206
1164
  ("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
1207
 
  N_("Log some not critical warnings to the log file."))  
 
1165
  _("Log some not critical warnings to the log file."))
1208
1166
  ("pid-file", po::value<fs::path>(&pid_file),
1209
 
  N_("Pid file used by drizzled."))
 
1167
  _("Pid file used by drizzled."))
1210
1168
  ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1211
 
  N_("Maximum time in seconds to wait for the port to become free. "))
 
1169
  _("Maximum time in seconds to wait for the port to become free. "))
1212
1170
  ("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1213
 
  N_("Include the SQL query in replicated protobuf messages."))
 
1171
  _("Include the SQL query in replicated protobuf messages."))
1214
1172
  ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1215
 
  N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
 
1173
  _("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1216
1174
     "within specified directory"))
1217
1175
  ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1218
 
  N_("Uniquely identifies the server instance in the community of "
 
1176
  _("Uniquely identifies the server instance in the community of "
1219
1177
     "replication partners."))
1220
 
  ("skip-stack-trace",  
1221
 
  N_("Don't print a stack trace on failure."))
 
1178
  ("skip-stack-trace",
 
1179
  _("Don't print a stack trace on failure."))
1222
1180
  ("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1223
 
  N_("Enable symbolic link support."))
 
1181
  _("Enable symbolic link support."))
1224
1182
  ("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1225
 
  N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1226
 
     "supported)")) 
 
1183
  _("Specify whether to time mutexes (only InnoDB mutexes are currently "
 
1184
     "supported)"))
1227
1185
  ("tmpdir,t", po::value<string>(),
1228
 
  N_("Path for temporary files."))
 
1186
  _("Path for temporary files."))
1229
1187
  ("transaction-isolation", po::value<string>(),
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."))
 
1188
  _("Default transaction isolation level."))
 
1189
  ("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
 
1190
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1233
1191
  ("user,u", po::value<string>(),
1234
 
  N_("Run drizzled daemon as user."))  
1235
 
  ("version,V", 
1236
 
  N_("Output version information and exit."))
 
1192
  _("Run drizzled daemon as user."))
 
1193
  ("version,V",
 
1194
  _("Output version information and exit."))
1237
1195
  ("back-log", po::value<back_log_constraints>(&back_log),
1238
 
  N_("The number of outstanding connection requests Drizzle can have. This "
 
1196
  _("The number of outstanding connection requests Drizzle can have. This "
1239
1197
     "comes into play when the main Drizzle thread gets very many connection "
1240
1198
     "requests in a very short time."))
1241
 
  ("bulk-insert-buffer-size", 
 
1199
  ("bulk-insert-buffer-size",
1242
1200
  po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1243
 
  N_("Size of tree cache used in bulk insert optimization. Note that this is "
 
1201
  _("Size of tree cache used in bulk insert optimization. Note that this is "
1244
1202
     "a limit per thread!"))
1245
1203
  ("div-precision-increment",  po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1246
 
  N_("Precision of the result of '/' operator will be increased on that "
 
1204
  _("Precision of the result of '/' operator will be increased on that "
1247
1205
     "value."))
1248
1206
  ("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1249
 
  N_("The maximum length of the result of function  group_concat."))
 
1207
  _("The maximum length of the result of function  group_concat."))
1250
1208
  ("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1251
 
  N_("The size of the buffer that is used for full joins."))
 
1209
  _("The size of the buffer that is used for full joins."))
1252
1210
  ("join-heap-threshold",
1253
1211
  po::value<uint64_t>()->default_value(0),
1254
 
  N_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
 
1212
  _("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1255
1213
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
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."))
 
1214
  _("Max packetlength to send/receive from to server."))
1260
1215
  ("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1261
 
  N_("Max number of errors/warnings to store for a statement."))
 
1216
  _("Max number of errors/warnings to store for a statement."))
1262
1217
  ("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1263
 
  N_("Don't allow creation of heap tables bigger than this."))
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),
1265
 
  N_("Joins that are probably going to read more than max_join_size records "
 
1218
  _("Don't allow creation of heap tables bigger than this."))
 
1219
  ("max-join-size", po::value<ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
 
1220
  _("Joins that are probably going to read more than max_join_size records "
1266
1221
     "return an error."))
1267
1222
  ("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1268
 
  N_("Max number of bytes in sorted records."))
 
1223
  _("Max number of bytes in sorted records."))
1269
1224
  ("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1270
 
  N_("Limit assumed max number of seeks when looking up rows based on a key"))
1271
 
  ("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),  
1272
 
  N_("The number of bytes to use when sorting BLOB or TEXT values "
 
1225
  _("Limit assumed max number of seeks when looking up rows based on a key"))
 
1226
  ("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
 
1227
  _("The number of bytes to use when sorting BLOB or TEXT values "
1273
1228
     "(only the first max_sort_length bytes of each value are used; the "
1274
1229
     "rest are ignored)."))
1275
1230
  ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1276
 
  N_("After this many write locks, allow some read locks to run in between."))
 
1231
  _("After this many write locks, allow some read locks to run in between."))
1277
1232
  ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1278
 
  N_("Don't log queries which examine less than min_examined_row_limit "
 
1233
  _("Don't log queries which examine less than min_examined_row_limit "
1279
1234
     "rows to file."))
1280
1235
  ("disable-optimizer-prune",
1281
 
  N_("Do not apply any heuristic(s) during query optimization to prune, "
 
1236
  _("Do not apply any heuristic(s) during query optimization to prune, "
1282
1237
     "thus perform an exhaustive search from the optimizer search space."))
1283
1238
  ("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1284
 
  N_("Maximum depth of search performed by the query optimizer. Values "
 
1239
  _("Maximum depth of search performed by the query optimizer. Values "
1285
1240
     "larger than the number of relations in a query result in better query "
1286
1241
     "plans, but take longer to compile a query. Smaller values than the "
1287
1242
     "number of tables in a relation result in faster optimization, but may "
1290
1245
     "optimizer will switch to the original find_best (used for "
1291
1246
     "testing/comparison)."))
1292
1247
  ("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1293
 
  N_("The size of the buffer that is allocated when preloading indexes"))
1294
 
  ("query-alloc-block-size", 
 
1248
  _("The size of the buffer that is allocated when preloading indexes"))
 
1249
  ("query-alloc-block-size",
1295
1250
  po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1296
 
  N_("Allocation block size for query parsing and execution"))
 
1251
  _("Allocation block size for query parsing and execution"))
1297
1252
  ("query-prealloc-size",
1298
1253
  po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1299
 
  N_("Persistent buffer for query parsing and execution"))
 
1254
  _("Persistent buffer for query parsing and execution"))
1300
1255
  ("range-alloc-block-size",
1301
1256
  po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1302
 
  N_("Allocation block size for storing ranges during optimization"))
 
1257
  _("Allocation block size for storing ranges during optimization"))
1303
1258
  ("read-buffer-size",
1304
1259
  po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1305
 
  N_("Each thread that does a sequential scan allocates a buffer of this "
 
1260
  _("Each thread that does a sequential scan allocates a buffer of this "
1306
1261
      "size for each table it scans. If you do many sequential scans, you may "
1307
1262
      "want to increase this value."))
1308
1263
  ("read-buffer-threshold",
1309
1264
  po::value<uint64_t>()->default_value(0),
1310
 
  N_("A global cap on the size of read-buffer-size (0 means unlimited)"))
 
1265
  _("A global cap on the size of read-buffer-size (0 means unlimited)"))
1311
1266
  ("read-rnd-buffer-size",
1312
1267
  po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1313
 
  N_("When reading rows in sorted order after a sort, the rows are read "
 
1268
  _("When reading rows in sorted order after a sort, the rows are read "
1314
1269
     "through this buffer to avoid a disk seeks. If not set, then it's set "
1315
1270
     "to the value of record_buffer."))
1316
1271
  ("read-rnd-threshold",
1317
1272
  po::value<uint64_t>()->default_value(0),
1318
 
  N_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
 
1273
  _("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1319
1274
  ("scheduler", po::value<string>(),
1320
 
  N_("Select scheduler to be used (by default multi-thread)."))
 
1275
  _("Select scheduler to be used (by default multi-thread)."))
1321
1276
  ("sort-buffer-size",
1322
1277
  po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1323
 
  N_("Each thread that needs to do a sort allocates a buffer of this size."))
 
1278
  _("Each thread that needs to do a sort allocates a buffer of this size."))
1324
1279
  ("sort-heap-threshold",
1325
1280
  po::value<uint64_t>()->default_value(0),
1326
 
  N_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
 
1281
  _("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1327
1282
  ("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1328
 
  N_("The number of cached table definitions."))
 
1283
  _("The number of cached table definitions."))
1329
1284
  ("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1330
 
  N_("The number of cached open tables."))
 
1285
  _("The number of cached open tables."))
1331
1286
  ("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1332
 
  N_("Timeout in seconds to wait for a table level lock before returning an "
 
1287
  _("Timeout in seconds to wait for a table level lock before returning an "
1333
1288
     "error. Used only if the connection has active cursors."))
1334
1289
  ("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1335
 
  N_("The stack size for each thread."))
1336
 
  ("tmp-table-size", 
 
1290
  _("The stack size for each thread."))
 
1291
  ("tmp-table-size",
1337
1292
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1338
 
  N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
 
1293
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
1339
1294
     " automatically convert it to an on-disk MyISAM table."))
 
1295
  ("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
 
1296
  _("The verbosity of messages from drizzled.  Possible values are INSPECT, INFO, WARN or ERROR"))
1340
1297
  ;
1341
1298
 
1342
1299
  full_options.add(long_options);
1358
1315
  }
1359
1316
  catch (std::exception&)
1360
1317
  {
1361
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
 
1318
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
1362
1319
    unireg_abort(1);
1363
1320
  }
1364
1321
 
1376
1333
    CachedDirectory config_conf_d(config_conf_d_location.file_string());
1377
1334
    if (not config_conf_d.fail())
1378
1335
    {
1379
 
 
1380
 
      for (CachedDirectory::Entries::const_iterator iter= config_conf_d.getEntries().begin();
1381
 
           iter != config_conf_d.getEntries().end();
1382
 
           ++iter)
 
1336
                        BOOST_FOREACH(CachedDirectory::Entries::const_reference iter, config_conf_d.getEntries())
1383
1337
      {
1384
 
        string file_entry((*iter)->filename);
 
1338
        string file_entry(iter->filename);
1385
1339
 
1386
1340
        if (not file_entry.empty()
1387
1341
            && file_entry != "."
1404
1358
  }
1405
1359
  catch (po::validation_error &err)
1406
1360
  {
1407
 
    errmsg_printf(ERRMSG_LVL_ERROR,  
 
1361
    errmsg_printf(error::ERROR,
1408
1362
                  _("%s: %s.\n"
1409
1363
                    "Use --help to get a list of available options\n"),
1410
1364
                  internal::my_progname, err.what());
1422
1376
  }
1423
1377
  catch (po::validation_error &err)
1424
1378
  {
1425
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1379
    errmsg_printf(error::ERROR,
1426
1380
                  _("%s: %s.\n"
1427
1381
                    "Use --help to get a list of available options\n"),
1428
1382
                  internal::my_progname, err.what());
1429
1383
    unireg_abort(1);
1430
1384
  }
1431
1385
 
 
1386
  return 0;
 
1387
}
 
1388
 
 
1389
int init_remaining_variables(module::Registry &plugins)
 
1390
{
 
1391
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
 
1392
 
 
1393
  current_pid= getpid();                /* Save for later ref */
 
1394
 
1432
1395
  /* At this point, we've read all the options we need to read from files and
1433
1396
     collected most of them into unknown options - now let's load everything
1434
1397
  */
1435
1398
 
1436
1399
  if (plugin_init(plugins, plugin_options))
1437
1400
  {
1438
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
 
1401
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1439
1402
    unireg_abort(1);
1440
1403
  }
1441
1404
 
1456
1419
  }
1457
1420
  catch (po::validation_error &err)
1458
1421
  {
1459
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1422
    errmsg_printf(error::ERROR,
1460
1423
                  _("%s: %s.\n"
1461
1424
                    "Use --help to get a list of available options\n"),
1462
1425
                  internal::my_progname, err.what());
1464
1427
  }
1465
1428
  catch (po::invalid_command_line_syntax &err)
1466
1429
  {
1467
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1430
    errmsg_printf(error::ERROR,
1468
1431
                  _("%s: %s.\n"
1469
1432
                    "Use --help to get a list of available options\n"),
1470
1433
                  internal::my_progname, err.what());
1472
1435
  }
1473
1436
  catch (po::unknown_option &err)
1474
1437
  {
1475
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1438
    errmsg_printf(error::ERROR,
1476
1439
                  _("%s\nUse --help to get a list of available options\n"),
1477
1440
                  err.what());
1478
1441
    unireg_abort(1);
1484
1447
  }
1485
1448
  catch (po::validation_error &err)
1486
1449
  {
1487
 
    errmsg_printf(ERRMSG_LVL_ERROR,  
 
1450
    errmsg_printf(error::ERROR,
1488
1451
                  _("%s: %s.\n"
1489
1452
                    "Use --help to get a list of available options\n"),
1490
1453
                  internal::my_progname, err.what());
1498
1461
  global_system_variables.optimizer_prune_level=
1499
1462
    vm.count("disable-optimizer-prune") ? false : true;
1500
1463
 
1501
 
  if (vm.count("help") == 0 && vm.count("help-extended") == 0)
 
1464
  if (! vm["help"].as<bool>())
1502
1465
  {
1503
1466
    if ((user_info= check_user(drizzled_user)))
1504
1467
    {
1508
1471
 
1509
1472
  fix_paths();
1510
1473
 
1511
 
  current_pid= getpid();                /* Save for later ref */
1512
1474
  init_time();                          /* Init time-functions (read zone) */
1513
1475
 
1514
1476
  if (item_create_init())
1522
1484
  if (!(default_charset_info=
1523
1485
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1524
1486
  {
1525
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
 
1487
    errmsg_printf(error::ERROR, _("Error getting default charset"));
1526
1488
    return 1;                           // Eof of the list
1527
1489
  }
1528
1490
 
1531
1493
 
1532
1494
  if (default_collation_name)
1533
1495
  {
1534
 
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
 
1496
    const charset_info_st * const default_collation= get_charset_by_name(default_collation_name);
1535
1497
    if (not default_collation)
1536
1498
    {
1537
 
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1499
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1538
1500
      return 1;
1539
1501
    }
1540
1502
    if (not my_charset_same(default_charset_info, default_collation))
1541
1503
    {
1542
 
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1504
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1543
1505
                    default_collation_name,
1544
1506
                    default_charset_info->csname);
1545
1507
      return 1;
1552
1514
  if (not (character_set_filesystem=
1553
1515
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1554
1516
  {
1555
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
 
1517
    errmsg_printf(error::ERROR, _("Error setting collation"));
1556
1518
    return 1;
1557
1519
  }
1558
1520
  global_system_variables.character_set_filesystem= character_set_filesystem;
1560
1522
  if (!(my_default_lc_time_names=
1561
1523
        my_locale_by_name(lc_time_names_name)))
1562
1524
  {
1563
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1525
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1564
1526
    return 1;
1565
1527
  }
1566
1528
  global_system_variables.lc_time_names= my_default_lc_time_names;
1580
1542
  */
1581
1543
  if (table_cache_init())
1582
1544
  {
1583
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
 
1545
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
1584
1546
    unireg_abort(1);
1585
1547
  }
1586
1548
 
1591
1553
 
1592
1554
  setup_fpu();
1593
1555
 
1594
 
  /* Setup logs */
1595
 
 
1596
 
  if (xid_cache_init())
1597
 
  {
1598
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1599
 
    unireg_abort(1);
1600
 
  }
1601
 
 
1602
1556
  /* Allow storage engine to give real error messages */
1603
1557
  ha_init_errors();
1604
1558
 
1619
1573
  else
1620
1574
  {
1621
1575
    scheduler_name= opt_scheduler_default;
1622
 
    opt_scheduler= opt_scheduler_default; 
 
1576
    opt_scheduler= opt_scheduler_default;
1623
1577
  }
1624
1578
 
1625
1579
  if (plugin::Scheduler::setPlugin(scheduler_name))
1626
1580
  {
1627
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
1581
      errmsg_printf(error::ERROR,
1628
1582
                   _("No scheduler found, cannot continue!\n"));
1629
1583
      unireg_abort(1);
1630
1584
  }
1649
1603
    engine= plugin::StorageEngine::findByName(name);
1650
1604
    if (engine == NULL)
1651
1605
    {
1652
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1606
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
1653
1607
                    default_storage_engine_str);
1654
1608
      unireg_abort(1);
1655
1609
    }
1675
1629
enum options_drizzled
1676
1630
{
1677
1631
  OPT_SOCKET=256,
1678
 
  OPT_BIND_ADDRESS,            
 
1632
  OPT_BIND_ADDRESS,
1679
1633
  OPT_PID_FILE,
1680
 
  OPT_STORAGE_ENGINE,          
 
1634
  OPT_STORAGE_ENGINE,
1681
1635
  OPT_INIT_FILE,
1682
1636
  OPT_WANT_CORE,
1683
1637
  OPT_MEMLOCK,
1690
1644
  OPT_BACK_LOG,
1691
1645
  OPT_JOIN_BUFF_SIZE,
1692
1646
  OPT_MAX_ALLOWED_PACKET,
1693
 
  OPT_MAX_CONNECT_ERRORS,
1694
1647
  OPT_MAX_HEP_TABLE_SIZE,
1695
1648
  OPT_MAX_JOIN_SIZE,
1696
1649
  OPT_MAX_SORT_LENGTH,
1744
1697
  {"help", '?', N_("Display this help and exit."),
1745
1698
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1746
1699
   0, 0},
 
1700
  {"daemon", 'd', N_("Run as daemon."),
 
1701
   (char**) &opt_daemon, (char**) &opt_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
1702
   0, 0},
1747
1703
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1748
1704
   N_("Auto-increment columns are incremented by this"),
1749
1705
   (char**) &global_system_variables.auto_increment_increment,
1780
1736
  {"datadir", 'h',
1781
1737
   N_("Path to the database root."),
1782
1738
   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 },
1791
1739
  /* See how it's handled in get_one_option() */
1792
1740
  {"exit-info", 'T',
1793
1741
   N_("Used for debugging;  Use at your own risk!"),
1798
1746
   N_("Set up signals usable for debugging"),
1799
1747
   (char**) &opt_debugging, (char**) &opt_debugging,
1800
1748
   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 },
1806
1749
  {"log-warnings", 'W',
1807
1750
   N_("Log some not critical warnings to the log file."),
1808
1751
   (char**) &global_system_variables.log_warnings,
1845
1788
      "supported)"),
1846
1789
   (char**) &internal::timed_mutexes, (char**) &internal::timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
1847
1790
    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},
1852
1791
  {"transaction-isolation", OPT_TX_ISOLATION,
1853
1792
   N_("Default transaction isolation level."),
1854
1793
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1857
1796
   N_("Run drizzled daemon as user."),
1858
1797
   0, 0, 0, GET_STR, REQUIRED_ARG,
1859
1798
   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},
1864
1799
  {"back_log", OPT_BACK_LOG,
1865
1800
   N_("The number of outstanding connection requests Drizzle can have. This "
1866
1801
      "comes into play when the main Drizzle thread gets very many connection "
1879
1814
   (char**) &global_system_variables.div_precincrement,
1880
1815
   (char**) &max_system_variables.div_precincrement, 0, GET_UINT,
1881
1816
   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},
1887
1817
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1888
1818
    N_("The size of the buffer that is used for full joins."),
1889
1819
   (char**) &global_system_variables.join_buff_size,
1895
1825
   (char**) &global_system_variables.max_allowed_packet,
1896
1826
   (char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1897
1827
   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},
1908
1828
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1909
1829
   N_("Don't allow creation of heap tables bigger than this."),
1910
1830
   (char**) &global_system_variables.max_heap_table_size,
2024
1944
   (char**) &max_system_variables.read_rnd_buff_size, 0,
2025
1945
   GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
2026
1946
   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},
2031
1947
  /* x8 compared to MySQL's x2. We have UTF8 to consider. */
2032
1948
  {"sort_buffer_size", OPT_SORT_BUFFER,
2033
1949
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
2087
2003
         "and you are welcome to modify and redistribute it under the GPL "
2088
2004
         "license\n\n"));
2089
2005
 
2090
 
 
 
2006
 
2091
2007
  printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
2092
2008
 
2093
2009
  po::options_description all_options("Drizzled Options");
2121
2037
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
2122
2038
  cleanup_done= 0;
2123
2039
  dropping_tables= ha_open_options=0;
2124
 
  test_flags.reset();
 
2040
  getDebug().reset();
2125
2041
  wake_thread=0;
2126
2042
  abort_loop= select_thread_in_use= false;
2127
 
  ready_to_exit= shutdown_in_progress= 0;
 
2043
  shutdown_in_progress= 0;
2128
2044
  drizzled_user= drizzled_chroot= 0;
2129
2045
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2130
2046
  key_map_full.set();
2189
2105
#else
2190
2106
  have_symlink=SHOW_OPTION_YES;
2191
2107
#endif
2192
 
 
2193
 
  connection_count= 0;
2194
2108
}
2195
2109
 
2196
2110
 
2203
2117
 
2204
2118
  fs::path &data_home_catalog= getDataHomeCatalog();
2205
2119
  data_home_catalog= getDataHome();
2206
 
  data_home_catalog /= "local"; 
 
2120
  data_home_catalog /= "local";
2207
2121
 
2208
2122
  if (vm.count("user"))
2209
2123
  {
2211
2125
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2212
2126
 
2213
2127
    else
2214
 
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
 
2128
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
2215
2129
                                       "set to '%s' earlier on the command line\n"),
2216
2130
                    vm["user"].as<string>().c_str(), drizzled_user);
2217
2131
  }
2225
2139
  if (vm.count("sort-heap-threshold"))
2226
2140
  {
2227
2141
    if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2228
 
      (vm["sort-heap-threshold"].as<uint64_t>() < 
 
2142
      (vm["sort-heap-threshold"].as<uint64_t>() <
2229
2143
      global_system_variables.sortbuff_size))
2230
2144
    {
2231
 
      cout << N_("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
 
2145
      cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2232
2146
      exit(-1);
2233
2147
    }
2234
2148
 
2241
2155
      (vm["join-heap-threshold"].as<uint64_t>() <
2242
2156
      global_system_variables.join_buff_size))
2243
2157
    {
2244
 
      cout << N_("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
 
2158
      cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2245
2159
      exit(-1);
2246
2160
    }
2247
2161
 
2254
2168
      (vm["read-rnd-threshold"].as<uint64_t>() <
2255
2169
      global_system_variables.read_rnd_buff_size))
2256
2170
    {
2257
 
      cout << N_("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
 
2171
      cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2258
2172
      exit(-1);
2259
2173
    }
2260
2174
 
2267
2181
      (vm["read-buffer-threshold"].as<uint64_t>() <
2268
2182
      global_system_variables.read_buff_size))
2269
2183
    {
2270
 
      cout << N_("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
 
2184
      cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2271
2185
      exit(-1);
2272
2186
    }
2273
2187
 
2278
2192
  {
2279
2193
    if (vm["exit-info"].as<long>())
2280
2194
    {
2281
 
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
 
2195
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
2282
2196
    }
2283
2197
  }
2284
2198
 
2285
2199
  if (vm.count("want-core"))
2286
2200
  {
2287
 
    test_flags.set(TEST_CORE_ON_SIGNAL);
 
2201
    getDebug().set(debug::CORE_ON_SIGNAL);
2288
2202
  }
2289
2203
 
2290
2204
  if (vm.count("skip-stack-trace"))
2291
2205
  {
2292
 
    test_flags.set(TEST_NO_STACKTRACE);
 
2206
    getDebug().set(debug::NO_STACKTRACE);
2293
2207
  }
2294
2208
 
2295
2209
  if (vm.count("skip-symlinks"))
2299
2213
 
2300
2214
  if (vm.count("transaction-isolation"))
2301
2215
  {
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);
 
2216
    int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
 
2217
    global_system_variables.tx_isolation= type - 1;
2305
2218
  }
2306
2219
 
2307
2220
  /* @TODO Make this all strings */
2328
2241
  if (opt_debugging)
2329
2242
  {
2330
2243
    /* Allow break with SIGINT, no core or stack trace */
2331
 
    test_flags.set(TEST_SIGINT);
2332
 
    test_flags.set(TEST_NO_STACKTRACE);
2333
 
    test_flags.reset(TEST_CORE_ON_SIGNAL);
 
2244
    getDebug().set(debug::ALLOW_SIGINT);
 
2245
    getDebug().set(debug::NO_STACKTRACE);
 
2246
    getDebug().reset(debug::CORE_ON_SIGNAL);
2334
2247
  }
2335
2248
 
2336
2249
  if (drizzled_chroot)
2356
2269
 
2357
2270
  if (not opt_help)
2358
2271
  {
2359
 
    const char *tmp_string= getenv("TMPDIR") ? getenv("TMPDIR") : NULL;
 
2272
    const char *tmp_string= getenv("TMPDIR");
2360
2273
    struct stat buf;
2361
2274
    drizzle_tmpdir.clear();
2362
2275
 
2382
2295
    {
2383
2296
      if (errno != EEXIST)
2384
2297
      {
2385
 
        perror(drizzle_tmpdir.c_str());
 
2298
        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());
2386
2299
        exit(1);
2387
2300
      }
2388
2301
    }
2389
2302
 
2390
2303
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2391
2304
    {
2392
 
      perror(drizzle_tmpdir.c_str());
 
2305
      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());
2393
2306
      exit(1);
2394
2307
    }
2395
2308
  }