diff options
author | unknown <brian@zim.(none)> | 2006-11-19 18:01:54 -0800 |
---|---|---|
committer | unknown <brian@zim.(none)> | 2006-11-19 18:01:54 -0800 |
commit | 7d6b4a1ab06b22505a68334aeae0204cf0e4bb7a (patch) | |
tree | 5a1d28bf16e44e62244be8effd391e8ebe3c51bc /storage/example | |
parent | 3e0eee1d7b530df3d4685acea74d1a8bb139e558 (diff) | |
download | mariadb-git-7d6b4a1ab06b22505a68334aeae0204cf0e4bb7a.tar.gz |
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.
Diffstat (limited to 'storage/example')
-rw-r--r-- | storage/example/ha_example.cc | 66 | ||||
-rw-r--r-- | storage/example/ha_example.h | 3 |
2 files changed, 16 insertions, 53 deletions
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, |