~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handlerton.h

  • Committer: Monty Taylor
  • Date: 2009-03-06 03:33:24 UTC
  • mfrom: (916.1.2 merge)
  • Revision ID: mordred@inaugust.com-20090306033324-dcedf80g9qzywbvu
Merged Brian's merge... re-rotate the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_PLUGIN_STORAGE_ENGINE_H
21
 
#define DRIZZLED_PLUGIN_STORAGE_ENGINE_H
 
20
#ifndef DRIZZLED_HANDLERTON_H
 
21
#define DRIZZLED_HANDLERTON_H
22
22
 
 
23
#include <stdint.h>
 
24
#include <bitset>
23
25
 
24
26
#include <drizzled/definitions.h>
25
 
#include <drizzled/plugin.h>
26
 
#include <drizzled/handler_structs.h>
27
 
#include <drizzled/message.h>
28
 
#include <drizzled/message/cache.h>
29
 
#include "drizzled/plugin/plugin.h"
30
 
#include "drizzled/sql_string.h"
31
 
#include "drizzled/identifier.h"
32
 
#include "drizzled/cached_directory.h"
33
 
#include "drizzled/plugin/monitored_in_transaction.h"
34
 
 
35
 
#include <bitset>
36
 
#include <string>
37
 
#include <vector>
38
 
#include <set>
39
 
 
40
 
namespace drizzled
41
 
{
 
27
#include <drizzled/sql_plugin.h>
42
28
 
43
29
class TableList;
44
30
class Session;
45
 
class Cursor;
46
 
typedef struct st_hash HASH;
 
31
class XID;
 
32
class handler;
47
33
 
48
 
class TableShare;
49
 
typedef drizzle_lex_string LEX_STRING;
 
34
class TABLE_SHARE;
 
35
typedef struct st_mysql_lex_string LEX_STRING;
50
36
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
51
37
                             const char *file, uint32_t file_len,
52
38
                             const char *status, uint32_t status_len);
 
39
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
53
40
 
54
 
/* Possible flags of a StorageEngine (there can be 32 of them) */
55
 
enum engine_flag_bits {
 
41
/* Possible flags of a handlerton (there can be 32 of them) */
 
42
enum hton_flag_bits {
 
43
  HTON_BIT_CLOSE_CURSORS_AT_COMMIT,
56
44
  HTON_BIT_ALTER_NOT_SUPPORTED,       // Engine does not support alter
 
45
  HTON_BIT_CAN_RECREATE,              // Delete all is used for truncate
57
46
  HTON_BIT_HIDDEN,                    // Engine does not appear in lists
 
47
  HTON_BIT_FLUSH_AFTER_RENAME,
58
48
  HTON_BIT_NOT_USER_SELECTABLE,
59
49
  HTON_BIT_TEMPORARY_NOT_SUPPORTED,   // Having temporary tables not supported
60
 
  HTON_BIT_TEMPORARY_ONLY,
61
 
  HTON_BIT_DOES_TRANSACTIONS,
62
 
  HTON_BIT_STATS_RECORDS_IS_EXACT,
63
 
  HTON_BIT_NULL_IN_KEY,
64
 
  HTON_BIT_CAN_INDEX_BLOBS,
65
 
  HTON_BIT_PRIMARY_KEY_IN_READ_INDEX,
66
 
  HTON_BIT_PARTIAL_COLUMN_READ,
67
 
  HTON_BIT_TABLE_SCAN_ON_INDEX,
68
 
  HTON_BIT_FAST_KEY_READ,
69
 
  HTON_BIT_NO_BLOBS,
70
 
  HTON_BIT_HAS_RECORDS,
71
 
  HTON_BIT_NO_AUTO_INCREMENT,
72
 
  HTON_BIT_DUPLICATE_POS,
73
 
  HTON_BIT_AUTO_PART_KEY,
74
 
  HTON_BIT_REQUIRE_PRIMARY_KEY,
75
 
  HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE,
76
 
  HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_DELETE,
77
 
  HTON_BIT_NO_PREFIX_CHAR_KEYS,
78
 
  HTON_BIT_HAS_CHECKSUM,
79
 
  HTON_BIT_SKIP_STORE_LOCK,
80
 
  HTON_BIT_SCHEMA_DICTIONARY,
81
 
