~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: patrick crews
  • Date: 2011-01-30 23:02:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2131.
  • Revision ID: gleebix@gmail.com-20110130230212-nnts892jsc0oiurv
Added initial docs for dbqp.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
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>
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
 
#include <drizzled/typelib.h>
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/debug.h"
 
73
 
 
74
#include "drizzled/definition/cache.h"
 
75
 
 
76
#include "drizzled/plugin/event_observer.h"
 
77
 
 
78
#include "drizzled/message/cache.h"
 
79
 
 
80
#include "drizzled/visibility.h"
81
81
 
82
82
#include <google/protobuf/stubs/common.h>
83
83
 
84
 
#include <drizzled/refresh_version.h>
85
 
 
86
84
#if TIME_WITH_SYS_TIME
87
85
# include <sys/time.h>
88
86
# include <time.h>
102
100
 
103
101
#include <errno.h>
104
102
#include <sys/stat.h>
105
 
#include <drizzled/option.h>
 
103
#include "drizzled/option.h"
106
104
#ifdef HAVE_SYSENT_H
107
105
#include <sysent.h>
108
106
#endif
136
134
#include <sys/fpu.h>
137
135
#endif
138
136
 
139
 
#include <drizzled/internal/my_pthread.h>                       // For thr_setconcurency()
140
 
#include <drizzled/constrained_value.h>
 
137
#include "drizzled/internal/my_pthread.h"                       // For thr_setconcurency()
 
138
#include "drizzled/constrained_value.h"
141
139
 
142
140
#include <drizzled/gettext.h>
143
141
 
158
156
namespace po=boost::program_options;
159
157
namespace dpo=drizzled::program_options;
160
158
 
161
 
bool opt_daemon= false;
162
159
 
163
160
namespace drizzled
164
161
{
308
305
fs::path system_config_dir(SYSCONFDIR);
309
306
 
310
307
 
 
308
char system_time_zone[30];
 
309
char *default_tz_name;
 
310
DRIZZLED_API char glob_hostname[FN_REFLEN];
 
311
 
311
312
char *opt_tc_log_file;
312
313
const key_map key_map_empty(0);
313
314
key_map key_map_full(0);                        // Will be initialized later
321
322
const char *in_additional_cond= "<IN COND>";
322
323
const char *in_having_cond= "<IN HAVING>";
323
324
 
 
325
type::Decimal decimal_zero;
324
326
/* classes for comparation parsing/processing */
325
327
 
326
328
FILE *stderror_file=0;
355
357
global_buffer_constraint<uint64_t> global_read_rnd_buffer(0);
356
358
global_buffer_constraint<uint64_t> global_read_buffer(0);
357
359
 
358
 
DRIZZLED_API size_t transaction_message_threshold;
 
360
/** 
 
361
  Refresh value. We use to test this to find out if a refresh even has happened recently.
 
362
*/
 
363
uint64_t refresh_version;  /* Increments on each reload */
 
364
 
 
365
/* Function declarations */
 
366
bool drizzle_rm_tmp_tables();
359
367
 
360
368
static void drizzle_init_variables(void);
361
369
static void get_options();
366
374
 
367
375
fs::path base_plugin_dir(PKGPLUGINDIR);
368
376
 
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"));
 
377
po::options_description config_options("Config File Options");
 
378
po::options_description long_options("Kernel Options");
 
379
po::options_description plugin_load_options("Plugin Loading Options");
 
380
po::options_description plugin_options("Plugin Options");
 
381
po::options_description initial_options("Config and Plugin Loading");
 
382
po::options_description full_options("Kernel and Plugin Loading and Plugin");
375
383
vector<string> unknown_options;
376
384
vector<string> defaults_file_list;
377
385
po::variables_map vm;
378
386
 
 
387
fs::path data_home(LOCALSTATEDIR);
 
388
fs::path full_data_home(LOCALSTATEDIR);
 
389
 
379
390
po::variables_map &getVariablesMap()
380
391
{
381
392
  return vm;
382
393
}
383
394
 
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
 
 
 
395
fs::path& getFullDataHome()
 
396
{
 
397
  return full_data_home;
 
398
}
 
399
 
 
400
fs::path& getDataHome()
 
401
{
 
402
  return data_home;
 
403
}
 
404
 
 
405
fs::path& getDataHomeCatalog()
 
406
{
 
407
  static fs::path data_home_catalog(getDataHome());
 
408
  return data_home_catalog;
 
409
}
 
410
 
 
411
 
404
412
/****************************************************************************
405
413
** Code to end drizzled
406
414
****************************************************************************/
480
488
 
481
489
  if (exit_code)
482
490
  {
483
 
    errmsg_printf(error::ERROR, _("Aborting"));
 
491
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
484
492
  }
485
493
  else if (opt_help)
486
494
  {
487
495
    usage();
488
496
  }
489
 
 
490
497
  clean_up(!opt_help && (exit_code));
491
498
  internal::my_end();
492
499
  exit(exit_code);
513
520
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
514
521
 
515
522
  if (print_message && server_start_time)
516
 
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
523
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
517
524
 
518
525
  session::Cache::singleton().shutdownFirst();
519
526
 
540
547
      tmp_user_info= getpwnam(user);
541
548
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
542
549
          global_system_variables.log_warnings)
