diff options
Diffstat (limited to 'storage/oqgraph/ha_oqgraph.cc')
-rw-r--r-- | storage/oqgraph/ha_oqgraph.cc | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index bab748937c2..b4292f33066 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -24,12 +24,6 @@ ====================================================================== */ -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#ifdef HAVE_OQGRAPH - #include <mysql_version.h> #include "ha_oqgraph.h" #include "graphcore.h" @@ -39,7 +33,6 @@ #include "table.h" #include "field.h" #include "key.h" -//#include "sql_class.h" #define OQGRAPH_STATS_UPDATE_THRESHOLD 10 @@ -62,17 +55,31 @@ static const char oqgraph_description[]= "(http://openquery.com/graph)"; static HASH oqgraph_open_tables; -static pthread_mutex_t LOCK_oqgraph; +static mysql_mutex_t LOCK_oqgraph; static bool oqgraph_init_done= 0; -static uchar* get_key(const uchar *ptr, size_t *length, - my_bool) +static uchar* get_key(const uchar *ptr, size_t *length, my_bool) { const OQGRAPH_INFO *share= (const OQGRAPH_INFO*) ptr; *length= strlen(share->name); return (uchar*) share->name; } +#ifdef HAVE_PSI_INTERFACE +static PSI_mutex_key key_LOCK_oqgraph; +static PSI_mutex_info all_mutexes[]= +{ + { &key_LOCK_oqgraph, "LOCK_oqgraph", PSI_FLAG_GLOBAL}, +}; + +static void init_psi_keys() +{ + mysql_mutex_register("oqgraph", all_mutexes, array_elements(all_mutexes)); +} +#else +#define init_psi_keys() /* no-op */ +#endif /* HAVE_PSI_INTERFACE */ + static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) { @@ -81,12 +88,13 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, static int oqgraph_init(handlerton *hton) { - if (pthread_mutex_init(&LOCK_oqgraph, MY_MUTEX_INIT_FAST)) + init_psi_keys(); + if (mysql_mutex_init(key_LOCK_oqgraph, &LOCK_oqgraph, MY_MUTEX_INIT_FAST)) goto error; if (my_hash_init(&oqgraph_open_tables, &my_charset_bin, 32, 0, 0, get_key, 0, 0)) { - pthread_mutex_destroy(&LOCK_oqgraph); + mysql_mutex_destroy(&LOCK_oqgraph); goto error; } hton->state= SHOW_OPTION_YES; @@ -102,7 +110,7 @@ error: static int oqgraph_fini(void *) { my_hash_free(&oqgraph_open_tables); - pthread_mutex_destroy(&LOCK_oqgraph); + mysql_mutex_destroy(&LOCK_oqgraph); oqgraph_init_done= FALSE; return 0; } @@ -112,7 +120,7 @@ static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0) OQGRAPH_INFO *share; uint length= strlen(name); - safe_mutex_assert_owner(&LOCK_oqgraph); + mysql_mutex_assert_owner(&LOCK_oqgraph); if (!(share= (OQGRAPH_INFO*) my_hash_search(&oqgraph_open_tables, (byte*) name, length))) { @@ -141,7 +149,7 @@ static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0) static int free_share(OQGRAPH_INFO *share, bool drop=0) { - safe_mutex_assert_owner(&LOCK_oqgraph); + mysql_mutex_assert_owner(&LOCK_oqgraph); if (!share) return 0; if (drop) @@ -294,7 +302,7 @@ ulong ha_oqgraph::index_flags(uint inx, uint part, bool all_parts) const int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) { - pthread_mutex_lock(&LOCK_oqgraph); + mysql_mutex_lock(&LOCK_oqgraph); if ((share = get_share(name, table))) { ref_length= oqgraph::sizeof_ref; @@ -317,17 +325,17 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) */ key_stat_version= share->key_stat_version-1; } - pthread_mutex_unlock(&LOCK_oqgraph); + mysql_mutex_unlock(&LOCK_oqgraph); return (share ? 0 : 1); } int ha_oqgraph::close(void) { - pthread_mutex_lock(&LOCK_oqgraph); + mysql_mutex_lock(&LOCK_oqgraph); oqgraph::free(graph); graph= 0; int res= free_share(share); - pthread_mutex_unlock(&LOCK_oqgraph); + mysql_mutex_unlock(&LOCK_oqgraph); return error_code(res); } @@ -736,16 +744,6 @@ int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2) int ha_oqgraph::info(uint flag) { stats.records= graph->vertices_count() + graph->edges_count(); -#if 0 - records= hp_info.records; - deleted= hp_info.deleted; - errkey= hp_info.errkey; - mean_rec_length= hp_info.reclength; - data_file_length= hp_info.data_length; - index_file_length= hp_info.index_length; - max_data_file_length= hp_info.max_records* hp_info.reclength; - delete_length= hp_info.deleted * hp_info.reclength; -#endif /* If info() is called for the first time after open(), we will still have to update the key statistics. Hoping that a table lock is now @@ -826,25 +824,25 @@ int ha_oqgraph::delete_table(const char *name) { int res= 0; OQGRAPH_INFO *share; - pthread_mutex_lock(&LOCK_oqgraph); + mysql_mutex_lock(&LOCK_oqgraph); if ((share= get_share(name))) { res= free_share(share, true); } - pthread_mutex_unlock(&LOCK_oqgraph); + mysql_mutex_unlock(&LOCK_oqgraph); return error_code(res); } int ha_oqgraph::rename_table(const char * from, const char * to) { - pthread_mutex_lock(&LOCK_oqgraph); + mysql_mutex_lock(&LOCK_oqgraph); if (OQGRAPH_INFO *share= get_share(from)) { strmov(share->name, to); my_hash_update(&oqgraph_open_tables, (byte*) share, (byte*) from, strlen(from)); } - pthread_mutex_unlock(&LOCK_oqgraph); + mysql_mutex_unlock(&LOCK_oqgraph); return 0; } @@ -853,8 +851,6 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, key_range *max_key) { KEY *key=table->key_info+inx; - //if (key->algorithm == HA_KEY_ALG_BTREE) - // return btree_records_in_range(file, inx, min_key, max_key); if (!min_key || !max_key || min_key->length != max_key->length || @@ -890,7 +886,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, int res = -1; OQGRAPH_INFO *share; - pthread_mutex_lock(&LOCK_oqgraph); + mysql_mutex_lock(&LOCK_oqgraph); if ((share= get_share(name))) { free_share(share); @@ -900,7 +896,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, if (!oqgraph_check_table_structure(table_arg)) res= 0;; } - pthread_mutex_unlock(&LOCK_oqgraph); + mysql_mutex_unlock(&LOCK_oqgraph); if (this->share) info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); @@ -911,8 +907,6 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, void ha_oqgraph::update_create_info(HA_CREATE_INFO *create_info) { table->file->info(HA_STATUS_AUTO); - //if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) - // create_info->auto_increment_value= auto_increment_value; } struct st_mysql_storage_engine oqgraph_storage_engine= @@ -935,5 +929,3 @@ maria_declare_plugin(oqgraph) MariaDB_PLUGIN_MATURITY_BETA } maria_declare_plugin_end; - -#endif |