~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2010-11-26 22:40:33 UTC
  • mto: This revision was merged to the branch mainline in revision 1958.
  • Revision ID: brian@tangent.org-20101126224033-yt9a3o82w2rhaihp
Adding select for update test with flush locks engaged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
22
 
#include <drizzled/configmake.h>
23
 
#include <drizzled/atomics.h>
24
 
#include <drizzled/data_home.h>
 
20
#include "config.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
 
#include <drizzled/typelib.h>
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_list.h"
 
64
#include "drizzled/charset.h"
 
65
#include "plugin/myisam/myisam.h"
 
66
#include "drizzled/drizzled.h"
 
67
#include "drizzled/module/registry.h"
 
68
#include "drizzled/module/load_list.h"
 
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>
102
95
 
103
96
#include <errno.h>
104
97
#include <sys/stat.h>
105
 
#include <drizzled/option.h>
 
98
#include "drizzled/option.h"
106
99
#ifdef HAVE_SYSENT_H
107
100
#include <sysent.h>
108
101
#endif
136
129
#include <sys/fpu.h>
137
130
#endif
138
131
 
139
 
#include <drizzled/internal/my_pthread.h>                       // For thr_setconcurency()
140
 
#include <drizzled/constrained_value.h>
 
132
#include "drizzled/internal/my_pthread.h"                       // For thr_setconcurency()
 
133
#include "drizzled/constrained_value.h"
141
134
 
142
135
#include <drizzled/gettext.h>
143
136
 
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
 
308
304
fs::path system_config_dir(SYSCONFDIR);
309
305
 
310
306
 
 
307
char system_time_zone[30];
 
308
char *default_tz_name;
 
309
char glob_hostname[FN_REFLEN];
 
310
 
311
311
char *opt_tc_log_file;
312
312
const key_map key_map_empty(0);
313
313
key_map key_map_full(0);                        // Will be initialized later
321
321
const char *in_additional_cond= "<IN COND>";
322
322
const char *in_having_cond= "<IN HAVING>";
323
323
 
 
324
my_decimal decimal_zero;
324
325
/* classes for comparation parsing/processing */
325
326
 
326
327
FILE *stderror_file=0;
327
328
 
328
 
drizzle_system_variables global_system_variables;
329
 
drizzle_system_variables max_system_variables;
330
 
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;
331
332
 
332
 
DRIZZLED_API const CHARSET_INFO *system_charset_info;
333
 
const CHARSET_INFO *files_charset_info;
 
333
const CHARSET_INFO *system_charset_info, *files_charset_info ;
334
334
const CHARSET_INFO *table_alias_charset;
335
335
const CHARSET_INFO *character_set_filesystem;
336
336
 
338
338
 
339
339
SHOW_COMP_OPTION have_symlink;
340
340
 
 
341
/* Thread specific variables */
 
342
boost::mutex LOCK_global_system_variables;
 
343
 
341
344
boost::condition_variable_any COND_refresh;
342
345
boost::condition_variable COND_thread_count;
343
346
pthread_t signal_thread;
 
347
boost::condition_variable COND_server_end;
344
348
 
345
349
/* Static variables */
346
350
 
348
352
 
349
353
passwd *user_info;
350
354
 
351
 
boost::detail::atomic_count connection_count(0);
 
355
atomic<uint32_t> connection_count;
352
356
 
353
357
global_buffer_constraint<uint64_t> global_sort_buffer(0);
354
358
global_buffer_constraint<uint64_t> global_join_buffer(0);
355
359
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
356
360
global_buffer_constraint<uint64_t> global_read_buffer(0);
357
361
 
358
 
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 */
 
366
 
 
367
/* Function declarations */
 
368
bool drizzle_rm_tmp_tables();
359
369
 
360
370
static void drizzle_init_variables(void);
361
371
static void get_options();
366
376
 
367
377
fs::path base_plugin_dir(PKGPLUGINDIR);
368
378
 
369
 
po::options_description config_options(_("Config File Options"));
370
 
po::options_description long_options(_("Kernel Options"));
371
 
po::options_description plugin_load_options(_("Plugin Loading Options"));
372
 
po::options_description plugin_options(_("Plugin Options"));
373
 
po::options_description initial_options(_("Config and Plugin Loading"));
374
 
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
 
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");
375
385
vector<string> unknown_options;
376
386
vector<string> defaults_file_list;
377
387
po::variables_map vm;
378
388
 
 
389
fs::path data_home(LOCALSTATEDIR);
 
390
fs::path full_data_home(LOCALSTATEDIR);
 
391
 
379
392
po::variables_map &getVariablesMap()
380
393
{
381
394
  return vm;
382
395
}
383
396
 
384
 
namespace
385
 
{
386
 
 
387
 
std::string &getGlobHostname()
388
 
{
389
 
  static std::string glob_hostname("localhost");
390
 
  return glob_hostname;
391
 
}
392
 
 
393
 
void setServerHostname(const std::string &hostname)
394
 
{
395
 
  getGlobHostname()= hostname;
396
 
}
397
 
}
398
 
 
399
 
const std::string &getServerHostname()
400
 
{
401
 
  return getGlobHostname();
402
 
}
403
 
 
 
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
 
404
409
/****************************************************************************
405
410
** Code to end drizzled
406
411
****************************************************************************/
438
443
 
439
444
  {
440
445
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
441
 
    session::Cache::list list= session::Cache::singleton().getCache();
 
446
    session::Cache::List list= session::Cache::singleton().getCache();
442
447
 
443
 
    for (session::Cache::list::iterator it= list.begin(); it != list.end(); ++it )
 
448
    for (session::Cache::List::iterator it= list.begin(); it != list.end(); ++it )
444
449
    {
445
450
      Session::shared_ptr tmp(*it);
446
451
 
447
452
      tmp->setKilled(Session::KILL_CONNECTION);
448
453
      tmp->scheduler->killSession(tmp.get());
449
454
      DRIZZLE_CONNECTION_DONE(tmp->thread_id);
450
 
 
451
455
      tmp->lockOnSys();
452
456
    }
453
457
  }
463
467
  for (;;)
464
468
  {
465
469
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
466
 
    session::Cache::list list= session::Cache::singleton().getCache();
 
470
    session::Cache::List list= session::Cache::singleton().getCache();
467
471
 
468
472
    if (list.empty())
469
473
    {
470
474
      break;
471
475
    }
472
476
    /* Close before unlock, avoiding crash. See LP bug#436685 */
473
 
    list.front()->getClient()->close();
 
477
    list.front()->client->close();
474
478
  }
475
479
}
476
480
 