543
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
550
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
544
551
                            "if running as root\n"));
545
552
    }
546
553
    return NULL;
547
554
  }
548
555
  if (not user)
549
556
  {
550
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
551
 
                                    "the manual to find out how to run drizzled as root"));
 
557
    errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
558
                                      "the manual to find out how to run drizzled as root!\n"));
552
559
    unireg_abort(1);
553
560
  }
554
 
 
555
 
  if (not strcmp(user, "root"))
 
561
  if (!strcmp(user,"root"))
556
562
    return NULL;                        // Avoid problem with dynamic libraries
557
563
 
558
564
  if (!(tmp_user_info= getpwnam(user)))
568
574
  return tmp_user_info;
569
575
 
570
576
err:
571
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
577
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
572
578
                    "Please check that the user exists!\n"),user);
573
579
  unireg_abort(1);
574
580
 
665
671
 
666
672
static void find_plugin_dir(string progname)
667
673
{
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"))
 
674
  if (progname[0] != FN_LIBCHAR)
 
675
  {
 
676
    /* We have a relative path and need to find the absolute */
 
677
    char working_dir[FN_REFLEN];
 
678
    char *working_dir_ptr= working_dir;
 
679
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
 
680
    string new_path(working_dir);
 
681
    if (*(new_path.end()-1) != '/')
 
682
      new_path.push_back('/');
 
683
    if (progname[0] == '.' && progname[1] == '/')
 
684
      new_path.append(progname.substr(2));
 
685
    else
 
686
      new_path.append(progname);
 
687
    progname.swap(new_path);
 
688
  }
 
689
 
 
690
  /* Now, trim off the exe name */
 
691
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
 
692
  if (progdir.rfind(".libs/") != string::npos)
 
693
  {
 
694
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
 
695
  }
 
696
  string testlofile(progdir);
 
697
  testlofile.append("drizzled.lo");
 
698
  string testofile(progdir);
 
699
  testofile.append("drizzled.o");
 
700
  struct stat testfile_stat;
 
701
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
677
702
  {
678
703
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
679
 
    base_plugin_dir= progdir.parent_path();
 
704
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
 
705
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
680
706
    base_plugin_dir /= "plugin";
681
707
    base_plugin_dir /= ".libs";
682
708
  }
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
1038
    cout << _("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));
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
 
1120
1150
  config_options.add_options()
1121
1151
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1122
1152
  _("Display this help and exit."))
1123
 
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1124
 
  _("Run as a daemon."))
1125
1153
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1126
1154
  _("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),
1162
1190
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1163
1191
  _("Default completion type."))
