~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2011-01-24 23:10:42 UTC
  • mto: This revision was merged to the branch mainline in revision 2113.
  • Revision ID: brian@tangent.org-20110124231042-hg2zx5cq1angsgjy
Minor cleanup, drop one of two needs for current session during parsing.

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"
81
79
 
82
80
#include <google/protobuf/stubs/common.h>
83
81
 
84
 
#include <drizzled/refresh_version.h>
85
 
 
86
82
#if TIME_WITH_SYS_TIME
87
83
# include <sys/time.h>
88
84
# include <time.h>
102
98
 
103
99
#include <errno.h>
104
100
#include <sys/stat.h>
105
 
#include <drizzled/option.h>
 
101
#include "drizzled/option.h"
106
102
#ifdef HAVE_SYSENT_H
107
103
#include <sysent.h>
108
104
#endif
136
132
#include <sys/fpu.h>
137
133
#endif
138
134
 
139
 
#include <drizzled/internal/my_pthread.h>                       // For thr_setconcurency()
140
 
#include <drizzled/constrained_value.h>
 
135
#include "drizzled/internal/my_pthread.h"                       // For thr_setconcurency()
 
136
#include "drizzled/constrained_value.h"
141
137
 
142
138
#include <drizzled/gettext.h>
143
139
 
158
154
namespace po=boost::program_options;
159
155
namespace dpo=drizzled::program_options;
160
156
 
161
 
bool opt_daemon= false;
162
157
 
163
158
namespace drizzled
164
159
{
234
229
 
235
230
/* Global variables */
236
231
 
 
232
bool volatile ready_to_exit;
237
233
char *drizzled_user;
238
234
bool volatile select_thread_in_use;
239
235
bool volatile abort_loop;
240
 
DRIZZLED_API bool volatile shutdown_in_progress;
 
236
bool volatile shutdown_in_progress;
241
237
char *opt_scheduler_default;
242
238
const char *opt_scheduler= NULL;
243
239
 
244
 
DRIZZLED_API size_t my_thread_stack_size= 0;
 
240
size_t my_thread_stack_size= 0;
245
241
 
246
242
/*
247
243
  Legacy global plugin::StorageEngine. These will be removed (please do not add more).
256
252
uint32_t tc_heuristic_recover= 0;
257
253
uint64_t session_startup_options;
258
254
back_log_constraints back_log(50);
259
 
DRIZZLED_API uint32_t server_id;
 
255
uint32_t server_id;
260
256
uint64_t table_cache_size;
261
257
size_t table_def_size;
262
258
uint32_t global_thread_id= 1UL;
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
type::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
 
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& 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
 
404
414
/****************************************************************************
405
415
** Code to end drizzled
406
416
****************************************************************************/
479
489
{
480
490
 
481
491
  if (exit_code)
482
 
  {
483
 
    errmsg_printf(error::ERROR, _("Aborting"));
484
 
  }
 
492
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
485
493
  else if (opt_help)
486
 
  {
487
494
    usage();
488
 
  }
489
 
 
490
495
  clean_up(!opt_help && (exit_code));
491
496
  internal::my_end();
492
497
  exit(exit_code);
513
518
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
514
519
 
515
520
  if (print_message && server_start_time)
516
 
    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;
517
525
 
518
 
  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
  }
519
529
 
520
530
  /*
521
531
    The following lines may never be executed as the main thread may have
540
550
      tmp_user_info= getpwnam(user);
541
551
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
542
552
          global_system_variables.log_warnings)
543
 
            errmsg_printf(error::WARN, _("One can only use the --user switch "
 
553
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
544
554
                            "if running as root\n"));
545
555
    }
546
556
    return NULL;
547
557
  }
548
558
  if (not user)
549
559
  {
550
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
551
 
                                    "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"));
552
562
    unireg_abort(1);
553
563
  }
554
 
 
555
 
  if (not strcmp(user, "root"))
 
564
  if (!strcmp(user,"root"))
556
565
    return NULL;                        // Avoid problem with dynamic libraries
557
566
 
558
567
  if (!(tmp_user_info= getpwnam(user)))
568
577
  return tmp_user_info;
569
578
 
570
579
err:
571
 
  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' ;  "
572
581
                    "Please check that the user exists!\n"),user);
573
582
  unireg_abort(1);
574
583
 
665
674
 
666
675
static void find_plugin_dir(string progname)
667
676
{
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"))
 
677
  if (progname[0] != FN_LIBCHAR)
 
678
  {
 
679
    /* We have a relative path and need to find the absolute */
 
680
    char working_dir[FN_REFLEN];
 
681
    char *working_dir_ptr= working_dir;
 
682
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
 
683
    string new_path(working_dir);
 
684
    if (*(new_path.end()-1) != '/')
 
685
      new_path.push_back('/');
 
686
    if (progname[0] == '.' && progname[1] == '/')
 
687
      new_path.append(progname.substr(2));
 
688
    else
 
689
      new_path.append(progname);
 
690
    progname.swap(new_path);
 
691
  }
 
692
 
 
693
  /* Now, trim off the exe name */
 
694
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
 
695
  if (progdir.rfind(".libs/") != string::npos)
 
696
  {
 
697
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
 
698
  }
 
699
  string testlofile(progdir);
 
700
  testlofile.append("drizzled.lo");
 
701
  string testofile(progdir);
 
702
  testofile.append("drizzled.o");
 
703
  struct stat testfile_stat;
 
704
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
677
705
  {
678
706
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
679
 
    base_plugin_dir= progdir.parent_path();
 
707
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
 
708
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
680
709
    base_plugin_dir /= "plugin";
681
710
    base_plugin_dir /= ".libs";
682
711
  }