479
483
{
480
484
 
481
485
  if (exit_code)
482
 
  {
483
 
    errmsg_printf(error::ERROR, _("Aborting"));
484
 
  }
 
486
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
485
487
  else if (opt_help)
486
 
  {
487
488
    usage();
488
 
  }
489
 
 
490
489
  clean_up(!opt_help && (exit_code));
491
490
  internal::my_end();
492
491
  exit(exit_code);
513
512
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
514
513
 
515
514
  if (print_message && server_start_time)
516
 
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
515
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
516
  {
 
517
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
518
    ready_to_exit= true;
517
519
 
518
 
  session::Cache::singleton().shutdownFirst();
 
520
    /* do the broadcast inside the lock to ensure that my_end() is not called */
 
521
    COND_server_end.notify_all();
 
522
  }
519
523
 
520
524
  /*
521
525
    The following lines may never be executed as the main thread may have
540
544
      tmp_user_info= getpwnam(user);
541
545
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
542
546
          global_system_variables.log_warnings)
543
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
547
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
544
548
                            "if running as root\n"));
545
549
    }
546
550
    return NULL;
547
551
  }
548
552
  if (not user)
549
553
  {
550
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
551
 
                                    "the manual to find out how to run drizzled as root"));
 
554
      errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
555
                      "the manual to find out how to run drizzled as root!\n"));
552
556
    unireg_abort(1);
553
557
  }
554
 
 
555
 
  if (not strcmp(user, "root"))
 
558
  if (!strcmp(user,"root"))
556
559
    return NULL;                        // Avoid problem with dynamic libraries
557
560
 
558
561
  if (!(tmp_user_info= getpwnam(user)))
559
562
  {
560
563
    // Allow a numeric uid to be used
561
564
    const char *pos;
562
 
    for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
 
565
    for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
563
566
    if (*pos)                                   // Not numeric id
564
567
      goto err;
565
568
    if (!(tmp_user_info= getpwuid(atoi(user))))
568
571
  return tmp_user_info;
569
572
 
570
573
err:
571
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
574
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
572
575
                    "Please check that the user exists!\n"),user);
573
576
  unireg_abort(1);
574
577
 
575
578
#ifdef PR_SET_DUMPABLE
576
 
  if (getDebug().test(debug::CORE_ON_SIGNAL))
 
579
  if (test_flags.test(TEST_CORE_ON_SIGNAL))
577
580
  {
578
581
    /* inform kernel that process is dumpable */
579
582
    (void) prctl(PR_SET_DUMPABLE, 1);
593
596
  initgroups((char*) user, user_info_arg->pw_gid);
594
597
  if (setgid(user_info_arg->pw_gid) == -1)
595
598
  {
596
 
    sql_perror(_("Set process group ID failed"));
 
599
    sql_perror(N_("Set process group ID failed"));
597
600
    unireg_abort(1);
598
601
  }
599
602
  if (setuid(user_info_arg->pw_uid) == -1)
600
603
  {
601
 
    sql_perror(_("Set process user ID failed"));
 
604
    sql_perror(N_("Set process user ID failed"));
602
605
    unireg_abort(1);
603
606
  }
604
607
}
610
613
{
611
614
  if ((chroot(path) == -1) || !chdir("/"))
612
615
  {
613
 
    sql_perror(_("Process chroot failed"));
 
616
    sql_perror(N_("Process chroot failed"));
614
617
    unireg_abort(1);
615
618
  }
616
619
}
624
627
    session              Thread handler
625
628
*/
626
629
 
627
 
void drizzled::Session::unlink(session_id_t &session_id)
628
 
