56 #include "status_tool.h"
57 #include <drizzled/status_helper.h>
62 using namespace drizzled;
63 using namespace plugin;
73 int val= strcmp(var1->name, var2->name);
78 StatusTool::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);
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());
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;
140 cumulativeStats->sumCurrentScoreboard(logging_stats->getCurrentScoreboard(), status_var_to_display, NULL);
141 status_var_to_display->merge(logging_stats->getCumulativeStats()->getGlobalStatusVars());
145 StatusTool::Generator::~Generator()
147 delete status_var_to_display;
150 bool StatusTool::Generator::populate()
152 if (status_var_to_display == NULL)
157 while (all_status_vars_it != all_status_vars_end)
161 if ((variables == NULL) || (variables->name == NULL))
167 MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
168 char *
const buff= (
char *) &buff_data;
177 for (var= variables; var->type == SHOW_FUNC; var= &tmp)
181 if (isWild(variables->name))
183 ++all_status_vars_it;
187 fill(variables->name, var->value, var->type);
189 ++all_status_vars_it;
197 void StatusTool::Generator::fill(
const string &name,
char *value, SHOW_TYPE show_type)
203 status_var= status_var_to_display->getStatusVarCounters();
205 return_value= StatusHelper::fillHelper(status_var, value, show_type);
208 if (return_value.length())