1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* Copyright (C) 2010 Sun Microsystems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "plugin/status_dictionary/dictionary.h"
#include <drizzled/pthread_globals.h>
#include <drizzled/internal/m_string.h>
#include <drizzled/definitions.h>
#include <drizzled/status_helper.h>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
using namespace drizzled;
StateTool::StateTool(const char *arg, bool global) :
plugin::TableFunction("DATA_DICTIONARY", arg),
option_type(global ? OPT_GLOBAL : OPT_SESSION)
{
add_field("VARIABLE_NAME");
add_field("VARIABLE_VALUE", 1024);
}
StateTool::Generator::Generator(Field **arg, sql_var_t option_arg,
drizzle_show_var *variables_args)
:
plugin::TableFunction::Generator(arg),
option_type(option_arg),
variables(variables_args)
{
}
StateTool::Generator::~Generator()
{
}
bool StateTool::Generator::populate()
{
while (variables && variables->name)
{
drizzle_show_var *var;
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
char * const buff= (char *) &buff_data;
/*
if var->type is SHOW_FUNC, call the function.
Repeat as necessary, if new var is again SHOW_FUNC
*/
{
drizzle_show_var tmp;
for (var= variables; var->type == SHOW_FUNC; var= &tmp)
((drizzle_show_var_func)((st_show_var_func_container *)var->value)->func)(&tmp, buff);
}
if (isWild(variables->name))
{
variables++;
continue;
}
fill(variables->name, var->value, var->type);
variables++;
return true;
}
return false;
}
void StateTool::Generator::fill(const std::string &name, char *value, SHOW_TYPE show_type)
{
std::ostringstream oss;
std::string return_value;
LOCK_global_system_variables.lock();
if (show_type == SHOW_SYS)
{
show_type= ((sys_var*) value)->show_type();
value= (char*) ((sys_var*) value)->value_ptr(&(getSession()), option_type,
&null_lex_str);
}
return_value= StatusHelper::fillHelper(NULL, value, show_type);
LOCK_global_system_variables.unlock();
push(name);
if (return_value.length())
push(return_value);
else
push(" ");
}
|