1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems, Inc.
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
#include <plugin/function_engine/function.h>
24
#include <plugin/function_engine/cursor.h>
29
using namespace drizzled;
31
Function::Function(const std::string &name_arg) :
32
drizzled::plugin::StorageEngine(name_arg,
33
HTON_ALTER_NOT_SUPPORTED |
34
HTON_HAS_SCHEMA_DICTIONARY |
35
HTON_SKIP_STORE_LOCK |
36
HTON_TEMPORARY_NOT_SUPPORTED),
37
information_message(new(message::Schema)),
38
data_dictionary_message(new(message::Schema))
41
information_message->set_name(INFORMATION_SCHEMA_IDENTIFIER.getSchemaName());
42
information_message->set_collation("utf8_general_ci");
43
information_message->mutable_replication_options()->set_dont_replicate(true);
45
data_dictionary_message->set_name(DATA_DICTIONARY_IDENTIFIER.getSchemaName());
46
data_dictionary_message->set_collation("utf8_general_ci");
47
data_dictionary_message->mutable_replication_options()->set_dont_replicate(true);
51
Cursor *Function::create(Table &table)
53
return new FunctionCursor(*this, table);
56
int Function::doGetTableDefinition(Session &,
57
const identifier::Table &identifier,
58
message::Table &table_proto)
60
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
67
function->define(table_proto);
72
void Function::doGetSchemaIdentifiers(identifier::Schema::vector& schemas)
74
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
75
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
78
drizzled::message::schema::shared_ptr Function::doGetSchemaDefinition(const identifier::Schema &schema_identifier)
80
drizzled::message::schema::shared_ptr schema_message;
82
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
84
schema_message= information_message;
86
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
88
schema_message= data_dictionary_message;
92
return drizzled::message::schema::shared_ptr();
95
return schema_message;
98
bool Function::doCanCreateTable(const drizzled::identifier::Table &table_identifier)
100
if (static_cast<const identifier::Schema&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
105
else if (static_cast<const identifier::Schema&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
113
bool Function::doDoesTableExist(Session&, const identifier::Table &identifier)
115
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
124
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
125
const drizzled::identifier::Schema &schema_identifier,
126
drizzled::identifier::Table::vector &set_of_identifiers)
128
set<std::string> set_of_names;
129
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
131
for (set<std::string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
133
set_of_identifiers.push_back(identifier::Table(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
137
static int init(drizzled::module::Context &context)
139
context.add(new Function("FunctionEngine"));
144
DRIZZLE_DECLARE_PLUGIN
150
"Function Engine provides the infrastructure for Table Functions,etc.",
152
init, /* Plugin Init */
154
NULL /* config options */
156
DRIZZLE_DECLARE_PLUGIN_END;