  HTON_BIT_FOREIGN_KEYS,
 
50
  HTON_BIT_SUPPORT_LOG_TABLES,        // Engine supports log tables
 
51
  HTON_BIT_NO_PARTITION,              // You can not partition these tables
82
52
  HTON_BIT_SIZE
83
53
};
84
54
 
85
55
static const std::bitset<HTON_BIT_SIZE> HTON_NO_FLAGS(0);
 
56
static const std::bitset<HTON_BIT_SIZE> HTON_CLOSE_CURSORS_AT_COMMIT(1 <<  HTON_BIT_CLOSE_CURSORS_AT_COMMIT);
86
57
static const std::bitset<HTON_BIT_SIZE> HTON_ALTER_NOT_SUPPORTED(1 << HTON_BIT_ALTER_NOT_SUPPORTED);
 
58
static const std::bitset<HTON_BIT_SIZE> HTON_CAN_RECREATE(1 << HTON_BIT_CAN_RECREATE);
87
59
static const std::bitset<HTON_BIT_SIZE> HTON_HIDDEN(1 << HTON_BIT_HIDDEN);
 
60
static const std::bitset<HTON_BIT_SIZE> HTON_FLUSH_AFTER_RENAME(1 << HTON_BIT_FLUSH_AFTER_RENAME);
88
61
static const std::bitset<HTON_BIT_SIZE> HTON_NOT_USER_SELECTABLE(1 << HTON_BIT_NOT_USER_SELECTABLE);
89
62
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_NOT_SUPPORTED(1 << HTON_BIT_TEMPORARY_NOT_SUPPORTED);
90
 
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_ONLY(1 << HTON_BIT_TEMPORARY_ONLY);
91
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_DOES_TRANSACTIONS(1 << HTON_BIT_DOES_TRANSACTIONS);
92
 
static const std::bitset<HTON_BIT_SIZE> HTON_STATS_RECORDS_IS_EXACT(1 << HTON_BIT_STATS_RECORDS_IS_EXACT);
93
 
static const std::bitset<HTON_BIT_SIZE> HTON_NULL_IN_KEY(1 << HTON_BIT_NULL_IN_KEY);
94
 
static const std::bitset<HTON_BIT_SIZE> HTON_CAN_INDEX_BLOBS(1 << HTON_BIT_CAN_INDEX_BLOBS);
95
 
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_IN_READ_INDEX(1 << HTON_BIT_PRIMARY_KEY_IN_READ_INDEX);
96
 
static const std::bitset<HTON_BIT_SIZE> HTON_PARTIAL_COLUMN_READ(1 << HTON_BIT_PARTIAL_COLUMN_READ);
97
 
static const std::bitset<HTON_BIT_SIZE> HTON_TABLE_SCAN_ON_INDEX(1 << HTON_BIT_TABLE_SCAN_ON_INDEX);
98
 
static const std::bitset<HTON_BIT_SIZE> HTON_FAST_KEY_READ(1 << HTON_BIT_FAST_KEY_READ);
99
 
static const std::bitset<HTON_BIT_SIZE> HTON_NO_BLOBS(1 << HTON_BIT_NO_BLOBS);
100
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_RECORDS(1 << HTON_BIT_HAS_RECORDS);
101
 
static const std::bitset<HTON_BIT_SIZE> HTON_NO_AUTO_INCREMENT(1 << HTON_BIT_NO_AUTO_INCREMENT);
102
 
static const std::bitset<HTON_BIT_SIZE> HTON_DUPLICATE_POS(1 << HTON_BIT_DUPLICATE_POS);
103
 
static const std::bitset<HTON_BIT_SIZE> HTON_AUTO_PART_KEY(1 << HTON_BIT_AUTO_PART_KEY);
104
 
static const std::bitset<HTON_BIT_SIZE> HTON_REQUIRE_PRIMARY_KEY(1 << HTON_BIT_REQUIRE_PRIMARY_KEY);
105
 
static const std::bitset<HTON_BIT_SIZE> HTON_REQUIRES_KEY_COLUMNS_FOR_DELETE(1 << HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE);
106
 
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_REQUIRED_FOR_DELETE(1 << HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_DELETE);
107
 
static const std::bitset<HTON_BIT_SIZE> HTON_NO_PREFIX_CHAR_KEYS(1 << HTON_BIT_NO_PREFIX_CHAR_KEYS);
108
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_CHECKSUM(1 << HTON_BIT_HAS_CHECKSUM);
109
 
static const std::bitset<HTON_BIT_SIZE> HTON_SKIP_STORE_LOCK(1 << HTON_BIT_SKIP_STORE_LOCK);
110
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_SCHEMA_DICTIONARY(1 << HTON_BIT_SCHEMA_DICTIONARY);
111
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_FOREIGN_KEYS(1 << HTON_BIT_FOREIGN_KEYS);
112
 
 
113
 
 
114
 
class Table;
115
 
class NamedSavepoint;
116
 
 
117
 
namespace plugin
118
 
{
119
 
 
120
 
typedef std::vector<StorageEngine *> EngineVector;
121
 
 
122
 
typedef std::set<std::string> TableNameList;
123
 
 
124
 
extern const std::string UNKNOWN_STRING;
125
 
extern const std::string DEFAULT_DEFINITION_FILE_EXT;
 
63
static const std::bitset<HTON_BIT_SIZE> HTON_SUPPORT_LOG_TABLES(1 << HTON_BIT_SUPPORT_LOG_TABLES);
 
64
static const std::bitset<HTON_BIT_SIZE> HTON_NO_PARTITION(1 << HTON_BIT_NO_PARTITION);
126
65
 
127
66
/*
128
 
  StorageEngine is a singleton structure - one instance per storage engine -
 
67
  handlerton is a singleton structure - one instance per storage engine -
129
68
  to provide access to storage engine functionality that works on the
130
 
  "global" level (unlike Cursor class that works on a per-table basis)
131
 
 
132
 
  usually StorageEngine instance is defined statically in ha_xxx.cc as
133
 
 
134
 
  static StorageEngine { ... } xxx_engine;
 
69
  "global" level (unlike handler class that works on a per-table basis)
 
70
 
 
71
  usually handlerton instance is defined statically in ha_xxx.cc as
 
72
 
 
73
  static handlerton { ... } xxx_hton;
 
74
 
 
75
  savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
135
76
*/
136
 
class StorageEngine : public Plugin,
137
 
                      public MonitoredInTransaction
 
77
struct handlerton
138
78
{
139
 
public:
140
 
  typedef uint64_t Table_flags;
141
 
 
142
 
private:
143
 
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
144
 
 
145
 
  static EngineVector &getSchemaEngines();
146
 
 
147
 
  virtual void setTransactionReadWrite(Session& session);
148
 
 
149
 
  /*
150
 
   * Indicates to a storage engine the start of a
151
 
   * new SQL statement.
152
 
   */
153
 
  virtual void doStartStatement(Session *session)
154
 
  {
155
 
    (void) session;
156
 
  }
157
 
 
158
 
  /*
159
 
   * Indicates to a storage engine the end of
160
 
   * the current SQL statement in the supplied
161
 
   * Session.
162
 
   */
163
 
  virtual void doEndStatement(Session *session)
164
 
  {
165
 
    (void) session;
166
 
  }
167
 
 
168
 
protected:
169
 
  std::string table_definition_ext;
170
 
 
171
 
public:
172
 
  const std::string& getTableDefinitionFileExtension()
173
 
  {
174
 
    return table_definition_ext;
175
 
  }
176
 
 
177
 
private:
178
 
  std::vector<std::string> aliases;
179
 
 
180
 
public:
181
 
  const std::vector<std::string>& getAliases() const
182
 
  {
183
 
    return aliases;
184
 
  }
185
 
 
186
 
  void addAlias(std::string alias)
187
 
  {
188
 
    aliases.push_back(alias);
189
 
  }
190
 
 
191
 
protected:
192
 
 
193
 
  /**
194
 
    @brief
195
 
    Used as a protobuf storage currently by TEMP only engines.
196
 
  */
197
 
  typedef std::map <std::string, message::Table> ProtoCache;
198
 
  ProtoCache proto_cache;
199
 
  pthread_mutex_t proto_cache_mutex;
200
 
 
201
 
public:
202
 
 
203
 
  StorageEngine(const std::string name_arg,
204
 
                const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
205
 
 
206
 
  virtual ~StorageEngine();
207
 
 
208
 
  virtual int doGetTableDefinition(Session &session,
209
 
                                   const drizzled::TableIdentifier &identifier,
210
 
                                   message::Table &table_message)
211
 
  {
212
 
    (void)session;
213
 
    (void)identifier;
214
 
    (void)table_message;
215
 
 
216
 
    return ENOENT;
217
 
  }
218
 
 
219
 
  /* Old style cursor errors */
220
 
protected:
221
 
  void print_keydup_error(uint32_t key_nr, const char *msg, Table &table);
222
 
  void print_error(int error, myf errflag, Table *table= NULL);
223
 
  virtual bool get_error_message(int error, String *buf);
224
 
public:
225
 
  virtual void print_error(int error, myf errflag, Table& table);
226
 
 
227
 
  bool is_user_selectable() const
228
 
  {
229
 
    return not flags.test(HTON_BIT_NOT_USER_SELECTABLE);
230
 
  }
231
 
 
232
 
  bool check_flag(const engine_flag_bits flag) const
233
 
  {
234
 
    return flags.test(flag);
235
 
  }
236
 
 
237
 
  // @todo match check_flag interface
238
 
  virtual uint32_t index_flags(enum  ha_key_alg) const { return 0; }
239
 
  virtual void startStatement(Session *session)
240
 
  {
241
 
    doStartStatement(session);
242
 
  }
243
 
  virtual void endStatement(Session *session)
244
 
  {
245
 
    doEndStatement(session);
246
 
  }
247
 
 
248
 
  /*
249
 
   * Called during Session::cleanup() for all engines
250
 
   */
251
 
  virtual int close_connection(Session  *)
252
 
  {
253
 
    return 0;
254
 
  }
255
 
  virtual Cursor *create(Table &)= 0;
256
 
  /* args: path */
257
 
  virtual bool flush_logs() { return false; }
258
 
  virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
259
 
  {
260
 
    return false;
261
 
  }
262
 
 
263
 
  /**
264
 
    If frm_error() is called then we will use this to find out what file
265
 
    extentions exist for the storage engine. This is also used by the default
266
 
    rename_table and delete_table method in Cursor.cc.
267
 
 
268
 
    For engines that have two file name extentions (separate meta/index file
269
 
    and data file), the order of elements is relevant. First element of engine
270
 
    file name extentions array should be meta/index file extention. Second
271
 
    element - data file extention. This order is assumed by
272
 
    prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
273
 
  */
274
 
  virtual const char **bas_ext() const =0;
275
 
 
276
 
protected:
277
 
  virtual int doCreateTable(Session &session,
278
 
                            Table &table_arg,
279
 
                            const drizzled::TableIdentifier &identifier,
280
 
                            message::Table &message)= 0;
281
 
 
282
 
  virtual int doRenameTable(Session &session,
283
 
                            const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to)= 0;
284
 
 
285
 
public:
286
 
 
287
 
  int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
288
 
 
289
 
  virtual void doGetTableIdentifiers(CachedDirectory &directory,
290
 
                                     const drizzled::SchemaIdentifier &schema_identifier,
291
 
                                     TableIdentifier::vector &set_of_identifiers)= 0;
292
 
 
293
 
  virtual int doDropTable(Session &session,
294
 
                          const drizzled::TableIdentifier &identifier)= 0;
295
 
 
296
 
  /* Class Methods for operating on plugin */
297
 
  static bool addPlugin(plugin::StorageEngine *engine);
298
 
  static void removePlugin(plugin::StorageEngine *engine);
299
 
 
300
 
  static int getTableDefinition(Session& session,
301
 
                                const drizzled::TableIdentifier &identifier,
302
 
                                message::table::shared_ptr &table_proto,
303
 
                                bool include_temporary_tables= true);
304
 
  static bool doesTableExist(Session &session,
305
 
                             const drizzled::TableIdentifier &identifier,
306
 
                             bool include_temporary_tables= true);
307
 
 
308
 
  virtual bool doDoesTableExist(Session& session, const drizzled::TableIdentifier &identifier);
309
 
 
310
 
  static plugin::StorageEngine *findByName(const std::string &find_str);
311
 
  static plugin::StorageEngine *findByName(Session& session, const std::string &find_str);
312
 
 
313
 
  static void closeConnection(Session* session);
314
 
  static void dropDatabase(char* path);
315
 
  static bool flushLogs(plugin::StorageEngine *db_type);
316
 
  static int dropTable(Session& session,
317
 
                       const drizzled::TableIdentifier &identifier);
318
 
  static int dropTable(Session& session,
319
 
                       StorageEngine &engine,
320
 
                       const drizzled::TableIdentifier &identifier);
321
 
  static void getIdentifiers(Session &session,
322
 
                             const SchemaIdentifier &schema_identifier,
323
 
                             TableIdentifier::vector &set_of_identifiers);
324
 
 
325
 
  // Check to see if any SE objects to creation.
326
 
  static bool canCreateTable(const drizzled::TableIdentifier &identifier);
327
 
  virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
328
 
  { (void)identifier;  return true; }
329
 
 
330
 
  // @note All schema methods defined here
331
 
  static void getIdentifiers(Session &session, SchemaIdentifier::vector &schemas);
332
 
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::schema::shared_ptr &proto);
333
 
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::schema::shared_ptr &proto);
334
 
  static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
335
 
  static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
336
 
  static bool createSchema(const drizzled::message::Schema &schema_message);
337
 
  static bool dropSchema(const drizzled::SchemaIdentifier &identifier);
338
 
  static bool alterSchema(const drizzled::message::Schema &schema_message);
339
 
 
340
 
  // @note make private/protected
341
 
  virtual void doGetSchemaIdentifiers(SchemaIdentifier::vector&)
342
 
  { }
343
 
 
344
 
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr&)
345
 
