~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

We've gotten further. Now things sometimes work, but some things aren't
being set properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
351
351
 
352
352
int cleanup_done;
353
353
static char *drizzle_home_ptr, *pidfile_name_ptr;
354
 
static int defaults_argc;
355
 
static char **defaults_argv;
356
354
 
357
355
passwd *user_info;
358
356
 
367
365
bool drizzle_rm_tmp_tables();
368
366
 
369
367
static void drizzle_init_variables(void);
370
 
static void get_options(int *argc,char **argv);
 
368
static void get_options();
371
369
int drizzled_get_one_option(int, const struct option *, char *);
372
370
static const char *get_relative_path(const char *path);
373
371
static void fix_paths(string progname);
375
373
static void usage(void);
376
374
void close_connections(void);
377
375
 
378
 
po::options_description long_options("Allowed Options");
 
376
po::options_description long_options("Kernel Options");
 
377
po::options_description plugin_options("Plugin Options");
 
378
vector<string> unknown_options;
379
379
po::variables_map vm;
380
380
 
381
381
po::variables_map &getVariablesMap()
500
500
  module::Registry &modules= module::Registry::singleton();
501
501
  modules.shutdownModules();
502
502
  xid_cache_free();
503
 
  if (defaults_argv)
504
 
    internal::free_defaults(defaults_argv);
505
503
  if (opt_secure_file_priv)
506
504
    free(opt_secure_file_priv);
507
505
 
1272
1270
 
1273
1271
  po::parsed_options parsed= po::command_line_parser(argc, argv).
1274
1272
    options(long_options).allow_unregistered().extra_parser(parse_size_arg).run();
1275
 
  vector<string> unknown_options=
 
1273
  unknown_options=
1276
1274
    po::collect_unrecognized(parsed.options, po::include_positional);
1277
1275
 
1278
1276
  po::store(parsed, vm);
1285
1283
 
1286
1284
  po::notify(vm);
1287
1285
 
1288
 
  internal::load_defaults("drizzled", load_default_groups, &argc, &argv);
1289
 
  defaults_argv=argv;
1290
 
  defaults_argc=argc;
1291
 
  get_options(&defaults_argc, defaults_argv);
 
1286
  get_options();
1292
1287
 
1293
1288
  if ((user_info= check_user(drizzled_user)))
1294
1289
  {
1369
1364
  return 0;
1370
1365
}
1371
1366
 
1372
 
int init_server_components(module::Registry &plugins, int, char**)
 
1367
int init_server_components(module::Registry &plugins)
1373
1368
{
1374
1369
  /*
1375
1370
    We need to call each of these following functions to ensure that
1395
1390
  /* Allow storage engine to give real error messages */
1396
1391
  ha_init_errors();
1397
1392
 
1398
 
  if (plugin_init(plugins, &defaults_argc, defaults_argv, long_options))
 
1393
  if (plugin_init(plugins, plugin_options))
1399
1394
  {
1400
1395
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
1401
1396
    unireg_abort(1);
1405
1400
  if (opt_help || opt_help_extended)
1406
1401
    unireg_abort(0);
1407
1402
 
1408
 
  po::parsed_options parsed= po::command_line_parser(defaults_argc,
1409
 
                                                     defaults_argv).
1410
 
    options(long_options).extra_parser(parse_size_arg).
 
1403
  po::parsed_options parsed= po::command_line_parser(unknown_options).
 
1404
    options(plugin_options).extra_parser(parse_size_arg).
1411
1405
    allow_unregistered().run();
1412
1406
 
1413
 
  vector<string> unknown_options=
 
1407
  vector<string> final_unknown_options=
1414
1408
    po::collect_unrecognized(parsed.options, po::include_positional);
1415
1409
 
1416
1410
  /* we do want to exit if there are any other unknown options */
1417
1411
  /** @TODO: We should perhaps remove allowed_unregistered() and catch the
1418
1412
    exception here */
1419
 
  if (unknown_options.size() > 0)
 
1413
  if (final_unknown_options.size() > 0)
1420
1414
  {
1421
1415
     errmsg_printf(ERRMSG_LVL_ERROR,
1422
 
            _("%s: Unknown options give (first unknown is '%s').\n"
1423
 
              "Use --verbose --help to get a list of available options\n"),
 
1416
            _("%s: Unknown options given (first unknown is '%s').\n"
 
1417
              "Use --help to get a list of available options\n"),
1424
1418
            internal::my_progname, unknown_options[0].c_str());
1425
1419
      unireg_abort(1);
1426
1420
  }
1917
1911
 
1918
1912
 
1919
1913
  printf(_("Usage: %s [OPTIONS]\n"), internal::my_progname);
1920
 
  /* Print out all the options including plugin supplied options */
1921
 
  my_print_help_inc_plugins(my_long_options);
1922
1914
 
1923
 
  cout << long_options << endl;
 
1915
  po::options_description all_options("Drizzled Options");
 
1916
  all_options.add(long_options);
 
1917
  all_options.add(plugin_options);
 
1918
  cout << all_options << endl;
1924
1919
 
1925
1920
}
1926
1921
 
1947
1942
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
1948
1943
  opt_secure_file_priv= 0;
1949
1944
  cleanup_done= 0;
1950
 
  defaults_argc= 0;
1951
 
  defaults_argv= 0;
1952
1945
  dropping_tables= ha_open_options=0;
1953
1946
  test_flags.reset();
1954
1947
  wake_thread=0;
2115
2108
  return 0;
2116
2109
}
2117
2110
 