1006
1035
 
1007
1036
static void check_limits_transaction_message_threshold(size_t in_transaction_message_threshold)
1008
1037
{
1009
 
  transaction_message_threshold= 1024*1024;
 
1038
  global_system_variables.transaction_message_threshold= 1024*1024;
1010
1039
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
1011
1040
  {
1012
1041
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
1013
1042
    exit(-1);
1014
1043
  }
1015
 
  transaction_message_threshold= in_transaction_message_threshold;
 
1044
  global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
1016
1045
}
1017
1046
 
1018
1047
static void process_defaults_files()
1066
1095
      defaults_file_list.push_back(*it);
1067
1096
    else
1068
1097
    {
1069
 
      errmsg_printf(error::ERROR,
 
1098
      errmsg_printf(ERRMSG_LVL_ERROR,
1070
1099
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1071
1100
      unireg_abort(1);
1072
1101
    }
1074
1103
  }
1075
1104
}
1076
1105
 
1077
 
int init_basic_variables(int argc, char **argv)
 
1106
int init_common_variables(int argc, char **argv, module::Registry &plugins)
1078
1107
{
1079
1108
  time_t curr_time;
1080
1109
  umask(((~internal::my_umask) & 0666));
1091
1120
  drizzle_init_variables();
1092
1121
 
1093
1122
  find_plugin_dir(argv[0]);
 
1123
  {
 
1124
    struct tm tm_tmp;
 
1125
    localtime_r(&server_start_time,&tm_tmp);
 
1126
    strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
 
1127
            sizeof(system_time_zone)-1);
1094
1128
 
 
1129
  }
1095
1130
  /*
1096
1131
    We set SYSTEM time zone as reasonable default and
1097
1132
    also for failure of my_tz_init() and bootstrap mode.
1100
1135
  */
1101
1136
  global_system_variables.time_zone= my_tz_SYSTEM;
1102
1137
 
1103
 
  char ret_hostname[FN_REFLEN];
1104
 
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
 
1138
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1105
1139
  {
1106
 
    errmsg_printf(error::WARN,
1107
 
                  _("gethostname failed, using '%s' as hostname"),
1108
 
                  getServerHostname().c_str());
 
1140
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
 
1141
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
 
1142
                  glob_hostname);
1109
1143
    pid_file= "drizzle";
1110
1144
  }
1111
1145
  else
1112
1146
  {
1113
 
    setServerHostname(ret_hostname);
1114
 
    pid_file= getServerHostname();
 
1147
    pid_file= glob_hostname;
1115
1148
  }
1116
1149
  pid_file.replace_extension(".pid");
1117
1150
 
1120
1153
  config_options.add_options()
1121
1154
  ("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1122
1155
  _("Display this help and exit."))
1123
 
  ("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1124
 
  _("Run as a daemon."))
1125
1156
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1126
1157
  _("Configuration file defaults are not used if no-defaults is set"))
1127
1158
  ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1162
1193
  ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1163
1194
  _("Default completion type."))
1164
1195
  ("core-file",  _("Write core on errors."))
1165
 
  ("datadir", po::value<fs::path>(&getDataHome()),
 
1196
  ("datadir", po::value<fs::path>(&data_home),
1166
1197
  _("Path to the database root."))
1167
1198
  ("default-storage-engine", po::value<string>(),
1168
1199
  _("Set the default storage engine for tables."))
1199
1230
  _("Path for temporary files."))
1200
1231
  ("transaction-isolation", po::value<string>(),
1201
1232
  _("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),
 
1233
  ("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1203
1234
  _("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1204
1235
  ("user,u", po::value<string>(),
1205
1236
  _("Run drizzled daemon as user."))  
1305
1336
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1306
1337
  _("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);
1328
1357
  }
1329
1358
  catch (std::exception&)
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
    }
1721
1742
  {"help", '?', N_("Display this help and exit."),
1722
1743
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1723
1744
   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
1745
  {"auto-increment-increment", OPT_AUTO_INCREMENT,
1728
1746
   N_("Auto-increment columns are incremented by this"),
1729
1747
   (char**) &global_system_variables.auto_increment_increment,
2064
2082
  getDebug().reset();
2065
2083
  wake_thread=0;
2066
2084
  abort_loop= select_thread_in_use= false;
2067
 
  shutdown_in_progress= 0;
 
2085
  ready_to_exit= shutdown_in_progress= 0;
2068
2086
  drizzled_user= drizzled_chroot= 0;
2069
2087
  memset(&current_global_counters, 0, sizeof(current_global_counters));
2070
2088
  key_map_full.set();
2149
2167
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2150
2168
 
2151
2169
    else
2152
 
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
 
2170
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
2153
2171
                                       "set to '%s' earlier on the command line\n"),
2154
2172
                    vm["user"].as<string>().c_str(), drizzled_user);
2155
2173
  }
2237
2255
 
2238
2256
  if (vm.count("transaction-isolation"))
2239
2257
  {
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;
 
2258
    int type;
 
2259
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2260
    global_system_variables.tx_isolation= (type-1);
2242
2261
  }
2243
2262
 
2244
2263
  /* @TODO Make this all strings */
2319
2338
    {
2320
2339
      if (errno != EEXIST)
2321
2340
      {
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());
 
2341
        perror(drizzle_tmpdir.c_str());
2323
2342
        exit(1);
2324
2343
      }
2325
2344
    }
2326
2345
 
2327
2346
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2328
2347
    {
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());
 
2348
      perror(drizzle_tmpdir.c_str());
2330
2349
      exit(1);
2331
2350
    }
2332
2351
  }