  { 
346
 
    return false; 
347
 
  }
348
 
 
349
 
  virtual bool doCreateSchema(const drizzled::message::Schema&)
350
 
  { return false; }
351
 
 
352
 
  virtual bool doAlterSchema(const drizzled::message::Schema&)
353
 
  { return false; }
354
 
 
355
 
  virtual bool doDropSchema(const drizzled::SchemaIdentifier&)
356
 
  { return false; }
357
 
 
358
 
  static inline const std::string &resolveName(const StorageEngine *engine)
359
 
  {
360
 
    return engine == NULL ? UNKNOWN_STRING : engine->getName();
361
 
  }
362
 
 
363
 
  static int createTable(Session& session,
364
 
                         const drizzled::TableIdentifier &identifier,
365
 
                         message::Table& table_proto);
366
 
 
367
 
  static void removeLostTemporaryTables(Session &session, const char *directory);
368
 
 
369
 
  Cursor *getCursor(Table &share);
370
 
 
371
 
  uint32_t max_record_length() const
372
 
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
373
 
  uint32_t max_keys() const
374
 
  { return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
375
 
  uint32_t max_key_parts() const
376
 
  { return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
377
 
  uint32_t max_key_length() const
378
 
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
379
 
  uint32_t max_key_part_length(void) const
380
 
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
381
 
 
382
 
  virtual uint32_t max_supported_record_length(void) const
383
 
  { return HA_MAX_REC_LENGTH; }
384
 
  virtual uint32_t max_supported_keys(void) const { return 0; }
385
 
  virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; }
386
 
  virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
387
 
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
388
 
 
389
 
  /* TODO-> Make private */
390
 
  static int deleteDefinitionFromPath(const drizzled::TableIdentifier &identifier);
391
 
  static int renameDefinitionFromPath(const drizzled::TableIdentifier &dest, const drizzled::TableIdentifier &src);
392
 
  static int writeDefinitionFromPath(const drizzled::TableIdentifier &identifier, message::Table &proto);
393
 
  static bool readTableFile(const std::string &path, message::Table &table_message);
394
 
 
395
 
public:
396
 
  /* 
397
 
   * The below are simple virtual overrides for the plugin::MonitoredInTransaction
398
 
   * interface.
399
 
   */
400
 
  virtual bool participatesInSqlTransaction() const
401
 
  {
402
 
    return false; /* plugin::StorageEngine is non-transactional in terms of SQL */
403
 
  }
404
 
  virtual bool participatesInXaTransaction() const
405
 
  {
406
 
    return false; /* plugin::StorageEngine is non-transactional in terms of XA */
407
 
  }
408
 
  virtual bool alwaysRegisterForXaTransaction() const
409
 
  {
410
 
    return false;
411
 
  }
412
 
 
413
 
  virtual bool validateCreateTableOption(const std::string &key, const std::string &state)
414
 
  {
415
 
    (void)key;
416
 
    (void)state;
417
 
 
418
 
    return false;
419
 
  }
420
 
 
421
 
  virtual bool validateCreateSchemaOption(const std::string &key, const std::string &state)
422
 
  {
423
 
    (void)key;
424
 
    (void)state;
425
 
 
426
 
    return false;
427
 
  }
 
79
  /*
 
80
    Name used for storage engine.
 
81
  */
 
82
  const char *name;
 
83
 
 
84
  /*
 
85
    Historical marker for if the engine is available of not
 
86
  */
 
87
  SHOW_COMP_OPTION state;
 
88
 
 
89
  /*
 
90
    Historical number used for frm file to determine the correct storage engine.
 
91
    This is going away and new engines will just use "name" for this.
 
92
  */
 
93
  enum legacy_db_type db_type;
 
94
  /*
 
95
    each storage engine has it's own memory area (actually a pointer)
 
96
    in the session, for storing per-connection information.
 
97
    It is accessed as
 
98
 
 
99
      session->ha_data[xxx_hton.slot]
 
100
 
 
101
   slot number is initialized by MySQL after xxx_init() is called.
 
102
   */
 
103
   uint32_t slot;
 
104
   /*
 
105
     to store per-savepoint data storage engine is provided with an area
 
106
     of a requested size (0 is ok here).
 
107
     savepoint_offset must be initialized statically to the size of
 
108
     the needed memory to store per-savepoint information.
 
109
     After xxx_init it is changed to be an offset to savepoint storage
 
110
     area and need not be used by storage engine.
 
111
     see binlog_hton and binlog_savepoint_set/rollback for an example.
 
112
   */
 
113
   uint32_t savepoint_offset;
 
114
   /*
 
115
     handlerton methods:
 
116
 
 
117
     close_connection is only called if
 
118
     session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
 
119
     this storage area - set it to something, so that MySQL would know
 
120
     this storage engine was accessed in this connection
 
121
   */
 
122
   int  (*close_connection)(handlerton *hton, Session *session);
 
123
   /*
 
124
     sv points to an uninitialized storage area of requested size
 
125
     (see savepoint_offset description)
 
126
   */
 
127
   int  (*savepoint_set)(handlerton *hton, Session *session, void *sv);
 
128
   /*
 
129
     sv points to a storage area, that was earlier passed
 
130
     to the savepoint_set call
 
131
   */
 
132
   int  (*savepoint_rollback)(handlerton *hton, Session *session, void *sv);
 
133
   int  (*savepoint_release)(handlerton *hton, Session *session, void *sv);
 
134
   /*
 
135
     'all' is true if it's a real commit, that makes persistent changes
 
136
     'all' is false if it's not in fact a commit but an end of the
 
137
     statement that is part of the transaction.
 
138
     NOTE 'all' is also false in auto-commit mode where 'end of statement'
 
139
     and 'real commit' mean the same event.
 
140
   */
 
141
   int  (*commit)(handlerton *hton, Session *session, bool all);
 
142
   int  (*rollback)(handlerton *hton, Session *session, bool all);
 
143
   int  (*prepare)(handlerton *hton, Session *session, bool all);
 
144
   int  (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
 
145
   int  (*commit_by_xid)(handlerton *hton, XID *xid);
 
146
   int  (*rollback_by_xid)(handlerton *hton, XID *xid);
 
147
   handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
 
148
   void (*drop_database)(handlerton *hton, char* path);
 
149
   int (*start_consistent_snapshot)(handlerton *hton, Session *session);
 
150
   bool (*flush_logs)(handlerton *hton);
 
151
   bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat);
 
152
   int (*fill_files_table)(handlerton *hton, Session *session,
 
153
                           TableList *tables,
 
154
                           class Item *cond);
 
155
   std::bitset<HTON_BIT_SIZE> flags; /* global handler flags */
 
156
   int (*release_temporary_latches)(handlerton *hton, Session *session);
 
157
 
 
158
   int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
 
159
                                 const char *name);
 
160
   uint32_t license; /* Flag for Engine License */
 
161
   void *data; /* Location for engines to keep personal structures */
428
162
};
429
163
 
