~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:13:33 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051333-pz1xy0f1dyc4jfms
talk about statement rollback (briefly) in replication docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
21
 
 
22
 
#include <drizzled/configmake.h>
23
 
#include <drizzled/atomics.h>
24
 
#include <drizzled/data_home.h>
 
21
#include "drizzled/configmake.h"
 
22
#include "drizzled/atomics.h"
 
23
#include "drizzled/data_home.h"
25
24
 
26
25
#include <netdb.h>
27
26
#include <sys/types.h>
32
31
#include <stdexcept>
33
32
 
34
33
#include <boost/program_options.hpp>
35
 
#include <drizzled/program_options/config_file.h>
 
34
#include "drizzled/program_options/config_file.h"
36
35
#include <boost/thread/recursive_mutex.hpp>
37
36
#include <boost/thread/mutex.hpp>
38
37
#include <boost/thread/shared_mutex.hpp>
40
39
#include <boost/filesystem.hpp>
41
40
#include <boost/detail/atomic_count.hpp>
42
41
 
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>
 
42
#include "drizzled/internal/my_sys.h"
 
43
#include "drizzled/internal/my_bit.h"
 
44
#include <drizzled/my_hash.h>
 
45
#include <drizzled/error.h>
49
46
#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>
 
47
#include <drizzled/tztime.h>
 
48
#include <drizzled/sql_base.h>
 
49
#include <drizzled/show.h>
 
50
#include <drizzled/sql_parse.h>
54
51
#include <drizzled/item/cmpfunc.h>
 
52
#include <drizzled/session.h>
55
53
#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
54
#include <drizzled/unireg.h>
78
 
#include <plugin/myisam/myisam.h>
79
 
 
80
 
#include "drizzled/visibility.h"
 
55
#include "drizzled/temporal_format.h" /* For init_temporal_formats() */
 
56
#include "drizzled/plugin/listen.h"
 
57
#include "drizzled/plugin/error_message.h"
 
58
#include "drizzled/plugin/client.h"
 
59
#include "drizzled/plugin/scheduler.h"
 
60
#include "drizzled/plugin/xa_resource_manager.h"
 
61
#include "drizzled/plugin/monitored_in_transaction.h"
 
62
#include "drizzled/replication_services.h" /* For ReplicationServices::evaluateRegisteredPlugins() */
 
63
#include "drizzled/probes.h"
 
64
#include "drizzled/session/cache.h"
 
65
#include "drizzled/charset.h"
 
66
#include "plugin/myisam/myisam.h"
 
67
#include "drizzled/drizzled.h"
 
68
#include "drizzled/module/registry.h"
 
69
#include "drizzled/module/load_list.h"
 
70
#include "drizzled/global_buffer.h"
 
71
 
 
72
#include "drizzled/definition/cache.h"
 
73
 
 
74
#include "drizzled/plugin/event_observer.h"
 
75
 
 
76
#include "drizzled/message/cache.h"
81
77
 
82
78
#include <google/protobuf/stubs/common.h>
83
79
 
84
 
#include <drizzled/refresh_version.h>
85
 
 
86
80
#if TIME_WITH_SYS_TIME
87
81
# include <sys/time.h>
88
82
# include <time.h>
158
152
namespace po=boost::program_options;
159
153
namespace dpo=drizzled::program_options;
160
154
 
161
 
bool opt_daemon= false;
162
155
 
