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",
80
status_columns->push_back(new plugin::ColumnInfo("VARIABLE_VALUE",
88
return status_columns;
92
* Initialize the I_S table.
94
* @return a pointer to an I_S table
96
plugin::InfoSchemaTable *GlobalStatusIS::getTable()
98
status_columns= createColumns();
102
methods= new StatusISMethods();
105
if (glob_status_table == NULL)
107
glob_status_table= new plugin::InfoSchemaTable("GLOBAL_STATUS",
109
-1, -1, false, false,
114
return glob_status_table;
118
* Delete memory allocated for the table, columns and methods.
120
void GlobalStatusIS::cleanup()
122
clearColumns(*status_columns);
123
delete glob_status_table;
125
delete status_columns;
129
* Initialize the I_S table.
131
* @return a pointer to an I_S table
133
plugin::InfoSchemaTable *SessionStatusIS::getTable()
135
if (sess_status_table == NULL)
137
sess_status_table= new plugin::InfoSchemaTable("SESSION_STATUS",
139
-1, -1, false, false,
144
return sess_status_table;
148
* Delete memory allocated for the table, columns and methods.
150
void SessionStatusIS::cleanup()
152
delete sess_status_table;
156
* Initialize the I_S table.
158
* @return a pointer to an I_S table
160
plugin::InfoSchemaTable *StatusIS::getTable()
162
if (status_table == NULL)
164
status_table= new plugin::InfoSchemaTable("STATUS",
166
-1, -1, true, false, 0,
174
* Delete memory allocated for the table, columns and methods.
176
void StatusIS::cleanup()
181
int StatusISMethods::fillTable(Session *session, TableList *tables)
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= tables->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, "", tables->table,
223
pthread_mutex_unlock(&LOCK_status);