{
629
 
  Session::shared_ptr session= session::Cache::singleton().find(session_id);
630
 
 
631
 
  if (session)
632
 
    unlink(session);
633
 
}
634
 
 
635
630
void drizzled::Session::unlink(Session::shared_ptr &session)
636
631
{
637
 
  --connection_count;
 
632
  connection_count.decrement();
638
633
 
639
634
  session->cleanup();
640
635
 
665
660
 
666
661
static void find_plugin_dir(string progname)
667
662
{
668
 
  fs::path full_progname(fs::system_complete(progname));
669
 
 
670
 
  fs::path progdir(full_progname.parent_path());
671
 
  if (progdir.filename() == ".libs")
672
 
  {
673
 
    progdir= progdir.parent_path();
674
 
  }
675
 
 
676
 
  if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
 
663
  if (progname[0] != FN_LIBCHAR)
 
664
  {
 
665
    /* We have a relative path and need to find the absolute */
 
666
    char working_dir[FN_REFLEN];
 
667
    char *working_dir_ptr= working_dir;
 
668
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
 
669
    string new_path(working_dir);
 
670
    if (*(new_path.end()-1) != '/')
 
671
      new_path.push_back('/');
 
672
    if (progname[0] == '.' && progname[1] == '/')
 
673
      new_path.append(progname.substr(2));
 
674
    else
 
675
      new_path.append(progname);
 
676
    progname.swap(new_path);
 
677
  }
 
678
 
 
679
  /* Now, trim off the exe name */
 
680
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
 
681
  if (progdir.rfind(".libs/") != string::npos)
 
682
  {
 
683
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
 
684
  }
 
685
  string testlofile(progdir);
 
686
  testlofile.append("drizzled.lo");
 
687
  string testofile(progdir);
 
688
  testofile.append("drizzled.o");
 
689
  struct stat testfile_stat;
 
690
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
677
691
  {
678
692
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
679
 
    base_plugin_dir= progdir.parent_path();
 
693
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
 
694
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
680
695
    base_plugin_dir /= "plugin";
681
696
    base_plugin_dir /= ".libs";
682
697
  }
710
725
  global_system_variables.auto_increment_increment= 1;
711
726
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
712
727
  {
713
 
    cout << _("Error: Invalid Value for auto_increment_increment");
 
728
    cout << N_("Error: Invalid Value for auto_increment_increment");
714
729
    exit(-1);
715
730
  }
716
731
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
721
736
  global_system_variables.auto_increment_offset= 1;
722
737
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
723
738
  {
724
 
    cout << _("Error: Invalid Value for auto_increment_offset");
 
739
    cout << N_("Error: Invalid Value for auto_increment_offset");
725
740
    exit(-1);
726
741
  }
727
742
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
732
747
  global_system_variables.completion_type= 0;
733
748
  if (in_completion_type > 2)
734
749
  {
735
 
    cout << _("Error: Invalid Value for completion_type");
 
750
    cout << N_("Error: Invalid Value for completion_type");
736
751
    exit(-1);
737
752
  }
738
753
  global_system_variables.completion_type= in_completion_type;
744
759
  global_system_variables.div_precincrement= 4;
745
760
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
746
761
  {
747
 
    cout << _("Error: Invalid Value for div-precision-increment");
 
762
    cout << N_("Error: Invalid Value for div-precision-increment");
748
763
    exit(-1);
749
764
  }
750
765
  global_system_variables.div_precincrement= in_div_precincrement;
755
770
  global_system_variables.group_concat_max_len= 1024;
756
771
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
757
772
  {
758
 
    cout << _("Error: Invalid Value for group_concat_max_len");
 
773
    cout << N_("Error: Invalid Value for group_concat_max_len");
759
774
    exit(-1);
760
775
  }
761
776
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
766
781
  global_system_variables.join_buff_size= (128*1024L);
767
782
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
768
783
  {
769
 
    cout << _("Error: Invalid Value for join_buffer_size");
 
784
    cout << N_("Error: Invalid Value for join_buffer_size");
770
785
    exit(-1);
771
786
  }
772
787
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
778
793
  global_system_variables.max_allowed_packet= (64*1024*1024L);
779
794
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
780
795
  {
781
 
    cout << _("Error: Invalid Value for max_allowed_packet");
 
796
    cout << N_("Error: Invalid Value for max_allowed_packet");
782
797
    exit(-1);
783
798
  }
784
799
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
785
800
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
786
801
}
787
802
 
 
803
static void check_limits_mce(uint64_t in_max_connect_errors)
 
804
{
 
805
  max_connect_errors= MAX_CONNECT_ERRORS;
 
806
  if (in_max_connect_errors < 1 || in_max_connect_errors > ULONG_MAX)
 
807
  {
 
808
    cout << N_("Error: Invalid Value for max_connect_errors");
 
809
    exit(-1);
 
810
  }
 
811
  max_connect_errors= in_max_connect_errors;
 
812
}
 
813
 
788
814
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
789
815
{
790
816
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
791
817
  if (in_max_error_count > 65535)
792
818
  {
793
 
    cout << _("Error: Invalid Value for max_error_count");
 
819
    cout << N_("Error: Invalid Value for max_error_count");
794
820
    exit(-1);
795
821
  }
796
822
  global_system_variables.max_error_count= in_max_error_count;
801
827
  global_system_variables.max_heap_table_size= (16*1024*1024L);
802
828
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
803
829
  {
804
 
    cout << _("Error: Invalid Value for max_heap_table_size");
 
830
    cout << N_("Error: Invalid Value for max_heap_table_size");
805
831
    exit(-1);
806
832
  }
807
833
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
813
839
  global_system_variables.min_examined_row_limit= 0;
814
840
  if (in_min_examined_row_limit > ULONG_MAX)
815
841
  {
816
 
    cout << _("Error: Invalid Value for min_examined_row_limit");
 
842
    cout << N_("Error: Invalid Value for min_examined_row_limit");
817
843
    exit(-1);
818
844
  }
819
845
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
824
850
  global_system_variables.max_join_size= INT32_MAX;
825
851
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
826
852
  {
827
 
    cout << _("Error: Invalid Value for max_join_size");
 
853
    cout << N_("Error: Invalid Value for max_join_size");
828
854
    exit(-1);
829
855
  }
830
856
  global_system_variables.max_join_size= in_max_join_size;
835
861
  global_system_variables.max_length_for_sort_data= 1024;
836
862
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
837
863
  {
838
 
    cout << _("Error: Invalid Value for max_length_for_sort_data");
 
864
    cout << N_("Error: Invalid Value for max_length_for_sort_data");
839
865
    exit(-1);
840
866
  }
841
867
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
846
872
  global_system_variables.max_seeks_for_key= ULONG_MAX;
847
873
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
848
874
  {
849
 
    cout << _("Error: Invalid Value for max_seeks_for_key");
 
875
    cout << N_("Error: Invalid Value for max_seeks_for_key");
850
876
    exit(-1);
851
877
  }
852
878
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
857
883
  global_system_variables.max_sort_length= 1024;
858
884
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
859
885
  {
860
 
    cout << _("Error: Invalid Value for max_sort_length");
 
886
    cout << N_("Error: Invalid Value for max_sort_length");
861
887
    exit(-1);
862
888
  }
863
889
  global_system_variables.max_sort_length= in_max_sort_length;
868
894
  global_system_variables.optimizer_search_depth= 0;
869
895
  if (in_optimizer_search_depth > MAX_TABLES + 2)
870
896
  {
871
 
    cout << _("Error: Invalid Value for optimizer_search_depth");
 
897
    cout << N_("Error: Invalid Value for optimizer_search_depth");
872
898
    exit(-1);
873
899
  }
874
900
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
879
905
  global_system_variables.preload_buff_size= (32*1024L);
880
906
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
881
907
  {
882
 
    cout << _("Error: Invalid Value for preload_buff_size");
 
908
    cout << N_("Error: Invalid Value for preload_buff_size");
883
909
    exit(-1);
884
910
  }
885
911
  global_system_variables.preload_buff_size= in_preload_buff_size;
890
916
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
891
917
  if (in_query_alloc_block_size < 1024)
892
918
  {
893
 
    cout << _("Error: Invalid Value for query_alloc_block_size");
 
919
    cout << N_("Error: Invalid Value for query_alloc_block_size");
894
920
    exit(-1);
895
921
  }
896
922
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
902
928
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
903
929
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
904
930
  {
905
 
    cout << _("Error: Invalid Value for query_prealloc_size");
 
931
    cout << N_("Error: Invalid Value for query_prealloc_size");
906
932
    exit(-1);
907
933
  }
908
934
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
914
940
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
915
941
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
916
942
  {
917
 
    cout << _("Error: Invalid Value for range_alloc_block_size");
 
943
    cout << N_("Error: Invalid Value for range_alloc_block_size");
918
944
    exit(-1);
919
945
  }
920
946
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
926
952
  global_system_variables.read_buff_size= (128*1024L);
927
953
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
928
954
  {
929
 
    cout << _("Error: Invalid Value for read_buff_size");
 
955
    cout << N_("Error: Invalid Value for read_buff_size");
930
956
    exit(-1);
931
957
  }
932
958
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
938
964
  global_system_variables.read_rnd_buff_size= (256*1024L);
939
965
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
940
966
  {
941
 
    cout << _("Error: Invalid Value for read_rnd_buff_size");
 
967
    cout << N_("Error: Invalid Value for read_rnd_buff_size");
942
968
    exit(-1);
943
969
  }
944
970
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
949
975
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
950
976
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
951
977
  {
952
 
    cout << _("Error: Invalid Value for sort_buff_size");
 
978
    cout << N_("Error: Invalid Value for sort_buff_size");
953
979
    exit(-1);
954
980
  }
955
981
  global_system_variables.sortbuff_size= in_sortbuff_size;
960
986
  table_def_size= 128;
961
987
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
962
988
  {
963
 
    cout << _("Error: Invalid Value for table_def_size");
 
989
    cout << N_("Error: Invalid Value for table_def_size");
964
990
    exit(-1);
965
991
  }
966
992
  table_def_size= in_table_def_size;
971
997
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
972
998
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
973
999
  {
974
 
    cout << _("Error: Invalid Value for table_cache_size");
 
1000
    cout << N_("Error: Invalid Value for table_cache_size");
975
1001
    exit(-1);
976
1002
  }
977
1003
  table_cache_size= in_table_cache_size;
982
1008
  table_lock_wait_timeout= 50;
983
1009
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
984
1010
  {
985
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1011
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
986
1012
    exit(-1);
987
1013
  }
988
1014
  table_lock_wait_timeout= in_table_lock_wait_timeout;
998
1024
  global_system_variables.tmp_table_size= 16*1024*1024L;
999
1025
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
1000
1026
  {
1001
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
 
1027
    cout << N_("Error: Invalid Value for table_lock_wait_timeout");
1002
1028
    exit(-1);
1003
1029
  }
1004
1030
  global_system_variables.tmp_table_size= in_tmp_table_size;
1006
1032
 
1007
1033
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1008
1034
{
1009
 
  transaction_message_threshold= 1024*1024;
 
1035
  global_system_variables.transaction_message_threshold= 1024*1024;
1010
1036
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1011
1037
  {
1012
 
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
 
1038
    cout << N_("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1013
1039
    exit(-1);
1014
1040
  }
1015
 
  transaction_message_threshold= in_transaction_message_threshold;
 
1041
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
1016
1042
}
1017
1043
 
1018
1044
static void process_defaults_files()
1066
1092
      defaults_file_list.push_back(*it);
1067
1093
    else
1068
1094
    {
1069
 
      errmsg_printf(error::ERROR,
 
1095
      errmsg_printf(ERRMSG_LVL_ERROR,
1070
1096
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1071
1097
      unireg_abort(1);
1072
1098
    }
1074
1100
  }
1075
1101
}
1076
1102
 
1077
 
int init_basic_variables(int argc, char **argv)
 
1103
int init_common_variables(int argc, char **argv, module::Registry &plugins)
1078
1104
{
1079
1105
  time_t curr_time;
1080
1106
  umask(((~internal::my_umask) & 0666));
1081
 
  decimal_zero.set_zero(); // set decimal_zero constant;
 
1107
  my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
1082
1108
  tzset();                      // Set tzname
1083
1109
 
1084
1110
  curr_time= time(NULL);
1091
1117
  drizzle_init_variables();
1092
1118
 
1093
1119
  find_plugin_dir(argv[0]);
 
1120
  {
 
1121
    struct tm tm_tmp;
 
1122
    localtime_r(&server_start_time,&tm_tmp);
 
1123
    strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
 
1124
            sizeof(system_time_zone)-1);
1094
1125
 
 
1126
  }
1095
1127
  /*
1096
1128
    We set SYSTEM time zone as reasonable default and
1097
1129
    also for failure of my_tz_init() and bootstrap mode.
1100
1132
  */
1101
1133
  global_system_variables.time_zone= my_tz_SYSTEM;
1102
1134
 
1103
 
  char ret_hostname[FN_REFLEN];
1104
 
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
 
1135
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1105
1136
  {
1106
 
    errmsg_printf(error::WARN,
1107
 
                  _("gethostname failed, using '%s' as hostname"),
1108
 
                  getServerHostname().c_str());
 
1137
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
 
1138
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
 
1139
                  glob_hostname);
1109
1140
    pid_file= "drizzle";
1110
1141
  }
1111
1142
  else
1112
1143
  {
1113
 
    setServerHostname(ret_hostname);
1114
 
    pid_file= getServerHostname();
 
1144
    pid_file= glob_hostname;
1115
1145
  }
1116
1146
  pid_file.replace_extension(".pid");
1117
1147
 
1119
1149
 
1120
1150
  config_options.add_options()
1121
1151
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1122
 
  _("Display this help and exit."))
1123
 
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1124
 
  _("Run as a daemon."))
 
