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.
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
29
#include "drizzled/tztime.h"
30
#include "drizzled/pthread_globals.h"
32
#include "helper_methods.h"
37
using namespace drizzled;
41
* Vectors of columns for the status I_S tables.
43
vector<const plugin::ColumnInfo *> *status_columns= NULL;
46
* Methods for the status related I_S tables.
48
static plugin::InfoSchemaMethods *methods= NULL;
53
static plugin::InfoSchemaTable *glob_status_table= NULL;
54
static plugin::InfoSchemaTable *sess_status_table= NULL;
55
static plugin::InfoSchemaTable *status_table= NULL;
58
* Populate the vectors of columns for the I_S table.
60
* @return a pointer to a std::vector of Columns.
62
vector<const plugin::ColumnInfo *> *GlobalStatusIS::createColumns()
64
if (status_columns == NULL)
66
status_columns= new vector<const plugin::ColumnInfo *>;
70
clearColumns(*status_columns);
73
status_columns->push_back(new plugin::ColumnInfo("VARIABLE_NAME",
80
status_columns->push_back(new plugin::ColumnInfo("VARIABLE_VALUE",
87
return status_columns;
91
* Initialize the I_S table.
93
* @return a pointer to an I_S table
95
plugin::InfoSchemaTable *GlobalStatusIS::getTable()
97
status_columns= createColumns();
101
methods= new StatusISMethods();
104
if (glob_status_table == NULL)
106
glob_status_table= new plugin::InfoSchemaTable("OLD_GLOBAL_STATUS",
108
-1, -1, false, false,
113
return glob_status_table;
117
* Delete memory allocated for the table, columns and methods.
119
void GlobalStatusIS::cleanup()
121
clearColumns(*status_columns);
122
delete glob_status_table;
124
delete status_columns;
128
* Initialize the I_S table.
130
* @return a pointer to an I_S table
132
plugin::InfoSchemaTable *SessionStatusIS::getTable()
134
if (sess_status_table == NULL)
136
sess_status_table= new plugin::InfoSchemaTable("OPEN_SESSION_STATUS",
138
-1, -1, false, false,
143
return sess_status_table;
147
* Delete memory allocated for the table, columns and methods.
149
void SessionStatusIS::cleanup()
151
delete sess_status_table;
155
* Initialize the I_S table.
157
* @return a pointer to an I_S table
159
plugin::InfoSchemaTable *StatusIS::getTable()
161
if (status_table == NULL)
163
status_table= new plugin::InfoSchemaTable("OLD_STATUS",
165
-1, -1, true, false, 0,
173
* Delete memory allocated for the table, columns and methods.
175
void StatusIS::cleanup()
180
int StatusISMethods::fillTable(Session *session,
182
plugin::InfoSchemaTable *schema_table)
184
LEX *lex= session->lex;
185
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
187
STATUS_VAR *tmp1, tmp;
188
const string schema_table_name= schema_table->getTableName();
189
sql_var_t option_type;
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);