56#include "status_tool.h"
57#include <drizzled/status_helper.h>
63using namespace plugin;
67class ShowVarCmpFunctor
70 ShowVarCmpFunctor() { }
73 int val= strcmp(var1->name, var2->name);
78StatusTool::StatusTool(
LoggingStats *in_logging_stats,
bool inIsLocal) :
79 TableFunction(
"DATA_DICTIONARY", inIsLocal ?
"SESSION_STATUS" :
"GLOBAL_STATUS"),
80 outer_logging_stats(in_logging_stats),
83 add_field(
"VARIABLE_NAME");
84 add_field(
"VARIABLE_VALUE", 1024);
88 std::vector<drizzle_show_var *>::iterator all_status_vars_iterator= all_status_vars.begin();
91 var= &StatusHelper::status_vars_defs[count];
92 if ((
var == NULL) || (
var->name == NULL))
96 all_status_vars_iterator= all_status_vars.insert(all_status_vars_iterator, var);
99 sort(all_status_vars.begin(), all_status_vars.end(), ShowVarCmpFunctor());
103 std::vector<drizzle_show_var *> *in_all_status_vars,
105 TableFunction::Generator(arg),
106 logging_stats(in_logging_stats),
109 all_status_vars_it= in_all_status_vars->begin();
110 all_status_vars_end= in_all_status_vars->end();
112 status_var_to_display= NULL;
115 ScoreboardSlot *scoreboard_slot= logging_stats->getCurrentScoreboard()->findOurScoreboardSlot(&getSession());
117 if (scoreboard_slot != NULL)
120 status_var_to_display=
new StatusVars(*scoreboard_slot->getStatusVars());
123 StatusVars current_scoreboard_status_vars;
124 CumulativeStats *cumulativeStats= logging_stats->getCumulativeStats();
125 cumulativeStats->sumCurrentScoreboard(logging_stats->getCurrentScoreboard(), ¤t_scoreboard_status_vars, NULL);
128 status_var_to_display->copyGlobalVariables(logging_stats->getCumulativeStats()->getGlobalStatusVars());
129 status_var_to_display->copyGlobalVariables(¤t_scoreboard_status_vars);
133 status_var_to_display= NULL;
138 status_var_to_display=
new StatusVars();
139 CumulativeStats *cumulativeStats= logging_stats->getCumulativeStats();
140 cumulativeStats->sumCurrentScoreboard(logging_stats->getCurrentScoreboard(), status_var_to_display, NULL);
141 status_var_to_display->merge(logging_stats->getCumulativeStats()->getGlobalStatusVars());
145StatusTool::Generator::~Generator()
147 delete status_var_to_display;
150bool StatusTool::Generator::populate()
152 if (status_var_to_display == NULL)
157 while (all_status_vars_it != all_status_vars_end)
159 drizzle_show_var *variables= *all_status_vars_it;
161 if ((variables == NULL) || (variables->name == NULL))
166 drizzle_show_var *var;
167 MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
168 char *
const buff= (
char *) &buff_data;
174 drizzle_show_var tmp;
175 for (var= variables; var->type == SHOW_FUNC; var= &tmp)
176 ((drizzle_show_var_func)((st_show_var_func_container *)var->value)->func)(&tmp, buff);
178 if (isWild(variables->name))
180 ++all_status_vars_it;
184 fill(variables->name, var->value, var->type);
186 ++all_status_vars_it;
194void StatusTool::Generator::fill(
const string &name,
char *value, SHOW_TYPE show_type)
196 struct system_status_var *status_var;
200 status_var= status_var_to_display->getStatusVarCounters();
202 return_value= StatusHelper::fillHelper(status_var, value, show_type);
205 if (return_value.length())
TODO: Rename this file - func.h is stupid.