1152
  N_("Display this help and exit."))
1125
1153
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1126
 
  _("Configuration file defaults are not used if no-defaults is set"))
 
1154
  N_("Configuration file defaults are not used if no-defaults is set"))
1127
1155
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1128
 
  _("Configuration file to use"))
 
1156
   N_("Configuration file to use"))
1129
1157
  ("config-dir", po::value<fs::path>(&system_config_dir),
1130
 
  _("Base location for config files"))
 
1158
   N_("Base location for config files"))
1131
1159
  ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
1132
 
  _("Directory for plugins."))
 
1160
  N_("Directory for plugins."))
1133
1161
  ;
1134
1162
 
1135
1163
  plugin_load_options.add_options()
1136
1164
  ("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1137
 
  _("Optional comma separated list of plugins to load at startup in addition "
 
1165
  N_("Optional comma separated list of plugins to load at startup in addition "
1138
1166
     "to the default list of plugins. "
1139
1167
     "[for example: --plugin_add=crc32,logger_gearman]"))    
1140
1168
  ("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1141
 
  _("Optional comma separated list of plugins to not load at startup. Effectively "
 
1169
  N_("Optional comma separated list of plugins to not load at startup. Effectively "
1142
1170
     "removes a plugin from the list of plugins to be loaded. "
1143
1171
     "[for example: --plugin_remove=crc32,logger_gearman]"))
1144
1172
  ("plugin-load", po::value<string>()->notifier(&notify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1145
 
  _("Optional comma separated list of plugins to load at starup instead of "
 
1173
  N_("Optional comma separated list of plugins to load at starup instead of "
1146
1174
     "the default plugin load list. "
1147
1175
     "[for example: --plugin_load=crc32,logger_gearman]"))
1148
1176
  ;
1149
1177
 
1150
1178
  long_options.add_options()
1151
1179
  ("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1152
 
  _("Auto-increment columns are incremented by this"))
 
1180
  N_("Auto-increment columns are incremented by this"))
1153
1181
  ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1154
 
  _("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
 
1182
  N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1155
1183
  ("basedir,b", po::value<fs::path>(&basedir),
1156
 
  _("Path to installation directory. All paths are usually resolved "
 
1184
  N_("Path to installation directory. All paths are usually resolved "
1157
1185
     "relative to this."))
1158
1186
  ("chroot,r", po::value<string>(),
1159
 
  _("Chroot drizzled daemon during startup."))
 
1187
  N_("Chroot drizzled daemon during startup."))
1160
1188
  ("collation-server", po::value<string>(),
1161
 
  _("Set the default collation."))      
 
1189
  N_("Set the default collation."))      
1162
1190
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1163
 
  _("Default completion type."))
1164
 
  ("core-file",  _("Write core on errors."))
1165
 
  ("datadir", po::value<fs::path>(&getDataHome()),
1166
 
  _("Path to the database root."))
 
1191
  N_("Default completion type."))
 
1192
  ("core-file",  N_("Write core on errors."))
 
1193
  ("datadir", po::value<fs::path>(&data_home),
 
1194
  N_("Path to the database root."))
1167
1195
  ("default-storage-engine", po::value<string>(),
1168
 
  _("Set the default storage engine for tables."))
 
1196
  N_("Set the default storage engine for tables."))
