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
* Plugins I_S table methods.
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
30
#include "helper_methods.h"
35
using namespace drizzled;
39
* Vectors of columns for the plugins I_S table.
41
static vector<const plugin::ColumnInfo *> *columns= NULL;
44
* Methods for the plugins I_S table.
46
static plugin::InfoSchemaMethods *methods= NULL;
51
static plugin::InfoSchemaTable *plugins_table= NULL;
54
* Populate the vectors of columns for the I_S table.
56
* @return a pointer to a std::vector of Columns.
58
vector<const plugin::ColumnInfo *> *PluginsIS::createColumns()
62
columns= new vector<const plugin::ColumnInfo *>;
66
clearColumns(*columns);
69
columns->push_back(new plugin::ColumnInfo("PLUGIN_NAME",
76
columns->push_back(new plugin::ColumnInfo("PLUGIN_TYPE",
83
columns->push_back(new plugin::ColumnInfo("IS_ACTIVE",
90
columns->push_back(new plugin::ColumnInfo("MODULE_NAME",
100
* Initialize the I_S table.
102
* @return a pointer to an I_S table
104
plugin::InfoSchemaTable *PluginsIS::getTable()
106
columns= createColumns();
110
methods= new PluginsISMethods();
113
if (plugins_table == NULL)
115
plugins_table= new plugin::InfoSchemaTable("OLD_PLUGINS",
117
-1, -1, false, false, 0,
121
return plugins_table;
125
* Delete memory allocated for the table, columns and methods.
127
void PluginsIS::cleanup()
129
clearColumns(*columns);
130
delete plugins_table;
136
: public unary_function<pair<const string, const drizzled::plugin::Plugin *>, bool>
140
plugin::InfoSchemaTable *schema_table;
142
ShowPlugins(Session *session_arg, Table *table_arg, plugin::InfoSchemaTable *sch_tab_arg)
143
: session(session_arg), table(table_arg), schema_table(sch_tab_arg) {}
145
result_type operator() (argument_type plugin)
147
const CHARSET_INFO * const cs= system_charset_info;
149
table->restoreRecordAsDefault();
151
/* mark fields that will be written to in the write bitset */
152
table->setWriteSet(0);
153
table->setWriteSet(1);
154
table->setWriteSet(2);
155
table->setWriteSet(3);
156
table->setWriteSet(4);
157
table->setWriteSet(5);
159
table->field[0]->store(plugin.first.c_str(),
160
plugin.first.size(), cs);
162
table->field[1]->store(plugin.second->getTypeName().c_str(),
163
plugin.second->getTypeName().size(), cs);
165
if (plugin.second->isActive())
167
table->field[2]->store(STRING_WITH_LEN("YES"),cs);
171
table->field[2]->store(STRING_WITH_LEN("NO"), cs);
174
table->field[3]->store(plugin.second->getModuleName().c_str(),
175
plugin.second->getModuleName().size(), cs);
177
schema_table->addRow(table->record[0], table->s->reclength);
182
int PluginsISMethods::fillTable(Session *session,
184
plugin::InfoSchemaTable *schema_table)
186
drizzled::plugin::Registry ®istry= drizzled::plugin::Registry::singleton();
187
const map<string, const drizzled::plugin::Plugin *> &plugin_map=
188
registry.getPluginsMap();
189
map<string, const drizzled::plugin::Plugin *>::const_iterator iter=
190
find_if(plugin_map.begin(), plugin_map.end(), ShowPlugins(session, table, schema_table));
191
if (iter != plugin_map.end())