163
156
namespace drizzled
164
157
{
234
227
 
235
228
/* Global variables */
236
229
 
 
230
bool volatile ready_to_exit;
237
231
char *drizzled_user;
238
232
bool volatile select_thread_in_use;
239
233
bool volatile abort_loop;
240
 
DRIZZLED_API bool volatile shutdown_in_progress;
 
234
bool volatile shutdown_in_progress;
241
235
char *opt_scheduler_default;
242
236
const char *opt_scheduler= NULL;
243
237
 
244
 
DRIZZLED_API size_t my_thread_stack_size= 0;
 
238
size_t my_thread_stack_size= 0;
245
239
 
246
240
/*
247
241
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
252
246
bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
253
247
 
254
248
uint32_t drizzled_bind_timeout;
 
249
std::bitset<12> test_flags;
255
250
uint32_t dropping_tables, ha_open_options;
256
251
uint32_t tc_heuristic_recover= 0;
257
252
uint64_t session_startup_options;
258
253
back_log_constraints back_log(50);
259
 
DRIZZLED_API uint32_t server_id;
 
254
uint32_t server_id;
260
255
uint64_t table_cache_size;
261
256
size_t table_def_size;
 
257
uint64_t max_connect_errors;
262
258
uint32_t global_thread_id= 1UL;
263
259
pid_t current_pid;
264
260
 
310
306
 
311
307
char system_time_zone[30];
312
308
char *default_tz_name;
313
 
DRIZZLED_API char glob_hostname[FN_REFLEN];
 
309
char glob_hostname[FN_REFLEN];
314
310
 
315
311
char *opt_tc_log_file;
316
312
const key_map key_map_empty(0);
325
321
const char *in_additional_cond= "<IN COND>";
326
322
const char *in_having_cond= "<IN HAVING>";
327
323
 
 
324
type::Decimal decimal_zero;
328
325
/* classes for comparation parsing/processing */
329
326
 
330
327
FILE *stderror_file=0;
331
328
 
332
 
drizzle_system_variables global_system_variables;
333
 
drizzle_system_variables max_system_variables;
334
 
global_counters current_global_counters;
 
329
struct drizzle_system_variables global_system_variables;
 
330
struct drizzle_system_variables max_system_variables;
 
331
struct global_counters current_global_counters;
335
332
 
336
 
DRIZZLED_API const CHARSET_INFO *system_charset_info;
337
 
const CHARSET_INFO *files_charset_info;
 
333
const CHARSET_INFO *system_charset_info, *files_charset_info ;
338
334
const CHARSET_INFO *table_alias_charset;
339
335
const CHARSET_INFO *character_set_filesystem;
340
336
 
342
338
 
343
339
SHOW_COMP_OPTION have_symlink;
344
340
 
 
341
/* Thread specific variables */
 
342
boost::mutex LOCK_global_system_variables;
 
343
 
345
344
boost::condition_variable_any COND_refresh;
346
345
boost::condition_variable COND_thread_count;
347
346
pthread_t signal_thread;
 
347
boost::condition_variable COND_server_end;
348
348
 
349
349
/* Static variables */
350
350
 
359
359
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
360
360
global_buffer_constraint<uint64_t> global_read_buffer(0);
361
361
 
362
 
DRIZZLED_API size_t transaction_message_threshold;
 
362
/** 
 
363
  Refresh value. We use to test this to find out if a refresh even has happened recently.
 
364
*/
 
365
uint64_t refresh_version;  /* Increments on each reload */
363
366
 
364
367
/* Function declarations */
365
368
bool drizzle_rm_tmp_tables();
383
386
vector<string> defaults_file_list;
384
387
po::variables_map vm;
385
388
 
 
389
fs::path data_home(LOCALSTATEDIR);
 
390
fs::path full_data_home(LOCALSTATEDIR);
 
391
 
386
392
po::variables_map &getVariablesMap()
387
393
{
388
394
  return vm;
389
395
}
390
396
 
391
 
 
 
397
fs::path& getFullDataHome()
 
398
{
 
399
  return full_data_home;
 
400
}
 
401
 
 
402
fs::path& getDataHome()
 
403
{
 
404
  return data_home;
 
405
}
 
406
 
 
407
fs::path& getDataHomeCatalog()
 
408
{
 
409
  static fs::path data_home_catalog(getDataHome());
 
410
  return data_home_catalog;
 
411
}
 
412
 
 
413
 
392
414
/****************************************************************************
393
415
** Code to end drizzled
394
416
****************************************************************************/
467
489
{
468
490
 
469
491
  if (exit_code)
470
 
  {
471
 
    errmsg_printf(error::ERROR, _("Aborting"));
472
 
  }
 
492
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
473
493
  else if (opt_help)
474
 
  {
475
494
    usage();
476
 
  }
477
 
 
478
495
  clean_up(!opt_help && (exit_code));
479
496
  internal::my_end();
480
497
  exit(exit_code);
501
518
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
502
519
 
503
520
  if (print_message && server_start_time)
504
 
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
521
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
522
  {
 
523
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
524
    ready_to_exit= true;
505
525
 
506
 
  session::Cache::singleton().shutdownFirst();
 
526
    /* do the broadcast inside the lock to ensure that my_end() is not called */
 
527
    COND_server_end.notify_all();
 
528
  }
507
529
 
508
530
  /*
509
531
    The following lines may never be executed as the main thread may have
528
550
      tmp_user_info= getpwnam(user);
529
551
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
530
552
          global_system_variables.log_warnings)
531
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
553
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
532
554
                            "if running as root\n"));
533
555
    }
534
556
    return NULL;
535
557
  }
536
558
  if (not user)
537
559
  {
538
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
539
 
                                    "the manual to find out how to run drizzled as root"));
 
560
      errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
561
                      "the manual to find out how to run drizzled as root!\n"));
540
562
    unireg_abort(1);
541
563
  }
542
 
 
543
 
  if (not strcmp(user, "root"))
 
564
  if (!strcmp(user,"root"))
544
565
    return NULL;                        // Avoid problem with dynamic libraries
545
566
 
546
567
  if (!(tmp_user_info= getpwnam(user)))
556
577
  return tmp_user_info;
557
578
 
558
579
err:
559
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
580
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
560
581
                    "Please check that the user exists!\n"),user);
561
582
  unireg_abort(1);
562
583
 
563
584
#ifdef PR_SET_DUMPABLE
564
 
  if (getDebug().test(debug::CORE_ON_SIGNAL))
 
585
  if (test_flags.test(TEST_CORE_ON_SIGNAL))
565
586
  {
566
587
    /* inform kernel that process is dumpable */
567
588
    (void) prctl(PR_SET_DUMPABLE, 1);
793
814
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
794
815
}
795
816
 
 
817
static void check_limits_mce(uint64_t in_max_connect_errors)
 
818
{
 
819
  max_connect_errors= MAX_CONNECT_ERRORS;
 
820
  if (in_max_connect_errors < 1 || in_max_connect_errors > ULONG_MAX)
 
821
  {
 
822
    cout << _("Error: Invalid Value for max_connect_errors");
 
823
    exit(-1);
 
824
  }
 
825
  max_connect_errors= in_max_connect_errors;
 
826
}
 
827
 
796
828
static void check_limits_max_err_cnt(uint64_t in_max_error_count)
797
829
{
798
830
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
1014
1046
 
1015
1047
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1016
1048
{
1017
 
  transaction_message_threshold= 1024*1024;
 
1049
  global_system_variables.transaction_message_threshold= 1024*1024;
1018
1050
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1019
1051
  {
1020
1052
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1021
1053
    exit(-1);
1022
1054
  }
1023
 
  transaction_message_threshold= in_transaction_message_threshold;
 
1055
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
1024
1056
}
1025
1057
 
1026
1058
static void process_defaults_files()
1074
1106
      defaults_file_list.push_back(*it);
1075
1107
    else
1076
1108
    {
1077
 
      errmsg_printf(error::ERROR,
 
1109
      errmsg_printf(ERRMSG_LVL_ERROR,
1078
1110
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1079
1111
      unireg_abort(1);
1080
1112
    }
1082
1114
  }
1083
1115
}
1084
1116
 
1085
 
int init_basic_variables(int argc, char **argv)
 
1117
int init_common_variables(int argc, char **argv, module::Registry &plugins)
1086
1118
{
1087
1119
  time_t curr_time;
1088
1120
  umask(((~internal::my_umask) & 0666));
1117
1149
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1118
1150
  {
1119
1151
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1120
 
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
 
1152
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1121
1153
                  glob_hostname);
1122
1154
    pid_file= "drizzle";
1123
1155
  }
1132
1164
  config_options.add_options()
1133
1165
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1134
1166
  _("Display this help and exit."))
1135
 
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1136
 
  _("Run as a daemon."))