1164
1192
  ("core-file",  _("Write core on errors."))
1165
 
  ("datadir", po::value<fs::path>(&getDataHome()),
 
1193
  ("datadir", po::value<fs::path>(&data_home),
1166
1194
  _("Path to the database root."))
1167
1195
  ("default-storage-engine", po::value<string>(),
1168
1196
  _("Set the default storage engine for tables."))
1199
1227
  _("Path for temporary files."))
1200
1228
  ("transaction-isolation", po::value<string>(),
1201
1229
  _("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),
 
1230
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1203
1231
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1204
1232
  ("user,u", po::value<string>(),
1205
1233
  _("Run drizzled daemon as user."))  
1305
1333
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1306
1334
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
1307
1335
     " 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
1336
  ;
1311
1337
 
1312
1338
  full_options.add(long_options);
1328
1354
  }
1329
1355
  catch (std::exception&)
1330
1356
  {
1331
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
 
1357
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
1332
1358
    unireg_abort(1);
1333
1359
  }
1334
1360
 
1374
1400
  }
1375
1401
  catch (po::validation_error &err)
1376
1402
  {
1377
 
    errmsg_printf(error::ERROR,  
 
1403
    errmsg_printf(ERRMSG_LVL_ERROR,  
1378
1404
                  _("%s: %s.\n"
1379
1405
                    "Use --help to get a list of available options\n"),
1380
1406
                  internal::my_progname, err.what());
1392
1418
  }
1393
1419
  catch (po::validation_error &err)
1394
1420
  {
1395
 
    errmsg_printf(error::ERROR,
 
1421
    errmsg_printf(ERRMSG_LVL_ERROR,
1396
1422
                  _("%s: %s.\n"
1397
1423
                    "Use --help to get a list of available options\n"),
1398
1424
                  internal::my_progname, err.what());
1399
1425
    unireg_abort(1);
1400
1426
  }
1401
1427
 
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
1428
  /* At this point, we've read all the options we need to read from files and
1412
1429
     collected most of them into unknown options - now let's load everything
1413
1430
  */
1414
1431
 
1415
1432
  if (plugin_init(plugins, plugin_options))
1416
1433
  {
1417
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
 
1434
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1418
1435
    unireg_abort(1);
1419
1436
  }
1420
1437
 
1435
1452
  }
1436
1453
  catch (po::validation_error &err)
1437
1454
  {
1438
 
    errmsg_printf(error::ERROR,
 
1455
    errmsg_printf(ERRMSG_LVL_ERROR,
1439
1456
                  _("%s: %s.\n"
1440
1457
                    "Use --help to get a list of available options\n"),
1441
1458
                  internal::my_progname, err.what());
1443
1460
  }
1444
1461
  catch (po::invalid_command_line_syntax &err)
1445
1462
  {
1446
 
    errmsg_printf(error::ERROR,
 
1463
    errmsg_printf(ERRMSG_LVL_ERROR,
1447
1464
                  _("%s: %s.\n"
1448
1465
                    "Use --help to get a list of available options\n"),
1449
1466
                  internal::my_progname, err.what());
1451
1468
  }
1452
1469
  catch (po::unknown_option &err)
1453
1470
  {
1454
 
    errmsg_printf(error::ERROR,
 
1471
    errmsg_printf(ERRMSG_LVL_ERROR,
1455
1472
                  _("%s\nUse --help to get a list of available options\n"),
1456
1473
                  err.what());
1457
1474
    unireg_abort(1);
1463
1480
  }
1464
1481
  catch (po::validation_error &err)
1465
1482
  {
1466
 
    errmsg_printf(error::ERROR,  
 
1483
    errmsg_printf(ERRMSG_LVL_ERROR,  
1467
1484
                  _("%s: %s.\n"
1468
1485
                    "Use --help to get a list of available options\n"),
1469
1486
                  internal::my_progname, err.what());
1487
1504
 
1488
1505
  fix_paths();
1489
1506
 
 
1507
  current_pid= getpid();                /* Save for later ref */
1490
1508
  init_time();                          /* Init time-functions (read zone) */
1491
1509
 
1492
1510
  if (item_create_init())
1500
1518
  if (!(default_charset_info=
1501
1519
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1502
1520
  {
1503
 
    errmsg_printf(error::ERROR, _("Error getting default charset"));
 
1521
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
1504
1522
    return 1;                           // Eof of the list
1505
1523
  }
1506
1524
 
1512
1530
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1513
1531
    if (not default_collation)
1514
1532
    {
1515
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1533
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1516
1534
      return 1;
1517
1535
    }
1518
1536
    if (not my_charset_same(default_charset_info, default_collation))
1519
1537
    {
1520
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1538
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1521
1539
                    default_collation_name,
1522
1540
                    default_charset_info->csname);
1523
1541
      return 1;
1530
1548
  if (not (character_set_filesystem=
1531
1549
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1532
1550
  {
1533
 
    errmsg_printf(error::ERROR, _("Error setting collation"));
 
1551
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
1534
1552
    return 1;
1535
1553
  }
1536
1554
  global_system_variables.character_set_filesystem= character_set_filesystem;
1538
1556
  if (!(my_default_lc_time_names=
1539
1557
        my_locale_by_name(lc_time_names_name)))
1540
1558
  {
1541
 
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1559
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1542
1560
    return 1;
1543
1561
  }
1544
1562
  global_system_variables.lc_time_names= my_default_lc_time_names;
1558
1576
  */
1559
1577
  if (table_cache_init())
1560
1578
  {
1561
 
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
 
1579
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
1562
1580
    unireg_abort(1);
1563
1581
  }
1564
1582
 
1573
1591
 
1574
1592
  if (xid_cache_init())
1575
1593
  {
1576
 
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1594
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
1577
1595
    unireg_abort(1);
1578
1596
  }
1579
1597
 
1602
1620
 
1603
1621
  if (plugin::Scheduler::setPlugin(scheduler_name))
1604
1622
  {
1605
 
      errmsg_printf(error::ERROR,
 
1623
      errmsg_printf(ERRMSG_LVL_ERROR,
1606
1624
                   _("No scheduler found, cannot continue!\n"));
1607
1625
      unireg_abort(1);
1608
1626
  }
1627
1645
    engine= plugin::StorageEngine::findByName(name);
1628
1646
    if (engine == NULL)
1629
1647
    {
1630
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1648
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
1631
1649
                    default_storage_engine_str);
1632
1650
      unireg_abort(1);
1633
1651
    }
1721
1739
  {"help", '?', N_("Display this help and exit."),
1722
1740
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1723
1741
   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
1742
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1728
1743
   N_("Auto-increment columns are incremented by this"),
1729
1744
   (char**) &global_system_variables.auto_increment_increment,
2149
2164
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2150
2165
 
2151
2166
    else
2152
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2167
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2153
2168
                                       "set to '%s' earlier on the command line\n"),
2154
2169
                    vm["user"].as<string>().c_str(), drizzled_user);
2155
2170
  }
2237
2252
 
2238
2253
  if (vm.count("transaction-isolation"))
2239
2254
  {
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;
 
2255
    int type;
 
2256
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2257
    global_system_variables.tx_isolation= (type-1);
2242
2258
  }
2243
2259
 
2244
2260
  /* @TODO Make this all strings */
2319
2335
    {
2320
2336
      if (errno != EEXIST)
2321
2337
      {
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());
 
2338
        errmsg_printf(ERRMSG_LVL_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());
2323
2339
        exit(1);
2324
2340
      }
2325
2341
    }
2326
2342
 
2327
2343
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2328
2344
    {
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());
 
2345
      errmsg_printf(ERRMSG_LVL_ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
2330
2346
      exit(1);
2331
2347
    }
2332
2348
  }