~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/status.cc

  • Committer: Brian Aker
  • Date: 2010-01-27 18:58:12 UTC
  • Revision ID: brian@gaz-20100127185812-n62n0vwetnx8jrjy
Remove dead code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2009 Sun Microsystems
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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
 
19
 */
 
20
 
 
21
/**
 
22
 * @file 
 
23
 *   status I_S table methods.
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
#include "drizzled/session.h"
 
28
#include "drizzled/show.h"
 
29
#include "drizzled/tztime.h"
 
30
#include "drizzled/pthread_globals.h"
 
31
 
 
32
#include "helper_methods.h"
 
33
#include "status.h"
 
34
 
 
35
#include <vector>
 
36
 
 
37
using namespace drizzled;
 
38
using namespace std;
 
39
 
 
40
/*
 
41
 * Vectors of columns for the status I_S tables.
 
42
 */
 
43
vector<const plugin::ColumnInfo *> *status_columns= NULL;
 
44
 
 
45
/*
 
46
 * Methods for the status related I_S tables.
 
47
 */
 
48
static plugin::InfoSchemaMethods *methods= NULL;
 
49
 
 
50
/*
 
51
 * status I_S tables.
 
52
 */
 
53
static plugin::InfoSchemaTable *glob_status_table= NULL;
 
54
static plugin::InfoSchemaTable *sess_status_table= NULL;
 
55
static plugin::InfoSchemaTable *status_table= NULL;
 
56
 
 
57
/**
 
58
 * Populate the vectors of columns for the I_S table.
 
59
 *
 
60
 * @return a pointer to a std::vector of Columns.
 
61
 */
 
62
vector<const plugin::ColumnInfo *> *GlobalStatusIS::createColumns()
 
63
{
 
64
  if (status_columns == NULL)
 
65
  {
 
66
    status_columns= new vector<const plugin::ColumnInfo *>;
 
67
  }
 
68
  else
 
69
  {
 
70
    clearColumns(*status_columns);
 
71
  }
 
72
 
 
73
  status_columns->push_back(new plugin::ColumnInfo("VARIABLE_NAME",
 
74
                                                   64,
 
75
                                                   DRIZZLE_TYPE_VARCHAR,
 
76
                                                   0,
 
77
                                                   0,
 
78
                                                   "Variable_name"));
 
79
 
 
80
  status_columns->push_back(new plugin::ColumnInfo("VARIABLE_VALUE",
 
81
                                                   16300,
 
82
                                                   DRIZZLE_TYPE_VARCHAR,
 
83
                                                   0,
 
84
                                                   1,
 
85
                                                   "Value"));
 
86
 
 
87
  return status_columns;
 
88
}
 
89
 
 
90
/**
 
91
 * Initialize the I_S table.
 
92
 *
 
93
 * @return a pointer to an I_S table
 
94
 */
 
95
plugin::InfoSchemaTable *GlobalStatusIS::getTable()
 
96
{
 
97
  status_columns= createColumns();
 
98
 
 
99
  if (methods == NULL)
 
100
  {
 
101
    methods= new StatusISMethods();
 
102
  }
 
103
 
 
104
  if (glob_status_table == NULL)
 
105
  {
 
106
    glob_status_table= new plugin::InfoSchemaTable("GLOBAL_STATUS",
 
107
                                                   *status_columns,
 
108
                                                   -1, -1, false, false,
 
109
                                                   0, 
 
110
                                                   methods);
 
111
  }
 
112
 
 
113
  return glob_status_table;
 
114
}
 
115
 
 
116
/**
 
117
 * Delete memory allocated for the table, columns and methods.
 
118
 */
 
119
void GlobalStatusIS::cleanup()
 
120
{
 
121
  clearColumns(*status_columns);
 
122
  delete glob_status_table;
 
123
  delete methods;
 
124
  delete status_columns;
 
125
}
 
126
 
 
127
/**
 
128
 * Initialize the I_S table.
 
129
 *
 
130
 * @return a pointer to an I_S table
 
131
 */
 
132
plugin::InfoSchemaTable *SessionStatusIS::getTable()
 
133
{
 
134
  if (sess_status_table == NULL)
 
135
  {
 
136
    sess_status_table= new plugin::InfoSchemaTable("SESSION_STATUS",
 
137
                                                   *status_columns,
 
138
                                                   -1, -1, false, false,
 
139
                                                   0, 
 
140
                                                   methods);
 
141
  }
 
142
 
 
143
  return sess_status_table;
 
144
}
 
145
 
 
146
/**
 
147
 * Delete memory allocated for the table, columns and methods.
 
148
 */
 
149
void SessionStatusIS::cleanup()
 
150
{
 
151
  delete sess_status_table;
 
152
}
 
153
 
 
154
/**
 
155
 * Initialize the I_S table.
 
156
 *
 
157
 * @return a pointer to an I_S table
 
158
 */
 
159
plugin::InfoSchemaTable *StatusIS::getTable()
 
160
{
 
161
  if (status_table == NULL)
 
162
  {
 
163
    status_table= new plugin::InfoSchemaTable("STATUS",
 
164
                                              *status_columns,
 
165
                                              -1, -1, true, false, 0,
 
166
                                              methods);
 
167
  }
 
168
 
 
169
  return status_table;
 
170
}
 
171
 
 
172
/**
 
173
 * Delete memory allocated for the table, columns and methods.
 
174
 */
 
175
void StatusIS::cleanup()
 
176
{
 
177
  delete status_table;
 
178
}
 
179
 
 
180
int StatusISMethods::fillTable(Session *session, 
 
181
                               Table *table,
 
182
                               plugin::InfoSchemaTable *schema_table)
 
183
{
 
184
  LEX *lex= session->lex;
 
185
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
 
186
  int res= 0;
 
187
  STATUS_VAR *tmp1, tmp;
 
188
  const string schema_table_name= schema_table->getTableName();
 
189
  enum enum_var_type option_type;
 
190
  bool upper_case_names= (schema_table_name.compare("STATUS") != 0);
 
191
 
 
192
  if (schema_table_name.compare("STATUS") == 0)
 
193
  {
 
194
    option_type= lex->option_type;
 
195
    if (option_type == OPT_GLOBAL)
 
196
    {
 
197
      tmp1= &tmp;
 
198
    }
 
199
    else
 
200
    {
 
201
      tmp1= session->initial_status_var;
 
202
    }
 
203
  }
 
204
  else if (schema_table_name.compare("GLOBAL_STATUS") == 0)
 
205
  {
 
206
    option_type= OPT_GLOBAL;
 
207
    tmp1= &tmp;
 
208
  }
 
209
  else
 
210
  {
 
211
    option_type= OPT_SESSION;
 
212
    tmp1= &session->status_var;
 
213
  }
 
214
 
 
215
  pthread_mutex_lock(&LOCK_status);
 
216
  if (option_type == OPT_GLOBAL)
 
217
  {
 
218
    calc_sum_of_all_status(&tmp);
 
219
  }
 
220
  res= show_status_array(session, wild,
 
221
                         getFrontOfStatusVars(),
 
222
                         option_type, tmp1, "", table,
 
223
                         upper_case_names,
 
224
                         schema_table);
 
225
  pthread_mutex_unlock(&LOCK_status);
 
226
  return res;
 
227
}
 
228