1137
1167
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1138
1168
  _("Configuration file defaults are not used if no-defaults is set"))
1139
1169
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1174
1204
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1175
1205
  _("Default completion type."))
1176
1206
  ("core-file",  _("Write core on errors."))
1177
 
  ("datadir", po::value<fs::path>(&getDataHome()),
 
1207
  ("datadir", po::value<fs::path>(&data_home),
1178
1208
  _("Path to the database root."))
1179
1209
  ("default-storage-engine", po::value<string>(),
1180
1210
  _("Set the default storage engine for tables."))
1211
1241
  _("Path for temporary files."))
1212
1242
  ("transaction-isolation", po::value<string>(),
1213
1243
  _("Default transaction isolation level."))
1214
 
  ("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
 
1244
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1215
1245
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1216
1246
  ("user,u", po::value<string>(),
1217
1247
  _("Run drizzled daemon as user."))  
1237
1267
  _("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1238
1268
  ("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1239
1269
  _("Max packetlength to send/receive from to server."))
 
1270
  ("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
 
1271
  _("If there is more than this number of interrupted connections from a "
 
1272
     "host this host will be blocked from further connections."))
1240
1273
  ("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1241
1274
  _("Max number of errors/warnings to store for a statement."))
1242
1275
  ("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1338
1371
  }
1339
1372
  catch (std::exception&)
1340
1373
  {
1341
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
 
1374
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1342
1375
    unireg_abort(1);
1343
1376
  }
1344
1377
 
1384
1417
  }
1385
1418
  catch (po::validation_error &err)
1386
1419
  {
1387
 
    errmsg_printf(error::ERROR,  
 
1420
    errmsg_printf(ERRMSG_LVL_ERROR,  
1388
1421
                  _("%s: %s.\n"
1389
1422
                    "Use --help to get a list of available options\n"),
1390
1423
                  internal::my_progname, err.what());
1402
1435
  }
1403
1436
  catch (po::validation_error &err)
1404
1437
  {
1405
 
    errmsg_printf(error::ERROR,
 
1438
    errmsg_printf(ERRMSG_LVL_ERROR,
1406
1439
                  _("%s: %s.\n"
1407
1440
                    "Use --help to get a list of available options\n"),
1408
1441
                  internal::my_progname, err.what());
1409
1442
    unireg_abort(1);
1410
1443
  }
1411
1444
 
1412
 
  return 0;
1413
 
}
1414
 
 
1415
 
int init_remaining_variables(module::Registry &plugins)
1416
 
{
1417
 
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1418
 
 
1419
 
  current_pid= getpid();                /* Save for later ref */
1420
 
 
1421
1445
  /* At this point, we've read all the options we need to read from files and
1422
1446
     collected most of them into unknown options - now let's load everything
1423
1447
  */
1424
1448
 
1425
1449
  if (plugin_init(plugins, plugin_options))
1426
1450
  {
1427
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
 
1451
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1428
1452
    unireg_abort(1);
1429
1453
  }
1430
1454
 
1445
1469
  }
1446
1470
  catch (po::validation_error &err)
1447
1471
  {
1448
 
    errmsg_printf(error::ERROR,
 
1472
    errmsg_printf(ERRMSG_LVL_ERROR,
1449
1473
                  _("%s: %s.\n"
1450
1474
                    "Use --help to get a list of available options\n"),
1451
1475
                  internal::my_progname, err.what());
1453
1477
  }
1454
1478
  catch (po::invalid_command_line_syntax &err)
1455
1479
  {
1456
 
    errmsg_printf(error::ERROR,
 
1480
    errmsg_printf(ERRMSG_LVL_ERROR,
1457
1481
                  _("%s: %s.\n"
1458
1482
                    "Use --help to get a list of available options\n"),
1459
1483
                  internal::my_progname, err.what());
1461
1485
  }
1462
1486
  catch (po::unknown_option &err)
1463
1487
  {
1464
 
    errmsg_printf(error::ERROR,
 
1488
    errmsg_printf(ERRMSG_LVL_ERROR,
1465
1489
                  _("%s\nUse --help to get a list of available options\n"),
1466
1490
                  err.what());
1467
1491
    unireg_abort(1);
1473
1497
  }
1474
1498
  catch (po::validation_error &err)
1475
1499
  {
1476
 
    errmsg_printf(error::ERROR,  
 
1500
    errmsg_printf(ERRMSG_LVL_ERROR,  
1477
1501
                  _("%s: %s.\n"
1478
1502
                    "Use --help to get a list of available options\n"),
1479
1503
                  internal::my_progname, err.what());
1497
1521
 
1498
1522
  fix_paths();
1499
1523
 
 
1524
  current_pid= getpid();                /* Save for later ref */
1500
1525
  init_time();                          /* Init time-functions (read zone) */
1501
1526
 
1502
1527
  if (item_create_init())
1510
1535
  if (!(default_charset_info=
1511
1536
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1512
1537
  {
1513
 
    errmsg_printf(error::ERROR, _("Error getting default charset"));
 
1538
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1514
1539
    return 1;                           // Eof of the list
1515
1540
  }
1516
1541
 
1522
1547
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1523
1548
    if (not default_collation)
1524
1549
    {
1525
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1550
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1526
1551
      return 1;
1527
1552
    }
1528
1553
    if (not my_charset_same(default_charset_info, default_collation))
1529
1554
    {
1530
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1555
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1531
1556
                    default_collation_name,
1532
1557
                    default_charset_info->csname);
1533
1558
      return 1;
1540
1565
  if (not (character_set_filesystem=
1541
1566
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1542
1567
  {
1543
 
    errmsg_printf(error::ERROR, _("Error setting collation"));
 
1568
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
1544
1569
    return 1;
1545
1570
  }
1546
1571
  global_system_variables.character_set_filesystem= character_set_filesystem;
1548
1573
  if (!(my_default_lc_time_names=
1549
1574
        my_locale_by_name(lc_time_names_name)))
1550
1575
  {
1551
 
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1576
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1552
1577
    return 1;
1553
1578
  }
1554
1579
  global_system_variables.lc_time_names= my_default_lc_time_names;
1568
1593
  */
1569
1594
  if (table_cache_init())
1570
1595
  {
1571
 
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
 
1596
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
1572
1597
    unireg_abort(1);
1573
1598
  }
1574
1599
 
1583
1608
 
1584
1609
  if (xid_cache_init())
1585
1610
  {
1586
 
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1611
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1587
1612
    unireg_abort(1);
1588
1613
  }
1589
1614
 
1612
1637
 
1613
1638
  if (plugin::Scheduler::setPlugin(scheduler_name))
1614
1639
  {
1615
 
      errmsg_printf(error::ERROR,
 
1640
      errmsg_printf(ERRMSG_LVL_ERROR,
1616
1641
                   _("No scheduler found, cannot continue!\n"));
1617
1642
      unireg_abort(1);
1618
1643
  }
1637
1662
    engine= plugin::StorageEngine::findByName(name);
1638
1663
    if (engine == NULL)
1639
1664
    {
1640
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1665
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1641
1666
                    default_storage_engine_str);
1642
1667
      unireg_abort(1);
1643
1668
    }
1678
1703
  OPT_BACK_LOG,
1679
1704
  OPT_JOIN_BUFF_SIZE,
1680
1705
  OPT_MAX_ALLOWED_PACKET,
 
1706
  OPT_MAX_CONNECT_ERRORS,
1681
1707
  OPT_MAX_HEP_TABLE_SIZE,
1682
1708
  OPT_MAX_JOIN_SIZE,
1683
1709
  OPT_MAX_SORT_LENGTH,
1731
1757
  {"help", '?', N_("Display this help and exit."),
1732
1758
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1733
1759
   0, 0},
1734
 
  {"daemon", 'd', N_("Run as daemon."),
1735
 
   (char**) &opt_daemon, (char**) &opt_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1736
 
   0, 0},
1737
1760
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1738
1761
   N_("Auto-increment columns are incremented by this"),
1739
1762
   (char**) &global_system_variables.auto_increment_increment,
1859
1882
   (char**) &global_system_variables.max_allowed_packet,
1860
1883
   (char**) &max_system_variables.max_allowed_packet, 0, GET_UINT32,
1861
1884
   REQUIRED_ARG, 64*1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
1885
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
 
1886
   N_("If there is more than this number of interrupted connections from a "
 
1887
      "host this host will be blocked from further connections."),
 
1888
   (char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_UINT64,
 
1889
   REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
1862
1890
  {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
1863
1891
   N_("Don't allow creation of heap tables bigger than this."),
1864
1892
   (char**) &global_system_variables.max_heap_table_size,
2071
2099
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
2072
2100
  cleanup_done= 0;
2073
2101
  dropping_tables= ha_open_options=0;
2074
 
  getDebug().reset();
 
2102
  test_flags.reset();
2075
2103
  wake_thread=0;
2076
2104
  abort_loop= select_thread_in_use= false;
2077
 
  shutdown_in_progress= 0;
 
2105
  ready_to_exit= shutdown_in_progress= 0;
2078
2106
  drizzled_user= drizzled_chroot= 0;
2079
2107
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2080
2108
  key_map_full.set();
2159
2187
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2160
2188
 
2161
2189
    else
2162
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2190
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2163
2191
                                       "set to '%s' earlier on the command line\n"),
2164
2192
                    vm["user"].as<string>().c_str(), drizzled_user);
2165
2193
  }
2226
2254
  {
2227
2255
    if (vm["exit-info"].as<long>())
2228
2256
    {
2229
 
      getDebug().set((uint32_t) vm["exit-info"].as<long>());
 
2257
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
2230
2258
    }
2231
2259
  }
2232
2260
 
2233
2261
  if (vm.count("want-core"))
2234
2262
  {
2235
 
    getDebug().set(debug::CORE_ON_SIGNAL);
 
2263
    test_flags.set(TEST_CORE_ON_SIGNAL);
2236
2264
  }
2237
2265
 
2238
2266
  if (vm.count("skip-stack-trace"))
2239
2267
  {
2240
 
    getDebug().set(debug::NO_STACKTRACE);
 
2268
    test_flags.set(TEST_NO_STACKTRACE);
2241
2269
  }
2242
2270
 
2243
2271
  if (vm.count("skip-symlinks"))
2247
2275
 
2248
2276
  if (vm.count("transaction-isolation"))
2249
2277
  {
2250
 
    int type= tx_isolation_typelib.find_type_or_exit(vm["transaction-isolation"].as<string>().c_str(), "transaction-isolation");
2251
 
    global_system_variables.tx_isolation= type - 1;
 
2278
    int type;
 
2279
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2280
    global_system_variables.tx_isolation= (type-1);
2252
2281
  }
2253
2282
 
2254
2283
  /* @TODO Make this all strings */
2275
2304
  if (opt_debugging)
2276
2305
  {
2277
2306
    /* Allow break with SIGINT, no core or stack trace */
2278
 
    getDebug().set(debug::ALLOW_SIGINT);
2279
 
    getDebug().set(debug::NO_STACKTRACE);
2280
 
    getDebug().reset(debug::CORE_ON_SIGNAL);
 
2307
    test_flags.set(TEST_SIGINT);
 
2308
    test_flags.set(TEST_NO_STACKTRACE);
 
2309
    test_flags.reset(TEST_CORE_ON_SIGNAL);
2281
2310
  }
2282
2311
 
2283
2312
  if (drizzled_chroot)
2329
2358
    {
2330
2359
      if (errno != EEXIST)
2331
2360
      {
2332
 
        errmsg_printf(error::ERROR, _("There was an error creating the '%s' part of the path '%s'.  Please check the path exists and is writable.\n"), fs::path(drizzle_tmpdir).leaf().c_str(), drizzle_tmpdir.c_str());
 
2361
        perror(drizzle_tmpdir.c_str());
2333
2362
        exit(1);
2334
2363
      }
2335
2364
    }
2336
2365
 
2337
2366
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2338
2367
    {
2339
 
      errmsg_printf(error::ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
 
2368
      perror(drizzle_tmpdir.c_str());
2340
2369
      exit(1);
2341
2370
    }
2342
2371
  }