1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems, Inc.
4
* Copyright (C) 2010 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
32
32
drizzled::plugin::StorageEngine(name_arg,
33
33
HTON_ALTER_NOT_SUPPORTED |
34
34
HTON_HAS_SCHEMA_DICTIONARY |
35
HTON_HAS_DATA_DICTIONARY |
35
36
HTON_SKIP_STORE_LOCK |
36
HTON_TEMPORARY_NOT_SUPPORTED),
37
information_message(new(message::Schema)),
38
data_dictionary_message(new(message::Schema))
37
HTON_TEMPORARY_NOT_SUPPORTED)
41
information_message->set_name(INFORMATION_SCHEMA_IDENTIFIER.getSchemaName());
42
data_dictionary_message->set_collation("utf8_general_ci");
44
data_dictionary_message->set_name(DATA_DICTIONARY_IDENTIFIER.getSchemaName());
45
data_dictionary_message->set_collation("utf8_general_ci");
49
Cursor *Function::create(Table &table)
42
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
51
return new FunctionCursor(*this, table);
44
return new (mem_root) FunctionCursor(*this, table);
54
47
int Function::doGetTableDefinition(Session &,
55
const identifier::Table &identifier,
48
TableIdentifier &identifier,
56
49
message::Table &table_proto)
58
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
51
string tab_name(identifier.getPath());
52
transform(tab_name.begin(), tab_name.end(),
53
tab_name.begin(), ::tolower);
55
drizzled::plugin::TableFunction *function= getFunction(tab_name);
70
void Function::doGetSchemaIdentifiers(identifier::Schema::vector& schemas)
72
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
73
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
76
bool Function::doGetSchemaDefinition(const identifier::Schema &schema_identifier, message::schema::shared_ptr &schema_message)
78
schema_message.reset(new message::Schema); // This should be fixed, we could just be using ones we built on startup.
80
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
68
void Function::doGetTableNames(drizzled::CachedDirectory&,
70
set<string> &set_of_names)
72
drizzled::plugin::TableFunction::getNames(db, set_of_names);
75
void Function::doGetSchemaNames(std::set<std::string>& set_of_names)
77
set_of_names.insert("information_schema"); // special cases suck
78
set_of_names.insert("data_dictionary"); // special cases suck
81
bool Function::doGetSchemaDefinition(const std::string &schema_name, message::Schema &schema_message)
83
if (not schema_name.compare("information_schema"))
82
schema_message= information_message;
85
schema_message.set_name("information_schema");
86
schema_message.set_collation("utf8_general_ci");
84
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
88
else if (not schema_name.compare("data_dictionary"))
86
schema_message= data_dictionary_message;
90
schema_message.set_name("data_dictionary");
91
schema_message.set_collation("utf8_general_ci");
96
bool Function::doCanCreateTable(const drizzled::identifier::Table &table_identifier)
101
bool Function::doCanCreateTable(const drizzled::TableIdentifier &identifier)
98
if (static_cast<const identifier::Schema&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
103
if (not strcasecmp(identifier.getSchemaName(), "information_schema"))
103
else if (static_cast<const identifier::Schema&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
108
if (not strcasecmp(identifier.getSchemaName(), "data_dictionary"))
111
bool Function::doDoesTableExist(Session&, const identifier::Table &identifier)
116
bool Function::doDoesTableExist(Session&, TableIdentifier &identifier)
113
118
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
122
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
123
const drizzled::identifier::Schema &schema_identifier,
124
drizzled::identifier::Table::vector &set_of_identifiers)
127
static drizzled::plugin::StorageEngine *function_plugin= NULL;
129
static int init(drizzled::plugin::Registry ®istry)
126
set<std::string> set_of_names;
127
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
131
function_plugin= new(std::nothrow) Function("FunctionEngine");
129
for (set<std::string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
133
if (not function_plugin)
131
set_of_identifiers.push_back(identifier::Table(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
138
registry.add(function_plugin);
135
static int init(drizzled::module::Context &context)
143
static int finalize(drizzled::plugin::Registry ®istry)
137
context.add(new Function("FunctionEngine"));
145
registry.remove(function_plugin);
146
delete function_plugin;
148
157
"Function Engine provides the infrastructure for Table Functions,etc.",
149
158
PLUGIN_LICENSE_GPL,
150
159
init, /* Plugin Init */
160
finalize, /* Plugin Deinit */
161
NULL, /* system variables */
152
162
NULL /* config options */
154
164
DRIZZLE_DECLARE_PLUGIN_END;