1169
1197
  ("default-time-zone", po::value<string>(),
1170
 
  _("Set the default time zone."))
 
1198
  N_("Set the default time zone."))
1171
1199
  ("exit-info,T", po::value<long>(),
1172
 
  _("Used for debugging;  Use at your own risk!"))
 
1200
  N_("Used for debugging;  Use at your own risk!"))
1173
1201
  ("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1174
 
  _("Set up signals usable for debugging"))
 
1202
  N_("Set up signals usable for debugging"))
1175
1203
  ("lc-time-name", po::value<string>(),
1176
 
  _("Set the language used for the month names and the days of the week."))
 
1204
  N_("Set the language used for the month names and the days of the week."))
1177
1205
  ("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
1178
 
  _("Log some not critical warnings to the log file."))  
 
1206
  N_("Log some not critical warnings to the log file."))  
1179
1207
  ("pid-file", po::value<fs::path>(&pid_file),
1180
 
  _("Pid file used by drizzled."))
 
1208
  N_("Pid file used by drizzled."))
1181
1209
  ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1182
 
  _("Maximum time in seconds to wait for the port to become free. "))
 
1210
  N_("Maximum time in seconds to wait for the port to become free. "))
1183
1211
  ("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1184
 
  _("Include the SQL query in replicated protobuf messages."))
 
1212
  N_("Include the SQL query in replicated protobuf messages."))
1185
1213
  ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1186
 
  _("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
 
1214
  N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1187
1215
     "within specified directory"))
1188
1216
  ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1189
 
  _("Uniquely identifies the server instance in the community of "
 
1217
  N_("Uniquely identifies the server instance in the community of "
1190
1218
     "replication partners."))
1191
1219
  ("skip-stack-trace",  
1192
 
  _("Don't print a stack trace on failure."))
 
1220
  N_("Don't print a stack trace on failure."))
1193
1221
  ("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1194
 
  _("Enable symbolic link support."))
 
1222
  N_("Enable symbolic link support."))
1195
1223
  ("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1196
 
  _("Specify whether to time mutexes (only InnoDB mutexes are currently "
 
1224
  N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1197
1225
     "supported)")) 
1198
1226
  ("tmpdir,t", po::value<string>(),
1199
 
  _("Path for temporary files."))
 
1227
  N_("Path for temporary files."))
1200
1228
  ("transaction-isolation", po::value<string>(),
1201
 
  _("Default transaction isolation level."))
1202
 
  ("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1203
 
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
 
1229
  N_("Default transaction isolation level."))
 
1230
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
 
1231
  N_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1204
1232
  ("user,u", po::value<string>(),
1205
 
  _("Run drizzled daemon as user."))  
 
1233
  N_("Run drizzled daemon as user."))  
1206
1234
  ("version,V", 
1207
 
  _("Output version information and exit."))
 
1235
  N_("Output version information and exit."))
1208
1236
  ("back-log", po::value<back_log_constraints>(&back_log),
1209
 
  _("The number of outstanding connection requests Drizzle can have. This "
 
1237
  N_("The number of outstanding connection requests Drizzle can have. This "
1210
1238
     "comes into play when the main Drizzle thread gets very many connection "
1211
1239
     "requests in a very short time."))
1212
1240
  ("bulk-insert-buffer-size", 
1213
1241
  po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1214
 
  _("Size of tree cache used in bulk insert optimization. Note that this is "
 
1242
  N_("Size of tree cache used in bulk insert optimization. Note that this is "
1215
1243
     "a limit per thread!"))
1216
1244
  ("div-precision-increment",  po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1217
 
  _("Precision of the result of '/' operator will be increased on that "
 
1245
  N_("Precision of the result of '/' operator will be increased on that "
1218
1246
     "value."))
1219
1247
  ("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1220
 
  _("The maximum length of the result of function  group_concat."))
 
1248
  N_("The maximum length of the result of function  group_concat."))
1221
1249
  ("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1222
 
  _("The size of the buffer that is used for full joins."))
 
1250
  N_("The size of the buffer that is used for full joins."))
1223
1251
  ("join-heap-threshold",
1224
1252
  po::value<uint64_t>()->default_value(0),
1225
 
  _("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
 
1253
  N_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1226
1254
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1227
 
  _("Max packetlength to send/receive from to server."))
 
1255
  N_("Max packetlength to send/receive from to server."))
 
1256
  ("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
 
1257
  N_("If there is more than this number of interrupted connections from a "
 
1258
     "host this host will be blocked from further connections."))
1228
1259
  ("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1229
 
  _("Max number of errors/warnings to store for a statement."))
 
1260
  N_("Max number of errors/warnings to store for a statement."))
1230
1261
  ("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1231
 
  _("Don't allow creation of heap tables bigger than this."))
 
1262
  N_("Don't allow creation of heap tables bigger than this."))
1232
1263
  ("max-join-size", po::value<drizzled::ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1233
 
  _("Joins that are probably going to read more than max_join_size records "
 
1264
  N_("Joins that are probably going to read more than max_join_size records "
1234
1265
     "return an error."))
1235
1266
  ("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1236
 
  _("Max number of bytes in sorted records."))
 
1267
  N_("Max number of bytes in sorted records."))
1237
1268
  ("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1238
 
  _("Limit assumed max number of seeks when looking up rows based on a key"))
 
1269
  N_("Limit assumed max number of seeks when looking up rows based on a key"))
1239
1270
  ("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),  
1240
 
  _("The number of bytes to use when sorting BLOB or TEXT values "
 
1271
  N_("The number of bytes to use when sorting BLOB or TEXT values "
1241
1272
     "(only the first max_sort_length bytes of each value are used; the "
1242
1273
     "rest are ignored)."))
1243
1274
  ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1244
 
  _("After this many write locks, allow some read locks to run in between."))
 
1275
  N_("After this many write locks, allow some read locks to run in between."))
1245
1276
  ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1246
 
  _("Don't log queries which examine less than min_examined_row_limit "
 
1277
  N_("Don't log queries which examine less than min_examined_row_limit "
1247
1278
     "rows to file."))
