~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Monty Taylor
  • Date: 2009-03-24 18:13:47 UTC
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 964.
  • Revision ID: mordred@inaugust.com-20090324181347-phblgoj913uph2hs
Rename hton to engine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
{
85
85
  plugin_ref plugin= ha_default_plugin(session);
86
86
  assert(plugin);
87
 
  StorageEngine *hton= plugin_data(plugin, StorageEngine*);
88
 
  assert(hton);
89
 
  return hton;
 
87
  StorageEngine *engine= plugin_data(plugin, StorageEngine*);
 
88
  assert(engine);
 
89
  return engine;
90
90
}
91
91
 
92
92
 
113
113
 
114
114
  if ((plugin= my_plugin_lock_by_name(session, name, DRIZZLE_STORAGE_ENGINE_PLUGIN)))
115
115
  {
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)))
118
118
      return plugin;
119
119
 
120
120
    /*
142
142
}
143
143
 
144
144
 
145
 
plugin_ref ha_lock_engine(Session *session, StorageEngine *hton)
 
145
plugin_ref ha_lock_engine(Session *session, StorageEngine *engine)
146
146
{
147
 
  if (hton)
 
147
  if (engine)
148
148
  {
149
 
    st_plugin_int **plugin= hton2plugin + hton->slot;
 
149
    st_plugin_int **plugin= hton2plugin + engine->slot;
150
150
 
151
151
    return my_plugin_lock(session, &plugin);
152
152
  }
160
160
StorageEngine *ha_checktype(Session *session, enum legacy_db_type database_type,
161
161
                          bool no_substitute, bool report_error)
162
162
{
163
 
  StorageEngine *hton= ha_resolve_by_legacy_type(session, database_type);
164
 
  if (ha_storage_engine_is_enabled(hton))
165
 
    return hton;
 
163
  StorageEngine *engine= ha_resolve_by_legacy_type(session, database_type);
 
164
  if (ha_storage_engine_is_enabled(engine))
 
165
    return engine;
166
166
 
167
167
  if (no_substitute)
168
168
  {
169
169
    if (report_error)
170
170
    {
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);
173
173
    }
174
174
    return NULL;
200
200
 
201
201
int ha_finalize_handlerton(st_plugin_int *plugin)
202
202
{
203
 
  StorageEngine *hton= (StorageEngine *)plugin->data;
 
203
  StorageEngine *engine= (StorageEngine *)plugin->data;
204
204
 
205
 
  switch (hton->state)
 
205
  switch (engine->state)
206
206
  {
207
207
  case SHOW_OPTION_NO:
208
208
  case SHOW_OPTION_DISABLED:
209
209
    break;
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;
213
213
    break;
214
214
  };
215
215
 
216
 
  if (hton && plugin->plugin->deinit)
217
 
    (void)plugin->plugin->deinit(hton);
 
216
  if (engine && plugin->plugin->deinit)
 
217
    (void)plugin->plugin->deinit(engine);
218
218
 
219
 
  free((unsigned char*)hton);
 
219
  free((unsigned char*)engine);
220
220
 
221
221
  return(0);
222
222
}
224
224
 
225
225
int ha_initialize_handlerton(st_plugin_int *plugin)
226
226
{
227
 
  StorageEngine *hton;
 
227
  StorageEngine *engine;
228
228
 
229
 
  hton= (StorageEngine *)malloc(sizeof(StorageEngine));
230
 
  memset(hton, 0, sizeof(StorageEngine));
 
229
  engine= (StorageEngine *)malloc(sizeof(StorageEngine));
 
230
  memset(engine, 0, sizeof(StorageEngine));
231
231
 
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)
235
235
  {
236
 
    if (plugin->plugin->init(hton))
 
236
    if (plugin->plugin->init(engine))
237
237
    {
238
238
      errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' init function returned error."),
239
239
                      plugin->name.str);
241
241
    }
242
242
  }
243
243
 
244
 
  hton->name= plugin->name.str;
 
244
  engine->name= plugin->name.str;
245
245
 
246
246
  /*
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
249
249
  */
250
 
  switch (hton->state) {
 
250
  switch (engine->state) {
251
251
  case SHOW_OPTION_NO:
252
252
    break;
253
253
  case SHOW_OPTION_YES:
254
254
    {
255
255
      uint32_t tmp;
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])
260
260
      {
261
261
        int idx= (int) DB_TYPE_FIRST_DYNAMIC;
262
262
 
268
268
          errmsg_printf(ERRMSG_LVL_WARN, _("Too many storage engines!"));
269
269
          return(1);
270
270
        }
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;
276
276
      }
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;
283
 
      if (hton->prepare)
 
281
      engine->slot= total_ha++;
 
282
      hton2plugin[engine->slot]=plugin;
 
283
      if (engine->prepare)
284
284
        total_ha_2pc++;
285
285
      break;
286
286
    }
287
287
    /* fall through */
288
288
  default:
289
 
    hton->state= SHOW_OPTION_DISABLED;
 
289
    engine->state= SHOW_OPTION_DISABLED;
290
290
    break;
291
291
  }
292
292
 
293
293
  /*
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.
297
297
  */
298
298
  if (strcmp(plugin->plugin->name, "MEMORY") == 0)
299
 
    heap_engine= hton;
 
299
    heap_engine= engine;
300
300
 
301
301
  if (strcmp(plugin->plugin->name, "MyISAM") == 0)
302
 
    myisam_engine= hton;
 
302
    myisam_engine= engine;
303
303
 
304
304
  plugin->state= PLUGIN_IS_READY;
305
305
 
329
329
         (db_type->state == SHOW_OPTION_YES) : false;
330
330
}
331
331
 
332
 
LEX_STRING *ha_storage_engine_name(const StorageEngine *hton)
 
332
LEX_STRING *ha_storage_engine_name(const StorageEngine *engine)
333
333
{
334
 
  return &hton2plugin[hton->slot]->name;
 
334
  return &hton2plugin[engine->slot]->name;
335
335
}