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
HTON_HAS_DATA_DICTIONARY |
37
HTON_HAS_SCHEMA_DICTIONARY |
35
38
HTON_SKIP_STORE_LOCK |
36
39
HTON_TEMPORARY_NOT_SUPPORTED)
41
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
44
Cursor *Function::create(TableShare &table)
43
return new (mem_root) FunctionCursor(*this, table);
46
return new FunctionCursor(*this, table);
46
49
int Function::doGetTableDefinition(Session &,
51
message::Table *table_proto)
50
const TableIdentifier &identifier,
51
message::Table &table_proto)
53
string tab_name(path);
54
transform(tab_name.begin(), tab_name.end(),
55
tab_name.begin(), ::tolower);
57
drizzled::plugin::TableFunction *function= getFunction(tab_name);
53
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
66
function->define(*table_proto);
60
function->define(table_proto);
73
void Function::doGetTableNames(drizzled::CachedDirectory&,
75
set<string> &set_of_names)
77
drizzled::plugin::TableFunction::getNames(db, set_of_names);
81
static drizzled::plugin::StorageEngine *function_plugin= NULL;
83
static int init(drizzled::plugin::Registry ®istry)
85
function_plugin= new(std::nothrow) Function("FunctionEngine");
87
if (not function_plugin)
92
registry.add(function_plugin);
97
static int finalize(drizzled::plugin::Registry ®istry)
99
registry.remove(function_plugin);
100
delete function_plugin;
65
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
67
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
68
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
71
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::Schema &schema_message)
73
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
75
schema_message.set_name("information_schema");
76
schema_message.set_collation("utf8_general_ci");
78
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
80
schema_message.set_name("data_dictionary");
81
schema_message.set_collation("utf8_general_ci");
91
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
93
if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
98
else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
106
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
108
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
117
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
118
const drizzled::SchemaIdentifier &schema_identifier,
119
drizzled::TableIdentifiers &set_of_identifiers)
121
set<string> set_of_names;
122
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
124
for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
126
set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
130
static int init(drizzled::module::Context &context)
132
context.add(new Function("FunctionEngine"));