Commit 7d6b4a1a authored by unknown's avatar unknown
Browse files

Refactored a number of engines to have correct init/deinit. Added pass support...

Refactored a number of engines to have correct init/deinit. Added pass support for "data" from plugin to plugin generic init to use memory location. 


plugin/daemon_example/plug.in:
  Switched the plug.in type (corrected)
sql/handler.h:
  Added data pointer to use for engines.
sql/sql_plugin.cc:
  Passing plugin to generic handlers to allow them to add data to "data"
storage/archive/ha_archive.cc:
  Refactored. Now uses less logic for startup/shutdown.
storage/csv/ha_tina.cc:
  Refactored init/deinit to use less code.
storage/example/ha_example.cc:
  Refactored example to show correct behavior for init/deinit.
storage/example/ha_example.h:
  Removed unneeded references to methods that do not need to be implemened.
storage/federated/ha_federated.cc:
  Refactored to use less code and startup/shutdown correctly.
parent 3e0eee1d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
MYSQL_STORAGE_ENGINE(daemon_example,,[Daemon Example Plugin],
        [This is an example plugin daemon.], [max,max-no-ndb])
MYSQL_PLUGIN(daemon_example,[Daemon Example Plugin],
        [This is an example plugin daemon.])
MYSQL_PLUGIN_DYNAMIC(daemon_example,   [libdaemon_example.la])
+1 −0
Original line number Diff line number Diff line
@@ -684,6 +684,7 @@ struct handlerton
   int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
                                 const char *name);
   uint32 license; /* Flag for Engine License */
   void *data; /* Location for engines to keep personal structures */
};


+2 −2
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ void plugin_deinitialize(struct st_plugin_int *plugin)
  else if (plugin->plugin->deinit)
  {
    DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
    if (plugin->plugin->deinit(NULL))
    if (plugin->plugin->deinit(plugin))
    {
      DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
                             plugin->name.str));
@@ -575,7 +575,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
  }
  else if (plugin->plugin->init)
  {
    if (plugin->plugin->init(NULL))
    if (plugin->plugin->init(plugin))
    {
      sql_print_error("Plugin '%s' init function returned error.",
                      plugin->name.str);
+4 −18
Original line number Diff line number Diff line
@@ -114,8 +114,6 @@
  data - The data is stored in a "row +blobs" format.
*/

/* If the archive storage engine has been inited */
static bool archive_inited= FALSE;
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
static HASH archive_open_tables;
@@ -142,7 +140,6 @@ static HASH archive_open_tables;
static handler *archive_create_handler(handlerton *hton, 
                                       TABLE_SHARE *table, 
                                       MEM_ROOT *mem_root);
int archive_db_end(handlerton *hton, ha_panic_function type);

/*
  Number of rows that will force a bulk insert.
@@ -183,13 +180,11 @@ int archive_db_init(void *p)
{
  DBUG_ENTER("archive_db_init");
  handlerton *archive_hton;
  if (archive_inited)
    DBUG_RETURN(FALSE);

  archive_hton= (handlerton *)p;
  archive_hton->state=SHOW_OPTION_YES;
  archive_hton->db_type=DB_TYPE_ARCHIVE_DB;
  archive_hton->create=archive_create_handler;
  archive_hton->panic=archive_db_end;
  archive_hton->flags=HTON_NO_FLAGS;

  if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
@@ -201,7 +196,6 @@ int archive_db_init(void *p)
  }
  else
  {
    archive_inited= TRUE;
    DBUG_RETURN(FALSE);
  }
error:
@@ -220,22 +214,14 @@ int archive_db_init(void *p)
*/

int archive_db_done(void *p)
{
  if (archive_inited)
{
  hash_free(&archive_open_tables);
  VOID(pthread_mutex_destroy(&archive_mutex));
  }
  archive_inited= 0;

  return 0;
}


int archive_db_end(handlerton *hton, ha_panic_function type)
{
  return archive_db_done(NULL);
}

ha_archive::ha_archive(handlerton *hton, TABLE_SHARE *table_arg)
  :handler(hton, table_arg), delayed_insert(0), bulk_insert(0)
{
+12 −34
Original line number Diff line number Diff line
@@ -73,11 +73,9 @@ static int write_meta_file(File meta_file, ha_rows rows, bool dirty);
/* Stuff for shares */
pthread_mutex_t tina_mutex;
static HASH tina_open_tables;
static int tina_init= 0;
static handler *tina_create_handler(handlerton *hton,
                                    TABLE_SHARE *table, 
                                    MEM_ROOT *mem_root);
int tina_end(handlerton *hton, ha_panic_function type);


off_t Transparent_file::read_next()
@@ -155,35 +153,23 @@ static int tina_init_func(void *p)
{
  handlerton *tina_hton;

  if (!tina_init)
  {
  tina_hton= (handlerton *)p;
    tina_init++;
  VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
  (void) hash_init(&tina_open_tables,system_charset_info,32,0,0,
                   (hash_get_key) tina_get_key,0,0);
  tina_hton->state= SHOW_OPTION_YES;
  tina_hton->db_type= DB_TYPE_CSV_DB;
  tina_hton->create= tina_create_handler;
    tina_hton->panic= tina_end;
  tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES | 
                     HTON_NO_PARTITION);
  }
  return 0;
}

static int tina_done_func(void *p)
{
  if (tina_init)
  {
    if (tina_open_tables.records)
    {
      return 1;
    }
  hash_free(&tina_open_tables);
  pthread_mutex_destroy(&tina_mutex);
    tina_init--;
  }

  return 0;
}

@@ -199,9 +185,6 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
  char *tmp_name;
  uint length;

  if (!tina_init)
     tina_init_func(NULL);

  pthread_mutex_lock(&tina_mutex);
  length=(uint) strlen(table_name);

@@ -455,11 +438,6 @@ static int free_share(TINA_SHARE *share)
  DBUG_RETURN(result_code);
}

int tina_end(handlerton *hton, ha_panic_function type)
{
  return tina_done_func(NULL);
}


/*
  This function finds the end of a line and returns the length
Loading