2118
 
static void option_error_reporter(enum loglevel level, const char *format, ...)
2119
 
{
2120
 
  va_list args;
2121
 
  va_start(args, format);
2122
 
 
2123
 
  /* Don't print warnings for --loose options during bootstrap */
2124
 
  if (level == ERROR_LEVEL || global_system_variables.log_warnings)
2125
 
  {
2126
 
    plugin::ErrorMessage::vprintf(NULL, ERROR_LEVEL, format, args);
2127
 
  }
2128
 
  va_end(args);
2129
 
}
2130
 
 
2131
2111
 
2132
2112
/**
2133
2113
  @todo
2134
2114
  - FIXME add EXIT_TOO_MANY_ARGUMENTS to "drizzled/error.h" and return that code?
2135
2115
*/
2136
 
static void get_options(int *argc,char **argv)
 
2116
static void get_options()
2137
2117
{
2138
 
  int ho_error;
2139
 
 
2140
 
  my_getopt_error_reporter= option_error_reporter;
 
2118
 
 
2119
  if (vm.count("base-dir"))
 
2120
  {
 
2121
    strncpy(drizzle_home,vm["base-dir"].as<string>().c_str(),sizeof(drizzle_home)-1);
 
2122
  }
 
2123
 
 
2124
  if (vm.count("datadir"))
 
2125
  {
 
2126
    cout << "In datadir" << endl;
 
2127
    strncpy(data_home_real,vm["datadir"].as<string>().c_str(), sizeof(data_home_real)-1);
 
2128
    /* Correct pointer set by my_getopt (for embedded library) */
 
2129
    data_home= data_home_real;
 
2130
    data_home_len= strlen(data_home);
 
2131
  }
 
2132
 
 
2133
  if (vm.count("user"))
 
2134
  {
 
2135
    if (! drizzled_user || ! strcmp(drizzled_user, vm["user"].as<string>().c_str()))
 
2136
      drizzled_user= (char *)vm["user"].as<string>().c_str();
 
2137
 
 
2138
    else
 
2139
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
 
2140
                                       "set to '%s' earlier on the command line\n"),
 
2141
                    vm["user"].as<string>().c_str(), drizzled_user);
 
2142
  }
 
2143
 
 
2144
  if (vm.count("language"))
 
2145
  {
 
2146
    strncpy(language, vm["language"].as<string>().c_str(), sizeof(language)-1);
 
2147
  }
 
2148
 
 
2149
  if (vm.count("version"))
 
2150
  {
 
2151
    print_version();
 
2152
    exit(0);
 
2153
  }
 
2154
 
 
2155
  if (vm.count("log-warnings"))
 
2156
  {
 
2157
    if (vm["log-warnings"].as<string>().empty())
 
2158
      global_system_variables.log_warnings++;
 
2159
    else if (vm["log-warnings"].as<string>().compare("0"))
 
2160
      global_system_variables.log_warnings= 0L;
 
2161
    else
 
2162
      global_system_variables.log_warnings= atoi(vm["log-warnings"].as<string>().c_str());
 
2163
  }
 
2164
 
 
2165
  if (vm.count("exit-info"))
 
2166
  {
 
2167
    if (vm["exit-info"].as<long>())
 
2168
    {
 
2169
      test_flags.set((uint32_t) vm["exit-info"].as<long>());
 
2170
    }
 
2171
  }
 
2172
 
 
2173
  if (vm.count("want-core"))
 
2174
  {
 
2175
    test_flags.set(TEST_CORE_ON_SIGNAL);
 
2176
  }
 
2177
 
 
2178
  if (vm.count("skip-stack-trace"))
 
2179
  {
 
2180
    test_flags.set(TEST_NO_STACKTRACE);
 
2181
  }
 
2182
 
 
2183
  if (vm.count("skip-symlinks"))
 
2184
  {
 
2185
    internal::my_use_symdir=0;
 
2186
  }
 
2187
 
 
2188
  if (vm.count("pid-file"))
 
2189
  {
 
2190
    strncpy(pidfile_name, vm["pid-file"].as<string>().c_str(), sizeof(pidfile_name)-1);
 
2191
  }
 
2192
 
 
2193
  if (vm.count("transaction-isolation"))
 
2194
  {
 
2195
    int type;
 
2196
    type= find_type_or_exit((char *)vm["transaction-isolation"].as<string>().c_str(), &tx_isolation_typelib, "transaction-isolation");
 
2197
    global_system_variables.tx_isolation= (type-1);
 
2198
  }
 
2199
 
2141
2200
 
2142
2201
  /* Skip unknown options so that they may be processed later by plugins */
2143
2202
  my_getopt_skip_unknown= true;
2144
2203
 
2145
 
  if ((ho_error= handle_options(argc, &argv, my_long_options,
2146
 
                                drizzled_get_one_option)))
2147
 
    exit(ho_error);
2148
 
  (*argc)++; /* add back one for the progname handle_options removes */
2149
 
             /* no need to do this for argv as we are discarding it. */
2150
2204
 
2151
2205
#if defined(HAVE_BROKEN_REALPATH)
2152
2206
  internal::my_use_symdir=0;