1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 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
* status I_S table methods.
26
#include "drizzled/server_includes.h"
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
29
#include "drizzled/tztime.h"
31
#include "helper_methods.h"
36
using namespace drizzled;
40
* Vectors of columns for the status I_S tables.
42
vector<const plugin::ColumnInfo *> *status_columns= NULL;
45
* Methods for the status related I_S tables.
47
static plugin::InfoSchemaMethods *methods= NULL;
52
static plugin::InfoSchemaTable *glob_status_table= NULL;
53
static plugin::InfoSchemaTable *sess_status_table= NULL;
54
static plugin::InfoSchemaTable *status_table= NULL;
57
* Populate the vectors of columns for the I_S table.
59
* @return a pointer to a std::vector of Columns.
61
vector<const plugin::ColumnInfo *> *GlobalStatusIS::createColumns()
63
if (status_columns == NULL)
65
status_columns= new vector<const plugin::ColumnInfo *>;
69
clearColumns(*status_columns);
72
status_columns->push_back(new plugin::ColumnInfo("VARIABLE_NAME",
79
status_columns->push_back(new plugin::ColumnInfo("VARIABLE_VALUE",
86
return status_columns;
90
* Initialize the I_S table.
92
* @return a pointer to an I_S table
94
plugin::InfoSchemaTable *GlobalStatusIS::getTable()
96
status_columns= createColumns();
100
methods= new StatusISMethods();
103
if (glob_status_table == NULL)
105
glob_status_table= new plugin::InfoSchemaTable("GLOBAL_STATUS",
107
-1, -1, false, false,
112
return glob_status_table;
116
* Delete memory allocated for the table, columns and methods.
118
void GlobalStatusIS::cleanup()
120
clearColumns(*status_columns);
121
delete glob_status_table;
123
delete status_columns;
127
* Initialize the I_S table.
129
* @return a pointer to an I_S table
131
plugin::InfoSchemaTable *SessionStatusIS::getTable()
133
if (sess_status_table == NULL)
135
sess_status_table= new plugin::InfoSchemaTable("SESSION_STATUS",
137
-1, -1, false, false,
142
return sess_status_table;
146
* Delete memory allocated for the table, columns and methods.
148
void SessionStatusIS::cleanup()
150
delete sess_status_table;
154
* Initialize the I_S table.
156
* @return a pointer to an I_S table
158
plugin::InfoSchemaTable *StatusIS::getTable()
160
if (status_table == NULL)
162
status_table= new plugin::InfoSchemaTable("STATUS",
164
-1, -1, true, false, 0,
172
* Delete memory allocated for the table, columns and methods.
174
void StatusIS::cleanup()
179
int StatusISMethods::fillTable(Session *session,
181
plugin::InfoSchemaTable *schema_table)
183
LEX *lex= session->lex;
184
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
186
STATUS_VAR *tmp1, tmp;
187
const string schema_table_name= schema_table->getTableName();
188
enum enum_var_type option_type;
189
bool upper_case_names= (schema_table_name.compare("STATUS") != 0);
191
if (schema_table_name.compare("STATUS") == 0)
193
option_type= lex->option_type;
194
if (option_type == OPT_GLOBAL)
200
tmp1= session->initial_status_var;
203
else if (schema_table_name.compare("GLOBAL_STATUS") == 0)
205
option_type= OPT_GLOBAL;
210
option_type= OPT_SESSION;
211
tmp1= &session->status_var;
214
pthread_mutex_lock(&LOCK_status);
215
if (option_type == OPT_GLOBAL)
217
calc_sum_of_all_status(&tmp);
219
res= show_status_array(session, wild,
220
getFrontOfStatusVars(),
221
option_type, tmp1, "", table,
224
pthread_mutex_unlock(&LOCK_status);