64
65
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 -
68
StorageEngine is a singleton structure - one instance per storage engine -
68
69
to provide access to storage engine functionality that works on the
69
70
"global" level (unlike handler class that works on a per-table basis)
71
usually handlerton instance is defined statically in ha_xxx.cc as
72
usually StorageEngine instance is defined statically in ha_xxx.cc as
73
static handlerton { ... } xxx_hton;
74
static StorageEngine { ... } xxx_engine;
75
76
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
80
81
Name used for storage engine.
83
const std::string name;
85
89
Historical marker for if the engine is available of not
108
108
the needed memory to store per-savepoint information.
109
109
After xxx_init it is changed to be an offset to savepoint storage
110
110
area and need not be used by storage engine.
111
see binlog_hton and binlog_savepoint_set/rollback for an example.
111
see binlog_engine and binlog_savepoint_set/rollback for an example.
113
113
uint32_t savepoint_offset;
114
uint32_t license; /* Flag for Engine License */
116
StorageEngine(const std::string &name_arg, bool support_2pc= false)
117
: name(name_arg), _2pc(support_2pc), savepoint_offset(0) {}
118
virtual ~StorageEngine() {}
127
bool is_enabled() const
129
return (state == SHOW_OPTION_YES);
132
std::string get_name() { return name; }
135
StorageEngine methods:
117
137
close_connection is only called if
118
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
138
session->ha_data[xxx_engine.slot] is non-zero, so even if you don't need
119
139
this storage area - set it to something, so that MySQL would know
120
140
this storage engine was accessed in this connection
122
int (*close_connection)(handlerton *hton, Session *session);
142
virtual int close_connection(Session *)
124
sv points to an uninitialized storage area of requested size
147
The void * points to an uninitialized storage area of requested size
125
148
(see savepoint_offset description)
127
int (*savepoint_set)(handlerton *hton, Session *session, void *sv);
150
virtual int savepoint_set(Session *, void *)
129
sv points to a storage area, that was earlier passed
156
The void * points to a storage area, that was earlier passed
130
157
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);
159
virtual int savepoint_rollback(Session *, void *)
164
virtual int savepoint_release(Session *, void *)
135
170
'all' is true if it's a real commit, that makes persistent changes
136
171
'all' is false if it's not in fact a commit but an end of the
138
173
NOTE 'all' is also false in auto-commit mode where 'end of statement'
139
174
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 */
176
virtual int commit(Session *, bool)
181
virtual int rollback(Session *, bool)
186
virtual int prepare(Session *, bool) { return 0; }
187
virtual int recover(XID *, uint32_t) { return 0; }
188
virtual int commit_by_xid(XID *) { return 0; }
189
virtual int rollback_by_xid(XID *) { return 0; }
190
virtual handler *create(TABLE_SHARE *, MEM_ROOT *)= 0;
192
virtual void drop_database(char*) { }
193
virtual int start_consistent_snapshot(Session *) { return 0; }
194
virtual bool flush_logs() { return false; }
195
virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
200
/* args: current_session, tables, cond */
201
virtual int fill_files_table(Session *, TableList *,
202
Item *) { return 0; }
203
virtual int release_temporary_latches(Session *) { return false; }
205
/* args: current_session, db, name */
206
virtual int table_exists_in_engine(Session*, const char *, const char *);
166
handlerton *ha_default_handlerton(Session *session);
211
StorageEngine *ha_default_storage_engine(Session *session);
167
212
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);
213
plugin_ref ha_lock_engine(Session *session, StorageEngine *engine);
171
214
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);
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);
215
StorageEngine *db_type);
216
const char *ha_resolve_storage_engine_name(const StorageEngine *db_type);
217
bool ha_check_storage_engine_flag(const StorageEngine *db_type, const engine_flag_bits flag);
218
LEX_STRING *ha_storage_engine_name(const StorageEngine *engine);
182
220
#endif /* DRIZZLED_HANDLERTON_H */