1248
1279
  ("disable-optimizer-prune",
1249
 
  _("Do not apply any heuristic(s) during query optimization to prune, "
 
1280
  N_("Do not apply any heuristic(s) during query optimization to prune, "
1250
1281
     "thus perform an exhaustive search from the optimizer search space."))
1251
1282
  ("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1252
 
  _("Maximum depth of search performed by the query optimizer. Values "
 
1283
  N_("Maximum depth of search performed by the query optimizer. Values "
1253
1284
     "larger than the number of relations in a query result in better query "
1254
1285
     "plans, but take longer to compile a query. Smaller values than the "
1255
1286
     "number of tables in a relation result in faster optimization, but may "
1258
1289
     "optimizer will switch to the original find_best (used for "
1259
1290
     "testing/comparison)."))
1260
1291
  ("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1261
 
  _("The size of the buffer that is allocated when preloading indexes"))
 
1292
  N_("The size of the buffer that is allocated when preloading indexes"))
1262
1293
  ("query-alloc-block-size", 
1263
1294
  po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1264
 
  _("Allocation block size for query parsing and execution"))
 
1295
  N_("Allocation block size for query parsing and execution"))
1265
1296
  ("query-prealloc-size",
1266
1297
  po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1267
 
  _("Persistent buffer for query parsing and execution"))
 
1298
  N_("Persistent buffer for query parsing and execution"))
1268
1299
  ("range-alloc-block-size",
1269
1300
  po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1270
 
  _("Allocation block size for storing ranges during optimization"))
 
1301
  N_("Allocation block size for storing ranges during optimization"))
1271
1302
  ("read-buffer-size",
1272
1303
  po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1273
 
  _("Each thread that does a sequential scan allocates a buffer of this "
 
1304
  N_("Each thread that does a sequential scan allocates a buffer of this "
1274
1305
      "size for each table it scans. If you do many sequential scans, you may "
1275
1306
      "want to increase this value."))
1276
1307
  ("read-buffer-threshold",
1277
1308
  po::value<uint64_t>()->default_value(0),
1278
 
  _("A global cap on the size of read-buffer-size (0 means unlimited)"))
 
1309
  N_("A global cap on the size of read-buffer-size (0 means unlimited)"))
1279
1310
  ("read-rnd-buffer-size",
1280
1311
  po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1281
 
  _("When reading rows in sorted order after a sort, the rows are read "
 
1312
  N_("When reading rows in sorted order after a sort, the rows are read "
1282
1313
     "through this buffer to avoid a disk seeks. If not set, then it's set "
1283
1314
     "to the value of record_buffer."))
1284
1315
  ("read-rnd-threshold",
1285
1316
  po::value<uint64_t>()->default_value(0),
1286
 
  _("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
 
1317
  N_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1287
1318
  ("scheduler", po::value<string>(),
1288
 
  _("Select scheduler to be used (by default multi-thread)."))
 
1319
  N_("Select scheduler to be used (by default multi-thread)."))
1289
1320
  ("sort-buffer-size",
1290
1321
  po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1291
 
  _("Each thread that needs to do a sort allocates a buffer of this size."))
 
1322
  N_("Each thread that needs to do a sort allocates a buffer of this size."))
1292
1323
  ("sort-heap-threshold",
1293
1324
  po::value<uint64_t>()->default_value(0),
1294
 
  _("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
 
1325
  N_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1295
1326
  ("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1296
 
  _("The number of cached table definitions."))
 
1327
  N_("The number of cached table definitions."))
1297
1328
  ("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1298
 
  _("The number of cached open tables."))
 
1329
  N_("The number of cached open tables."))
1299
1330
  ("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1300
 
  _("Timeout in seconds to wait for a table level lock before returning an "
 
1331
  N_("Timeout in seconds to wait for a table level lock before returning an "
1301
1332
     "error. Used only if the connection has active cursors."))
1302
1333
  ("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1303
 
  _("The stack size for each thread."))
 
1334
  N_("The stack size for each thread."))
1304
1335
  ("tmp-table-size", 
1305
1336
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1306
 
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
 
1337
  N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1307
1338
     " automatically convert it to an on-disk MyISAM table."))
1308
 
  ("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
1309
 
  _("The stack size for each thread."))
1310
1339
  ;
1311
1340
 
1312
1341
  full_options.add(long_options);
1326
1355
  {
1327
1356
    po::store(parsed, vm);
1328
1357
  }
1329
 
  catch (std::exception&)
 
1358
  catch (...)
1330
1359
  {
1331
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
 
1360
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1332
1361
    unireg_abort(1);
1333
1362
  }
1334
1363
 
1374
1403
  }
1375
1404
  catch (po::validation_error &err)
