~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
400
400
extern "C" bool drizzled_get_one_option(int, const struct my_option *, char *);
401
401
static int init_thread_environment();
402
402
static const char *get_relative_path(const char *path);
403
 
static void fix_paths(void);
 
403
static void fix_paths(string &progname);
404
404
extern "C" pthread_handler_t handle_slave(void *arg);
405
405
static void clean_up(bool print_message);
406
406
 
1507
1507
  */
1508
1508
  const std::string myisam_engine_name("MyISAM");
1509
1509
  const std::string heap_engine_name("MEMORY");
1510
 
  myisam_engine= plugin::StorageEngine::findByName(NULL, myisam_engine_name);
1511
 
  heap_engine= plugin::StorageEngine::findByName(NULL, heap_engine_name);
 
1510
  myisam_engine= plugin::StorageEngine::findByName(myisam_engine_name);
 
1511
  heap_engine= plugin::StorageEngine::findByName(heap_engine_name);
1512
1512
 
1513
1513
  /*
1514
1514
    Check that the default storage engine is actually available.
1518
1518
    const std::string name(default_storage_engine_str);
1519
1519
    plugin::StorageEngine *engine;
1520
1520
 
1521
 
    engine= plugin::StorageEngine::findByName(0, name);
 
1521
    engine= plugin::StorageEngine::findByName(name);
1522
1522
    if (engine == NULL)
1523
1523
    {
1524
1524
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported table type: %s"),
1657
1657
 
1658
1658
  init_status_vars();
1659
1659
 
1660
 
  errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_STARTUP)), my_progname, VERSION,
1661
 
                COMPILATION_COMMENT);
 
1660
  errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_STARTUP)), my_progname,
 
1661
                PANDORA_RELEASE_VERSION, COMPILATION_COMMENT);
1662
1662
 
1663
1663
 
1664
1664
  /* Listen for new connections and start new session for each connection
1760
1760
  OPT_ENABLE_LARGE_PAGES,
1761
1761
  OPT_TIMED_MUTEXES,
1762
1762
  OPT_TABLE_LOCK_WAIT_TIMEOUT,
 
1763
  OPT_PLUGIN_ADD,
1763
1764
  OPT_PLUGIN_LOAD,
1764
1765
  OPT_PLUGIN_DIR,
1765
1766
  OPT_PORT_OPEN_TIMEOUT,
2052
2053
   N_("Directory for plugins."),
2053
2054
   (char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
2054
2055
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
2056
  {"plugin_add", OPT_PLUGIN_ADD,
 
2057
   N_("Optional comma separated list of plugins to load at startup in addition "
 
2058
      "to the default list of plugins. "
 
2059
      "[for example: --plugin_add=crc32,logger_gearman]"),
 
2060
   (char**) &opt_plugin_add, (char**) &opt_plugin_add, 0,
 
2061
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2055
2062
  {"plugin_load", OPT_PLUGIN_LOAD,
2056
 
   N_("Optional comma separated list of plugins to load at starup."
 
2063
   N_("Optional comma separated list of plugins to load at starup instead of "
 
2064
      "the default plugin load list. "
2057
2065
      "[for example: --plugin_load=crc32,logger_gearman]"),
2058
2066
   (char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
2059
2067
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2151
2159
    version from the output of 'drizzled --version', so don't change it!
2152
2160
  */
2153
2161
  printf("%s  Ver %s for %s-%s on %s (%s)\n",my_progname,
2154
 
         VERSION, HOST_VENDOR, HOST_OS, HOST_CPU, COMPILATION_COMMENT);
 
2162
         PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU,
 
2163
         COMPILATION_COMMENT);
2155
2164
}
2156
2165
 
2157
2166
static void usage(void)
2404
2413
 
2405
2414
  my_getopt_error_reporter= option_error_reporter;
2406
2415
 
 
2416
  string progname(argv[0]);
 
2417
 
2407
2418
  /* Skip unknown options so that they may be processed later by plugins */
2408
2419
  my_getopt_skip_unknown= true;
2409
2420
 
2434
2445
 
2435
2446
  if (drizzled_chroot)
2436
2447
    set_root(drizzled_chroot);
2437
 
  fix_paths();
 
2448
  fix_paths(progname);
2438
2449
 
2439
2450
  /*
2440
2451
    Set some global variables from the global_system_variables
2459
2470
}
2460
2471
 
2461
2472
 
2462
 
static void fix_paths(void)
 
2473
static void fix_paths(string &progname)
2463
2474
{
2464
2475
  char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX];
2465
2476
  convert_dirname(drizzle_home,drizzle_home,NULL);
2487
2498
  (void) my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
2488
2499
  (void) my_load_path(drizzle_real_data_home, drizzle_real_data_home,drizzle_home);
2489
2500
  (void) my_load_path(pidfile_name, pidfile_name,drizzle_real_data_home);
2490
 
  (void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr ? opt_plugin_dir_ptr :
2491
 
                                      get_relative_path(PKGPLUGINDIR),
2492
 
                                      drizzle_home);
 
2501
 
 
2502
  if (opt_plugin_dir_ptr == NULL)
 
2503
  {
 
2504
    /* No plugin dir has been specified. Figure out where the plugins are */
 
2505
    if (progname[0] != FN_LIBCHAR)
 
2506
    {
 
2507
      /* We have a relative path and need to find the absolute */
 
2508
      char working_dir[FN_REFLEN];
 
2509
      char *working_dir_ptr= working_dir;
 
2510
      working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
 
2511
      string new_path(working_dir);
 
2512
      if (*(new_path.end()-1) != '/')
 
2513
        new_path.push_back('/');
 
2514
      if (progname[0] == '.' && progname[1] == '/')
 
2515
        new_path.append(progname.substr(2));
 
2516
      else
 
2517
        new_path.append(progname);
 
2518
      progname.swap(new_path);
 
2519
    }
 
2520
 
 
2521
    /* Now, trim off the exe name */
 
2522
    string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
 
2523
    if (progdir.rfind(".libs/") != string::npos)
 
2524
    {
 
2525
      progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
 
2526
    }
 
2527
    string testfile(progdir);
 
2528
    testfile.append("drizzled.o");
 
2529
    struct stat testfile_stat;
 
2530
    if (stat(testfile.c_str(), &testfile_stat))
 
2531
    {
 
2532
      /* drizzled.o doesn't exist - we are not in a source dir.
 
2533
       * Go on as usual
 
2534
       */
 
2535
      (void) my_load_path(opt_plugin_dir, get_relative_path(PKGPLUGINDIR),
 
2536
                                          drizzle_home);
 
2537
    }
 
2538
    else
 
2539
    {
 
2540
      /* We are in a source dir! Plugin dir is ../plugin/.libs */
 
2541
      size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
 
2542
      string source_plugindir(progdir.substr(0,last_libchar_pos));
 
2543
      source_plugindir.append("plugin/.libs");
 
2544
      (void) my_load_path(opt_plugin_dir, source_plugindir.c_str(), "");
 
2545
    }
 
2546
  }
 
2547
  else
 
2548
  {
 
2549
    (void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, drizzle_home);
 
2550
  }
2493
2551
  opt_plugin_dir_ptr= opt_plugin_dir;
2494
2552
 
2495
2553
  const char *sharedir= get_relative_path(PKGDATADIR);