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.
26
#include "drizzled/server_includes.h"
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
30
#include "helper_methods.h"
31
#include "variables.h"
35
using namespace drizzled;
39
* Vectors of columns for the variables I_S tables.
41
extern vector<const plugin::ColumnInfo *> *status_columns;
44
* Methods for the variables related I_S tables.
46
static plugin::InfoSchemaMethods *methods= NULL;
49
* variables I_S tables.
51
static plugin::InfoSchemaTable *glob_var_table= NULL;
52
static plugin::InfoSchemaTable *sess_var_table= NULL;
53
static plugin::InfoSchemaTable *var_table= NULL;
56
* Initialize the I_S table.
58
* @return a pointer to an I_S table
60
plugin::InfoSchemaTable *GlobalVariablesIS::getTable()
64
methods= new VariablesISMethods();
67
if (glob_var_table == NULL)
69
glob_var_table= new plugin::InfoSchemaTable("GLOBAL_VARIABLES",
76
return glob_var_table;
80
* Delete memory allocated for the table, columns and methods.
82
void GlobalVariablesIS::cleanup()
84
delete glob_var_table;
89
* Initialize the I_S table.
91
* @return a pointer to an I_S table
93
plugin::InfoSchemaTable *SessionVariablesIS::getTable()
95
if (sess_var_table == NULL)
97
sess_var_table= new plugin::InfoSchemaTable("SESSION_VARIABLES",
99
-1, -1, false, false, 0,
103
return sess_var_table;
107
* Delete memory allocated for the table, columns and methods.
109
void SessionVariablesIS::cleanup()
111
delete sess_var_table;
115
* Initialize the I_S table.
117
* @return a pointer to an I_S table
119
plugin::InfoSchemaTable *VariablesIS::getTable()
121
if (var_table == NULL)
123
var_table= new plugin::InfoSchemaTable("VARIABLES",
125
-1, -1, true, false, 0,
133
* Delete memory allocated for the table, columns and methods.
135
void VariablesIS::cleanup()
140
int VariablesISMethods::fillTable(Session *session, TableList *tables)
143
LEX *lex= session->lex;
144
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
145
const string schema_table_name= tables->schema_table->getTableName();
146
enum enum_var_type option_type= OPT_SESSION;
147
bool upper_case_names= (schema_table_name.compare("VARIABLES") != 0);
148
bool sorted_vars= (schema_table_name.compare("VARIABLES") == 0);
150
if (lex->option_type == OPT_GLOBAL ||
151
schema_table_name.compare("GLOBAL_VARIABLES") == 0)
153
option_type= OPT_GLOBAL;
156
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
157
res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
158
option_type, NULL, "", tables->table, upper_case_names);
159
pthread_rwlock_unlock(&LOCK_system_variables_hash);