1376
1405
  {
1377
 
    errmsg_printf(error::ERROR,  
 
1406
    errmsg_printf(ERRMSG_LVL_ERROR,  
1378
1407
                  _("%s: %s.\n"
1379
1408
                    "Use --help to get a list of available options\n"),
1380
1409
                  internal::my_progname, err.what());
1392
1421
  }
1393
1422
  catch (po::validation_error &err)
1394
1423
  {
1395
 
    errmsg_printf(error::ERROR,
 
1424
    errmsg_printf(ERRMSG_LVL_ERROR,
1396
1425
                  _("%s: %s.\n"
1397
1426
                    "Use --help to get a list of available options\n"),
1398
1427
                  internal::my_progname, err.what());
1399
1428
    unireg_abort(1);
1400
1429
  }
1401
1430
 
1402
 
  return 0;
1403
 
}
1404
 
 
1405
 
int init_remaining_variables(module::Registry &plugins)
1406
 
{
1407
 
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1408
 
 
1409
 
  current_pid= getpid();                /* Save for later ref */
1410
 
 
1411
1431
  /* At this point, we've read all the options we need to read from files and
1412
1432
     collected most of them into unknown options - now let's load everything
1413
1433
  */
1414
1434
 
1415
1435
  if (plugin_init(plugins, plugin_options))
1416
1436
  {
1417
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
 
1437
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1418
1438
    unireg_abort(1);
1419
1439
  }
1420
1440
 
1435
1455
  }
1436
1456
  catch (po::validation_error &err)
1437
1457
  {
1438
 
    errmsg_printf(error::ERROR,
 
1458
    errmsg_printf(ERRMSG_LVL_ERROR,
1439
1459
                  _("%s: %s.\n"
1440
1460
                    "Use --help to get a list of available options\n"),
1441
1461
                  internal::my_progname, err.what());
1443
1463
  }
1444
1464
  catch (po::invalid_command_line_syntax &err)
1445
1465
  {
1446
 
    errmsg_printf(error::ERROR,
 
1466
    errmsg_printf(ERRMSG_LVL_ERROR,
1447
1467
                  _("%s: %s.\n"
1448
1468
                    "Use --help to get a list of available options\n"),
1449
1469
                  internal::my_progname, err.what());
1451
1471
  }
1452
1472
  catch (po::unknown_option &err)
1453
1473
  {
1454
 
    errmsg_printf(error::ERROR,
 
1474
    errmsg_printf(ERRMSG_LVL_ERROR,
1455
1475
                  _("%s\nUse --help to get a list of available options\n"),
1456
1476
                  err.what());
1457
1477
    unireg_abort(1);
1463
1483
  }
1464
1484
  catch (po::validation_error &err)
1465
1485
  {
1466
 
    errmsg_printf(error::ERROR,  
 
1486
    errmsg_printf(ERRMSG_LVL_ERROR,  
1467
1487
                  _("%s: %s.\n"
1468
1488
                    "Use --help to get a list of available options\n"),
1469
1489
                  internal::my_progname, err.what());
1487
1507
 
1488
1508
  fix_paths();
1489
1509
 
 
1510
  current_pid= getpid();                /* Save for later ref */
1490
1511
  init_time();                          /* Init time-functions (read zone) */
1491
1512
 
1492
1513
  if (item_create_init())
1500
1521
  if (!(default_charset_info=
1501
1522
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1502
1523
  {
1503
 
    errmsg_printf(error::ERROR, _("Error getting default charset"));
 
1524
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1504
1525
    return 1;                           // Eof of the list
1505
1526
  }
1506
1527
 
1512
1533
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1513
1534
    if (not default_collation)
1514
1535
    {
1515
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1536
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1516
1537
      return 1;
1517
1538
    }
1518
1539
    if (not my_charset_same(default_charset_info, default_collation))
1519
1540
    {
1520
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1541
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1521
1542
                    default_collation_name,
1522
1543
                    default_charset_info->csname);
1523
1544
      return 1;
1530
1551
  if (not (character_set_filesystem=
1531
1552
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1532
1553
  {
1533
 
    errmsg_printf(error::ERROR, _("Error setting collation"));
 
1554
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
1534
1555
    return 1;
1535
1556
  }
1536
1557
  global_system_variables.character_set_filesystem= character_set_filesystem;
1538
1559
  if (!(my_default_lc_time_names=
1539
1560
        my_locale_by_name(lc_time_names_name)))
1540
1561
  {
1541
 
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1562
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1542
1563
    return 1;
1543
1564
  }
1544
1565
  global_system_variables.lc_time_names= my_default_lc_time_names;
1558
1579
  */
1559
1580
  if (table_cache_init())
1560
1581
  {
1561
 
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
 
1582
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
1562
1583
    unireg_abort(1);
1563
1584
  }
1564
1585
 
1573
1594
 
1574
1595
  if (xid_cache_init())
1575
1596
  {
1576
 
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1597
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1577
1598
    unireg_abort(1);
1578
1599
  }
1579
1600
 
1602
1623
 
1603
1624
  if (plugin::Scheduler::setPlugin(scheduler_name))
1604
1625
  {
1605
 
      errmsg_printf(error::ERROR,
 
1626
      errmsg_printf(ERRMSG_LVL_ERROR,
1606
1627
                   _("No scheduler found, cannot continue!\n"));
1607
1628
      unireg_abort(1);
1608
1629
  }
1627
1648
    engine= plugin::StorageEngine::findByName(name);
1628
1649
    if (engine == NULL)
1629
1650
    {
1630
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1651
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1631
1652
                    default_storage_engine_str);
1632
1653
      unireg_abort(1);
1633
1654
    }
1668
1689
  OPT_BACK_LOG,
1669
1690
  OPT_JOIN_BUFF_SIZE,
1670
1691
  OPT_MAX_ALLOWED_PACKET,
 
1692
  OPT_MAX_CONNECT_ERRORS,
1671
1693
  OPT_MAX_HEP_TABLE_SIZE,
1672
1694
  OPT_MAX_JOIN_SIZE,
1673
1695
  OPT_MAX_SORT_LENGTH,
1721
1743
  {"help", '?', N_("Display this help and exit."),
1722
1744
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1723
1745
   0, 0},
1724
 
  {"daemon", 'd', N_("Run as daemon."),
1725
 
   (char**) &opt_daemon, (char**) &opt_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1726
 
   0, 0},
1727
1746
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1728
1747
   N_("Auto-increment columns are incremented by this"),
1729
1748
   (char**) &global_system_variables.auto_increment_increment,
1760
1779
  {"datadir", 'h',
1761
1780
   N_("Path to the database root."),
1762
1781
   NULL, NULL, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1782
  {"default-storage-engine", OPT_STORAGE_ENGINE,
 
1783
   N_("Set the default storage engine (table type) for tables."),
 
1784
   (char**)&default_storage_engine_str, (char**)&default_storage_engine_str,
 
1785
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1786
  {"default-time-zone", OPT_DEFAULT_TIME_ZONE,
 
1787
   N_("Set the default time zone."),
 
1788
   (char**) &default_tz_name, (char**) &default_tz_name,
 
1789
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1763
1790
  /* See how it's handled in get_one_option() */
1764
1791
  {"exit-info", 'T',
1765
1792
   N_("Used for debugging;  Use at your own risk!"),
1770
1797
   N_("Set up signals usable for debugging"),
1771
1798
   (char**) &opt_debugging, (char**) &opt_debugging,
1772
1799
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
1800
  {"lc-time-names", OPT_LC_TIME_NAMES,
 
1801
   N_("Set the language used for the month names and the days of the week."),
 
1802
   (char**) &lc_time_names_name,
 
1803
   (char**) &lc_time_names_name,
 
1804
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1773
1805
  {"log-warnings", 'W',
1774
1806
   N_("Log some not critical warnings to the log file."),
1775
1807
   (char**) &global_system_variables.log_warnings,
1812
1844
      "supported)"),
1813
1845
   (char**) &internal::timed_mutexes, (char**) &internal::timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
1814
1846
    0, 0, 0, 0, 0},
 
1847
  {"tmpdir", 't',
 
1848
   N_("Path for temporary files."),
 
1849
   (char**) &opt_drizzle_tmpdir,
 
1850
   (char**) &opt_drizzle_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1815
1851
  {"transaction-isolation", OPT_TX_ISOLATION,
1816
1852
   N_("Default transaction isolation level."),
1817
1853
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
1820
1856
   N_("Run drizzled daemon as user."),
1821
1857
   0, 0, 0, GET_STR, REQUIRED_ARG,
1822
1858
   0, 0, 0, 0, 0, 0},
 
1859
  {"version", 'V',
 
1860
   N_("Output version information and exit."),
 
1861
   0, 0, 0, GET_NO_ARG,
 
1862
   NO_ARG, 0, 0, 0, 0, 0, 0},
1823
1863
  {"back_log", OPT_BACK_LOG,
1824
1864
   N_("The number of outstanding connection requests Drizzle can have. This "
1825
1865
      "comes into play when the main Drizzle thread gets very many connection "
1838
1878
   (char**) &global_system_variables.div_precincrement,
1839
1879
   (char**) &max_system_variables.div_precincrement, 0, GET_UINT,
1840
1880
   REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
 
1881
  { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
 
1882
    N_("The maximum length of the result of function  group_concat."),
 
1883
    (char**) &global_system_variables.group_concat_max_len,
 
1884
    (char**) &max_system_variables.group_concat_max_len, 0, GET_UINT64,
 
1885
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
1841
1886
  { "join_buffer_size", OPT_JOIN_BUFF_SIZE,
1842
1887
    N_("The size of the buffer that is used for full joins."),
1843
1888
   (char**) &global_system_variables.join_buff_size,
1849
1894
   (char**) &global_system_variables.max_allowed_packet,
1850
1895
   (char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1851
1896
   REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
1897
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
 
1898
   N_("If there is more than this number of interrupted connections from a "
 
1899
      "host this host will be blocked from further connections."),
 
1900
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
 
1901
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
 
1902
  {"max_error_count", OPT_MAX_ERROR_COUNT,
 
1903
   N_("Max number of errors/warnings to store for a statement."),
 
1904
   (char**) &global_system_variables.max_error_count,
 
1905
   (char**) &max_system_variables.max_error_count,
 
1906
   0, GET_UINT64, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
1852
1907
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1853
1908
   N_("Don't allow creation of heap tables bigger than this."),
1854
1909
   (char**) &global_system_variables.max_heap_table_size,
1968
2023
   (char**) &max_system_variables.read_rnd_buff_size, 0,
1969
2024
   GET_UINT, REQUIRED_ARG, 256*1024L, 64 /*IO_SIZE*2+MALLOC_OVERHEAD*/ ,
1970
2025
   UINT32_MAX, MALLOC_OVERHEAD, 1 /* Small lower limit to be able to test MRR */, 0},
 
2026
  {"scheduler", OPT_SCHEDULER,
 
2027
   N_("Select scheduler to be used (by default multi-thread)."),
 
2028
   (char**)&opt_scheduler, (char**)&opt_scheduler,
 
2029
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1971
2030
  /* x8 compared to MySQL's x2. We have UTF8 to consider. */
1972
2031
  {"sort_buffer_size", OPT_SORT_BUFFER,
1973
2032
   N_("Each thread that needs to do a sort allocates a buffer of this size."),
2061
2120
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
2062
2121
  cleanup_done= 0;
2063
2122
  dropping_tables= ha_open_options=0;
2064
 
  getDebug().reset();
 
2123
  test_flags.reset();
2065
2124
  wake_thread=0;
2066
2125
  abort_loop= select_thread_in_use= false;
2067
 
  shutdown_in_progress= 0;
 
2126
  ready_to_exit= shutdown_in_progress= 0;
2068
2127
  drizzled_user= drizzled_chroot= 0;
2069
2128
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2070
2129
  key_map_full.set();
2129
2188
#else
2130
2189
  have_symlink=SHOW_OPTION_YES;
2131
2190
#endif
 
2191
 
 
2192
  connection_count= 0;
2132
2193
}
2133
2194
 
2134
2195
 
2149
2210
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2150
2211
 
2151
2212
    else
2152
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2213
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2153
2214
                                       "set to '%s' earlier on the command line\n"),
2154
2215
                    vm["user"].as<string>().c_str(), drizzled_user);
2155
2216
  }
2166
2227
      (vm["sort-heap-threshold"].as<uint64_t>() < 
2167
2228
      global_system_variables.sortbuff_size))
2168
2229
    {
2169
 
      cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
 
2230
      cout << N_("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2170
2231
      exit(-1);
2171
2232
    }
2172
2233
 
2179
2240
      (vm["join-heap-threshold"].as<uint64_t>() <
2180
2241
      global_system_variables.join_buff_size))
2181
2242
    {
2182
 
      cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
 
2243
      cout << N_("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2183
2244
      exit(-1);
2184
2245
    }
2185
2246
 
2192
2253
      (vm["read-rnd-threshold"].as<uint64_t>() <
2193
2254
      global_system_variables.read_rnd_buff_size))
2194
2255
    {
2195
 
      cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
 
2256
      cout << N_("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2196
2257
      exit(-1);
2197
2258
    }
2198
2259
 
2205
2266
      (vm["read-buffer-threshold"].as<uint64_t>() <
2206
2267
      global_system_variables.read_buff_size))
2207
2268
    {
2208
 
      cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
 
2269
      cout << N_("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2209
2270
      exit(-1);
2210
2271
    }
2211
2272
 
2216
2277
  {
2217
2278
    if (vm["exit-info"].as<long>())
2218
2279
    {
2219
 
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
 
2280
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
2220
2281
    }
2221
2282
  }
2222
2283
 
2223
2284
  if (vm.count("want-core"))
2224
2285
  {
2225
 
    getDebug().set(debug::CORE_ON_SIGNAL);
 
2286
    test_flags.set(TEST_CORE_ON_SIGNAL);
2226
2287
  }
2227
2288
 
2228
2289
  if (vm.count("skip-stack-trace"))
2229
2290
  {
2230
 
    getDebug().set(debug::NO_STACKTRACE);
 
2291
    test_flags.set(TEST_NO_STACKTRACE);
2231
2292
  }
2232
2293
 
2233
2294
  if (vm.count("skip-symlinks"))
2237
2298
 
2238
2299
  if (vm.count("transaction-isolation"))
2239
2300
  {
2240
 
    int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
2241
 
    global_system_variables.tx_isolation= type - 1;
 
2301
    int type;
 
2302
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2303
    global_system_variables.tx_isolation= (type-1);
2242
2304
  }
2243
2305
 
2244
2306
  /* @TODO Make this all strings */
2265
2327
  if (opt_debugging)
2266
2328
  {
2267
2329
    /* Allow break with SIGINT, no core or stack trace */
2268
 
    getDebug().set(debug::ALLOW_SIGINT);
2269
 
    getDebug().set(debug::NO_STACKTRACE);
2270
 
    getDebug().reset(debug::CORE_ON_SIGNAL);
 
2330
    test_flags.set(TEST_SIGINT);
 
2331
    test_flags.set(TEST_NO_STACKTRACE);
 
2332
    test_flags.reset(TEST_CORE_ON_SIGNAL);
2271
2333
  }
2272
2334
 
2273
2335
  if (drizzled_chroot)
2319
2381
    {
2320
2382
      if (errno != EEXIST)
2321
2383
      {
2322
 
        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());
 
2384
        perror(drizzle_tmpdir.c_str());
2323
2385
        exit(1);
2324
2386
      }
2325
2387
    }
2326
2388
 
2327
2389
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2328
2390
    {
2329
 
      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());
 
2391
      perror(drizzle_tmpdir.c_str());
2330
2392
      exit(1);
2331
2393
    }
2332
2394
  }