64
64
static const std::bitset<HTON_BIT_SIZE> HTON_NO_PARTITION(1 << HTON_BIT_NO_PARTITION);
67
handlerton is a singleton structure - one instance per storage engine -
67
StorageEngine is a singleton structure - one instance per storage engine -
68
68
to provide access to storage engine functionality that works on the
69
69
"global" level (unlike handler class that works on a per-table basis)
71
usually handlerton instance is defined statically in ha_xxx.cc as
71
usually StorageEngine instance is defined statically in ha_xxx.cc as
73
static handlerton { ... } xxx_hton;
73
static StorageEngine { ... } xxx_engine;
75
75
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
81
StorageEngine(): _2pc(false) {}
82
StorageEngine(bool support_2pc): _2pc(support_2pc) {}
83
virtual ~StorageEngine() {}
80
91
Name used for storage engine.
92
@todo change to std::string
108
121
the needed memory to store per-savepoint information.
109
122
After xxx_init it is changed to be an offset to savepoint storage
110
123
area and need not be used by storage engine.
111
see binlog_hton and binlog_savepoint_set/rollback for an example.
124
see binlog_engine and binlog_savepoint_set/rollback for an example.
113
126
uint32_t savepoint_offset;
127
uint32_t license; /* Flag for Engine License */
128
void *data; /* Location for engines to keep personal structures */
131
StorageEngine methods:
117
133
close_connection is only called if
118
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
134
session->ha_data[xxx_engine.slot] is non-zero, so even if you don't need
119
135
this storage area - set it to something, so that MySQL would know
120
136
this storage engine was accessed in this connection
122
int (*close_connection)(handlerton *hton, Session *session);
138
virtual int close_connection(Session *)
124
sv points to an uninitialized storage area of requested size
143
The void * points to an uninitialized storage area of requested size
125
144
(see savepoint_offset description)
127
int (*savepoint_set)(handlerton *hton, Session *session, void *sv);
146
virtual int savepoint_set(Session *, void *)
129
sv points to a storage area, that was earlier passed
152
The void * points to a storage area, that was earlier passed
130
153
to the savepoint_set call
132
int (*savepoint_rollback)(handlerton *hton, Session *session, void *sv);
133
int (*savepoint_release)(handlerton *hton, Session *session, void *sv);
155
virtual int savepoint_rollback(Session *, void *)
160
virtual int savepoint_release(Session *, void *)
135
166
'all' is true if it's a real commit, that makes persistent changes
136
167
'all' is false if it's not in fact a commit but an end of the
138
169
NOTE 'all' is also false in auto-commit mode where 'end of statement'
139
170
and 'real commit' mean the same event.
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,
155
std::bitset<HTON_BIT_SIZE> flags; /* global handler flags */
156
int (*release_temporary_latches)(handlerton *hton, Session *session);
158
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
160
uint32_t license; /* Flag for Engine License */
161
void *data; /* Location for engines to keep personal structures */
172
virtual int commit(Session *, bool)
177
virtual int rollback(Session *, bool)
182
virtual int prepare(Session *, bool) { return 0; }
183
virtual int recover(XID *, uint32_t) { return 0; }
184
virtual int commit_by_xid(XID *) { return 0; }
185
virtual int rollback_by_xid(XID *) { return 0; }
186
virtual handler *create(TABLE_SHARE *, MEM_ROOT *)= 0;
188
virtual void drop_database(char*) { }
189
virtual int start_consistent_snapshot(Session *) { return 0; }
190
virtual bool flush_logs() { return false; }
191
virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
196
/* args: current_session, tables, cond */
197
virtual int fill_files_table(Session *, TableList *,
198
Item *) { return 0; }
199
virtual int release_temporary_latches(Session *) { return false; }
201
/* args: current_session, db, name */
202
virtual int table_exists_in_engine(Session*, const char *, const char *);
166
handlerton *ha_default_handlerton(Session *session);
207
StorageEngine *ha_default_storage_engine(Session *session);
167
208
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,
209
plugin_ref ha_lock_engine(Session *session, StorageEngine *engine);
210
StorageEngine *ha_resolve_by_legacy_type(Session *session,
170
211
enum legacy_db_type db_type);
171
212
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,
213
StorageEngine *db_type);
214
StorageEngine *ha_checktype(Session *session, enum legacy_db_type database_type,
174
215
bool no_substitute, bool report_error);
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);
217
enum legacy_db_type ha_legacy_type(const StorageEngine *db_type);
218
const char *ha_resolve_storage_engine_name(const StorageEngine *db_type);
219
bool ha_check_storage_engine_flag(const StorageEngine *db_type, const engine_flag_bits flag);
220
bool ha_storage_engine_is_enabled(const StorageEngine *db_type);
221
LEX_STRING *ha_storage_engine_name(const StorageEngine *engine);
182
223
#endif /* DRIZZLED_HANDLERTON_H */