28
28
using namespace std;
29
29
using namespace drizzled;
31
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA");
32
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY");
31
34
Function::Function(const std::string &name_arg) :
32
35
drizzled::plugin::StorageEngine(name_arg,
33
36
HTON_ALTER_NOT_SUPPORTED |
34
37
HTON_HAS_SCHEMA_DICTIONARY |
35
HTON_HAS_DATA_DICTIONARY |
36
38
HTON_SKIP_STORE_LOCK |
37
39
HTON_TEMPORARY_NOT_SUPPORTED)
47
49
int Function::doGetTableDefinition(Session &,
52
message::Table *table_proto)
50
TableIdentifier &identifier,
51
message::Table &table_proto)
54
string tab_name(path);
53
string tab_name(identifier.getPath());
55
54
transform(tab_name.begin(), tab_name.end(),
56
55
tab_name.begin(), ::tolower);
67
function->define(*table_proto);
64
function->define(table_proto);
74
70
void Function::doGetTableNames(drizzled::CachedDirectory&,
71
drizzled::SchemaIdentifier &schema_identifier,
76
72
set<string> &set_of_names)
78
drizzled::plugin::TableFunction::getNames(db, set_of_names);
81
void Function::doGetSchemaNames(std::set<std::string>& set_of_names)
83
set_of_names.insert("information_schema"); // special cases suck
84
set_of_names.insert("data_dictionary"); // special cases suck
87
bool Function::doGetSchemaDefinition(const std::string &schema_name, message::Schema &schema_message)
89
if (not schema_name.compare("information_schema"))
74
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
77
void Function::doGetSchemaIdentifiers(SchemaIdentifierList& schemas)
79
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
80
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
83
bool Function::doGetSchemaDefinition(SchemaIdentifier &schema_identifier, message::Schema &schema_message)
85
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
91
87
schema_message.set_name("information_schema");
92
88
schema_message.set_collation("utf8_general_ci");
94
else if (not schema_name.compare("data_dictionary"))
90
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
96
92
schema_message.set_name("data_dictionary");
97
93
schema_message.set_collation("utf8_general_ci");
107
bool Function::doCanCreateTable(const drizzled::TableIdentifier &identifier)
103
bool Function::doCanCreateTable(drizzled::TableIdentifier &table_identifier)
109
if (not strcasecmp(identifier.getSchemaName(), "information_schema"))
105
if (static_cast<SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
114
if (not strcasecmp(identifier.getSchemaName(), "data_dictionary"))
110
else if (static_cast<SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
123
static drizzled::plugin::StorageEngine *function_plugin= NULL;
125
static int init(drizzled::plugin::Registry ®istry)
127
function_plugin= new(std::nothrow) Function("FunctionEngine");
129
if (not function_plugin)
118
bool Function::doDoesTableExist(Session&, TableIdentifier &identifier)
120
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
129
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
130
drizzled::SchemaIdentifier &schema_identifier,
131
drizzled::TableIdentifiers &set_of_identifiers)
133
set<string> set_of_names;
134
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
136
for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
138
set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter));
134
registry.add(function_plugin);
139
static int finalize(drizzled::plugin::Registry ®istry)
142
static int init(drizzled::plugin::Context &context)
141
registry.remove(function_plugin);
142
delete function_plugin;
144
context.add(new Function("FunctionEngine"));
153
155
"Function Engine provides the infrastructure for Table Functions,etc.",
154
156
PLUGIN_LICENSE_GPL,
155
157
init, /* Plugin Init */
156
finalize, /* Plugin Deinit */
157
158
NULL, /* system variables */
158
159
NULL /* config options */