1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
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
21
#ifndef PLUGIN_INFORMATION_ENGINE_INFORMATION_ENGINE_H
22
#define PLUGIN_INFORMATION_ENGINE_INFORMATION_ENGINE_H
24
#include <drizzled/thr_lock.h>
25
#include <drizzled/plugin/info_schema_table.h>
26
#include <drizzled/plugin/storage_engine.h>
28
static const char *information_exts[] = {
33
class InformationEngine : public drizzled::plugin::StorageEngine
36
InformationEngine(const std::string &name_arg)
37
: drizzled::plugin::StorageEngine(name_arg,
38
drizzled::HTON_ALTER_NOT_SUPPORTED |
39
drizzled::HTON_SKIP_STORE_LOCK |
40
drizzled::HTON_HIDDEN |
41
drizzled::HTON_TEMPORARY_NOT_SUPPORTED)
43
pthread_mutex_init(&mutex, NULL);
48
pthread_mutex_destroy(&mutex);
55
drizzled::plugin::InfoSchemaTable *table;
58
drizzled::THR_LOCK lock;
60
Share(const std::string &in_name) :
63
table= drizzled::plugin::InfoSchemaTable::getTable(in_name.c_str());
73
void deinitThreadLock()
75
thr_lock_delete(&lock);
79
* Increment the counter which tracks how many instances of this share are
81
* @return the new counter value
83
uint32_t incUseCount(void)
89
* Decrement the count which tracks how many instances of this share are
91
* @return the new counter value
93
uint32_t decUseCount(void)
99
* @ return the value of the use counter for this share
101
uint32_t getUseCount() const
107
* @return the table name associated with this share.
109
const std::string &getName() const
111
return table->getTableName();
115
* Set the I_S table associated with this share.
116
* @param[in] name the name of the I_S table
118
void setInfoSchemaTable(const std::string &name)
120
table= drizzled::plugin::InfoSchemaTable::getTable(name.c_str());
124
* @return the I_S table associated with this share.
126
drizzled::plugin::InfoSchemaTable *getInfoSchemaTable()
133
typedef std::map<const std::string, Share> OpenTables;
134
typedef std::pair<const std::string, Share> Record;
136
OpenTables open_tables;
137
pthread_mutex_t mutex; // Mutext used in getShare() calls
141
// Follow Two Methods are for "share"
142
Share *getShare(const std::string &name_arg);
143
void freeShare(Share *share);
146
int doCreateTable(drizzled::Session *,
149
drizzled::message::Table&)
154
int doDropTable(drizzled::Session&, const std::string)
159
virtual drizzled::Cursor *create(drizzled::TableShare &table,
160
drizzled::memory::Root *mem_root);
162
const char **bas_ext() const
164
return information_exts;
167
void doGetTableNames(drizzled::CachedDirectory&,
169
std::set<std::string> &set_of_names);
171
int doGetTableDefinition(drizzled::Session &session,
174
const char *table_name,
176
drizzled::message::Table *table_proto);
180
#endif /* PLUGIN_INFORMATION_ENGINE_INFORMATION_ENGINE_H */