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
* Modules 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"
35
using namespace drizzled;
39
* Vectors of columns for the modules I_S table.
41
static vector<const plugin::ColumnInfo *> *columns= NULL;
44
* Methods for the modules I_S table.
46
static plugin::InfoSchemaMethods *methods= NULL;
51
static plugin::InfoSchemaTable *mods_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 *> *ModulesIS::createColumns()
62
columns= new vector<const plugin::ColumnInfo *>;
66
clearColumns(*columns);
69
columns->push_back(new plugin::ColumnInfo("MODULE_NAME",
77
columns->push_back(new plugin::ColumnInfo("MODULE_VERSION",
85
columns->push_back(new plugin::ColumnInfo("MODULE_AUTHOR",
93
columns->push_back(new plugin::ColumnInfo("IS_BUILTIN",
101
columns->push_back(new plugin::ColumnInfo("MODULE_LIBRARY",
103
DRIZZLE_TYPE_VARCHAR,
109
columns->push_back(new plugin::ColumnInfo("MODULE_DESCRIPTION",
111
DRIZZLE_TYPE_VARCHAR,
117
columns->push_back(new plugin::ColumnInfo("MODULE_LICENSE",
119
DRIZZLE_TYPE_VARCHAR,
128
* Initialize the I_S table.
130
* @return a pointer to an I_S table
132
plugin::InfoSchemaTable *ModulesIS::getTable()
134
columns= createColumns();
138
methods= new ModulesISMethods();
141
if (mods_table == NULL)
143
mods_table= new plugin::InfoSchemaTable("MODULES",
145
-1, -1, false, false, 0,
153
* Delete memory allocated for the table, columns and methods.
155
void ModulesIS::cleanup()
157
clearColumns(*columns);
163
class ShowModules : public unary_function<drizzled::plugin::Module *, bool>
168
ShowModules(Session *session_arg, Table *table_arg)
169
: session(session_arg), table(table_arg) {}
171
result_type operator() (argument_type module)
173
const drizzled::plugin::Manifest &manifest= module->getManifest();
174
const CHARSET_INFO * const cs= system_charset_info;
176
table->restoreRecordAsDefault();
178
table->field[0]->store(module->getName().c_str(),
179
module->getName().size(), cs);
181
if (manifest.version)
183
table->field[1]->store(manifest.version, strlen(manifest.version), cs);
184
table->field[1]->set_notnull();
187
table->field[1]->set_null();
191
table->field[2]->store(manifest.author, strlen(manifest.author), cs);
192
table->field[2]->set_notnull();
196
table->field[2]->set_null();
199
if (module->plugin_dl == NULL)
201
table->field[3]->store(STRING_WITH_LEN("YES"),cs);
202
table->field[4]->set_null();
206
table->field[3]->store(STRING_WITH_LEN("NO"),cs);
207
table->field[4]->store(module->plugin_dl->dl.str,
208
module->plugin_dl->dl.length, cs);
213
table->field[5]->store(manifest.descr, strlen(manifest.descr), cs);
214
table->field[5]->set_notnull();
218
table->field[5]->set_null();
221
switch (manifest.license) {
222
case PLUGIN_LICENSE_GPL:
223
table->field[6]->store(drizzled::plugin::LICENSE_GPL_STRING.c_str(),
224
drizzled::plugin::LICENSE_GPL_STRING.size(), cs);
226
case PLUGIN_LICENSE_BSD:
227
table->field[6]->store(drizzled::plugin::LICENSE_BSD_STRING.c_str(),
228
drizzled::plugin::LICENSE_BSD_STRING.size(), cs);
230
case PLUGIN_LICENSE_LGPL:
231
table->field[6]->store(drizzled::plugin::LICENSE_LGPL_STRING.c_str(),
232
drizzled::plugin::LICENSE_LGPL_STRING.size(), cs);
235
table->field[6]->store(drizzled::plugin::LICENSE_PROPRIETARY_STRING.c_str(),
236
drizzled::plugin::LICENSE_PROPRIETARY_STRING.size(),
240
table->field[6]->set_notnull();
242
return schema_table_store_record(session, table);
246
int ModulesISMethods::fillTable(Session *session, TableList *tables)
248
Table *table= tables->table;
250
drizzled::plugin::Registry ®istry= drizzled::plugin::Registry::singleton();
251
vector<drizzled::plugin::Module *> modules= registry.getList(true);
252
vector<drizzled::plugin::Module *>::iterator iter=
253
find_if(modules.begin(), modules.end(), ShowModules(session, table));
254
if (iter != modules.end())