114
114
if ((plugin= my_plugin_lock_by_name(session, name, DRIZZLE_STORAGE_ENGINE_PLUGIN)))
116
StorageEngine *hton= plugin_data(plugin, StorageEngine *);
117
if (!(hton->flags.test(HTON_BIT_NOT_USER_SELECTABLE)))
116
StorageEngine *engine= plugin_data(plugin, StorageEngine *);
117
if (!(engine->flags.test(HTON_BIT_NOT_USER_SELECTABLE)))
145
plugin_ref ha_lock_engine(Session *session, StorageEngine *hton)
145
plugin_ref ha_lock_engine(Session *session, StorageEngine *engine)
149
st_plugin_int **plugin= hton2plugin + hton->slot;
149
st_plugin_int **plugin= hton2plugin + engine->slot;
151
151
return my_plugin_lock(session, &plugin);
160
160
StorageEngine *ha_checktype(Session *session, enum legacy_db_type database_type,
161
161
bool no_substitute, bool report_error)
163
StorageEngine *hton= ha_resolve_by_legacy_type(session, database_type);
164
if (ha_storage_engine_is_enabled(hton))
163
StorageEngine *engine= ha_resolve_by_legacy_type(session, database_type);
164
if (ha_storage_engine_is_enabled(engine))
167
167
if (no_substitute)
169
169
if (report_error)
171
const char *engine_name= ha_resolve_storage_engine_name(hton);
171
const char *engine_name= ha_resolve_storage_engine_name(engine);
172
172
my_error(ER_FEATURE_DISABLED,MYF(0),engine_name,engine_name);
201
201
int ha_finalize_handlerton(st_plugin_int *plugin)
203
StorageEngine *hton= (StorageEngine *)plugin->data;
203
StorageEngine *engine= (StorageEngine *)plugin->data;
205
switch (engine->state)
207
207
case SHOW_OPTION_NO:
208
208
case SHOW_OPTION_DISABLED:
210
210
case SHOW_OPTION_YES:
211
if (installed_htons[hton->db_type] == hton)
212
installed_htons[hton->db_type]= NULL;
211
if (installed_htons[engine->db_type] == engine)
212
installed_htons[engine->db_type]= NULL;
216
if (hton && plugin->plugin->deinit)
217
(void)plugin->plugin->deinit(hton);
216
if (engine && plugin->plugin->deinit)
217
(void)plugin->plugin->deinit(engine);
219
free((unsigned char*)hton);
219
free((unsigned char*)engine);
225
225
int ha_initialize_handlerton(st_plugin_int *plugin)
227
StorageEngine *engine;
229
hton= (StorageEngine *)malloc(sizeof(StorageEngine));
230
memset(hton, 0, sizeof(StorageEngine));
229
engine= (StorageEngine *)malloc(sizeof(StorageEngine));
230
memset(engine, 0, sizeof(StorageEngine));
232
232
/* Historical Requirement */
233
plugin->data= hton; // shortcut for the future
233
plugin->data= engine; // shortcut for the future
234
234
if (plugin->plugin->init)
236
if (plugin->plugin->init(hton))
236
if (plugin->plugin->init(engine))
238
238
errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' init function returned error."),
239
239
plugin->name.str);
244
hton->name= plugin->name.str;
244
engine->name= plugin->name.str;
247
the switch below and hton->state should be removed when
247
the switch below and engine->state should be removed when
248
248
command-line options for plugins will be implemented
250
switch (hton->state) {
250
switch (engine->state) {
251
251
case SHOW_OPTION_NO:
253
253
case SHOW_OPTION_YES:
256
256
/* now check the db_type for conflict */
257
if (hton->db_type <= DB_TYPE_UNKNOWN ||
258
hton->db_type >= DB_TYPE_DEFAULT ||
259
installed_htons[hton->db_type])
257
if (engine->db_type <= DB_TYPE_UNKNOWN ||
258
engine->db_type >= DB_TYPE_DEFAULT ||
259
installed_htons[engine->db_type])
261
261
int idx= (int) DB_TYPE_FIRST_DYNAMIC;
268
268
errmsg_printf(ERRMSG_LVL_WARN, _("Too many storage engines!"));
271
if (hton->db_type != DB_TYPE_UNKNOWN)
271
if (engine->db_type != DB_TYPE_UNKNOWN)
272
272
errmsg_printf(ERRMSG_LVL_WARN,
273
273
_("Storage engine '%s' has conflicting typecode. Assigning value %d."),
274
274
plugin->plugin->name, idx);
275
hton->db_type= (enum legacy_db_type) idx;
275
engine->db_type= (enum legacy_db_type) idx;
277
installed_htons[hton->db_type]= hton;
278
tmp= hton->savepoint_offset;
279
hton->savepoint_offset= savepoint_alloc_size;
277
installed_htons[engine->db_type]= engine;
278
tmp= engine->savepoint_offset;
279
engine->savepoint_offset= savepoint_alloc_size;
280
280
savepoint_alloc_size+= tmp;
281
hton->slot= total_ha++;
282
hton2plugin[hton->slot]=plugin;
281
engine->slot= total_ha++;
282
hton2plugin[engine->slot]=plugin;
287
287
/* fall through */
289
hton->state= SHOW_OPTION_DISABLED;
289
engine->state= SHOW_OPTION_DISABLED;
294
This is entirely for legacy. We will create a new "disk based" hton and a
295
"memory" hton which will be configurable longterm. We should be able to
294
This is entirely for legacy. We will create a new "disk based" engine and a
295
"memory" engine which will be configurable longterm. We should be able to
296
296
remove partition and myisammrg.
298
298
if (strcmp(plugin->plugin->name, "MEMORY") == 0)
301
301
if (strcmp(plugin->plugin->name, "MyISAM") == 0)
302
myisam_engine= engine;
304
304
plugin->state= PLUGIN_IS_READY;
329
329
(db_type->state == SHOW_OPTION_YES) : false;
332
LEX_STRING *ha_storage_engine_name(const StorageEngine *hton)
332
LEX_STRING *ha_storage_engine_name(const StorageEngine *engine)
334
return &hton2plugin[hton->slot]->name;
334
return &hton2plugin[engine->slot]->name;