1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include "plugin/status_dictionary/dictionary.h"
25
#include <drizzled/pthread_globals.h>
26
#include <drizzled/internal/m_string.h>
27
#include <drizzled/definitions.h>
28
#include <drizzled/status_helper.h>
35
using namespace drizzled;
37
StateTool::StateTool(const char *arg, bool global) :
38
plugin::TableFunction("DATA_DICTIONARY", arg),
39
option_type(global ? OPT_GLOBAL : OPT_SESSION)
41
add_field("VARIABLE_NAME");
42
add_field("VARIABLE_VALUE", 1024);
45
StateTool::Generator::Generator(Field **arg, sql_var_t option_arg,
46
drizzle_show_var *variables_args)
48
plugin::TableFunction::Generator(arg),
49
option_type(option_arg),
50
variables(variables_args)
54
StateTool::Generator::~Generator()
58
bool StateTool::Generator::populate()
60
while (variables && variables->name)
62
drizzle_show_var *var;
63
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
64
char * const buff= (char *) &buff_data;
67
if var->type is SHOW_FUNC, call the function.
68
Repeat as necessary, if new var is again SHOW_FUNC
73
for (var= variables; var->type == SHOW_FUNC; var= &tmp)
74
((mysql_show_var_func)((st_show_var_func_container *)var->value)->func)(&tmp, buff);
77
if (isWild(variables->name))
83
fill(variables->name, var->value, var->type);
93
void StateTool::Generator::fill(const std::string &name, char *value, SHOW_TYPE show_type)
95
std::ostringstream oss;
96
std::string return_value;
98
LOCK_global_system_variables.lock();
100
if (show_type == SHOW_SYS)
102
show_type= ((sys_var*) value)->show_type();
103
value= (char*) ((sys_var*) value)->value_ptr(&(getSession()), option_type,
107
return_value= StatusHelper::fillHelper(NULL, value, show_type);
109
LOCK_global_system_variables.unlock();
111
if (return_value.length())