140
130
usually StorageEngine instance is defined statically in ha_xxx.cc as
142
132
static StorageEngine { ... } xxx_engine;
134
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
144
class StorageEngine : public Plugin,
145
public MonitoredInTransaction
136
class StorageEngine : public Plugin
148
139
typedef uint64_t Table_flags;
144
Name used for storage engine.
146
const bool two_phase_commit;
151
149
const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
153
virtual void setTransactionReadWrite(Session& session);
156
* Indicates to a storage engine the start of a
159
virtual void doStartStatement(Session *session)
165
* Indicates to a storage engine the end of
166
* the current SQL statement in the supplied
169
virtual void doEndStatement(Session *session)
151
void setTransactionReadWrite(Session& session);
175
154
std::string table_definition_ext;
204
183
ProtoCache proto_cache;
205
184
pthread_mutex_t proto_cache_mutex;
187
* Implementing classes should override these to provide savepoint
190
virtual int savepoint_set_hook(Session *, NamedSavepoint &) { return 0; }
192
virtual int savepoint_rollback_hook(Session *, NamedSavepoint &) { return 0; }
194
virtual int savepoint_release_hook(Session *, NamedSavepoint &) { return 0; }
209
198
StorageEngine(const std::string name_arg,
210
const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
199
const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS,
200
bool support_2pc= false);
212
202
virtual ~StorageEngine();
237
227
virtual void print_error(int error, myf errflag, Table& table);
230
each storage engine has it's own memory area (actually a pointer)
231
in the session, for storing per-connection information.
234
session->ha_data[xxx_engine.slot]
236
slot number is initialized by MySQL after xxx_init() is called.
240
inline uint32_t getSlot (void) { return slot; }
241
inline uint32_t getSlot (void) const { return slot; }
242
inline void setSlot (uint32_t value) { slot= value; }
246
return two_phase_commit;
250
bool is_enabled() const
239
255
bool is_user_selectable() const
241
257
return not flags.test(HTON_BIT_NOT_USER_SELECTABLE);
249
265
// @todo match check_flag interface
250
266
virtual uint32_t index_flags(enum ha_key_alg) const { return 0; }
251
virtual void startStatement(Session *session)
253
doStartStatement(session);
255
virtual void endStatement(Session *session)
257
doEndStatement(session);
269
void enable() { enabled= true; }
270
void disable() { enabled= false; }
261
* Called during Session::cleanup() for all engines
273
StorageEngine methods:
275
close_connection is only called if
276
session->ha_data[xxx_engine.slot] is non-zero, so even if you don't need
277
this storage area - set it to something, so that MySQL would know
278
this storage engine was accessed in this connection
263
280
virtual int close_connection(Session *)
285
'all' is true if it's a real commit, that makes persistent changes
286
'all' is false if it's not in fact a commit but an end of the
287
statement that is part of the transaction.
288
NOTE 'all' is also false in auto-commit mode where 'end of statement'
289
and 'real commit' mean the same event.
291
virtual int commit(Session *, bool)
296
virtual int rollback(Session *, bool)
302
The void * points to an uninitialized storage area of requested size
303
(see savepoint_offset description)
305
int savepoint_set(Session *session, NamedSavepoint &sp)
307
return savepoint_set_hook(session, sp);
311
The void * points to a storage area, that was earlier passed
312
to the savepoint_set call
314
int savepoint_rollback(Session *session, NamedSavepoint &sp)
316
return savepoint_rollback_hook(session, sp);
319
int savepoint_release(Session *session, NamedSavepoint &sp)
321
return savepoint_release_hook(session, sp);
324
virtual int prepare(Session *, bool) { return 0; }
325
virtual int recover(XID *, uint32_t) { return 0; }
326
virtual int commit_by_xid(XID *) { return 0; }
327
virtual int rollback_by_xid(XID *) { return 0; }
267
328
virtual Cursor *create(TableShare &, memory::Root *)= 0;
330
virtual void drop_database(char*) { }
331
virtual int start_consistent_snapshot(Session *) { return 0; }
269
332
virtual bool flush_logs() { return false; }
270
333
virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
338
virtual int release_temporary_latches(Session *) { return false; }
276
341
If frm_error() is called then we will use this to find out what file
277
342
extentions exist for the storage engine. This is also used by the default
303
369
return doRenameTable(session, from, to);
306
// @todo move these to protected
372
// TODO: move these to protected
307
373
virtual void doGetTableNames(CachedDirectory &directory,
308
374
std::string& db_name,
309
TableNameList &set_of_names);
375
std::set<std::string>& set_of_names);
310
376
virtual int doDropTable(Session& session,
311
const std::string &table_path)= 0;
377
const std::string table_path)= 0;
313
379
const char *checkLowercaseNames(const char *path, char *tmp_path);
319
385
static int getTableDefinition(Session& session,
320
386
TableIdentifier &identifier,
321
message::Table *table_proto= NULL,
322
bool include_temporary_tables= true);
387
message::Table *table_proto= NULL);
323
388
static int getTableDefinition(Session& session,
324
389
const char* path,
326
391
const char *table_name,
327
392
const bool is_tmp,
328
message::Table *table_proto= NULL,
329
bool include_temporary_tables= true);
330
static bool doesTableExist(Session& session,
331
TableIdentifier &identifier,
332
bool include_temporary_tables= true);
393
message::Table *table_proto= NULL);
334
395
static plugin::StorageEngine *findByName(std::string find_str);
335
396
static plugin::StorageEngine *findByName(Session& session,
336
397
std::string find_str);
337
398
static void closeConnection(Session* session);
338
399
static void dropDatabase(char* path);
400
static int commitOrRollbackByXID(XID *xid, bool commit);
401
static int releaseTemporaryLatches(Session *session);
339
402
static bool flushLogs(plugin::StorageEngine *db_type);
403
static int recover(HASH *commit_list);
404
static int startConsistentSnapshot(Session *session);
340
405
static int dropTable(Session& session,
341
TableIdentifier &identifier);
342
static void getTableNames(const std::string& db_name, TableNameList &set_of_names);
344
// Check to see if any SE objects to creation.
345
static bool canCreateTable(drizzled::TableIdentifier &identifier);
346
virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
347
{ (void)identifier; return true; }
406
TableIdentifier &identifier,
407
bool generate_warning);
408
static void getTableNames(const std::string& db_name, std::set<std::string> &set_of_names);
349
410
// @note All schema methods defined here
350
static void getSchemaNames(SchemaNameList &set_of_names);
411
static void getSchemaNames(std::set<std::string>& set_of_names);
351
412
static bool getSchemaDefinition(const std::string &schema_name, message::Schema &proto);
352
static bool doesSchemaExist(const std::string &schema_name);
353
static const CHARSET_INFO *getSchemaCollation(const std::string &schema_name);
354
static bool createSchema(const drizzled::message::Schema &schema_message);
355
static bool dropSchema(const std::string &schema_name);
356
static bool alterSchema(const drizzled::message::Schema &schema_message);
358
// @note make private/protected
359
virtual void doGetSchemaNames(SchemaNameList &set_of_names)
360
{ (void)set_of_names; }
362
virtual bool doGetSchemaDefinition(const std::string &schema_name, drizzled::message::Schema &proto)
370
virtual bool doCreateSchema(const drizzled::message::Schema &schema_message)
371
{ (void)schema_message; return false; }
373
virtual bool doAlterSchema(const drizzled::message::Schema &schema_message)
374
{ (void)schema_message; return false; }
376
virtual bool doDropSchema(const std::string &schema_name)
377
{ (void)schema_name; return false; }
379
415
static inline const std::string &resolveName(const StorageEngine *engine)
413
450
static int deleteDefinitionFromPath(TableIdentifier &identifier);
414
451
static int renameDefinitionFromPath(TableIdentifier &dest, TableIdentifier &src);
415
452
static int writeDefinitionFromPath(TableIdentifier &identifier, message::Table &proto);
419
* The below are simple virtual overrides for the plugin::MonitoredInTransaction
422
virtual bool participatesInSqlTransaction() const
424
return false; /* plugin::StorageEngine is non-transactional in terms of SQL */
426
virtual bool participatesInXaTransaction() const
428
return false; /* plugin::StorageEngine is non-transactional in terms of XA */
430
virtual bool alwaysRegisterForXaTransaction() const
436
455
} /* namespace plugin */