430
 
} /* namespace plugin */
431
 
} /* namespace drizzled */
432
 
 
433
 
#endif /* DRIZZLED_PLUGIN_STORAGE_ENGINE_H */
 
164
 
 
165
/* lookups */
 
166
handlerton *ha_default_handlerton(Session *session);
 
167
plugin_ref ha_resolve_by_name(Session *session, const LEX_STRING *name);
 
168
plugin_ref ha_lock_engine(Session *session, handlerton *hton);
 
169
handlerton *ha_resolve_by_legacy_type(Session *session,
 
170
                                      enum legacy_db_type db_type);
 
171
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
 
172
                         handlerton *db_type);
 
173
handlerton *ha_checktype(Session *session, enum legacy_db_type database_type,
 
174
                         bool no_substitute, bool report_error);
 
175
 
 
176
enum legacy_db_type ha_legacy_type(const handlerton *db_type);
 
177
const char *ha_resolve_storage_engine_name(const handlerton *db_type);
 
178
bool ha_check_storage_engine_flag(const handlerton *db_type, const hton_flag_bits flag);
 
179
bool ha_storage_engine_is_enabled(const handlerton *db_type);
 
180
LEX_STRING *ha_storage_engine_name(const handlerton *hton);
 
181
 
 
182
#endif /* DRIZZLED_HANDLERTON_H */