~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/loader.cc

Removed some plugin loading cruft.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
  if (!test_plugin_options(tmp_root, tmp, argc, argv))
265
265
  {
266
266
    registry.add(tmp);
267
 
    init_alloc_root(&tmp->mem_root, 4096, 4096);
268
267
    return false;
269
268
  }
270
269
  errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY),
1616
1615
 
1617
1616
 
1618
1617
static int construct_options(MEM_ROOT *mem_root, plugin::Module *tmp,
1619
 
                             my_option *options, bool can_disable)
 
1618
                             my_option *options)
1620
1619
{
1621
1620
  const char *plugin_name= tmp->getManifest().name;
1622
1621
  uint32_t namelen= strlen(plugin_name), optnamelen;
1623
 
  uint32_t buffer_length= namelen * 4 + (can_disable ? 75 : 10);
 
1622
  uint32_t buffer_length= namelen * 4 +  75;
1624
1623
  char *name= (char*) alloc_root(mem_root, buffer_length);
1625
1624
  bool *enabled_value= (bool*) alloc_root(mem_root, sizeof(bool));
1626
1625
  char *optname, *p;
1638
1637
    if (*p == '_')
1639
1638
      *p= '-';
1640
1639
 
1641
 
  if (can_disable)
1642
 
  {
1643
 
    sprintf(name+namelen*2+10,
1644
 
            "Enable %s plugin. Disable with --skip-%s (will save memory).",
1645
 
            plugin_name, name);
1646
 
    /*
1647
 
      Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 +
1648
 
      20 + namelen + 20 + 1 == namelen * 4 + 67.
1649
 
    */
 
1640
  sprintf(name+namelen*2+10,
 
1641
          "Enable %s plugin. Disable with --skip-%s (will save memory).",
 
1642
          plugin_name, name);
 
1643
  /*
 
1644
    Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 +
 
1645
    20 + namelen + 20 + 1 == namelen * 4 + 67.
 
1646
  */
1650
1647
 
1651
 
    options[0].comment= name + namelen*2 + 10;
1652
 
  }
 
1648
  options[0].comment= name + namelen*2 + 10;
1653
1649
 
1654
1650
  /*
1655
1651
    This whole code around variables and command line parameters is turd
1847
1843
{
1848
1844
  drizzle_sys_var **opt;
1849
1845
  my_option *opts;
1850
 
  bool can_disable;
1851
1846
  uint32_t count= EXTRA_OPTIONS;
1852
1847
 
1853
1848
  for (opt= p->getManifest().system_vars; opt && *opt; opt++, count+= 2) {};
1858
1853
 
1859
1854
  memset(opts, 0, sizeof(my_option) * count);
1860
1855
 
1861
 
  if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MyISAM") == 0))
1862
 
    can_disable= false;
1863
 
  else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MEMORY") == 0))
1864
 
    can_disable= false;
1865
 
  else
1866
 
    can_disable= true;
1867
 
 
1868
 
 
1869
 
  if (construct_options(mem_root, p, opts, can_disable))
 
1856
  if (construct_options(mem_root, p, opts))
1870
1857
    return NULL;
1871
1858
 
1872
1859
  return(opts);
1905
1892
                               int *argc, char **argv)
1906
1893
{
1907
1894
  struct sys_var_chain chain= { NULL, NULL };
1908
 
  bool can_disable;
1909
1895
  drizzle_sys_var **opt;
1910
1896
  my_option *opts= NULL;
1911
1897
  int error;
1916
1902
  for (opt= tmp->getManifest().system_vars; opt && *opt; opt++)
1917
1903
    count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
1918
1904
 
1919
 
  if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MyISAM") == 0))
1920
 
    can_disable= false;
1921
 
  else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MEMORY") == 0))
1922
 
    can_disable= false;
1923
 
  else
1924
 
    can_disable= true;
1925
1905
 
1926
1906
  if (count > EXTRA_OPTIONS || (*argc > 1))
1927
1907
  {
1932
1912
    }
1933
1913
    memset(opts, 0, sizeof(my_option) * count);
1934
1914
 
1935
 
    if (construct_options(tmp_root, tmp, opts, can_disable))
 
1915
    if (construct_options(tmp_root, tmp, opts))
1936
1916
    {
1937
1917
      errmsg_printf(ERRMSG_LVL_ERROR, _("Bad options for plugin '%s'."), tmp->getName().c_str());
1938
1918
      return(-1);