~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/info_schema_methods.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-06-29 16:05:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1081.
  • Revision ID: osullivan.padraig@gmail.com-20090629160547-0c2ktadq91vx6id0
Extracted the PLUGINS table into the I_S plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
  return (res);
265
265
}
266
266
 
 
267
class ShowPlugins : public unary_function<st_plugin_int *, bool>
 
268
{
 
269
  Session *session;
 
270
  Table *table;
 
271
public:
 
272
  ShowPlugins(Session *session_arg, Table *table_arg)
 
273
    : session(session_arg), table(table_arg) {}
 
274
 
 
275
  result_type operator() (argument_type plugin)
 
276
  {
 
277
    struct drizzled_plugin_manifest *plug= plugin_decl(plugin);
 
278
    const CHARSET_INFO * const cs= system_charset_info;
 
279
 
 
280
    table->restoreRecordAsDefault();
 
281
 
 
282
    table->field[0]->store(plugin_name(plugin)->str,
 
283
                           plugin_name(plugin)->length, cs);
 
284
 
 
285
    if (plug->version)
 
286
    {
 
287
      table->field[1]->store(plug->version, strlen(plug->version), cs);
 
288
      table->field[1]->set_notnull();
 
289
    }
 
290
    else
 
291
      table->field[1]->set_null();
 
292
 
 
293
    if (plugin->isInited)
 
294
    {
 
295
      table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
 
296
    }
 
297
    else
 
298
    {
 
299
      table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
 
300
    }
 
301
 
 
302
    if (plug->author)
 
303
    {
 
304
      table->field[3]->store(plug->author, strlen(plug->author), cs);
 
305
      table->field[3]->set_notnull();
 
306
    }
 
307
    else
 
308
    {
 
309
      table->field[3]->set_null();
 
310
    }
 
311
 
 
312
    if (plug->descr)
 
313
    {
 
314
      table->field[4]->store(plug->descr, strlen(plug->descr), cs);
 
315
      table->field[4]->set_notnull();
 
316
    }
 
317
    else
 
318
    {
 
319
      table->field[4]->set_null();
 
320
    }
 
321
 
 
322
    switch (plug->license) {
 
323
    case PLUGIN_LICENSE_GPL:
 
324
      table->field[5]->store(PLUGIN_LICENSE_GPL_STRING,
 
325
                             strlen(PLUGIN_LICENSE_GPL_STRING), cs);
 
326
      break;
 
327
    case PLUGIN_LICENSE_BSD:
 
328
      table->field[5]->store(PLUGIN_LICENSE_BSD_STRING,
 
329
                             strlen(PLUGIN_LICENSE_BSD_STRING), cs);
 
330
      break;
 
331
    case PLUGIN_LICENSE_LGPL:
 
332
      table->field[5]->store(PLUGIN_LICENSE_LGPL_STRING,
 
333
                             strlen(PLUGIN_LICENSE_LGPL_STRING), cs);
 
334
      break;
 
335
    default:
 
336
      table->field[5]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
 
337
                             strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
 
338
      break;
 
339
    }
 
340
    table->field[5]->set_notnull();
 
341
 
 
342
    return schema_table_store_record(session, table);
 
343
  }
 
344
};
 
345
 
 
346
int PluginsISMethods::fillTable(Session *session, TableList *tables, COND *)
 
347
{
 
348
  Table *table= tables->table;
 
349
 
 
350
  PluginRegistry &registry= PluginRegistry::getPluginRegistry();
 
351
  vector<st_plugin_int *> plugins= registry.get_list(true);
 
352
  vector<st_plugin_int *>::iterator iter=
 
353
    find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));
 
354
  if (iter != plugins.end())
 
355
  {
 
356
    return 1;
 
357
  }
 
358
  return (0);
 
359
}
 
360
 
267
361
int ProcessListISMethods::fillTable(Session* session, TableList* tables, COND*)
268
362
{
269
363
  Table *table= tables->table;