diff options
-rw-r--r-- | plugin/daemon_example/plug.in | 4 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 4 | ||||
-rw-r--r-- | storage/archive/ha_archive.cc | 22 | ||||
-rw-r--r-- | storage/csv/ha_tina.cc | 46 | ||||
-rw-r--r-- | storage/example/ha_example.cc | 66 | ||||
-rw-r--r-- | storage/example/ha_example.h | 3 | ||||
-rw-r--r-- | storage/federated/ha_federated.cc | 17 |
8 files changed, 42 insertions, 121 deletions
diff --git a/plugin/daemon_example/plug.in b/plugin/daemon_example/plug.in index fecca83acd2..72e87a70f59 100644 --- a/plugin/daemon_example/plug.in +++ b/plugin/daemon_example/plug.in @@ -1,3 +1,3 @@ -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]) diff --git a/sql/handler.h b/sql/handler.h index 888f837d427..f27912f4d1e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -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 */ }; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index c788d26c147..8982db9e6b3 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -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); diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 81cb9182e3f..cb701b07ed7 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -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: @@ -221,21 +215,13 @@ error: int archive_db_done(void *p) { - if (archive_inited) - { - hash_free(&archive_open_tables); - VOID(pthread_mutex_destroy(&archive_mutex)); - } - archive_inited= 0; + hash_free(&archive_open_tables); + VOID(pthread_mutex_destroy(&archive_mutex)); + 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) { diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index f7e5aa9d50c..7051bd41cb1 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -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); - } + tina_hton= (handlerton *)p; + 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->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--; - } + hash_free(&tina_open_tables); + pthread_mutex_destroy(&tina_mutex); + 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 diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 6d199d4391f..1ef6da9f300 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -77,8 +77,6 @@ static handler *example_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); static int example_init_func(); -static bool example_init_func_for_handlerton(); -static int example_panic(enum ha_panic_function flag); handlerton *example_hton; @@ -101,19 +99,17 @@ static byte* example_get_key(EXAMPLE_SHARE *share,uint *length, static int example_init_func(void *p) { DBUG_ENTER("example_init_func"); - if (!example_init) - { - example_hton= (handlerton *)p; - example_init= 1; - VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST)); - (void) hash_init(&example_open_tables,system_charset_info,32,0,0, - (hash_get_key) example_get_key,0,0); - - example_hton->state= SHOW_OPTION_YES; - example_hton->db_type= DB_TYPE_EXAMPLE_DB; - example_hton->create= example_create_handler; - example_hton->flags= HTON_CAN_RECREATE; - } + + example_hton= (handlerton *)p; + VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST)); + (void) hash_init(&example_open_tables,system_charset_info,32,0,0, + (hash_get_key) example_get_key,0,0); + + example_hton->state= SHOW_OPTION_YES; + example_hton->db_type= DB_TYPE_EXAMPLE_DB; + example_hton->create= example_create_handler; + example_hton->flags= HTON_CAN_RECREATE; + DBUG_RETURN(0); } @@ -122,14 +118,11 @@ static int example_done_func(void *p) int error= 0; DBUG_ENTER("example_done_func"); - if (example_init) - { - example_init= 0; - if (example_open_tables.records) - error= 1; - hash_free(&example_open_tables); - pthread_mutex_destroy(&example_mutex); - } + if (example_open_tables.records) + error= 1; + hash_free(&example_open_tables); + pthread_mutex_destroy(&example_mutex); + DBUG_RETURN(0); } @@ -354,20 +347,6 @@ int ha_example::index_read(byte * buf, const byte * key, /* - Positions an index cursor to the index specified in key. Fetches the - row if any. This is only used to read whole keys. -*/ -int ha_example::index_read_idx(byte * buf, uint index, const byte * key, - uint key_len __attribute__((unused)), - enum ha_rkey_function find_flag - __attribute__((unused))) -{ - DBUG_ENTER("ha_example::index_read_idx"); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - - -/* Used to read forward through the index. */ int ha_example::index_next(byte * buf) @@ -550,19 +529,6 @@ int ha_example::extra(enum ha_extra_function operation) /* - Deprecated and likely to be removed in the future. Storage engines normally - just make a call like: - ha_example::extra(HA_EXTRA_RESET); - to handle it. -*/ -int ha_example::reset(void) -{ - DBUG_ENTER("ha_example::reset"); - DBUG_RETURN(0); -} - - -/* Used to delete all rows in a table. Both for cases of truncate and for cases where the optimizer realizes that all rows will be removed as a result of a SQL statement. diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h index f98377ee157..4e2de9be3d3 100644 --- a/storage/example/ha_example.h +++ b/storage/example/ha_example.h @@ -117,8 +117,6 @@ public: int delete_row(const byte * buf); int index_read(byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag); - int index_read_idx(byte * buf, uint idx, const byte * key, - uint key_len, enum ha_rkey_function find_flag); int index_next(byte * buf); int index_prev(byte * buf); int index_first(byte * buf); @@ -139,7 +137,6 @@ public: int info(uint); //required int extra(enum ha_extra_function operation); - int reset(void); int external_lock(THD *thd, int lock_type); //required int delete_all_rows(void); ha_rows records_in_range(uint inx, key_range *min_key, diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 51c9f4c192e..5f0d51f62df 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -350,7 +350,6 @@ /* Variables for federated share methods */ static HASH federated_open_tables; // To track open tables pthread_mutex_t federated_mutex; // To init the hash -static int federated_init= FALSE; // Checking the state of hash /* Variables used when chopping off trailing characters */ static const uint sizeof_trailing_comma= sizeof(", ") - 1; @@ -365,7 +364,6 @@ static handler *federated_create_handler(handlerton *hton, static int federated_commit(handlerton *hton, THD *thd, bool all); static int federated_rollback(handlerton *hton, THD *thd, bool all); static int federated_db_init(void); -static int federated_db_end(handlerton *hton, ha_panic_function type); /* Federated storage engine handlerton */ @@ -408,7 +406,6 @@ int federated_db_init(void *p) federated_hton->commit= federated_commit; federated_hton->rollback= federated_rollback; federated_hton->create= federated_create_handler; - federated_hton->panic= federated_db_end; federated_hton->flags= HTON_ALTER_NOT_SUPPORTED; if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST)) @@ -416,7 +413,6 @@ int federated_db_init(void *p) if (!hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0, (hash_get_key) federated_get_key, 0, 0)) { - federated_init= TRUE; DBUG_RETURN(FALSE); } @@ -437,14 +433,11 @@ error: FALSE OK */ -int federated_db_end(handlerton *hton, ha_panic_function type) +int federated_done(void *p) { - if (federated_init) - { - hash_free(&federated_open_tables); - VOID(pthread_mutex_destroy(&federated_mutex)); - } - federated_init= 0; + hash_free(&federated_open_tables); + VOID(pthread_mutex_destroy(&federated_mutex)); + return 0; } @@ -2897,7 +2890,7 @@ mysql_declare_plugin(federated) "Federated MySQL storage engine", PLUGIN_LICENSE_GPL, federated_db_init, /* Plugin Init */ - NULL, /* Plugin Deinit */ + federated_done, /* Plugin Deinit */ 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ |