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
* variables I_S table methods.
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
30
#include "helper_methods.h"
31
#include "variables.h"
35
#include "drizzled/pthread_globals.h"
37
using namespace drizzled;
41
* Vectors of columns for the variables I_S tables.
43
extern vector<const plugin::ColumnInfo *> *status_columns;
46
* Methods for the variables related I_S tables.
48
static plugin::InfoSchemaMethods *methods= NULL;
51
* variables I_S tables.
53
static plugin::InfoSchemaTable *glob_var_table= NULL;
54
static plugin::InfoSchemaTable *sess_var_table= NULL;
55
static plugin::InfoSchemaTable *var_table= NULL;
58
* Initialize the I_S table.
60
* @return a pointer to an I_S table
62
plugin::InfoSchemaTable *GlobalVariablesIS::getTable()
66
methods= new VariablesISMethods();
69
if (glob_var_table == NULL)
71
glob_var_table= new plugin::InfoSchemaTable("OLD_GLOBAL_VARIABLES",
78
return glob_var_table;
82
* Delete memory allocated for the table, columns and methods.
84
void GlobalVariablesIS::cleanup()
86
delete glob_var_table;
91
* Initialize the I_S table.
93
* @return a pointer to an I_S table
95
plugin::InfoSchemaTable *SessionVariablesIS::getTable()
97
if (sess_var_table == NULL)
99
sess_var_table= new plugin::InfoSchemaTable("OLD_SESSION_VARIABLES",
101
-1, -1, false, false, 0,
105
return sess_var_table;
109
* Delete memory allocated for the table, columns and methods.
111
void SessionVariablesIS::cleanup()
113
delete sess_var_table;
117
* Initialize the I_S table.
119
* @return a pointer to an I_S table
121
plugin::InfoSchemaTable *VariablesIS::getTable()
123
if (var_table == NULL)
125
var_table= new plugin::InfoSchemaTable("OLD_VARIABLES",
127
-1, -1, true, false, 0,
135
* Delete memory allocated for the table, columns and methods.
137
void VariablesIS::cleanup()
142
int VariablesISMethods::fillTable(Session *session,
144
plugin::InfoSchemaTable *schema_table)
147
LEX *lex= session->lex;
148
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
149
const string schema_table_name= schema_table->getTableName();
150
sql_var_t option_type= OPT_SESSION;
151
bool sorted_vars= (schema_table_name.compare("OLD_VARIABLES") == 0);
153
if (lex->option_type == OPT_GLOBAL ||
154
schema_table_name.compare("GLOBAL_VARIABLES") == 0)
156
option_type= OPT_GLOBAL;
159
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
160
res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
161
option_type, NULL, "", table, false, schema_table);
162
pthread_rwlock_unlock(&LOCK_system_variables_hash);