41
42
class HeapEngine : public plugin::StorageEngine
44
HeapEngine(string name_arg)
45
: plugin::StorageEngine(name_arg,
46
HTON_STATS_RECORDS_IS_EXACT |
51
HTON_SKIP_STORE_LOCK |
45
explicit HeapEngine(string name_arg) :
46
plugin::StorageEngine(name_arg,
47
HTON_STATS_RECORDS_IS_EXACT |
52
HTON_HAS_DATA_DICTIONARY |
53
HTON_SKIP_STORE_LOCK |
56
pthread_mutex_init(&THR_LOCK_heap, MY_MUTEX_INIT_FAST);
61
hp_panic(HA_PANIC_CLOSE);
63
pthread_mutex_destroy(&THR_LOCK_heap);
55
66
virtual Cursor *create(TableShare &table,
56
67
memory::Root *mem_root)
78
89
message::Table &create_proto,
79
90
HP_SHARE **internal_share);
81
int doRenameTable(Session*, const char * from, const char * to);
92
int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
83
94
int doDropTable(Session&, TableIdentifier &identifier);
103
114
HA_KEY_SCAN_NOT_ROR);
117
bool doDoesTableExist(Session& session, TableIdentifier &identifier);
108
int HeapEngine::doGetTableDefinition(Session&,
120
bool HeapEngine::doDoesTableExist(Session& session, TableIdentifier &identifier)
122
return session.doesTableMessageExist(identifier);
125
int HeapEngine::doGetTableDefinition(Session &session,
109
126
TableIdentifier &identifier,
110
127
message::Table &table_proto)
113
ProtoCache::iterator iter;
115
pthread_mutex_lock(&proto_cache_mutex);
116
iter= proto_cache.find(identifier.getPath());
118
if (iter!= proto_cache.end())
120
table_proto.CopyFrom(((*iter).second));
123
pthread_mutex_unlock(&proto_cache_mutex);
129
if (session.getTableMessage(identifier, table_proto))
128
135
We have to ignore ENOENT entries as the MEMORY table is created on open and
129
136
not when doing a CREATE on the table.
131
int HeapEngine::doDropTable(Session&, TableIdentifier &identifier)
138
int HeapEngine::doDropTable(Session &session, TableIdentifier &identifier)
133
ProtoCache::iterator iter;
135
pthread_mutex_lock(&proto_cache_mutex);
136
iter= proto_cache.find(identifier.getPath());
138
if (iter!= proto_cache.end())
139
proto_cache.erase(iter);
140
pthread_mutex_unlock(&proto_cache_mutex);
140
session.removeTableMessage(identifier);
142
142
return heap_delete_table(identifier.getPath().c_str());
145
145
static HeapEngine *heap_storage_engine= NULL;
147
static int heap_init(plugin::Registry ®istry)
147
static int heap_init(plugin::Context &context)
149
149
heap_storage_engine= new HeapEngine(engine_name);
150
registry.add(heap_storage_engine);
151
pthread_mutex_init(&THR_LOCK_heap, MY_MUTEX_INIT_FAST);
150
context.add(heap_storage_engine);
155
static int heap_deinit(plugin::Registry ®istry)
157
registry.remove(heap_storage_engine);
158
delete heap_storage_engine;
160
int ret= hp_panic(HA_PANIC_CLOSE);
162
pthread_mutex_destroy(&THR_LOCK_heap);
169
155
/*****************************************************************************
656
int HeapEngine::doRenameTable(Session*,
657
const char *from, const char *to)
642
int HeapEngine::doRenameTable(Session &session, TableIdentifier &from, TableIdentifier &to)
659
return heap_rename(from,to);
644
session.renameTableMessage(from, to);
645
return heap_rename(from.getPath().c_str(), to.getPath().c_str());