~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memcached_stats/memcached_stats.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-07-18 03:36:32 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100718033632-p7q6qtgliqbhe38p
Fix for Bug 592444

There were two problems:
o. In greedy_search optimizer method, best_extension_by_limited search
   maintains join embedding(nestedness) of tables added so far, so that 
   correct(valid)  join order is selected
   These are requirements from nested outer join executioner.
   The problem was, embedding_map was not correctly updated when a table 
   is added to optimal plan outside best_extension_by_limited search, 
   by greedy_search method. We need to update join->cur_embedding_map
   correctly here so that execution plan for other tables get
   generated.
   Invoked checked_interleaving_with_nj from greedy_search on the
   best_table selected. Fixed its prototype to take only one JoinTab
   This is same as mysql 5.1 source tree.
o. The other problem was, join->cur_embedding_map was not restored correctly
   when a table is added to the optimal plan to reflect the current embedding 
   map. 
   Taken good documented method restore_prev_nj_state which restores 
   cur_embedding_map from mysql 5.1 source tree and modified it for drizzled 
   code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "config.h"
31
31
#include "drizzled/show.h"
32
32
#include "drizzled/gettext.h"
33
 
#include <boost/program_options.hpp>
34
 
#include <drizzled/module/option_map.h>
 
33
 
35
34
#include "stats_table.h"
36
35
#include "analysis_table.h"
37
36
#include "sysvar_holder.h"
39
38
#include <string>
40
39
#include <map>
41
40
 
42
 
namespace po=boost::program_options;
43
 
 
44
 
namespace drizzle_plugin
45
 
{
46
 
 
 
41
using namespace std;
 
42
using namespace drizzled;
47
43
 
48
44
/*
49
45
 * DATA_DICTIONARY tables.
55
51
/*
56
52
 * System variable related variables.
57
53
 */
58
 
static std::string sysvar_memcached_servers;
 
54
static char *sysvar_memcached_servers= NULL;
59
55
 
60
56
/**
61
57
 * Initialize the memcached stats plugin.
63
59
 * @param[in] registry the drizzled::plugin::Registry singleton
64
60
 * @return false on success; true on failure.
65
61
 */
66
 
static int init(drizzled::module::Context &context)
 
62
static int init(module::Context &context)
67
63
{
68
 
  const drizzled::module::option_map &vm= context.getOptions();
 
64
 
 
65
  SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
66
  sysvar_holder.setServersString(sysvar_memcached_servers);
69
67
 
70
68
  /* we are good to go */
71
 
  stats_table_tool= new StatsTableTool; 
 
69
  stats_table_tool= new(std::nothrow)StatsTableTool; 
72
70
  context.add(stats_table_tool);
73
71
 
74
 
  analysis_table_tool= new AnalysisTableTool;
 
72
  analysis_table_tool= new(std::nothrow)AnalysisTableTool;
75
73
  context.add(analysis_table_tool);
76
74
 
77
 
  context.registerVariable(new sys_var_std_string("servers",
78
 
                                                  sysvar_memcached_servers));
79
 
                          
80
75
  return 0;
81
76
}
82
77
 
83
 
static void init_options(drizzled::module::option_context &context)
84
 
{
85
 
  context("servers",
86
 
          po::value<std::string>()->default_value(""),
87
 
          N_("List of memcached servers."));
88
 
}
89
 
 
90
 
} /* namespace drizzle_plugin */
 
78
static int check_memc_servers(Session *,
 
79
                              drizzle_sys_var *,
 
80
                              void *save,
 
81
                              drizzle_value *value)
 
82
{
 
83
  char buff[STRING_BUFFER_USUAL_SIZE];
 
84
  int len= sizeof(buff);
 
85
  const char *input= value->val_str(value, buff, &len);
 
86
 
 
87
  if (input)
 
88
  {
 
89
    SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
90
    sysvar_holder.setServersStringVar(input);
 
91
    *(bool *) save= (bool) true;
 
92
    return 0;
 
93
  }
 
94
 
 
95
  *(bool *) save= (bool) false;
 
96
  return 1;
 
97
}
 
98
 
 
99
static void set_memc_servers(Session *,
 
100
                             drizzle_sys_var *,
 
101
                             void *var_ptr,
 
102
                             const void *save)
 
103
{
 
104
  if (*(bool *) save != false)
 
105
  {
 
106
    SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
107
    sysvar_holder.updateServersSysvar((const char **) var_ptr);
 
108
  }
 
109
}
 
110
 
 
111
static DRIZZLE_SYSVAR_STR(servers,
 
112
                          sysvar_memcached_servers,
 
113
                          PLUGIN_VAR_OPCMDARG,
 
114
                          N_("List of memcached servers."),
 
115
                          check_memc_servers, /* check func */
 
116
                          set_memc_servers, /* update func */
 
117
                          ""); /* default value */
 
118
 
 
119
static drizzle_sys_var *system_variables[]=
 
120
{
 
121
  DRIZZLE_SYSVAR(servers),
 
122
  NULL
 
123
};
91
124
 
92
125
DRIZZLE_DECLARE_PLUGIN
93
126
{
97
130
  "Padraig O'Sullivan",
98
131
  N_("Memcached Stats as I_S tables"),
99
132
  PLUGIN_LICENSE_BSD,
100
 
  drizzle_plugin::init,   /* Plugin Init      */
101
 
  NULL, /* system variables */
102
 
  drizzle_plugin::init_options    /* config options   */
 
133
  init,   /* Plugin Init      */
 
134
  system_variables, /* system variables */
 
135
  NULL    /* config options   */
103
136
}
104
137
DRIZZLE_DECLARE_PLUGIN_END;