1
/* Copyright (C) 2003 MySQL AB
2
Copyright (C) 2010 Brian Aker
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#include "drizzled/field.h"
18
#include "drizzled/field/blob.h"
19
#include "drizzled/field/timestamp.h"
20
#include "plugin/myisam/myisam.h"
21
#include "drizzled/table.h"
22
#include "drizzled/session.h"
23
#include <drizzled/thr_lock.h>
24
#include <drizzled/my_hash.h>
25
#include <drizzled/cursor.h>
34
#include <boost/unordered_map.hpp>
35
#include "drizzled/util/string.h"
38
#include "plugin/archive/ha_archive.h"
46
#ifndef PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
47
#define PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
49
/* The file extension */
50
#define ARZ ".arz" // The data file
51
#define ARN ".ARN" // Files used during an optimize call
54
We just implement one additional file extension.
56
static const char *ha_archive_exts[] = {
62
class ArchiveEngine : public drizzled::plugin::StorageEngine
64
typedef boost::unordered_map<std::string, ArchiveShare *, drizzled::util::insensitive_hash, drizzled::util::insensitive_equal_to> ArchiveMap;
65
ArchiveMap archive_open_tables;
67
/* Variables for archive share methods */
68
pthread_mutex_t _mutex;
72
drizzled::plugin::StorageEngine("ARCHIVE",
73
drizzled::HTON_STATS_RECORDS_IS_EXACT |
74
drizzled::HTON_HAS_RECORDS),
77
pthread_mutex_init(&_mutex, NULL);
78
table_definition_ext= ARZ;
82
pthread_mutex_destroy(&_mutex);
85
pthread_mutex_t &mutex()
90
virtual drizzled::Cursor *create(drizzled::TableShare &table)
92
return new ha_archive(*this, table);
95
const char **bas_ext() const {
96
return ha_archive_exts;
99
int doCreateTable(drizzled::Session &session,
100
drizzled::Table &table_arg,
101
const drizzled::TableIdentifier &identifier,
102
drizzled::message::Table& proto);
104
int doGetTableDefinition(drizzled::Session& session,
105
const drizzled::TableIdentifier &identifier,
106
drizzled::message::Table &table_message);
108
int doDropTable(drizzled::Session&, const drizzled::TableIdentifier &identifier);
110
ArchiveShare *findOpenTable(const std::string table_name);
111
void addOpenTable(const std::string &table_name, ArchiveShare *);
112
void deleteOpenTable(const std::string &table_name);
114
uint32_t max_supported_keys() const { return 1; }
115
uint32_t max_supported_key_length() const { return sizeof(uint64_t); }
116
uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
118
uint32_t index_flags(enum drizzled::ha_key_alg) const
120
return HA_ONLY_WHOLE_INDEX;
123
bool doDoesTableExist(drizzled::Session&, const drizzled::TableIdentifier &identifier);
124
int doRenameTable(drizzled::Session&, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
126
void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
127
const drizzled::SchemaIdentifier &schema_identifier,
128
drizzled::TableIdentifiers &set_of_identifiers);
131
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */