Backport of:

----------------------------------------------------------
revno: 2617.22.5
committer: Konstantin Osipov <kostja@sun.com>
branch nick: mysql-6.0-runtime
timestamp: Tue 2009-01-27 05:08:48 +0300
message:
  Remove non-prefixed use of HASH.
  Always use my_hash_init(), my_hash_inited(), my_hash_search(),
  my_hash_element(), my_hash_delete(), my_hash_free() rather
  than non-prefixed counterparts (hash_init(), etc).
  Remove the backward-compatible defines.
This commit is contained in:
Konstantin Osipov 2009-10-14 20:37:38 +04:00
parent 2b75d952e6
commit 9b41c7532d
44 changed files with 561 additions and 578 deletions

View File

@ -861,9 +861,9 @@ static int get_options(int *argc, char ***argv)
load_defaults("my",load_default_groups,argc,argv); load_defaults("my",load_default_groups,argc,argv);
defaults_argv= *argv; defaults_argv= *argv;
if (hash_init(&ignore_table, charset_info, 16, 0, 0, if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
(hash_get_key) get_table_key, (my_hash_get_key) get_table_key,
(hash_free_key) free_table_ent, 0)) (my_hash_free_key) free_table_ent, 0))
return(EX_EOM); return(EX_EOM);
/* Don't copy internal log tables */ /* Don't copy internal log tables */
if (my_hash_insert(&ignore_table, if (my_hash_insert(&ignore_table,
@ -1367,8 +1367,8 @@ static void free_resources()
if (md_result_file && md_result_file != stdout) if (md_result_file && md_result_file != stdout)
my_fclose(md_result_file, MYF(0)); my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (hash_inited(&ignore_table)) if (my_hash_inited(&ignore_table))
hash_free(&ignore_table); my_hash_free(&ignore_table);
if (extended_insert) if (extended_insert)
dynstr_free(&extended_row); dynstr_free(&extended_row);
if (insert_pat_inited) if (insert_pat_inited)
@ -3958,7 +3958,7 @@ static int init_dumping(char *database, int init_func(char*))
my_bool include_table(const uchar *hash_key, size_t len) my_bool include_table(const uchar *hash_key, size_t len)
{ {
return !hash_search(&ignore_table, hash_key, len); return ! my_hash_search(&ignore_table, hash_key, len);
} }

View File

@ -1135,7 +1135,7 @@ void free_used_memory()
close_connections(); close_connections();
close_files(); close_files();
hash_free(&var_hash); my_hash_free(&var_hash);
for (i= 0 ; i < q_lines.elements ; i++) for (i= 0 ; i < q_lines.elements ; i++)
{ {
@ -1998,7 +1998,7 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
if (length >= MAX_VAR_NAME_LENGTH) if (length >= MAX_VAR_NAME_LENGTH)
die("Too long variable name: %s", save_var_name); die("Too long variable name: %s", save_var_name);
if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name, if (!(v = (VAR*) my_hash_search(&var_hash, (const uchar*) save_var_name,
length))) length)))
{ {
char buff[MAX_VAR_NAME_LENGTH+1]; char buff[MAX_VAR_NAME_LENGTH+1];
@ -2030,7 +2030,7 @@ err:
VAR *var_obtain(const char *name, int len) VAR *var_obtain(const char *name, int len)
{ {
VAR* v; VAR* v;
if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len))) if ((v = (VAR*)my_hash_search(&var_hash, (const uchar *) name, len)))
return v; return v;
v = var_init(0, name, len, "", 0); v = var_init(0, name, len, "", 0);
my_hash_insert(&var_hash, (uchar*)v); my_hash_insert(&var_hash, (uchar*)v);
@ -7580,7 +7580,7 @@ int main(int argc, char **argv)
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024); my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024);
if (hash_init(&var_hash, charset_info, if (my_hash_init(&var_hash, charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0))) 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed"); die("Variable hash initialization failed");

View File

@ -21,40 +21,6 @@
extern "C" { extern "C" {
#endif #endif
/*
There was a problem on MacOSX with a shared object ha_example.so.
It used hash_search(). During build of ha_example.so no libmysys
was specified. Since MacOSX had a hash_search() in the system
library, it built the shared object so that the dynamic linker
linked hash_search() to the system library, which caused a crash
when called. To come around this, we renamed hash_search() to
my_hash_search(), as we did long ago with hash_insert() and
hash_reset(). However, this time we made the move complete with
all names. To keep compatibility, we redefine the old names.
Since every C and C++ file, that uses HASH, needs to include
this file, the change is complete. Both names could be used
in the code, but the my_* versions are recommended now.
*/
#define hash_get_key my_hash_get_key
#define hash_free_key my_hash_free_key
#define hash_init my_hash_init
#define hash_init2 my_hash_init2
#define _hash_init _my_hash_init
#define hash_free my_hash_free
#define hash_reset my_hash_reset
#define hash_element my_hash_element
#define hash_search my_hash_search
#define hash_first my_hash_first
#define hash_next my_hash_next
#define hash_insert my_hash_insert
#define hash_delete my_hash_delete
#define hash_update my_hash_update
#define hash_replace my_hash_replace
#define hash_check my_hash_check
#define hash_clear my_hash_clear
#define hash_inited my_hash_inited
#define hash_init_opt my_hash_init_opt
/* /*
Overhead to store an element in hash Overhead to store an element in hash
Can be used to approximate memory consumption for a hash Can be used to approximate memory consumption for a hash

View File

@ -108,8 +108,8 @@ static my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
uchar *default_value) uchar *default_value)
{ {
DBUG_ENTER("safe_hash"); DBUG_ENTER("safe_hash");
if (hash_init(&hash->hash, &my_charset_bin, elements, if (my_hash_init(&hash->hash, &my_charset_bin, elements,
0, 0, (hash_get_key) safe_hash_entry_get, 0, 0, (my_hash_get_key) safe_hash_entry_get,
(void (*)(void*)) safe_hash_entry_free, 0)) (void (*)(void*)) safe_hash_entry_free, 0))
{ {
hash->default_value= 0; hash->default_value= 0;
@ -137,7 +137,7 @@ static void safe_hash_free(SAFE_HASH *hash)
*/ */
if (hash->default_value) if (hash->default_value)
{ {
hash_free(&hash->hash); my_hash_free(&hash->hash);
rwlock_destroy(&hash->mutex); rwlock_destroy(&hash->mutex);
hash->default_value=0; hash->default_value=0;
} }
@ -152,7 +152,7 @@ static uchar *safe_hash_search(SAFE_HASH *hash, const uchar *key, uint length)
uchar *result; uchar *result;
DBUG_ENTER("safe_hash_search"); DBUG_ENTER("safe_hash_search");
rw_rdlock(&hash->mutex); rw_rdlock(&hash->mutex);
result= hash_search(&hash->hash, key, length); result= my_hash_search(&hash->hash, key, length);
rw_unlock(&hash->mutex); rw_unlock(&hash->mutex);
if (!result) if (!result)
result= hash->default_value; result= hash->default_value;
@ -192,7 +192,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, (long) data)); DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, (long) data));
rw_wrlock(&hash->mutex); rw_wrlock(&hash->mutex);
entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length); entry= (SAFE_HASH_ENTRY*) my_hash_search(&hash->hash, key, length);
if (data == hash->default_value) if (data == hash->default_value)
{ {
@ -206,7 +206,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
/* unlink entry from list */ /* unlink entry from list */
if ((*entry->prev= entry->next)) if ((*entry->prev= entry->next))
entry->next->prev= entry->prev; entry->next->prev= entry->prev;
hash_delete(&hash->hash, (uchar*) entry); my_hash_delete(&hash->hash, (uchar*) entry);
goto end; goto end;
} }
if (entry) if (entry)
@ -277,7 +277,7 @@ static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)
{ {
if ((*entry->prev= entry->next)) if ((*entry->prev= entry->next))
entry->next->prev= entry->prev; entry->next->prev= entry->prev;
hash_delete(&hash->hash, (uchar*) entry); my_hash_delete(&hash->hash, (uchar*) entry);
} }
else else
entry->data= new_data; entry->data= new_data;

View File

@ -355,8 +355,8 @@ Thd_ndb::Thd_ndb()
m_error_code= 0; m_error_code= 0;
query_state&= NDB_QUERY_NORMAL; query_state&= NDB_QUERY_NORMAL;
options= 0; options= 0;
(void) hash_init(&open_tables, &my_charset_bin, 5, 0, 0, (void) my_hash_init(&open_tables, &my_charset_bin, 5, 0, 0,
(hash_get_key)thd_ndb_share_get_key, 0, 0); (my_hash_get_key)thd_ndb_share_get_key, 0, 0);
} }
Thd_ndb::~Thd_ndb() Thd_ndb::~Thd_ndb()
@ -380,7 +380,7 @@ Thd_ndb::~Thd_ndb()
ndb= NULL; ndb= NULL;
} }
changed_tables.empty(); changed_tables.empty();
hash_free(&open_tables); my_hash_free(&open_tables);
} }
void void
@ -4587,9 +4587,9 @@ int ha_ndbcluster::init_handler_for_statement(THD *thd, Thd_ndb *thd_ndb)
const void *key= m_table; const void *key= m_table;
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
THD_NDB_SHARE *thd_ndb_share= THD_NDB_SHARE *thd_ndb_share=
(THD_NDB_SHARE*)hash_first(&thd_ndb->open_tables, (uchar *)&key, sizeof(key), &state); (THD_NDB_SHARE*)my_hash_first(&thd_ndb->open_tables, (uchar *)&key, sizeof(key), &state);
while (thd_ndb_share && thd_ndb_share->key != key) while (thd_ndb_share && thd_ndb_share->key != key)
thd_ndb_share= (THD_NDB_SHARE*)hash_next(&thd_ndb->open_tables, (uchar *)&key, sizeof(key), &state); thd_ndb_share= (THD_NDB_SHARE*)my_hash_next(&thd_ndb->open_tables, (uchar *)&key, sizeof(key), &state);
if (thd_ndb_share == 0) if (thd_ndb_share == 0)
{ {
thd_ndb_share= (THD_NDB_SHARE *) alloc_root(&thd->transaction.mem_root, thd_ndb_share= (THD_NDB_SHARE *) alloc_root(&thd->transaction.mem_root,
@ -5523,7 +5523,7 @@ int ha_ndbcluster::create(const char *name,
*/ */
{ {
uint length= (uint) strlen(name); uint length= (uint) strlen(name);
if ((share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, if ((share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) name, length))) (uchar*) name, length)))
handle_trailing_share(share); handle_trailing_share(share);
} }
@ -7118,18 +7118,18 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
NdbDictionary::Object::UserTable) != 0) NdbDictionary::Object::UserTable) != 0)
ERR_RETURN(dict->getNdbError()); ERR_RETURN(dict->getNdbError());
if (hash_init(&ndb_tables, system_charset_info,list.count,0,0, if (my_hash_init(&ndb_tables, system_charset_info,list.count,0,0,
(hash_get_key)tables_get_key,0,0)) (my_hash_get_key)tables_get_key,0,0))
{ {
DBUG_PRINT("error", ("Failed to init HASH ndb_tables")); DBUG_PRINT("error", ("Failed to init HASH ndb_tables"));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (hash_init(&ok_tables, system_charset_info,32,0,0, if (my_hash_init(&ok_tables, system_charset_info,32,0,0,
(hash_get_key)tables_get_key,0,0)) (my_hash_get_key)tables_get_key,0,0))
{ {
DBUG_PRINT("error", ("Failed to init HASH ok_tables")); DBUG_PRINT("error", ("Failed to init HASH ok_tables"));
hash_free(&ndb_tables); my_hash_free(&ndb_tables);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
@ -7170,7 +7170,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
{ {
bool file_on_disk= FALSE; bool file_on_disk= FALSE;
DBUG_PRINT("info", ("%s", file_name->str)); DBUG_PRINT("info", ("%s", file_name->str));
if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length)) if (my_hash_search(&ndb_tables, (uchar*) file_name->str,
file_name->length))
{ {
build_table_filename(name, sizeof(name) - 1, db, build_table_filename(name, sizeof(name) - 1, db,
file_name->str, reg_ext, 0); file_name->str, reg_ext, 0);
@ -7205,10 +7206,10 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
if (file_on_disk) if (file_on_disk)
{ {
// Ignore this ndb table // Ignore this ndb table
uchar *record= hash_search(&ndb_tables, (uchar*) file_name->str, uchar *record= my_hash_search(&ndb_tables, (uchar*) file_name->str,
file_name->length); file_name->length);
DBUG_ASSERT(record); DBUG_ASSERT(record);
hash_delete(&ndb_tables, record); my_hash_delete(&ndb_tables, record);
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_EXISTS_ERROR, ER_TABLE_EXISTS_ERROR,
"Local table %s.%s shadows ndb table", "Local table %s.%s shadows ndb table",
@ -7242,7 +7243,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
build_table_filename(name, sizeof(name) - 1, db, "", "", 0); build_table_filename(name, sizeof(name) - 1, db, "", "", 0);
for (i= 0; i < ok_tables.records; i++) for (i= 0; i < ok_tables.records; i++)
{ {
file_name_str= (char*)hash_element(&ok_tables, i); file_name_str= (char*)my_hash_element(&ok_tables, i);
end= end1 + end= end1 +
tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name)); tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
@ -7258,8 +7259,9 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
List<char> create_list; List<char> create_list;
for (i= 0 ; i < ndb_tables.records ; i++) for (i= 0 ; i < ndb_tables.records ; i++)
{ {
file_name_str= (char*) hash_element(&ndb_tables, i); file_name_str= (char*) my_hash_element(&ndb_tables, i);
if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str))) if (!my_hash_search(&ok_tables, (uchar*) file_name_str,
strlen(file_name_str)))
{ {
build_table_filename(name, sizeof(name) - 1, build_table_filename(name, sizeof(name) - 1,
db, file_name_str, reg_ext, 0); db, file_name_str, reg_ext, 0);
@ -7313,8 +7315,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
hash_free(&ok_tables); my_hash_free(&ok_tables);
hash_free(&ndb_tables); my_hash_free(&ndb_tables);
// Delete schema file from files // Delete schema file from files
if (!strcmp(db, NDB_REP_DB)) if (!strcmp(db, NDB_REP_DB))
@ -7478,8 +7480,8 @@ static int ndbcluster_init(void *p)
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
(void) hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0, (void) my_hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0,
(hash_get_key) ndbcluster_get_key,0,0); (my_hash_get_key) ndbcluster_get_key,0,0);
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
/* start the ndb injector thread */ /* start the ndb injector thread */
if (ndbcluster_binlog_start()) if (ndbcluster_binlog_start())
@ -7492,7 +7494,7 @@ static int ndbcluster_init(void *p)
if (pthread_create(&tmp, &connection_attrib, ndb_util_thread_func, 0)) if (pthread_create(&tmp, &connection_attrib, ndb_util_thread_func, 0))
{ {
DBUG_PRINT("error", ("Could not create ndb utility thread")); DBUG_PRINT("error", ("Could not create ndb utility thread"));
hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread);
@ -7509,7 +7511,7 @@ static int ndbcluster_init(void *p)
if (!ndb_util_thread_running) if (!ndb_util_thread_running)
{ {
DBUG_PRINT("error", ("ndb utility thread exited prematurely")); DBUG_PRINT("error", ("ndb utility thread exited prematurely"));
hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread);
@ -7560,7 +7562,7 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
while (ndbcluster_open_tables.records) while (ndbcluster_open_tables.records)
{ {
NDB_SHARE *share= NDB_SHARE *share=
(NDB_SHARE*) hash_element(&ndbcluster_open_tables, 0); (NDB_SHARE*) my_hash_element(&ndbcluster_open_tables, 0);
#ifndef DBUG_OFF #ifndef DBUG_OFF
fprintf(stderr, "NDB: table share %s with use_count %d not freed\n", fprintf(stderr, "NDB: table share %s with use_count %d not freed\n",
share->key, share->use_count); share->key, share->use_count);
@ -7570,7 +7572,7 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
pthread_mutex_unlock(&ndbcluster_mutex); pthread_mutex_unlock(&ndbcluster_mutex);
} }
#endif #endif
hash_free(&ndbcluster_open_tables); my_hash_free(&ndbcluster_open_tables);
if (g_ndb) if (g_ndb)
{ {
@ -7903,7 +7905,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
dbname, tabname, "", 0); dbname, tabname, "", 0);
DBUG_PRINT("enter", ("name: %s", name)); DBUG_PRINT("enter", ("name: %s", name));
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables, if (!(share=(NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) name, (uchar*) name,
strlen(name)))) strlen(name))))
{ {
@ -8165,7 +8167,7 @@ static void print_ndbcluster_open_tables()
fprintf(DBUG_FILE, ">ndbcluster_open_tables\n"); fprintf(DBUG_FILE, ">ndbcluster_open_tables\n");
for (uint i= 0; i < ndbcluster_open_tables.records; i++) for (uint i= 0; i < ndbcluster_open_tables.records; i++)
print_share("", print_share("",
(NDB_SHARE*)hash_element(&ndbcluster_open_tables, i)); (NDB_SHARE*)my_hash_element(&ndbcluster_open_tables, i));
fprintf(DBUG_FILE, "<ndbcluster_open_tables\n"); fprintf(DBUG_FILE, "<ndbcluster_open_tables\n");
DBUG_UNLOCK_FILE; DBUG_UNLOCK_FILE;
} }
@ -8276,7 +8278,7 @@ int handle_trailing_share(NDB_SHARE *share)
at the cost of a possible mem leak, by "renaming" the share at the cost of a possible mem leak, by "renaming" the share
- First remove from hash - First remove from hash
*/ */
hash_delete(&ndbcluster_open_tables, (uchar*) share); my_hash_delete(&ndbcluster_open_tables, (uchar*) share);
/* /*
now give it a new name, just a running number now give it a new name, just a running number
@ -8309,12 +8311,12 @@ static int rename_share(NDB_SHARE *share, const char *new_key)
uint new_length= (uint) strlen(new_key); uint new_length= (uint) strlen(new_key);
DBUG_PRINT("rename_share", ("old_key: %s old__length: %d", DBUG_PRINT("rename_share", ("old_key: %s old__length: %d",
share->key, share->key_length)); share->key, share->key_length));
if ((tmp= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, if ((tmp= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) new_key, new_length))) (uchar*) new_key, new_length)))
handle_trailing_share(tmp); handle_trailing_share(tmp);
/* remove the share from hash */ /* remove the share from hash */
hash_delete(&ndbcluster_open_tables, (uchar*) share); my_hash_delete(&ndbcluster_open_tables, (uchar*) share);
dbug_print_open_tables(); dbug_print_open_tables();
/* save old stuff if insert should fail */ /* save old stuff if insert should fail */
@ -8415,7 +8417,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
if (!(share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, if (!(share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) key, (uchar*) key,
length))) length)))
{ {
@ -8493,7 +8495,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
DBUG_ENTER("ndbcluster_real_free_share"); DBUG_ENTER("ndbcluster_real_free_share");
dbug_print_share("ndbcluster_real_free_share:", *share); dbug_print_share("ndbcluster_real_free_share:", *share);
hash_delete(&ndbcluster_open_tables, (uchar*) *share); my_hash_delete(&ndbcluster_open_tables, (uchar*) *share);
thr_lock_delete(&(*share)->lock); thr_lock_delete(&(*share)->lock);
pthread_mutex_destroy(&(*share)->mutex); pthread_mutex_destroy(&(*share)->mutex);
@ -9397,7 +9399,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
} }
for (i= 0, open_count= 0; i < record_count; i++) for (i= 0, open_count= 0; i < record_count; i++)
{ {
share= (NDB_SHARE *)hash_element(&ndbcluster_open_tables, i); share= (NDB_SHARE *)my_hash_element(&ndbcluster_open_tables, i);
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
if ((share->use_count - (int) (share->op != 0) - (int) (share->op != 0)) if ((share->use_count - (int) (share->op != 0) - (int) (share->op != 0))
<= 0) <= 0)

View File

@ -740,7 +740,7 @@ static NDB_SHARE *ndbcluster_check_ndb_apply_status_share()
{ {
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
void *share= hash_search(&ndbcluster_open_tables, void *share= my_hash_search(&ndbcluster_open_tables,
(uchar*) NDB_APPLY_TABLE_FILE, (uchar*) NDB_APPLY_TABLE_FILE,
sizeof(NDB_APPLY_TABLE_FILE) - 1); sizeof(NDB_APPLY_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx", DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx",
@ -758,7 +758,7 @@ static NDB_SHARE *ndbcluster_check_ndb_schema_share()
{ {
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
void *share= hash_search(&ndbcluster_open_tables, void *share= my_hash_search(&ndbcluster_open_tables,
(uchar*) NDB_SCHEMA_TABLE_FILE, (uchar*) NDB_SCHEMA_TABLE_FILE,
sizeof(NDB_SCHEMA_TABLE_FILE) - 1); sizeof(NDB_SCHEMA_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx", DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx",
@ -2184,7 +2184,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
{ {
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
NDB_SCHEMA_OBJECT *ndb_schema_object= NDB_SCHEMA_OBJECT *ndb_schema_object=
(NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects, (NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects,
(uchar*) key, strlen(key)); (uchar*) key, strlen(key));
if (ndb_schema_object) if (ndb_schema_object)
{ {
@ -2571,7 +2571,7 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
/* Handle any trailing share */ /* Handle any trailing share */
NDB_SHARE *share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, NDB_SHARE *share= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
(uchar*) key, key_len); (uchar*) key, key_len);
if (share && share_may_exist) if (share && share_may_exist)
@ -3558,7 +3558,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
if (!have_lock) if (!have_lock)
pthread_mutex_lock(&ndbcluster_mutex); pthread_mutex_lock(&ndbcluster_mutex);
while (!(ndb_schema_object= while (!(ndb_schema_object=
(NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects, (NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects,
(uchar*) key, (uchar*) key,
length))) length)))
{ {
@ -3609,7 +3609,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
if (!--(*ndb_schema_object)->use_count) if (!--(*ndb_schema_object)->use_count)
{ {
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count)); DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object); my_hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
pthread_mutex_destroy(&(*ndb_schema_object)->mutex); pthread_mutex_destroy(&(*ndb_schema_object)->mutex);
my_free((uchar*) *ndb_schema_object, MYF(0)); my_free((uchar*) *ndb_schema_object, MYF(0));
*ndb_schema_object= 0; *ndb_schema_object= 0;
@ -3713,8 +3713,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
} }
/* init hash for schema object distribution */ /* init hash for schema object distribution */
(void) hash_init(&ndb_schema_objects, system_charset_info, 32, 0, 0, (void) my_hash_init(&ndb_schema_objects, system_charset_info, 32, 0, 0,
(hash_get_key)ndb_schema_objects_get_key, 0, 0); (my_hash_get_key)ndb_schema_objects_get_key, 0, 0);
/* /*
Expose global reference to our ndb object. Expose global reference to our ndb object.
@ -4365,7 +4365,7 @@ err:
i_ndb= 0; i_ndb= 0;
} }
hash_free(&ndb_schema_objects); my_hash_free(&ndb_schema_objects);
net_end(&thd->net); net_end(&thd->net);
thd->cleanup(); thd->cleanup();

View File

@ -1533,7 +1533,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
} }
// recovery mode // recovery mode
if (info->commit_list ? if (info->commit_list ?
hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : my_hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 :
tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
@ -1649,7 +1649,7 @@ bool mysql_xa_recover(THD *thd)
DBUG_RETURN(1); DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_xid_cache); pthread_mutex_lock(&LOCK_xid_cache);
while ((xs= (XID_STATE*)hash_element(&xid_cache, i++))) while ((xs= (XID_STATE*) my_hash_element(&xid_cache, i++)))
{ {
if (xs->xa_state==XA_PREPARED) if (xs->xa_state==XA_PREPARED)
{ {
@ -2972,9 +2972,9 @@ static bool update_frm_version(TABLE *table)
if ((result= my_pwrite(file,(uchar*) version,4,51L,MYF_RW))) if ((result= my_pwrite(file,(uchar*) version,4,51L,MYF_RW)))
goto err; goto err;
for (entry=(TABLE*) hash_first(&open_cache,(uchar*) key,key_length, &state); for (entry=(TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length, &state);
entry; entry;
entry= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, &state)) entry= (TABLE*) my_hash_next(&open_cache,(uchar*) key,key_length, &state))
entry->s->mysql_version= MYSQL_VERSION_ID; entry->s->mysql_version= MYSQL_VERSION_ID;
} }
err: err:

View File

@ -38,8 +38,8 @@ class hash_filo_element
class hash_filo class hash_filo
{ {
const uint size, key_offset, key_length; const uint size, key_offset, key_length;
const hash_get_key get_key; const my_hash_get_key get_key;
hash_free_key free_element; my_hash_free_key free_element;
bool init; bool init;
CHARSET_INFO *hash_charset; CHARSET_INFO *hash_charset;
@ -49,7 +49,7 @@ public:
HASH cache; HASH cache;
hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg, hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
hash_get_key get_key_arg, hash_free_key free_element_arg, my_hash_get_key get_key_arg, my_hash_free_key free_element_arg,
CHARSET_INFO *hash_charset_arg) CHARSET_INFO *hash_charset_arg)
:size(size_arg), key_offset(key_offset_arg), key_length(key_length_arg), :size(size_arg), key_offset(key_offset_arg), key_length(key_length_arg),
get_key(get_key_arg), free_element(free_element_arg),init(0), get_key(get_key_arg), free_element(free_element_arg),init(0),
@ -63,7 +63,7 @@ public:
if (init) if (init)
{ {
if (cache.array.buffer) /* Avoid problems with thread library */ if (cache.array.buffer) /* Avoid problems with thread library */
(void) hash_free(&cache); (void) my_hash_free(&cache);
pthread_mutex_destroy(&lock); pthread_mutex_destroy(&lock);
} }
} }
@ -76,8 +76,8 @@ public:
} }
if (!locked) if (!locked)
(void) pthread_mutex_lock(&lock); (void) pthread_mutex_lock(&lock);
(void) hash_free(&cache); (void) my_hash_free(&cache);
(void) hash_init(&cache,hash_charset,size,key_offset, (void) my_hash_init(&cache,hash_charset,size,key_offset,
key_length, get_key, free_element,0); key_length, get_key, free_element,0);
if (!locked) if (!locked)
(void) pthread_mutex_unlock(&lock); (void) pthread_mutex_unlock(&lock);
@ -87,7 +87,7 @@ public:
hash_filo_element *search(uchar* key, size_t length) hash_filo_element *search(uchar* key, size_t length)
{ {
hash_filo_element *entry=(hash_filo_element*) hash_filo_element *entry=(hash_filo_element*)
hash_search(&cache,(uchar*) key,length); my_hash_search(&cache,(uchar*) key,length);
if (entry) if (entry)
{ // Found; link it first { // Found; link it first
if (entry != first_link) if (entry != first_link)
@ -113,7 +113,7 @@ public:
{ {
hash_filo_element *tmp=last_link; hash_filo_element *tmp=last_link;
last_link=last_link->prev_used; last_link=last_link->prev_used;
hash_delete(&cache,(uchar*) tmp); my_hash_delete(&cache,(uchar*) tmp);
} }
if (my_hash_insert(&cache,(uchar*) entry)) if (my_hash_insert(&cache,(uchar*) entry))
{ {

View File

@ -64,7 +64,7 @@ bool hostname_cache_init()
uint offset= (uint) ((char*) (&tmp.ip) - (char*) &tmp); uint offset= (uint) ((char*) (&tmp.ip) - (char*) &tmp);
if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset, if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset,
sizeof(struct in_addr),NULL, sizeof(struct in_addr),NULL,
(hash_free_key) free, (my_hash_free_key) free,
&my_charset_bin))) &my_charset_bin)))
return 1; return 1;
hostname_cache->clear(); hostname_cache->clear();

View File

@ -4960,12 +4960,12 @@ int item_create_init()
DBUG_ENTER("item_create_init"); DBUG_ENTER("item_create_init");
if (hash_init(& native_functions_hash, if (my_hash_init(& native_functions_hash,
system_charset_info, system_charset_info,
array_elements(func_array), array_elements(func_array),
0, 0,
0, 0,
(hash_get_key) get_native_fct_hash_key, (my_hash_get_key) get_native_fct_hash_key,
NULL, /* Nothing to free */ NULL, /* Nothing to free */
MYF(0))) MYF(0)))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -4979,7 +4979,7 @@ int item_create_init()
#ifndef DBUG_OFF #ifndef DBUG_OFF
for (uint i=0 ; i < native_functions_hash.records ; i++) for (uint i=0 ; i < native_functions_hash.records ; i++)
{ {
func= (Native_func_registry*) hash_element(& native_functions_hash, i); func= (Native_func_registry*) my_hash_element(& native_functions_hash, i);
DBUG_PRINT("info", ("native function: %s length: %u", DBUG_PRINT("info", ("native function: %s length: %u",
func->name.str, (uint) func->name.length)); func->name.str, (uint) func->name.length));
} }
@ -4997,7 +4997,7 @@ int item_create_init()
void item_create_cleanup() void item_create_cleanup()
{ {
DBUG_ENTER("item_create_cleanup"); DBUG_ENTER("item_create_cleanup");
hash_free(& native_functions_hash); my_hash_free(& native_functions_hash);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -5008,7 +5008,7 @@ find_native_function_builder(THD *thd, LEX_STRING name)
Create_func *builder= NULL; Create_func *builder= NULL;
/* Thread safe */ /* Thread safe */
func= (Native_func_registry*) hash_search(& native_functions_hash, func= (Native_func_registry*) my_hash_search(& native_functions_hash,
(uchar*) name.str, (uchar*) name.str,
name.length); name.length);

View File

@ -3284,7 +3284,7 @@ public:
{ {
if (key) if (key)
{ {
hash_delete(&hash_user_locks,(uchar*) this); my_hash_delete(&hash_user_locks,(uchar*) this);
my_free(key, MYF(0)); my_free(key, MYF(0));
} }
pthread_cond_destroy(&cond); pthread_cond_destroy(&cond);
@ -3308,8 +3308,8 @@ static bool item_user_lock_inited= 0;
void item_user_lock_init(void) void item_user_lock_init(void)
{ {
pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW); pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
hash_init(&hash_user_locks,system_charset_info, my_hash_init(&hash_user_locks,system_charset_info,
16,0,0,(hash_get_key) ull_get_key,NULL,0); 16,0,0,(my_hash_get_key) ull_get_key,NULL,0);
item_user_lock_inited= 1; item_user_lock_inited= 1;
} }
@ -3318,7 +3318,7 @@ void item_user_lock_free(void)
if (item_user_lock_inited) if (item_user_lock_inited)
{ {
item_user_lock_inited= 0; item_user_lock_inited= 0;
hash_free(&hash_user_locks); my_hash_free(&hash_user_locks);
pthread_mutex_destroy(&LOCK_user_locks); pthread_mutex_destroy(&LOCK_user_locks);
} }
} }
@ -3385,7 +3385,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
this case, we will not be waiting, but rather, just waste CPU and this case, we will not be waiting, but rather, just waste CPU and
memory on the whole deal memory on the whole deal
*/ */
if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks, if (!(ull= ((User_level_lock*) my_hash_search(&hash_user_locks,
(uchar*) lock_name, (uchar*) lock_name,
lock_name_len)))) lock_name_len))))
{ {
@ -3488,7 +3488,7 @@ longlong Item_func_get_lock::val_int()
thd->ull=0; thd->ull=0;
} }
if (!(ull= ((User_level_lock *) hash_search(&hash_user_locks, if (!(ull= ((User_level_lock *) my_hash_search(&hash_user_locks,
(uchar*) res->ptr(), (uchar*) res->ptr(),
(size_t) res->length())))) (size_t) res->length()))))
{ {
@ -3592,7 +3592,7 @@ longlong Item_func_release_lock::val_int()
result=0; result=0;
pthread_mutex_lock(&LOCK_user_locks); pthread_mutex_lock(&LOCK_user_locks);
if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks, if (!(ull= ((User_level_lock*) my_hash_search(&hash_user_locks,
(const uchar*) res->ptr(), (const uchar*) res->ptr(),
(size_t) res->length())))) (size_t) res->length()))))
{ {
@ -3774,12 +3774,12 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
{ {
user_var_entry *entry; user_var_entry *entry;
if (!(entry = (user_var_entry*) hash_search(hash, (uchar*) name.str, if (!(entry = (user_var_entry*) my_hash_search(hash, (uchar*) name.str,
name.length)) && name.length)) &&
create_if_not_exists) create_if_not_exists)
{ {
uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size; uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
if (!hash_inited(hash)) if (!my_hash_inited(hash))
return 0; return 0;
if (!(entry = (user_var_entry*) my_malloc(size,MYF(MY_WME)))) if (!(entry = (user_var_entry*) my_malloc(size,MYF(MY_WME))))
return 0; return 0;
@ -5709,7 +5709,7 @@ longlong Item_func_is_free_lock::val_int()
} }
pthread_mutex_lock(&LOCK_user_locks); pthread_mutex_lock(&LOCK_user_locks);
ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(), ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
(size_t) res->length()); (size_t) res->length());
pthread_mutex_unlock(&LOCK_user_locks); pthread_mutex_unlock(&LOCK_user_locks);
if (!ull || !ull->locked) if (!ull || !ull->locked)
@ -5728,7 +5728,7 @@ longlong Item_func_is_used_lock::val_int()
return 0; return 0;
pthread_mutex_lock(&LOCK_user_locks); pthread_mutex_lock(&LOCK_user_locks);
ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(), ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
(size_t) res->length()); (size_t) res->length());
pthread_mutex_unlock(&LOCK_user_locks); pthread_mutex_unlock(&LOCK_user_locks);
if (!ull || !ull->locked) if (!ull || !ull->locked)

View File

@ -1029,10 +1029,10 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
if (check_in_use) if (check_in_use)
{ {
/* Only insert the table if we haven't insert it already */ /* Only insert the table if we haven't insert it already */
for (table=(TABLE*) hash_first(&open_cache, (uchar*)key, for (table=(TABLE*) my_hash_first(&open_cache, (uchar*)key,
key_length, &state); key_length, &state);
table ; table ;
table = (TABLE*) hash_next(&open_cache,(uchar*) key, table = (TABLE*) my_hash_next(&open_cache,(uchar*) key,
key_length, &state)) key_length, &state))
{ {
if (table->in_use == thd) if (table->in_use == thd)
@ -1060,7 +1060,7 @@ void unlock_table_name(THD *thd, TABLE_LIST *table_list)
{ {
if (table_list->table) if (table_list->table)
{ {
hash_delete(&open_cache, (uchar*) table_list->table); my_hash_delete(&open_cache, (uchar*) table_list->table);
broadcast_refresh(); broadcast_refresh();
} }
} }
@ -1235,10 +1235,10 @@ is_table_name_exclusively_locked_by_this_thread(THD *thd, uchar *key,
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
TABLE *table; TABLE *table;
for (table= (TABLE*) hash_first(&open_cache, key, for (table= (TABLE*) my_hash_first(&open_cache, key,
key_length, &state); key_length, &state);
table ; table ;
table= (TABLE*) hash_next(&open_cache, key, table= (TABLE*) my_hash_next(&open_cache, key,
key_length, &state)) key_length, &state))
{ {
if (table->in_use == thd && if (table->in_use == thd &&

View File

@ -5433,7 +5433,7 @@ int TC_LOG_MMAP::recover()
goto err1; goto err1;
} }
if (hash_init(&xids, &my_charset_bin, tc_log_page_size/3, 0, if (my_hash_init(&xids, &my_charset_bin, tc_log_page_size/3, 0,
sizeof(my_xid), 0, 0, MYF(0))) sizeof(my_xid), 0, 0, MYF(0)))
goto err1; goto err1;
@ -5447,12 +5447,12 @@ int TC_LOG_MMAP::recover()
if (ha_recover(&xids)) if (ha_recover(&xids))
goto err2; goto err2;
hash_free(&xids); my_hash_free(&xids);
bzero(data, (size_t)file_length); bzero(data, (size_t)file_length);
return 0; return 0;
err2: err2:
hash_free(&xids); my_hash_free(&xids);
err1: err1:
sql_print_error("Crash recovery failed. Either correct the problem " sql_print_error("Crash recovery failed. Either correct the problem "
"(if it's, for example, out of memory error) and restart, " "(if it's, for example, out of memory error) and restart, "
@ -5636,7 +5636,7 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle)
MEM_ROOT mem_root; MEM_ROOT mem_root;
if (! fdle->is_valid() || if (! fdle->is_valid() ||
hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0, my_hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0,
sizeof(my_xid), 0, 0, MYF(0))) sizeof(my_xid), 0, 0, MYF(0)))
goto err1; goto err1;
@ -5662,12 +5662,12 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle)
goto err2; goto err2;
free_root(&mem_root, MYF(0)); free_root(&mem_root, MYF(0));
hash_free(&xids); my_hash_free(&xids);
return 0; return 0;
err2: err2:
free_root(&mem_root, MYF(0)); free_root(&mem_root, MYF(0));
hash_free(&xids); my_hash_free(&xids);
err1: err1:
sql_print_error("Crash recovery failed. Either correct the problem " sql_print_error("Crash recovery failed. Either correct the problem "
"(if it's, for example, out of memory error) and restart, " "(if it's, for example, out of memory error) and restart, "

View File

@ -146,10 +146,10 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
pthread_mutex_lock(&LOCK_slave_list); pthread_mutex_lock(&LOCK_slave_list);
SLAVE_INFO* old_si; SLAVE_INFO* old_si;
if ((old_si = (SLAVE_INFO*)hash_search(&slave_list, if ((old_si = (SLAVE_INFO*)my_hash_search(&slave_list,
(uchar*)&thd->server_id, 4)) && (uchar*)&thd->server_id, 4)) &&
(!only_mine || old_si->thd == thd)) (!only_mine || old_si->thd == thd))
hash_delete(&slave_list, (uchar*)old_si); my_hash_delete(&slave_list, (uchar*)old_si);
if (need_mutex) if (need_mutex)
pthread_mutex_unlock(&LOCK_slave_list); pthread_mutex_unlock(&LOCK_slave_list);
@ -221,17 +221,18 @@ extern "C" void slave_info_free(void *s)
void init_slave_list() void init_slave_list()
{ {
hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0, my_hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
(hash_get_key) slave_list_key, (hash_free_key) slave_info_free, 0); (my_hash_get_key) slave_list_key,
(my_hash_free_key) slave_info_free, 0);
pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST); pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST);
} }
void end_slave_list() void end_slave_list()
{ {
/* No protection by a mutex needed as we are only called at shutdown */ /* No protection by a mutex needed as we are only called at shutdown */
if (hash_inited(&slave_list)) if (my_hash_inited(&slave_list))
{ {
hash_free(&slave_list); my_hash_free(&slave_list);
pthread_mutex_destroy(&LOCK_slave_list); pthread_mutex_destroy(&LOCK_slave_list);
} }
} }
@ -547,7 +548,7 @@ HOSTS";
uint32 log_server_id; uint32 log_server_id;
SLAVE_INFO* si, *old_si; SLAVE_INFO* si, *old_si;
log_server_id = atoi(row[0]); log_server_id = atoi(row[0]);
if ((old_si= (SLAVE_INFO*)hash_search(&slave_list, if ((old_si= (SLAVE_INFO*)my_hash_search(&slave_list,
(uchar*)&log_server_id,4))) (uchar*)&log_server_id,4)))
si = old_si; si = old_si;
else else
@ -682,7 +683,7 @@ bool show_slave_hosts(THD* thd)
for (uint i = 0; i < slave_list.records; ++i) for (uint i = 0; i < slave_list.records; ++i)
{ {
SLAVE_INFO* si = (SLAVE_INFO*) hash_element(&slave_list, i); SLAVE_INFO* si = (SLAVE_INFO*) my_hash_element(&slave_list, i);
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store((uint32) si->server_id); protocol->store((uint32) si->server_id);
protocol->store(si->host, &my_charset_bin); protocol->store(si->host, &my_charset_bin);

View File

@ -32,9 +32,9 @@ Rpl_filter::Rpl_filter() :
Rpl_filter::~Rpl_filter() Rpl_filter::~Rpl_filter()
{ {
if (do_table_inited) if (do_table_inited)
hash_free(&do_table); my_hash_free(&do_table);
if (ignore_table_inited) if (ignore_table_inited)
hash_free(&ignore_table); my_hash_free(&ignore_table);
if (wild_do_table_inited) if (wild_do_table_inited)
free_string_array(&wild_do_table); free_string_array(&wild_do_table);
if (wild_ignore_table_inited) if (wild_ignore_table_inited)
@ -103,12 +103,12 @@ Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables)
len= (uint) (strmov(end, tables->table_name) - hash_key); len= (uint) (strmov(end, tables->table_name) - hash_key);
if (do_table_inited) // if there are any do's if (do_table_inited) // if there are any do's
{ {
if (hash_search(&do_table, (uchar*) hash_key, len)) if (my_hash_search(&do_table, (uchar*) hash_key, len))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (ignore_table_inited) // if there are any ignores if (ignore_table_inited) // if there are any ignores
{ {
if (hash_search(&ignore_table, (uchar*) hash_key, len)) if (my_hash_search(&ignore_table, (uchar*) hash_key, len))
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (wild_do_table_inited && if (wild_do_table_inited &&
@ -387,7 +387,7 @@ void free_table_ent(void* a)
void void
Rpl_filter::init_table_rule_hash(HASH* h, bool* h_inited) Rpl_filter::init_table_rule_hash(HASH* h, bool* h_inited)
{ {
hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0, my_hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0,
get_table_key, free_table_ent, 0); get_table_key, free_table_ent, 0);
*h_inited = 1; *h_inited = 1;
} }
@ -458,7 +458,7 @@ Rpl_filter::table_rule_ent_hash_to_str(String* s, HASH* h, bool inited)
{ {
for (uint i= 0; i < h->records; i++) for (uint i= 0; i < h->records; i++)
{ {
TABLE_RULE_ENT* e= (TABLE_RULE_ENT*) hash_element(h, i); TABLE_RULE_ENT* e= (TABLE_RULE_ENT*) my_hash_element(h, i);
if (s->length()) if (s->length())
s->append(','); s->append(',');
s->append(e->db,e->key_len); s->append(e->db,e->key_len);

View File

@ -34,10 +34,10 @@ table_mapping::table_mapping()
No "free_element" function for entries passed here, as the entries are No "free_element" function for entries passed here, as the entries are
allocated in a MEM_ROOT (freed as a whole in the destructor), they cannot allocated in a MEM_ROOT (freed as a whole in the destructor), they cannot
be freed one by one. be freed one by one.
Note that below we don't test if hash_init() succeeded. This constructor Note that below we don't test if my_hash_init() succeeded. This
is called at startup only. constructor is called at startup only.
*/ */
(void) hash_init(&m_table_ids,&my_charset_bin,TABLE_ID_HASH_SIZE, (void) my_hash_init(&m_table_ids,&my_charset_bin,TABLE_ID_HASH_SIZE,
offsetof(entry,table_id),sizeof(ulong), offsetof(entry,table_id),sizeof(ulong),
0,0,0); 0,0,0);
/* We don't preallocate any block, this is consistent with m_free=0 above */ /* We don't preallocate any block, this is consistent with m_free=0 above */
@ -49,7 +49,7 @@ table_mapping::~table_mapping()
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
clear_tables(); clear_tables();
#endif #endif
hash_free(&m_table_ids); my_hash_free(&m_table_ids);
free_root(&m_mem_root, MYF(0)); free_root(&m_mem_root, MYF(0));
} }
@ -115,7 +115,7 @@ int table_mapping::set_table(ulong table_id, TABLE* table)
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
free_table_map_log_event(e->table); free_table_map_log_event(e->table);
#endif #endif
hash_delete(&m_table_ids,(uchar *)e); my_hash_delete(&m_table_ids,(uchar *)e);
} }
e->table_id= table_id; e->table_id= table_id;
e->table= table; e->table= table;
@ -132,7 +132,7 @@ int table_mapping::remove_table(ulong table_id)
entry *e= find_entry(table_id); entry *e= find_entry(table_id);
if (e) if (e)
{ {
hash_delete(&m_table_ids,(uchar *)e); my_hash_delete(&m_table_ids,(uchar *)e);
/* we add this entry to the chain of free (free for use) entries */ /* we add this entry to the chain of free (free for use) entries */
e->next= m_free; e->next= m_free;
m_free= e; m_free= e;
@ -150,7 +150,7 @@ void table_mapping::clear_tables()
DBUG_ENTER("table_mapping::clear_tables()"); DBUG_ENTER("table_mapping::clear_tables()");
for (uint i= 0; i < m_table_ids.records; i++) for (uint i= 0; i < m_table_ids.records; i++)
{ {
entry *e= (entry *)hash_element(&m_table_ids, i); entry *e= (entry *)my_hash_element(&m_table_ids, i);
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
free_table_map_log_event(e->table); free_table_map_log_event(e->table);
#endif #endif

View File

@ -90,7 +90,7 @@ private:
entry *find_entry(ulong table_id) entry *find_entry(ulong table_id)
{ {
return (entry *)hash_search(&m_table_ids, return (entry *) my_hash_search(&m_table_ids,
(uchar*)&table_id, (uchar*)&table_id,
sizeof(table_id)); sizeof(table_id));
} }

View File

@ -3249,7 +3249,7 @@ int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
error: error:
for (; first != var; first= first->next) for (; first != var; first= first->next)
hash_delete(&system_variable_hash, (uchar*) first); my_hash_delete(&system_variable_hash, (uchar*) first);
return 1; return 1;
} }
@ -3273,7 +3273,7 @@ int mysql_del_sys_var_chain(sys_var *first)
/* A write lock should be held on LOCK_system_variables_hash */ /* A write lock should be held on LOCK_system_variables_hash */
for (sys_var *var= first; var; var= var->next) for (sys_var *var= first; var; var= var->next)
result|= hash_delete(&system_variable_hash, (uchar*) var); result|= my_hash_delete(&system_variable_hash, (uchar*) var);
return result; return result;
} }
@ -3310,7 +3310,7 @@ SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted)
for (i= 0; i < count; i++) for (i= 0; i < count; i++)
{ {
sys_var *var= (sys_var*) hash_element(&system_variable_hash, i); sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i);
show->name= var->name; show->name= var->name;
show->value= (char*) var; show->value= (char*) var;
show->type= SHOW_SYS; show->type= SHOW_SYS;
@ -3347,8 +3347,8 @@ int set_var_init()
for (sys_var *var=vars.first; var; var= var->next, count++); for (sys_var *var=vars.first; var; var= var->next, count++);
if (hash_init(&system_variable_hash, system_charset_info, count, 0, if (my_hash_init(&system_variable_hash, system_charset_info, count, 0,
0, (hash_get_key) get_sys_var_length, 0, HASH_UNIQUE)) 0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
goto error; goto error;
vars.last->next= NULL; vars.last->next= NULL;
@ -3373,7 +3373,7 @@ error:
void set_var_free() void set_var_free()
{ {
hash_free(&system_variable_hash); my_hash_free(&system_variable_hash);
} }
@ -3399,7 +3399,7 @@ sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
This function is only called from the sql_plugin.cc. This function is only called from the sql_plugin.cc.
A lock on LOCK_system_variable_hash should be held A lock on LOCK_system_variable_hash should be held
*/ */
var= (sys_var*) hash_search(&system_variable_hash, var= (sys_var*) my_hash_search(&system_variable_hash,
(uchar*) str, length ? length : strlen(str)); (uchar*) str, length ? length : strlen(str));
if (!(var || no_error)) if (!(var || no_error))
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);

View File

@ -1500,11 +1500,11 @@ static bool add_used_routine(LEX *lex, Query_arena *arena,
const LEX_STRING *key, const LEX_STRING *key,
TABLE_LIST *belong_to_view) TABLE_LIST *belong_to_view)
{ {
hash_init_opt(&lex->sroutines, system_charset_info, my_hash_init_opt(&lex->sroutines, system_charset_info,
Query_tables_list::START_SROUTINES_HASH_SIZE, Query_tables_list::START_SROUTINES_HASH_SIZE,
0, 0, sp_sroutine_key, 0, 0); 0, 0, sp_sroutine_key, 0, 0);
if (!hash_search(&lex->sroutines, (uchar *)key->str, key->length)) if (!my_hash_search(&lex->sroutines, (uchar *)key->str, key->length))
{ {
Sroutine_hash_entry *rn= Sroutine_hash_entry *rn=
(Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry) + (Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry) +
@ -1569,7 +1569,7 @@ void sp_remove_not_own_routines(LEX *lex)
but we want to be more future-proof. but we want to be more future-proof.
*/ */
next_rt= not_own_rt->next; next_rt= not_own_rt->next;
hash_delete(&lex->sroutines, (uchar *)not_own_rt); my_hash_delete(&lex->sroutines, (uchar *)not_own_rt);
} }
*(Sroutine_hash_entry **)lex->sroutines_list_own_last= NULL; *(Sroutine_hash_entry **)lex->sroutines_list_own_last= NULL;
@ -1598,8 +1598,8 @@ void sp_update_sp_used_routines(HASH *dst, HASH *src)
{ {
for (uint i=0 ; i < src->records ; i++) for (uint i=0 ; i < src->records ; i++)
{ {
Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i); Sroutine_hash_entry *rt= (Sroutine_hash_entry *)my_hash_element(src, i);
if (!hash_search(dst, (uchar *)rt->key.str, rt->key.length)) if (!my_hash_search(dst, (uchar *)rt->key.str, rt->key.length))
my_hash_insert(dst, (uchar *)rt); my_hash_insert(dst, (uchar *)rt);
} }
} }
@ -1625,7 +1625,7 @@ sp_update_stmt_used_routines(THD *thd, LEX *lex, HASH *src,
{ {
for (uint i=0 ; i < src->records ; i++) for (uint i=0 ; i < src->records ; i++)
{ {
Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i); Sroutine_hash_entry *rt= (Sroutine_hash_entry *)my_hash_element(src, i);
(void)add_used_routine(lex, thd->stmt_arena, &rt->key, belong_to_view); (void)add_used_routine(lex, thd->stmt_arena, &rt->key, belong_to_view);
} }
} }

View File

@ -44,7 +44,8 @@ public:
inline sp_head *lookup(char *name, uint namelen) inline sp_head *lookup(char *name, uint namelen)
{ {
return (sp_head *)hash_search(&m_hashtable, (const uchar *)name, namelen); return (sp_head *) my_hash_search(&m_hashtable, (const uchar *)name,
namelen);
} }
#ifdef NOT_USED #ifdef NOT_USED
@ -255,14 +256,14 @@ sp_cache::sp_cache()
sp_cache::~sp_cache() sp_cache::~sp_cache()
{ {
hash_free(&m_hashtable); my_hash_free(&m_hashtable);
} }
void void
sp_cache::init() sp_cache::init()
{ {
hash_init(&m_hashtable, system_charset_info, 0, 0, 0, my_hash_init(&m_hashtable, system_charset_info, 0, 0, 0,
hash_get_key_for_sp_head, hash_free_sp_head, 0); hash_get_key_for_sp_head, hash_free_sp_head, 0);
version= 0; version= 0;
} }
@ -271,5 +272,5 @@ sp_cache::init()
void void
sp_cache::cleanup() sp_cache::cleanup()
{ {
hash_free(&m_hashtable); my_hash_free(&m_hashtable);
} }

View File

@ -531,8 +531,9 @@ sp_head::sp_head()
m_backpatch.empty(); m_backpatch.empty();
m_cont_backpatch.empty(); m_cont_backpatch.empty();
m_lex.empty(); m_lex.empty();
hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0); my_hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0);
hash_init(&m_sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key, 0, 0); my_hash_init(&m_sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key,
0, 0);
m_body_utf8.str= NULL; m_body_utf8.str= NULL;
m_body_utf8.length= 0; m_body_utf8.length= 0;
@ -781,8 +782,8 @@ sp_head::destroy()
m_thd->lex= lex; m_thd->lex= lex;
} }
hash_free(&m_sptabs); my_hash_free(&m_sptabs);
hash_free(&m_sroutines); my_hash_free(&m_sroutines);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -3820,7 +3821,7 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
for (uint i= 0 ; i < m_sptabs.records ; i++) for (uint i= 0 ; i < m_sptabs.records ; i++)
{ {
tab= (SP_TABLE *)hash_element(&m_sptabs, i); tab= (SP_TABLE*) my_hash_element(&m_sptabs, i);
tab->query_lock_count= 0; tab->query_lock_count= 0;
} }
@ -3854,8 +3855,8 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
(and therefore should not be prelocked). Otherwise we will erroneously (and therefore should not be prelocked). Otherwise we will erroneously
treat table with same name but with different alias as non-temporary. treat table with same name but with different alias as non-temporary.
*/ */
if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (uchar *)tname, tlen)) || if ((tab= (SP_TABLE*) my_hash_search(&m_sptabs, (uchar *)tname, tlen)) ||
((tab= (SP_TABLE *)hash_search(&m_sptabs, (uchar *)tname, ((tab= (SP_TABLE*) my_hash_search(&m_sptabs, (uchar *)tname,
tlen - alen - 1)) && tlen - alen - 1)) &&
tab->temp)) tab->temp))
{ {
@ -3940,7 +3941,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
{ {
char *tab_buff, *key_buff; char *tab_buff, *key_buff;
TABLE_LIST *table; TABLE_LIST *table;
SP_TABLE *stab= (SP_TABLE *)hash_element(&m_sptabs, i); SP_TABLE *stab= (SP_TABLE*) my_hash_element(&m_sptabs, i);
if (stab->temp) if (stab->temp)
continue; continue;

View File

@ -261,8 +261,8 @@ my_bool acl_init(bool dont_read_acl_tables)
DBUG_ENTER("acl_init"); DBUG_ENTER("acl_init");
acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0, acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0,
(hash_get_key) acl_entry_get_key, (my_hash_get_key) acl_entry_get_key,
(hash_free_key) free, (my_hash_free_key) free,
lower_case_file_system ? lower_case_file_system ?
system_charset_info : &my_charset_bin); system_charset_info : &my_charset_bin);
if (dont_read_acl_tables) if (dont_read_acl_tables)
@ -638,7 +638,7 @@ void acl_free(bool end)
delete_dynamic(&acl_users); delete_dynamic(&acl_users);
delete_dynamic(&acl_dbs); delete_dynamic(&acl_dbs);
delete_dynamic(&acl_wild_hosts); delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts); my_hash_free(&acl_check_hosts);
if (!end) if (!end)
acl_cache->clear(1); /* purecov: inspected */ acl_cache->clear(1); /* purecov: inspected */
else else
@ -714,7 +714,7 @@ my_bool acl_reload(THD *thd)
old_acl_dbs=acl_dbs; old_acl_dbs=acl_dbs;
old_mem=mem; old_mem=mem;
delete_dynamic(&acl_wild_hosts); delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts); my_hash_free(&acl_check_hosts);
if ((return_val= acl_load(thd, tables))) if ((return_val= acl_load(thd, tables)))
{ // Error. Revert to old list { // Error. Revert to old list
@ -1429,8 +1429,8 @@ static void init_check_host(void)
DBUG_ENTER("init_check_host"); DBUG_ENTER("init_check_host");
VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip), VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
acl_users.elements,1)); acl_users.elements,1));
VOID(hash_init(&acl_check_hosts,system_charset_info,acl_users.elements,0,0, VOID(my_hash_init(&acl_check_hosts,system_charset_info,acl_users.elements,0,0,
(hash_get_key) check_get_key,0,0)); (my_hash_get_key) check_get_key,0,0));
if (!allow_all_hosts) if (!allow_all_hosts)
{ {
for (uint i=0 ; i < acl_users.elements ; i++) for (uint i=0 ; i < acl_users.elements ; i++)
@ -1452,7 +1452,8 @@ static void init_check_host(void)
if (j == acl_wild_hosts.elements) // If new if (j == acl_wild_hosts.elements) // If new
(void) push_dynamic(&acl_wild_hosts,(uchar*) &acl_user->host); (void) push_dynamic(&acl_wild_hosts,(uchar*) &acl_user->host);
} }
else if (!hash_search(&acl_check_hosts,(uchar*) acl_user->host.hostname, else if (!my_hash_search(&acl_check_hosts,(uchar*)
acl_user->host.hostname,
strlen(acl_user->host.hostname))) strlen(acl_user->host.hostname)))
{ {
if (my_hash_insert(&acl_check_hosts,(uchar*) acl_user)) if (my_hash_insert(&acl_check_hosts,(uchar*) acl_user))
@ -1480,7 +1481,7 @@ static void init_check_host(void)
void rebuild_check_host(void) void rebuild_check_host(void)
{ {
delete_dynamic(&acl_wild_hosts); delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts); my_hash_free(&acl_check_hosts);
init_check_host(); init_check_host();
} }
@ -1493,8 +1494,8 @@ bool acl_check_host(const char *host, const char *ip)
return 0; return 0;
VOID(pthread_mutex_lock(&acl_cache->lock)); VOID(pthread_mutex_lock(&acl_cache->lock));
if ((host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) || if ((host && my_hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) ||
(ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip)))) (ip && my_hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))))
{ {
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
return 0; // Found host return 0; // Found host
@ -2298,8 +2299,8 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
const char *t, ulong p, ulong c) const char *t, ulong p, ulong c)
:GRANT_NAME(h,d,u,t,p), cols(c) :GRANT_NAME(h,d,u,t,p), cols(c)
{ {
(void) hash_init2(&hash_columns,4,system_charset_info, (void) my_hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0); 0,0,0, (my_hash_get_key) get_key_column,0,0);
} }
@ -2339,15 +2340,15 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
if (!db || !tname) if (!db || !tname)
{ {
/* Wrong table row; Ignore it */ /* Wrong table row; Ignore it */
hash_clear(&hash_columns); /* allow for destruction */ my_hash_clear(&hash_columns); /* allow for destruction */
cols= 0; cols= 0;
return; return;
} }
cols= (ulong) form->field[7]->val_int(); cols= (ulong) form->field[7]->val_int();
cols = fix_rights_for_column(cols); cols = fix_rights_for_column(cols);
(void) hash_init2(&hash_columns,4,system_charset_info, (void) my_hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0); 0,0,0, (my_hash_get_key) get_key_column,0,0);
if (cols) if (cols)
{ {
uint key_prefix_len; uint key_prefix_len;
@ -2399,7 +2400,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
GRANT_TABLE::~GRANT_TABLE() GRANT_TABLE::~GRANT_TABLE()
{ {
hash_free(&hash_columns); my_hash_free(&hash_columns);
} }
@ -2413,7 +2414,7 @@ static uchar* get_grant_table(GRANT_NAME *buff, size_t *length,
void free_grant_table(GRANT_TABLE *grant_table) void free_grant_table(GRANT_TABLE *grant_table)
{ {
hash_free(&grant_table->hash_columns); my_hash_free(&grant_table->hash_columns);
} }
@ -2431,10 +2432,10 @@ static GRANT_NAME *name_hash_search(HASH *name_hash,
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1; len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1;
for (grant_name= (GRANT_NAME*) hash_first(name_hash, (uchar*) helping, for (grant_name= (GRANT_NAME*) my_hash_first(name_hash, (uchar*) helping,
len, &state); len, &state);
grant_name ; grant_name ;
grant_name= (GRANT_NAME*) hash_next(name_hash,(uchar*) helping, grant_name= (GRANT_NAME*) my_hash_next(name_hash,(uchar*) helping,
len, &state)) len, &state))
{ {
if (exact) if (exact)
@ -2479,7 +2480,8 @@ table_hash_search(const char *host, const char *ip, const char *db,
inline GRANT_COLUMN * inline GRANT_COLUMN *
column_hash_search(GRANT_TABLE *t, const char *cname, uint length) column_hash_search(GRANT_TABLE *t, const char *cname, uint length)
{ {
return (GRANT_COLUMN*) hash_search(&t->hash_columns, (uchar*) cname,length); return (GRANT_COLUMN*) my_hash_search(&t->hash_columns,
(uchar*) cname, length);
} }
@ -2659,7 +2661,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
goto end; /* purecov: deadcode */ goto end; /* purecov: deadcode */
} }
if (grant_column) if (grant_column)
hash_delete(&g_t->hash_columns,(uchar*) grant_column); my_hash_delete(&g_t->hash_columns,(uchar*) grant_column);
} }
} }
} while (!table->file->index_next(table->record[0]) && } while (!table->file->index_next(table->record[0]) &&
@ -2785,7 +2787,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
} }
else else
{ {
hash_delete(&column_priv_hash,(uchar*) grant_table); my_hash_delete(&column_priv_hash,(uchar*) grant_table);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -2906,7 +2908,8 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
} }
else else
{ {
hash_delete(is_proc ? &proc_priv_hash : &func_priv_hash,(uchar*) grant_name); my_hash_delete(is_proc ? &proc_priv_hash : &func_priv_hash,(uchar*)
grant_name);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -3147,8 +3150,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
column_priv= 0; column_priv= 0;
for (uint idx=0 ; idx < grant_table->hash_columns.records ; idx++) for (uint idx=0 ; idx < grant_table->hash_columns.records ; idx++)
{ {
grant_column= (GRANT_COLUMN*) hash_element(&grant_table->hash_columns, grant_column= (GRANT_COLUMN*)
idx); my_hash_element(&grant_table->hash_columns, idx);
grant_column->rights&= ~rights; // Fix other columns grant_column->rights&= ~rights; // Fix other columns
column_priv|= grant_column->rights; column_priv|= grant_column->rights;
} }
@ -3479,9 +3482,9 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
void grant_free(void) void grant_free(void)
{ {
DBUG_ENTER("grant_free"); DBUG_ENTER("grant_free");
hash_free(&column_priv_hash); my_hash_free(&column_priv_hash);
hash_free(&proc_priv_hash); my_hash_free(&proc_priv_hash);
hash_free(&func_priv_hash); my_hash_free(&func_priv_hash);
free_root(&memex,MYF(0)); free_root(&memex,MYF(0));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -3538,11 +3541,11 @@ static my_bool grant_load_procs_priv(TABLE *p_table)
MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
THR_MALLOC); THR_MALLOC);
DBUG_ENTER("grant_load_procs_priv"); DBUG_ENTER("grant_load_procs_priv");
(void) hash_init(&proc_priv_hash,system_charset_info, (void) my_hash_init(&proc_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (my_hash_get_key) get_grant_table,
0,0); 0,0);
(void) hash_init(&func_priv_hash,system_charset_info, (void) my_hash_init(&func_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (my_hash_get_key) get_grant_table,
0,0); 0,0);
p_table->file->ha_index_init(0, 1); p_table->file->ha_index_init(0, 1);
p_table->use_all_columns(); p_table->use_all_columns();
@ -3639,9 +3642,9 @@ static my_bool grant_load(THD *thd, TABLE_LIST *tables)
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
(void) hash_init(&column_priv_hash,system_charset_info, (void) my_hash_init(&column_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (my_hash_get_key) get_grant_table,
(hash_free_key) free_grant_table,0); (my_hash_free_key) free_grant_table,0);
t_table = tables[0].table; t_table = tables[0].table;
c_table = tables[1].table; c_table = tables[1].table;
@ -3744,8 +3747,8 @@ static my_bool grant_reload_procs_priv(THD *thd)
} }
else else
{ {
hash_free(&old_proc_priv_hash); my_hash_free(&old_proc_priv_hash);
hash_free(&old_func_priv_hash); my_hash_free(&old_func_priv_hash);
} }
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
@ -3814,7 +3817,7 @@ my_bool grant_reload(THD *thd)
} }
else else
{ {
hash_free(&old_column_priv_hash); my_hash_free(&old_column_priv_hash);
free_root(&old_mem,MYF(0)); free_root(&old_mem,MYF(0));
} }
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
@ -4210,7 +4213,7 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
for (uint idx= 0; idx < hash->records; ++idx) for (uint idx= 0; idx < hash->records; ++idx)
{ {
GRANT_NAME *item= (GRANT_NAME*) hash_element(hash, idx); GRANT_NAME *item= (GRANT_NAME*) my_hash_element(hash, idx);
if (strcmp(item->user, sctx->priv_user) == 0 && if (strcmp(item->user, sctx->priv_user) == 0 &&
strcmp(item->db, db) == 0 && strcmp(item->db, db) == 0 &&
@ -4243,7 +4246,8 @@ bool check_grant_db(THD *thd,const char *db)
for (uint idx=0 ; idx < column_priv_hash.records ; idx++) for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
{ {
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, GRANT_TABLE *grant_table= (GRANT_TABLE*)
my_hash_element(&column_priv_hash,
idx); idx);
if (len < grant_table->key_length && if (len < grant_table->key_length &&
!memcmp(grant_table->hash_key,helping,len) && !memcmp(grant_table->hash_key,helping,len) &&
@ -4716,8 +4720,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
for (index=0 ; index < column_priv_hash.records ; index++) for (index=0 ; index < column_priv_hash.records ; index++)
{ {
const char *user, *host; const char *user, *host;
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, GRANT_TABLE *grant_table= (GRANT_TABLE*)
index); my_hash_element(&column_priv_hash, index);
if (!(user=grant_table->user)) if (!(user=grant_table->user))
user= ""; user= "";
@ -4770,7 +4774,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
col_index++) col_index++)
{ {
GRANT_COLUMN *grant_column = (GRANT_COLUMN*) GRANT_COLUMN *grant_column = (GRANT_COLUMN*)
hash_element(&grant_table->hash_columns,col_index); my_hash_element(&grant_table->hash_columns,col_index);
if (grant_column->rights & j) if (grant_column->rights & j)
{ {
if (!found_col) if (!found_col)
@ -4860,7 +4864,7 @@ static int show_routine_grants(THD* thd, LEX_USER *lex_user, HASH *hash,
for (index=0 ; index < hash->records ; index++) for (index=0 ; index < hash->records ; index++)
{ {
const char *user, *host; const char *user, *host;
GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(hash, index); GRANT_NAME *grant_proc= (GRANT_NAME*) my_hash_element(hash, index);
if (!(user=grant_proc->user)) if (!(user=grant_proc->user))
user= ""; user= "";
@ -5373,13 +5377,13 @@ static int handle_grant_struct(uint struct_no, bool drop,
break; break;
case 2: case 2:
grant_name= (GRANT_NAME*) hash_element(&column_priv_hash, idx); grant_name= (GRANT_NAME*) my_hash_element(&column_priv_hash, idx);
user= grant_name->user; user= grant_name->user;
host= grant_name->host.hostname; host= grant_name->host.hostname;
break; break;
case 3: case 3:
grant_name= (GRANT_NAME*) hash_element(&proc_priv_hash, idx); grant_name= (GRANT_NAME*) my_hash_element(&proc_priv_hash, idx);
user= grant_name->user; user= grant_name->user;
host= grant_name->host.hostname; host= grant_name->host.hostname;
break; break;
@ -5412,11 +5416,11 @@ static int handle_grant_struct(uint struct_no, bool drop,
break; break;
case 2: case 2:
hash_delete(&column_priv_hash, (uchar*) grant_name); my_hash_delete(&column_priv_hash, (uchar*) grant_name);
break; break;
case 3: case 3:
hash_delete(&proc_priv_hash, (uchar*) grant_name); my_hash_delete(&proc_priv_hash, (uchar*) grant_name);
break; break;
} }
elements--; elements--;
@ -5930,8 +5934,8 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
for (counter= 0, revoked= 0 ; counter < column_priv_hash.records ; ) for (counter= 0, revoked= 0 ; counter < column_priv_hash.records ; )
{ {
const char *user,*host; const char *user,*host;
GRANT_TABLE *grant_table= (GRANT_TABLE*)hash_element(&column_priv_hash, GRANT_TABLE *grant_table=
counter); (GRANT_TABLE*) my_hash_element(&column_priv_hash, counter);
if (!(user=grant_table->user)) if (!(user=grant_table->user))
user= ""; user= "";
if (!(host=grant_table->host.hostname)) if (!(host=grant_table->host.hostname))
@ -5977,7 +5981,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
for (counter= 0, revoked= 0 ; counter < hash->records ; ) for (counter= 0, revoked= 0 ; counter < hash->records ; )
{ {
const char *user,*host; const char *user,*host;
GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(hash, counter); GRANT_NAME *grant_proc= (GRANT_NAME*) my_hash_element(hash, counter);
if (!(user=grant_proc->user)) if (!(user=grant_proc->user))
user= ""; user= "";
if (!(host=grant_proc->host.hostname)) if (!(host=grant_proc->host.hostname))
@ -6125,7 +6129,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
{ {
for (counter= 0, revoked= 0 ; counter < hash->records ; ) for (counter= 0, revoked= 0 ; counter < hash->records ; )
{ {
GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(hash, counter); GRANT_NAME *grant_proc= (GRANT_NAME*) my_hash_element(hash, counter);
if (!my_strcasecmp(system_charset_info, grant_proc->db, sp_db) && if (!my_strcasecmp(system_charset_info, grant_proc->db, sp_db) &&
!my_strcasecmp(system_charset_info, grant_proc->tname, sp_name)) !my_strcasecmp(system_charset_info, grant_proc->tname, sp_name))
{ {
@ -6515,7 +6519,7 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
for (index=0 ; index < column_priv_hash.records ; index++) for (index=0 ; index < column_priv_hash.records ; index++)
{ {
const char *user, *host, *is_grantable= "YES"; const char *user, *host, *is_grantable= "YES";
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash,
index); index);
if (!(user=grant_table->user)) if (!(user=grant_table->user))
user= ""; user= "";
@ -6598,7 +6602,7 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
for (index=0 ; index < column_priv_hash.records ; index++) for (index=0 ; index < column_priv_hash.records ; index++)
{ {
const char *user, *host, *is_grantable= "YES"; const char *user, *host, *is_grantable= "YES";
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash,
index); index);
if (!(user=grant_table->user)) if (!(user=grant_table->user))
user= ""; user= "";
@ -6633,7 +6637,7 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
col_index++) col_index++)
{ {
GRANT_COLUMN *grant_column = (GRANT_COLUMN*) GRANT_COLUMN *grant_column = (GRANT_COLUMN*)
hash_element(&grant_table->hash_columns,col_index); my_hash_element(&grant_table->hash_columns,col_index);
if ((grant_column->rights & j) && (table_access & j)) if ((grant_column->rights & j) && (table_access & j))
{ {
if (update_schema_privilege(thd, table, buff, grant_table->db, if (update_schema_privilege(thd, table, buff, grant_table->db,

View File

@ -126,9 +126,9 @@ extern "C" uchar *table_cache_key(const uchar *record, size_t *length,
bool table_cache_init(void) bool table_cache_init(void)
{ {
return hash_init(&open_cache, &my_charset_bin, table_cache_size+16, return my_hash_init(&open_cache, &my_charset_bin, table_cache_size+16,
0, 0, table_cache_key, 0, 0, table_cache_key,
(hash_free_key) free_cache_entry, 0) != 0; (my_hash_free_key) free_cache_entry, 0) != 0;
} }
void table_cache_free(void) void table_cache_free(void)
@ -138,7 +138,7 @@ void table_cache_free(void)
{ {
close_cached_tables(NULL, NULL, FALSE, FALSE, FALSE); close_cached_tables(NULL, NULL, FALSE, FALSE, FALSE);
if (!open_cache.records) // Safety first if (!open_cache.records) // Safety first
hash_free(&open_cache); my_hash_free(&open_cache);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -173,7 +173,7 @@ static void check_unused(void)
} }
for (idx=0 ; idx < open_cache.records ; idx++) for (idx=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *entry=(TABLE*) hash_element(&open_cache,idx); TABLE *entry=(TABLE*) my_hash_element(&open_cache,idx);
if (!entry->in_use) if (!entry->in_use)
count--; count--;
if (entry->file) if (entry->file)
@ -286,9 +286,9 @@ bool table_def_init(void)
oldest_unused_share= &end_of_unused_share; oldest_unused_share= &end_of_unused_share;
end_of_unused_share.prev= &oldest_unused_share; end_of_unused_share.prev= &oldest_unused_share;
return hash_init(&table_def_cache, &my_charset_bin, table_def_size, return my_hash_init(&table_def_cache, &my_charset_bin, table_def_size,
0, 0, table_def_key, 0, 0, table_def_key,
(hash_free_key) table_def_free_entry, 0) != 0; (my_hash_free_key) table_def_free_entry, 0) != 0;
} }
@ -299,7 +299,7 @@ void table_def_free(void)
{ {
table_def_inited= 0; table_def_inited= 0;
pthread_mutex_destroy(&LOCK_table_share); pthread_mutex_destroy(&LOCK_table_share);
hash_free(&table_def_cache); my_hash_free(&table_def_cache);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -345,7 +345,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
*error= 0; *error= 0;
/* Read table definition from cache */ /* Read table definition from cache */
if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache,(uchar*) key,
key_length))) key_length)))
goto found; goto found;
@ -383,7 +383,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
if (open_table_def(thd, share, db_flags)) if (open_table_def(thd, share, db_flags))
{ {
*error= share->error; *error= share->error;
(void) hash_delete(&table_def_cache, (uchar*) share); (void) my_hash_delete(&table_def_cache, (uchar*) share);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
share->ref_count++; // Mark in use share->ref_count++; // Mark in use
@ -435,7 +435,7 @@ found:
oldest_unused_share->next) oldest_unused_share->next)
{ {
pthread_mutex_lock(&oldest_unused_share->mutex); pthread_mutex_lock(&oldest_unused_share->mutex);
VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
} }
DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u", DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
@ -590,7 +590,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type)
if (to_be_deleted) if (to_be_deleted)
{ {
DBUG_PRINT("info", ("Deleting share")); DBUG_PRINT("info", ("Deleting share"));
hash_delete(&table_def_cache, (uchar*) share); my_hash_delete(&table_def_cache, (uchar*) share);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
@ -621,7 +621,8 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name)
table_list.db= (char*) db; table_list.db= (char*) db;
table_list.table_name= (char*) table_name; table_list.table_name= (char*) table_name;
key_length= create_table_def_key((THD*) 0, key, &table_list, 0); key_length= create_table_def_key((THD*) 0, key, &table_list, 0);
return (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length); return (TABLE_SHARE*) my_hash_search(&table_def_cache,
(uchar*) key, key_length);
} }
@ -718,7 +719,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++) for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++)
{ {
OPEN_TABLE_LIST *table; OPEN_TABLE_LIST *table;
TABLE *entry=(TABLE*) hash_element(&open_cache,idx); TABLE *entry=(TABLE*) my_hash_element(&open_cache,idx);
TABLE_SHARE *share= entry->s; TABLE_SHARE *share= entry->s;
if (db && my_strcasecmp(system_charset_info, db, share->db.str)) if (db && my_strcasecmp(system_charset_info, db, share->db.str))
@ -867,17 +868,17 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
while (unused_tables) while (unused_tables)
{ {
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
if (hash_delete(&open_cache,(uchar*) unused_tables)) if (my_hash_delete(&open_cache,(uchar*) unused_tables))
printf("Warning: Couldn't delete open table from hash\n"); printf("Warning: Couldn't delete open table from hash\n");
#else #else
VOID(hash_delete(&open_cache,(uchar*) unused_tables)); VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
#endif #endif
} }
/* Free table shares */ /* Free table shares */
while (oldest_unused_share->next) while (oldest_unused_share->next)
{ {
pthread_mutex_lock(&oldest_unused_share->mutex); pthread_mutex_lock(&oldest_unused_share->mutex);
VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share));
} }
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu",
refresh_version)); refresh_version));
@ -922,7 +923,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
*/ */
for (uint idx=0 ; idx < open_cache.records ; idx++) for (uint idx=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *table=(TABLE*) hash_element(&open_cache,idx); TABLE *table=(TABLE*) my_hash_element(&open_cache,idx);
if (table->in_use) if (table->in_use)
table->in_use->some_tables_deleted= 1; table->in_use->some_tables_deleted= 1;
} }
@ -966,7 +967,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
found=0; found=0;
for (uint idx=0 ; idx < open_cache.records ; idx++) for (uint idx=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *table=(TABLE*) hash_element(&open_cache,idx); TABLE *table=(TABLE*) my_hash_element(&open_cache,idx);
/* Avoid a self-deadlock. */ /* Avoid a self-deadlock. */
if (table->in_use == thd) if (table->in_use == thd)
continue; continue;
@ -1048,7 +1049,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh,
for (idx= 0; idx < table_def_cache.records; idx++) for (idx= 0; idx < table_def_cache.records; idx++)
{ {
TABLE_SHARE *share= (TABLE_SHARE *) hash_element(&table_def_cache, idx); TABLE_SHARE *share= (TABLE_SHARE *) my_hash_element(&table_def_cache, idx);
/* Ignore if table is not open or does not have a connect_string */ /* Ignore if table is not open or does not have a connect_string */
if (!share->connect_string.length || !share->ref_count) if (!share->connect_string.length || !share->ref_count)
@ -1204,7 +1205,7 @@ static void close_open_tables(THD *thd)
/* Free tables to hold down open files */ /* Free tables to hold down open files */
while (open_cache.records > table_cache_size && unused_tables) while (open_cache.records > table_cache_size && unused_tables)
VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
check_unused(); check_unused();
if (found_old_table) if (found_old_table)
{ {
@ -1390,7 +1391,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr)
if (table->needs_reopen_or_name_lock() || if (table->needs_reopen_or_name_lock() ||
thd->version != refresh_version || !table->db_stat) thd->version != refresh_version || !table->db_stat)
{ {
VOID(hash_delete(&open_cache,(uchar*) table)); VOID(my_hash_delete(&open_cache,(uchar*) table));
found_old_table=1; found_old_table=1;
} }
else else
@ -2093,7 +2094,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock)
/* Remove table from open_tables list. */ /* Remove table from open_tables list. */
*prev= list->next; *prev= list->next;
/* Close table. */ /* Close table. */
VOID(hash_delete(&open_cache,(uchar*) list)); // Close table VOID(my_hash_delete(&open_cache,(uchar*) list)); // Close table
} }
else else
{ {
@ -2398,7 +2399,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db,
key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1; key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1;
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
if (hash_search(&open_cache, (uchar *)key, key_length)) if (my_hash_search(&open_cache, (uchar *)key, key_length))
{ {
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_PRINT("info", ("Table is cached, name-lock is not obtained")); DBUG_PRINT("info", ("Table is cached, name-lock is not obtained"));
@ -2753,10 +2754,10 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
an implicit "pending locks queue" - see an implicit "pending locks queue" - see
wait_for_locked_table_names for details. wait_for_locked_table_names for details.
*/ */
for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, for (table= (TABLE*) my_hash_first(&open_cache, (uchar*) key, key_length,
&state); &state);
table && table->in_use ; table && table->in_use ;
table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, table= (TABLE*) my_hash_next(&open_cache, (uchar*) key, key_length,
&state)) &state))
{ {
DBUG_PRINT("tcache", ("in_use table: '%s'.'%s' 0x%lx", table->s->db.str, DBUG_PRINT("tcache", ("in_use table: '%s'.'%s' 0x%lx", table->s->db.str,
@ -2869,7 +2870,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
DBUG_PRINT("tcache", ("opening new table")); DBUG_PRINT("tcache", ("opening new table"));
/* Free cache if too big */ /* Free cache if too big */
while (open_cache.records > table_cache_size && unused_tables) while (open_cache.records > table_cache_size && unused_tables)
VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */
if (table_list->create) if (table_list->create)
{ {
@ -3326,7 +3327,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
*/ */
if (table->child_l || table->parent) if (table->child_l || table->parent)
detach_merge_children(table, TRUE); detach_merge_children(table, TRUE);
VOID(hash_delete(&open_cache,(uchar*) table)); VOID(my_hash_delete(&open_cache,(uchar*) table));
error=1; error=1;
} }
else else
@ -3355,7 +3356,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
{ {
while (err_tables) while (err_tables)
{ {
VOID(hash_delete(&open_cache, (uchar*) err_tables)); VOID(my_hash_delete(&open_cache, (uchar*) err_tables));
err_tables= err_tables->next; err_tables= err_tables->next;
} }
} }
@ -3507,10 +3508,10 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock)
DBUG_PRINT("loop", ("table_name: %s", table->alias)); DBUG_PRINT("loop", ("table_name: %s", table->alias));
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
for (TABLE *search= (TABLE*) hash_first(&open_cache, (uchar*) key, for (TABLE *search= (TABLE*) my_hash_first(&open_cache, (uchar*) key,
key_length, &state); key_length, &state);
search ; search ;
search= (TABLE*) hash_next(&open_cache, (uchar*) key, search= (TABLE*) my_hash_next(&open_cache, (uchar*) key,
key_length, &state)) key_length, &state))
{ {
DBUG_PRINT("info", ("share: 0x%lx " DBUG_PRINT("info", ("share: 0x%lx "
@ -3637,7 +3638,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name)
else else
{ {
/* We already have a name lock, remove copy */ /* We already have a name lock, remove copy */
VOID(hash_delete(&open_cache,(uchar*) table)); VOID(my_hash_delete(&open_cache,(uchar*) table));
} }
} }
else else
@ -4611,7 +4612,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
Let us free memory used by 'sroutines' hash here since we never Let us free memory used by 'sroutines' hash here since we never
call destructor for this LEX. call destructor for this LEX.
*/ */
hash_free(&tables->view->sroutines); my_hash_free(&tables->view->sroutines);
goto process_view_routines; goto process_view_routines;
} }
@ -5875,7 +5876,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
field_ptr= table->field + cached_field_index; field_ptr= table->field + cached_field_index;
else if (table->s->name_hash.records) else if (table->s->name_hash.records)
{ {
field_ptr= (Field**) hash_search(&table->s->name_hash, (uchar*) name, field_ptr= (Field**) my_hash_search(&table->s->name_hash, (uchar*) name,
length); length);
if (field_ptr) if (field_ptr)
{ {
@ -6122,7 +6123,7 @@ Field *find_field_in_table_sef(TABLE *table, const char *name)
Field **field_ptr; Field **field_ptr;
if (table->s->name_hash.records) if (table->s->name_hash.records)
{ {
field_ptr= (Field**)hash_search(&table->s->name_hash,(uchar*) name, field_ptr= (Field**)my_hash_search(&table->s->name_hash,(uchar*) name,
strlen(name)); strlen(name));
if (field_ptr) if (field_ptr)
{ {
@ -8365,7 +8366,7 @@ void remove_db_from_cache(const char *db)
{ {
for (uint idx=0 ; idx < open_cache.records ; idx++) for (uint idx=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *table=(TABLE*) hash_element(&open_cache,idx); TABLE *table=(TABLE*) my_hash_element(&open_cache,idx);
if (!strcmp(table->s->db.str, db)) if (!strcmp(table->s->db.str, db))
{ {
table->s->version= 0L; /* Free when thread is ready */ table->s->version= 0L; /* Free when thread is ready */
@ -8374,7 +8375,7 @@ void remove_db_from_cache(const char *db)
} }
} }
while (unused_tables && !unused_tables->s->version) while (unused_tables && !unused_tables->s->version)
VOID(hash_delete(&open_cache,(uchar*) unused_tables)); VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
} }
@ -8390,7 +8391,7 @@ void flush_tables()
{ {
(void) pthread_mutex_lock(&LOCK_open); (void) pthread_mutex_lock(&LOCK_open);
while (unused_tables) while (unused_tables)
hash_delete(&open_cache,(uchar*) unused_tables); my_hash_delete(&open_cache,(uchar*) unused_tables);
(void) pthread_mutex_unlock(&LOCK_open); (void) pthread_mutex_unlock(&LOCK_open);
} }
@ -8427,10 +8428,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
result= signalled= 0; result= signalled= 0;
for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, for (table= (TABLE*) my_hash_first(&open_cache, (uchar*) key, key_length,
&state); &state);
table; table;
table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, table= (TABLE*) my_hash_next(&open_cache, (uchar*) key, key_length,
&state)) &state))
{ {
THD *in_use; THD *in_use;
@ -8498,11 +8499,11 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
} }
} }
while (unused_tables && !unused_tables->s->version) while (unused_tables && !unused_tables->s->version)
VOID(hash_delete(&open_cache,(uchar*) unused_tables)); VOID(my_hash_delete(&open_cache,(uchar*) unused_tables));
DBUG_PRINT("info", ("Removing table from table_def_cache")); DBUG_PRINT("info", ("Removing table from table_def_cache"));
/* Remove table from table definition cache if it's not in use */ /* Remove table from table definition cache if it's not in use */
if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache,(uchar*) key,
key_length))) key_length)))
{ {
DBUG_PRINT("info", ("share version: %lu ref_count: %u", DBUG_PRINT("info", ("share version: %lu ref_count: %u",
@ -8511,7 +8512,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
if (share->ref_count == 0) if (share->ref_count == 0)
{ {
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
VOID(hash_delete(&table_def_cache, (uchar*) share)); VOID(my_hash_delete(&table_def_cache, (uchar*) share));
} }
} }
@ -8759,10 +8760,10 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1; key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1;
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
for (table= (TABLE*) hash_first(&open_cache,(uchar*) key,key_length, for (table= (TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length,
&state) ; &state) ;
table; table;
table= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, table= (TABLE*) my_hash_next(&open_cache,(uchar*) key,key_length,
&state)) &state))
{ {
THD *in_use= table->in_use; THD *in_use= table->in_use;

View File

@ -1249,7 +1249,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
/* Check if another thread is processing the same query? */ /* Check if another thread is processing the same query? */
Query_cache_block *competitor = (Query_cache_block *) Query_cache_block *competitor = (Query_cache_block *)
hash_search(&queries, (uchar*) thd->query, tot_length); my_hash_search(&queries, (uchar*) thd->query, tot_length);
DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor)); DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor));
if (competitor == 0) if (competitor == 0)
{ {
@ -1278,7 +1278,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
{ {
refused++; refused++;
DBUG_PRINT("warning", ("tables list including failed")); DBUG_PRINT("warning", ("tables list including failed"));
hash_delete(&queries, (uchar *) query_block); my_hash_delete(&queries, (uchar *) query_block);
header->unlock_n_destroy(); header->unlock_n_destroy();
free_memory_block(query_block); free_memory_block(query_block);
unlock(); unlock();
@ -1483,7 +1483,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
(int)flags.autocommit)); (int)flags.autocommit));
memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
(uchar*) &flags, QUERY_CACHE_FLAGS_SIZE); (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
query_block = (Query_cache_block *) hash_search(&queries, (uchar*) sql, query_block = (Query_cache_block *) my_hash_search(&queries, (uchar*) sql,
tot_length); tot_length);
/* Quick abort on unlocked data */ /* Quick abort on unlocked data */
if (query_block == 0 || if (query_block == 0 ||
@ -2092,7 +2092,7 @@ ulong Query_cache::init_cache()
DUMP(this); DUMP(this);
VOID(hash_init(&queries, &my_charset_bin, def_query_hash_size, 0, 0, VOID(my_hash_init(&queries, &my_charset_bin, def_query_hash_size, 0, 0,
query_cache_query_get_key, 0, 0)); query_cache_query_get_key, 0, 0));
#ifndef FN_NO_CASE_SENCE #ifndef FN_NO_CASE_SENCE
/* /*
@ -2103,7 +2103,7 @@ ulong Query_cache::init_cache()
lower_case_table_names == 0 then we should distinguish my_table lower_case_table_names == 0 then we should distinguish my_table
and MY_TABLE cases and so again can use binary collation. and MY_TABLE cases and so again can use binary collation.
*/ */
VOID(hash_init(&tables, &my_charset_bin, def_table_hash_size, 0, 0, VOID(my_hash_init(&tables, &my_charset_bin, def_table_hash_size, 0, 0,
query_cache_table_get_key, 0, 0)); query_cache_table_get_key, 0, 0));
#else #else
/* /*
@ -2167,8 +2167,8 @@ void Query_cache::free_cache()
my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR)); my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR));
make_disabled(); make_disabled();
hash_free(&queries); my_hash_free(&queries);
hash_free(&tables); my_hash_free(&tables);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -2343,7 +2343,7 @@ void Query_cache::free_query(Query_cache_block *query_block)
(ulong) query_block, (ulong) query_block,
query_block->query()->length() )); query_block->query()->length() ));
hash_delete(&queries,(uchar *) query_block); my_hash_delete(&queries,(uchar *) query_block);
free_query_internal(query_block); free_query_internal(query_block);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -2672,7 +2672,7 @@ void
Query_cache::invalidate_table_internal(THD *thd, uchar *key, uint32 key_length) Query_cache::invalidate_table_internal(THD *thd, uchar *key, uint32 key_length)
{ {
Query_cache_block *table_block= Query_cache_block *table_block=
(Query_cache_block*)hash_search(&tables, key, key_length); (Query_cache_block*)my_hash_search(&tables, key, key_length);
if (table_block) if (table_block)
{ {
Query_cache_block_table *list_root= table_block->table(0); Query_cache_block_table *list_root= table_block->table(0);
@ -2870,7 +2870,7 @@ Query_cache::insert_table(uint key_len, char *key,
THD *thd= current_thd; THD *thd= current_thd;
Query_cache_block *table_block= Query_cache_block *table_block=
(Query_cache_block *)hash_search(&tables, (uchar*) key, key_len); (Query_cache_block *) my_hash_search(&tables, (uchar*) key, key_len);
if (table_block && if (table_block &&
table_block->table()->engine_data() != engine_data) table_block->table()->engine_data() != engine_data)
@ -2986,7 +2986,7 @@ void Query_cache::unlink_table(Query_cache_block_table *node)
Query_cache_block *table_block= neighbour->block(); Query_cache_block *table_block= neighbour->block();
double_linked_list_exclude(table_block, double_linked_list_exclude(table_block,
&tables_blocks); &tables_blocks);
hash_delete(&tables,(uchar *) table_block); my_hash_delete(&tables,(uchar *) table_block);
free_memory_block(table_block); free_memory_block(table_block);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -3671,7 +3671,7 @@ my_bool Query_cache::move_by_type(uchar **border,
uchar *key; uchar *key;
size_t key_length; size_t key_length;
key=query_cache_table_get_key((uchar*) block, &key_length, 0); key=query_cache_table_get_key((uchar*) block, &key_length, 0);
hash_first(&tables, (uchar*) key, key_length, &record_idx); my_hash_first(&tables, (uchar*) key, key_length, &record_idx);
block->destroy(); block->destroy();
new_block->init(len); new_block->init(len);
@ -3705,7 +3705,7 @@ my_bool Query_cache::move_by_type(uchar **border,
/* Fix pointer to table name */ /* Fix pointer to table name */
new_block->table()->table(new_block->table()->db() + tablename_offset); new_block->table()->table(new_block->table()->db() + tablename_offset);
/* Fix hash to point at moved block */ /* Fix hash to point at moved block */
hash_replace(&tables, &record_idx, (uchar*) new_block); my_hash_replace(&tables, &record_idx, (uchar*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border)); len, (ulong) new_block, (ulong) *border));
@ -3731,7 +3731,7 @@ my_bool Query_cache::move_by_type(uchar **border,
uchar *key; uchar *key;
size_t key_length; size_t key_length;
key=query_cache_query_get_key((uchar*) block, &key_length, 0); key=query_cache_query_get_key((uchar*) block, &key_length, 0);
hash_first(&queries, (uchar*) key, key_length, &record_idx); my_hash_first(&queries, (uchar*) key, key_length, &record_idx);
// Move table of used tables // Move table of used tables
memmove((char*) new_block->table(0), (char*) block->table(0), memmove((char*) new_block->table(0), (char*) block->table(0),
ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
@ -3799,7 +3799,7 @@ my_bool Query_cache::move_by_type(uchar **border,
query_cache_tls->first_query_block= new_block; query_cache_tls->first_query_block= new_block;
} }
/* Fix hash to point at moved block */ /* Fix hash to point at moved block */
hash_replace(&queries, &record_idx, (uchar*) new_block); my_hash_replace(&queries, &record_idx, (uchar*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border)); len, (ulong) new_block, (ulong) *border));
break; break;
@ -4210,13 +4210,13 @@ my_bool Query_cache::check_integrity(bool locked)
if (!locked) if (!locked)
lock_and_suspend(); lock_and_suspend();
if (hash_check(&queries)) if (my_hash_check(&queries))
{ {
DBUG_PRINT("error", ("queries hash is damaged")); DBUG_PRINT("error", ("queries hash is damaged"));
result = 1; result = 1;
} }
if (hash_check(&tables)) if (my_hash_check(&tables))
{ {
DBUG_PRINT("error", ("tables hash is damaged")); DBUG_PRINT("error", ("tables hash is damaged"));
result = 1; result = 1;
@ -4383,7 +4383,7 @@ my_bool Query_cache::check_integrity(bool locked)
(ulong) block, (uint) block->type)); (ulong) block, (uint) block->type));
size_t length; size_t length;
uchar *key = query_cache_query_get_key((uchar*) block, &length, 0); uchar *key = query_cache_query_get_key((uchar*) block, &length, 0);
uchar* val = hash_search(&queries, key, length); uchar* val = my_hash_search(&queries, key, length);
if (((uchar*)block) != val) if (((uchar*)block) != val)
{ {
DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx", DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx",
@ -4418,7 +4418,7 @@ my_bool Query_cache::check_integrity(bool locked)
(ulong) block, (uint) block->type)); (ulong) block, (uint) block->type));
size_t length; size_t length;
uchar *key = query_cache_table_get_key((uchar*) block, &length, 0); uchar *key = query_cache_table_get_key((uchar*) block, &length, 0);
uchar* val = hash_search(&tables, key, length); uchar* val = my_hash_search(&tables, key, length);
if (((uchar*)block) != val) if (((uchar*)block) != val)
{ {
DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx", DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx",

View File

@ -465,7 +465,7 @@ THD::THD()
killed= NOT_KILLED; killed= NOT_KILLED;
col_access=0; col_access=0;
is_slave_error= thread_specific_used= FALSE; is_slave_error= thread_specific_used= FALSE;
hash_clear(&handler_tables_hash); my_hash_clear(&handler_tables_hash);
tmp_table=0; tmp_table=0;
used_tables=0; used_tables=0;
cuted_fields= 0L; cuted_fields= 0L;
@ -525,9 +525,9 @@ THD::THD()
profiling.set_thd(this); profiling.set_thd(this);
#endif #endif
user_connect=(USER_CONN *)0; user_connect=(USER_CONN *)0;
hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key, (my_hash_get_key) get_var_key,
(hash_free_key) free_user_var, 0); (my_hash_free_key) free_user_var, 0);
sp_proc_cache= NULL; sp_proc_cache= NULL;
sp_func_cache= NULL; sp_func_cache= NULL;
@ -942,9 +942,9 @@ void THD::change_user(void)
cleanup_done= 0; cleanup_done= 0;
init(); init();
stmt_map.reset(); stmt_map.reset();
hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key, (my_hash_get_key) get_var_key,
(hash_free_key) free_user_var, 0); (my_hash_free_key) free_user_var, 0);
sp_cache_clear(&sp_proc_cache); sp_cache_clear(&sp_proc_cache);
sp_cache_clear(&sp_func_cache); sp_cache_clear(&sp_func_cache);
} }
@ -975,7 +975,7 @@ void THD::cleanup(void)
} }
mysql_ha_cleanup(this); mysql_ha_cleanup(this);
delete_dynamic(&user_var_events); delete_dynamic(&user_var_events);
hash_free(&user_vars); my_hash_free(&user_vars);
close_temporary_tables(this); close_temporary_tables(this);
my_free((char*) variables.time_format, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) variables.time_format, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) variables.date_format, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) variables.date_format, MYF(MY_ALLOW_ZERO_PTR));
@ -2602,11 +2602,11 @@ Statement_map::Statement_map() :
START_STMT_HASH_SIZE = 16, START_STMT_HASH_SIZE = 16,
START_NAME_HASH_SIZE = 16 START_NAME_HASH_SIZE = 16
}; };
hash_init(&st_hash, &my_charset_bin, START_STMT_HASH_SIZE, 0, 0, my_hash_init(&st_hash, &my_charset_bin, START_STMT_HASH_SIZE, 0, 0,
get_statement_id_as_hash_key, get_statement_id_as_hash_key,
delete_statement_as_hash_key, MYF(0)); delete_statement_as_hash_key, MYF(0));
hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0, my_hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0,
(hash_get_key) get_stmt_name_hash_key, (my_hash_get_key) get_stmt_name_hash_key,
NULL,MYF(0)); NULL,MYF(0));
} }
@ -2672,9 +2672,9 @@ int Statement_map::insert(THD *thd, Statement *statement)
err_max: err_max:
if (statement->name.str) if (statement->name.str)
hash_delete(&names_hash, (uchar*) statement); my_hash_delete(&names_hash, (uchar*) statement);
err_names_hash: err_names_hash:
hash_delete(&st_hash, (uchar*) statement); my_hash_delete(&st_hash, (uchar*) statement);
err_st_hash: err_st_hash:
return 1; return 1;
} }
@ -2695,9 +2695,9 @@ void Statement_map::erase(Statement *statement)
if (statement == last_found_statement) if (statement == last_found_statement)
last_found_statement= 0; last_found_statement= 0;
if (statement->name.str) if (statement->name.str)
hash_delete(&names_hash, (uchar *) statement); my_hash_delete(&names_hash, (uchar *) statement);
hash_delete(&st_hash, (uchar *) statement); my_hash_delete(&st_hash, (uchar *) statement);
pthread_mutex_lock(&LOCK_prepared_stmt_count); pthread_mutex_lock(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count > 0); DBUG_ASSERT(prepared_stmt_count > 0);
prepared_stmt_count--; prepared_stmt_count--;
@ -2727,8 +2727,8 @@ Statement_map::~Statement_map()
prepared_stmt_count-= st_hash.records; prepared_stmt_count-= st_hash.records;
pthread_mutex_unlock(&LOCK_prepared_stmt_count); pthread_mutex_unlock(&LOCK_prepared_stmt_count);
hash_free(&names_hash); my_hash_free(&names_hash);
hash_free(&st_hash); my_hash_free(&st_hash);
} }
bool select_dumpvar::send_data(List<Item> &items) bool select_dumpvar::send_data(List<Item> &items)
@ -3265,15 +3265,15 @@ void xid_free_hash(void *ptr)
bool xid_cache_init() bool xid_cache_init()
{ {
pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST); pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST);
return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0, return my_hash_init(&xid_cache, &my_charset_bin, 100, 0, 0,
xid_get_hash_key, xid_free_hash, 0) != 0; xid_get_hash_key, xid_free_hash, 0) != 0;
} }
void xid_cache_free() void xid_cache_free()
{ {
if (hash_inited(&xid_cache)) if (my_hash_inited(&xid_cache))
{ {
hash_free(&xid_cache); my_hash_free(&xid_cache);
pthread_mutex_destroy(&LOCK_xid_cache); pthread_mutex_destroy(&LOCK_xid_cache);
} }
} }
@ -3281,7 +3281,8 @@ void xid_cache_free()
XID_STATE *xid_cache_search(XID *xid) XID_STATE *xid_cache_search(XID *xid)
{ {
pthread_mutex_lock(&LOCK_xid_cache); pthread_mutex_lock(&LOCK_xid_cache);
XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(), xid->key_length()); XID_STATE *res=(XID_STATE *)my_hash_search(&xid_cache, xid->key(),
xid->key_length());
pthread_mutex_unlock(&LOCK_xid_cache); pthread_mutex_unlock(&LOCK_xid_cache);
return res; return res;
} }
@ -3292,7 +3293,7 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
XID_STATE *xs; XID_STATE *xs;
my_bool res; my_bool res;
pthread_mutex_lock(&LOCK_xid_cache); pthread_mutex_lock(&LOCK_xid_cache);
if (hash_search(&xid_cache, xid->key(), xid->key_length())) if (my_hash_search(&xid_cache, xid->key(), xid->key_length()))
res=0; res=0;
else if (!(xs=(XID_STATE *)my_malloc(sizeof(*xs), MYF(MY_WME)))) else if (!(xs=(XID_STATE *)my_malloc(sizeof(*xs), MYF(MY_WME))))
res=1; res=1;
@ -3311,7 +3312,7 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
bool xid_cache_insert(XID_STATE *xid_state) bool xid_cache_insert(XID_STATE *xid_state)
{ {
pthread_mutex_lock(&LOCK_xid_cache); pthread_mutex_lock(&LOCK_xid_cache);
DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(), DBUG_ASSERT(my_hash_search(&xid_cache, xid_state->xid.key(),
xid_state->xid.key_length())==0); xid_state->xid.key_length())==0);
my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state); my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
pthread_mutex_unlock(&LOCK_xid_cache); pthread_mutex_unlock(&LOCK_xid_cache);
@ -3322,7 +3323,7 @@ bool xid_cache_insert(XID_STATE *xid_state)
void xid_cache_delete(XID_STATE *xid_state) void xid_cache_delete(XID_STATE *xid_state)
{ {
pthread_mutex_lock(&LOCK_xid_cache); pthread_mutex_lock(&LOCK_xid_cache);
hash_delete(&xid_cache, (uchar *)xid_state); my_hash_delete(&xid_cache, (uchar *)xid_state);
pthread_mutex_unlock(&LOCK_xid_cache); pthread_mutex_unlock(&LOCK_xid_cache);
} }

View File

@ -772,7 +772,7 @@ public:
Statement *find_by_name(LEX_STRING *name) Statement *find_by_name(LEX_STRING *name)
{ {
Statement *stmt; Statement *stmt;
stmt= (Statement*)hash_search(&names_hash, (uchar*)name->str, stmt= (Statement*)my_hash_search(&names_hash, (uchar*)name->str,
name->length); name->length);
return stmt; return stmt;
} }
@ -782,7 +782,7 @@ public:
if (last_found_statement == 0 || id != last_found_statement->id) if (last_found_statement == 0 || id != last_found_statement->id)
{ {
Statement *stmt; Statement *stmt;
stmt= (Statement *) hash_search(&st_hash, (uchar *) &id, sizeof(id)); stmt= (Statement *) my_hash_search(&st_hash, (uchar *) &id, sizeof(id));
if (stmt && stmt->name.str) if (stmt && stmt->name.str)
return NULL; return NULL;
last_found_statement= stmt; last_found_statement= stmt;

View File

@ -61,7 +61,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
user_len= strlen(user); user_len= strlen(user);
temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
(void) pthread_mutex_lock(&LOCK_user_conn); (void) pthread_mutex_lock(&LOCK_user_conn);
if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, if (!(uc = (struct user_conn *) my_hash_search(&hash_user_connections,
(uchar*) temp_user, temp_len))) (uchar*) temp_user, temp_len)))
{ {
/* First connection for user; Create a user connection object */ /* First connection for user; Create a user connection object */
@ -191,7 +191,7 @@ void decrease_user_connections(USER_CONN *uc)
if (!--uc->connections && !mqh_used) if (!--uc->connections && !mqh_used)
{ {
/* Last connection for user; Delete it */ /* Last connection for user; Delete it */
(void) hash_delete(&hash_user_connections,(uchar*) uc); (void) my_hash_delete(&hash_user_connections,(uchar*) uc);
} }
(void) pthread_mutex_unlock(&LOCK_user_conn); (void) pthread_mutex_unlock(&LOCK_user_conn);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -524,10 +524,10 @@ extern "C" void free_user(struct user_conn *uc)
void init_max_user_conn(void) void init_max_user_conn(void)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
(void) hash_init(&hash_user_connections,system_charset_info,max_connections, (void)
0,0, my_hash_init(&hash_user_connections,system_charset_info,max_connections,
(hash_get_key) get_key_conn, (hash_free_key) free_user, 0,0, (my_hash_get_key) get_key_conn,
0); (my_hash_free_key) free_user, 0);
#endif #endif
} }
@ -535,7 +535,7 @@ void init_max_user_conn(void)
void free_max_user_conn(void) void free_max_user_conn(void)
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
hash_free(&hash_user_connections); my_hash_free(&hash_user_connections);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */ #endif /* NO_EMBEDDED_ACCESS_CHECKS */
} }
@ -553,8 +553,9 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0)
memcpy(temp_user,lu->user.str,lu->user.length); memcpy(temp_user,lu->user.str,lu->user.length);
memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length); memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length);
temp_user[lu->user.length]='\0'; temp_user[temp_len-1]=0; temp_user[lu->user.length]='\0'; temp_user[temp_len-1]=0;
if ((uc = (struct user_conn *) hash_search(&hash_user_connections, if ((uc = (struct user_conn *) my_hash_search(&hash_user_connections,
(uchar*) temp_user, temp_len))) (uchar*) temp_user,
temp_len)))
{ {
uc->questions=0; uc->questions=0;
get_mqh(temp_user,&temp_user[lu->user.length+1],uc); get_mqh(temp_user,&temp_user[lu->user.length+1],uc);
@ -567,8 +568,8 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0)
/* for FLUSH PRIVILEGES and FLUSH USER_RESOURCES */ /* for FLUSH PRIVILEGES and FLUSH USER_RESOURCES */
for (uint idx=0;idx < hash_user_connections.records; idx++) for (uint idx=0;idx < hash_user_connections.records; idx++)
{ {
USER_CONN *uc=(struct user_conn *) hash_element(&hash_user_connections, USER_CONN *uc=(struct user_conn *)
idx); my_hash_element(&hash_user_connections, idx);
if (get_them) if (get_them)
get_mqh(uc->user,uc->host,uc); get_mqh(uc->user,uc->host,uc);
uc->questions=0; uc->questions=0;

View File

@ -105,7 +105,7 @@ static my_bool lock_db_insert(const char *dbname, uint length)
safe_mutex_assert_owner(&LOCK_lock_db); safe_mutex_assert_owner(&LOCK_lock_db);
if (!(opt= (my_dblock_t*) hash_search(&lock_db_cache, if (!(opt= (my_dblock_t*) my_hash_search(&lock_db_cache,
(uchar*) dbname, length))) (uchar*) dbname, length)))
{ {
/* Db is not in the hash, insert it */ /* Db is not in the hash, insert it */
@ -139,9 +139,9 @@ void lock_db_delete(const char *name, uint length)
{ {
my_dblock_t *opt; my_dblock_t *opt;
safe_mutex_assert_owner(&LOCK_lock_db); safe_mutex_assert_owner(&LOCK_lock_db);
if ((opt= (my_dblock_t *)hash_search(&lock_db_cache, if ((opt= (my_dblock_t *)my_hash_search(&lock_db_cache,
(const uchar*) name, length))) (const uchar*) name, length)))
hash_delete(&lock_db_cache, (uchar*) opt); my_hash_delete(&lock_db_cache, (uchar*) opt);
} }
@ -221,13 +221,13 @@ bool my_database_names_init(void)
if (!dboptions_init) if (!dboptions_init)
{ {
dboptions_init= 1; dboptions_init= 1;
error= hash_init(&dboptions, lower_case_table_names ? error= my_hash_init(&dboptions, lower_case_table_names ?
&my_charset_bin : system_charset_info, &my_charset_bin : system_charset_info,
32, 0, 0, (hash_get_key) dboptions_get_key, 32, 0, 0, (my_hash_get_key) dboptions_get_key,
free_dbopt,0) || free_dbopt,0) ||
hash_init(&lock_db_cache, lower_case_table_names ? my_hash_init(&lock_db_cache, lower_case_table_names ?
&my_charset_bin : system_charset_info, &my_charset_bin : system_charset_info,
32, 0, 0, (hash_get_key) lock_db_get_key, 32, 0, 0, (my_hash_get_key) lock_db_get_key,
lock_db_free_element,0); lock_db_free_element,0);
} }
@ -245,9 +245,9 @@ void my_database_names_free(void)
if (dboptions_init) if (dboptions_init)
{ {
dboptions_init= 0; dboptions_init= 0;
hash_free(&dboptions); my_hash_free(&dboptions);
(void) rwlock_destroy(&LOCK_dboptions); (void) rwlock_destroy(&LOCK_dboptions);
hash_free(&lock_db_cache); my_hash_free(&lock_db_cache);
} }
} }
@ -259,10 +259,10 @@ void my_database_names_free(void)
void my_dbopt_cleanup(void) void my_dbopt_cleanup(void)
{ {
rw_wrlock(&LOCK_dboptions); rw_wrlock(&LOCK_dboptions);
hash_free(&dboptions); my_hash_free(&dboptions);
hash_init(&dboptions, lower_case_table_names ? my_hash_init(&dboptions, lower_case_table_names ?
&my_charset_bin : system_charset_info, &my_charset_bin : system_charset_info,
32, 0, 0, (hash_get_key) dboptions_get_key, 32, 0, 0, (my_hash_get_key) dboptions_get_key,
free_dbopt,0); free_dbopt,0);
rw_unlock(&LOCK_dboptions); rw_unlock(&LOCK_dboptions);
} }
@ -289,7 +289,7 @@ static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create)
length= (uint) strlen(dbname); length= (uint) strlen(dbname);
rw_rdlock(&LOCK_dboptions); rw_rdlock(&LOCK_dboptions);
if ((opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length))) if ((opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname, length)))
{ {
create->default_table_charset= opt->charset; create->default_table_charset= opt->charset;
error= 0; error= 0;
@ -321,7 +321,8 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create)
length= (uint) strlen(dbname); length= (uint) strlen(dbname);
rw_wrlock(&LOCK_dboptions); rw_wrlock(&LOCK_dboptions);
if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length))) if (!(opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname,
length)))
{ {
/* Options are not in the hash, insert them */ /* Options are not in the hash, insert them */
char *tmp_name; char *tmp_name;
@ -361,9 +362,9 @@ void del_dbopt(const char *path)
{ {
my_dbopt_t *opt; my_dbopt_t *opt;
rw_wrlock(&LOCK_dboptions); rw_wrlock(&LOCK_dboptions);
if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const uchar*) path, if ((opt= (my_dbopt_t *)my_hash_search(&dboptions, (const uchar*) path,
strlen(path)))) strlen(path))))
hash_delete(&dboptions, (uchar*) opt); my_hash_delete(&dboptions, (uchar*) opt);
rw_unlock(&LOCK_dboptions); rw_unlock(&LOCK_dboptions);
} }
@ -1719,8 +1720,8 @@ lock_databases(THD *thd, const char *db1, uint length1,
{ {
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);
while (!thd->killed && while (!thd->killed &&
(hash_search(&lock_db_cache,(uchar*) db1, length1) || (my_hash_search(&lock_db_cache,(uchar*) db1, length1) ||
hash_search(&lock_db_cache,(uchar*) db2, length2))) my_hash_search(&lock_db_cache,(uchar*) db2, length2)))
{ {
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);

View File

@ -207,20 +207,20 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (! hash_inited(&thd->handler_tables_hash)) if (! my_hash_inited(&thd->handler_tables_hash))
{ {
/* /*
HASH entries are of type TABLE_LIST. HASH entries are of type TABLE_LIST.
*/ */
if (hash_init(&thd->handler_tables_hash, &my_charset_latin1, if (my_hash_init(&thd->handler_tables_hash, &my_charset_latin1,
HANDLER_TABLES_HASH_SIZE, 0, 0, HANDLER_TABLES_HASH_SIZE, 0, 0,
(hash_get_key) mysql_ha_hash_get_key, (my_hash_get_key) mysql_ha_hash_get_key,
(hash_free_key) mysql_ha_hash_free, 0)) (my_hash_free_key) mysql_ha_hash_free, 0))
goto err; goto err;
} }
else if (! reopen) /* Otherwise we have 'tables' already. */ else if (! reopen) /* Otherwise we have 'tables' already. */
{ {
if (hash_search(&thd->handler_tables_hash, (uchar*) tables->alias, if (my_hash_search(&thd->handler_tables_hash, (uchar*) tables->alias,
strlen(tables->alias) + 1)) strlen(tables->alias) + 1))
{ {
DBUG_PRINT("info",("duplicate '%s'", tables->alias)); DBUG_PRINT("info",("duplicate '%s'", tables->alias));
@ -367,12 +367,12 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
DBUG_PRINT("enter",("'%s'.'%s' as '%s'", DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->table_name, tables->alias)); tables->db, tables->table_name, tables->alias));
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash,
(uchar*) tables->alias, (uchar*) tables->alias,
strlen(tables->alias) + 1))) strlen(tables->alias) + 1)))
{ {
mysql_ha_close_table(thd, hash_tables, FALSE); mysql_ha_close_table(thd, hash_tables, FALSE);
hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
} }
else else
{ {
@ -439,7 +439,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
it++; it++;
retry: retry:
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash,
(uchar*) tables->alias, (uchar*) tables->alias,
strlen(tables->alias) + 1))) strlen(tables->alias) + 1)))
{ {
@ -719,7 +719,7 @@ static TABLE_LIST *mysql_ha_find(THD *thd, TABLE_LIST *tables)
/* search for all handlers with matching table names */ /* search for all handlers with matching table names */
for (uint i= 0; i < thd->handler_tables_hash.records; i++) for (uint i= 0; i < thd->handler_tables_hash.records; i++)
{ {
hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
for (tables= first; tables; tables= tables->next_local) for (tables= first; tables; tables= tables->next_local)
{ {
if ((! *tables->db || if ((! *tables->db ||
@ -763,7 +763,7 @@ void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables, bool is_locked)
next= hash_tables->next_local; next= hash_tables->next_local;
if (hash_tables->table) if (hash_tables->table)
mysql_ha_close_table(thd, hash_tables, is_locked); mysql_ha_close_table(thd, hash_tables, is_locked);
hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
hash_tables= next; hash_tables= next;
} }
@ -789,7 +789,7 @@ void mysql_ha_flush(THD *thd)
for (uint i= 0; i < thd->handler_tables_hash.records; i++) for (uint i= 0; i < thd->handler_tables_hash.records; i++)
{ {
hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock()) if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock())
mysql_ha_close_table(thd, hash_tables, TRUE); mysql_ha_close_table(thd, hash_tables, TRUE);
} }
@ -813,12 +813,12 @@ void mysql_ha_cleanup(THD *thd)
for (uint i= 0; i < thd->handler_tables_hash.records; i++) for (uint i= 0; i < thd->handler_tables_hash.records; i++)
{ {
hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
if (hash_tables->table) if (hash_tables->table)
mysql_ha_close_table(thd, hash_tables, FALSE); mysql_ha_close_table(thd, hash_tables, FALSE);
} }
hash_free(&thd->handler_tables_hash); my_hash_free(&thd->handler_tables_hash);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -2156,7 +2156,7 @@ void Query_tables_list::reset_query_tables_list(bool init)
We delay real initialization of hash (and therefore related We delay real initialization of hash (and therefore related
memory allocation) until first insertion into this hash. memory allocation) until first insertion into this hash.
*/ */
hash_clear(&sroutines); my_hash_clear(&sroutines);
} }
else if (sroutines.records) else if (sroutines.records)
{ {
@ -2179,7 +2179,7 @@ void Query_tables_list::reset_query_tables_list(bool init)
void Query_tables_list::destroy_query_tables_list() void Query_tables_list::destroy_query_tables_list()
{ {
hash_free(&sroutines); my_hash_free(&sroutines);
} }

View File

@ -574,14 +574,15 @@ static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int ty
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{ {
struct st_plugin_int *plugin= (st_plugin_int *) struct st_plugin_int *plugin= (st_plugin_int *)
hash_search(&plugin_hash[i], (const uchar *)name->str, name->length); my_hash_search(&plugin_hash[i], (const uchar *)name->str, name->length);
if (plugin) if (plugin)
DBUG_RETURN(plugin); DBUG_RETURN(plugin);
} }
} }
else else
DBUG_RETURN((st_plugin_int *) DBUG_RETURN((st_plugin_int *)
hash_search(&plugin_hash[type], (const uchar *)name->str, name->length)); my_hash_search(&plugin_hash[type], (const uchar *)name->str,
name->length));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -858,7 +859,7 @@ static void plugin_del(struct st_plugin_int *plugin)
safe_mutex_assert_owner(&LOCK_plugin); safe_mutex_assert_owner(&LOCK_plugin);
/* Free allocated strings before deleting the plugin. */ /* Free allocated strings before deleting the plugin. */
plugin_vars_free_values(plugin->system_vars); plugin_vars_free_values(plugin->system_vars);
hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin); my_hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin);
if (plugin->plugin_dl) if (plugin->plugin_dl)
plugin_dl_del(&plugin->plugin_dl->dl); plugin_dl_del(&plugin->plugin_dl->dl);
plugin->state= PLUGIN_IS_FREED; plugin->state= PLUGIN_IS_FREED;
@ -1133,7 +1134,7 @@ int plugin_init(int *argc, char **argv, int flags)
init_alloc_root(&plugin_mem_root, 4096, 4096); init_alloc_root(&plugin_mem_root, 4096, 4096);
init_alloc_root(&tmp_root, 4096, 4096); init_alloc_root(&tmp_root, 4096, 4096);
if (hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0, if (my_hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0,
get_bookmark_hash_key, NULL, HASH_UNIQUE)) get_bookmark_hash_key, NULL, HASH_UNIQUE))
goto err; goto err;
@ -1148,7 +1149,7 @@ int plugin_init(int *argc, char **argv, int flags)
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{ {
if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0, if (my_hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0,
get_plugin_hash_key, NULL, HASH_UNIQUE)) get_plugin_hash_key, NULL, HASH_UNIQUE))
goto err; goto err;
} }
@ -1627,7 +1628,7 @@ void plugin_shutdown(void)
/* Dispose of the memory */ /* Dispose of the memory */
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
hash_free(&plugin_hash[i]); my_hash_free(&plugin_hash[i]);
delete_dynamic(&plugin_array); delete_dynamic(&plugin_array);
count= plugin_dl_array.elements; count= plugin_dl_array.elements;
@ -1639,7 +1640,7 @@ void plugin_shutdown(void)
my_afree(dl); my_afree(dl);
delete_dynamic(&plugin_dl_array); delete_dynamic(&plugin_dl_array);
hash_free(&bookmark_hash); my_hash_free(&bookmark_hash);
free_root(&plugin_mem_root, MYF(0)); free_root(&plugin_mem_root, MYF(0));
global_variables_dynamic_size= 0; global_variables_dynamic_size= 0;
@ -1827,7 +1828,7 @@ bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
HASH *hash= plugin_hash + type; HASH *hash= plugin_hash + type;
for (idx= 0; idx < total; idx++) for (idx= 0; idx < total; idx++)
{ {
plugin= (struct st_plugin_int *) hash_element(hash, idx); plugin= (struct st_plugin_int *) my_hash_element(hash, idx);
plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL; plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
} }
} }
@ -2226,7 +2227,7 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name,
varname[0]= flags & PLUGIN_VAR_TYPEMASK; varname[0]= flags & PLUGIN_VAR_TYPEMASK;
result= (st_bookmark*) hash_search(&bookmark_hash, result= (st_bookmark*) my_hash_search(&bookmark_hash,
(const uchar*) varname, length - 1); (const uchar*) varname, length - 1);
my_afree(varname); my_afree(varname);
@ -2387,7 +2388,7 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
{ {
sys_var_pluginvar *pi; sys_var_pluginvar *pi;
sys_var *var; sys_var *var;
st_bookmark *v= (st_bookmark*) hash_element(&bookmark_hash,idx); st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx);
if (v->version <= thd->variables.dynamic_variables_version || if (v->version <= thd->variables.dynamic_variables_version ||
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || !(var= intern_find_sys_var(v->key + 1, v->name_len, true)) ||
@ -2481,7 +2482,7 @@ static void cleanup_variables(THD *thd, struct system_variables *vars)
rw_rdlock(&LOCK_system_variables_hash); rw_rdlock(&LOCK_system_variables_hash);
for (idx= 0; idx < bookmark_hash.records; idx++) for (idx= 0; idx < bookmark_hash.records; idx++)
{ {
v= (st_bookmark*) hash_element(&bookmark_hash, idx); v= (st_bookmark*) my_hash_element(&bookmark_hash, idx);
if (v->version > vars->dynamic_variables_version || if (v->version > vars->dynamic_variables_version ||
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || !(var= intern_find_sys_var(v->key + 1, v->name_len, true)) ||
!(pivar= var->cast_pluginvar()) || !(pivar= var->cast_pluginvar()) ||

View File

@ -1027,7 +1027,7 @@ static bool insert_params_from_vars(Prepared_statement *stmt,
{ {
Item_param *param= *it; Item_param *param= *it;
varname= var_it++; varname= var_it++;
entry= (user_var_entry*)hash_search(&stmt->thd->user_vars, entry= (user_var_entry*)my_hash_search(&stmt->thd->user_vars,
(uchar*) varname->str, (uchar*) varname->str,
varname->length); varname->length);
if (param->set_from_user_var(stmt->thd, entry) || if (param->set_from_user_var(stmt->thd, entry) ||
@ -1074,8 +1074,8 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
Item_param *param= *it; Item_param *param= *it;
varname= var_it++; varname= var_it++;
entry= (user_var_entry *) hash_search(&thd->user_vars, (uchar*) varname->str, entry= (user_var_entry *) my_hash_search(&thd->user_vars, (uchar*)
varname->length); varname->str, varname->length);
/* /*
We have to call the setup_one_conversion_function() here to set We have to call the setup_one_conversion_function() here to set
the parameter's members that might be needed further the parameter's members that might be needed further
@ -2149,7 +2149,7 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len)
convert it for error messages to be uniform. convert it for error messages to be uniform.
*/ */
if ((entry= if ((entry=
(user_var_entry*)hash_search(&thd->user_vars, (user_var_entry*)my_hash_search(&thd->user_vars,
(uchar*)lex->prepared_stmt_code.str, (uchar*)lex->prepared_stmt_code.str,
lex->prepared_stmt_code.length)) lex->prepared_stmt_code.length))
&& entry->value) && entry->value)

View File

@ -13891,8 +13891,8 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
extra_length= ALIGN_SIZE(key_length)-key_length; extra_length= ALIGN_SIZE(key_length)-key_length;
} }
if (hash_init(&hash, &my_charset_bin, (uint) file->stats.records, 0, if (my_hash_init(&hash, &my_charset_bin, (uint) file->stats.records, 0,
key_length, (hash_get_key) 0, 0, 0)) key_length, (my_hash_get_key) 0, 0, 0))
{ {
my_free((char*) key_buffer,MYF(0)); my_free((char*) key_buffer,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
@ -13933,7 +13933,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
key_pos+= *field_length++; key_pos+= *field_length++;
} }
/* Check if it exists before */ /* Check if it exists before */
if (hash_search(&hash, org_key_pos, key_length)) if (my_hash_search(&hash, org_key_pos, key_length))
{ {
/* Duplicated found ; Remove the row */ /* Duplicated found ; Remove the row */
if ((error=file->ha_delete_row(record))) if ((error=file->ha_delete_row(record)))
@ -13944,14 +13944,14 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
key_pos+=extra_length; key_pos+=extra_length;
} }
my_free((char*) key_buffer,MYF(0)); my_free((char*) key_buffer,MYF(0));
hash_free(&hash); my_hash_free(&hash);
file->extra(HA_EXTRA_NO_CACHE); file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end(); (void) file->ha_rnd_end();
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
my_free((char*) key_buffer,MYF(0)); my_free((char*) key_buffer,MYF(0));
hash_free(&hash); my_hash_free(&hash);
file->extra(HA_EXTRA_NO_CACHE); file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end(); (void) file->ha_rnd_end();
if (error) if (error)

View File

@ -120,8 +120,8 @@ bool servers_init(bool dont_read_servers_table)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* initialise our servers cache */ /* initialise our servers cache */
if (hash_init(&servers_cache, system_charset_info, 32, 0, 0, if (my_hash_init(&servers_cache, system_charset_info, 32, 0, 0,
(hash_get_key) servers_cache_get_key, 0, 0)) (my_hash_get_key) servers_cache_get_key, 0, 0))
{ {
return_val= TRUE; /* we failed, out of memory? */ return_val= TRUE; /* we failed, out of memory? */
goto end; goto end;
@ -646,7 +646,8 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options)
server_options->server_name_length)); server_options->server_name_length));
if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache, if (!(server= (FOREIGN_SERVER *)
my_hash_search(&servers_cache,
(uchar*) server_options->server_name, (uchar*) server_options->server_name,
server_options->server_name_length))) server_options->server_name_length)))
{ {
@ -663,7 +664,7 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options)
server->server_name, server->server_name,
server->server_name_length)); server->server_name_length));
VOID(hash_delete(&servers_cache, (uchar*) server)); VOID(my_hash_delete(&servers_cache, (uchar*) server));
error= 0; error= 0;
@ -770,7 +771,7 @@ int update_server_record_in_cache(FOREIGN_SERVER *existing,
/* /*
delete the existing server struct from the server cache delete the existing server struct from the server cache
*/ */
VOID(hash_delete(&servers_cache, (uchar*)existing)); VOID(my_hash_delete(&servers_cache, (uchar*)existing));
/* /*
Insert the altered server struct into the server cache Insert the altered server struct into the server cache
@ -965,7 +966,7 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
rw_wrlock(&THR_LOCK_servers); rw_wrlock(&THR_LOCK_servers);
/* hit the memory first */ /* hit the memory first */
if (hash_search(&servers_cache, (uchar*) server_options->server_name, if (my_hash_search(&servers_cache, (uchar*) server_options->server_name,
server_options->server_name_length)) server_options->server_name_length))
goto end; goto end;
@ -1014,7 +1015,7 @@ int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
rw_wrlock(&THR_LOCK_servers); rw_wrlock(&THR_LOCK_servers);
if (!(existing= (FOREIGN_SERVER *) hash_search(&servers_cache, if (!(existing= (FOREIGN_SERVER *) my_hash_search(&servers_cache,
(uchar*) name.str, (uchar*) name.str,
name.length))) name.length)))
goto end; goto end;
@ -1195,7 +1196,7 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options,
void servers_free(bool end) void servers_free(bool end)
{ {
DBUG_ENTER("servers_free"); DBUG_ENTER("servers_free");
if (!hash_inited(&servers_cache)) if (!my_hash_inited(&servers_cache))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
if (!end) if (!end)
{ {
@ -1205,7 +1206,7 @@ void servers_free(bool end)
} }
rwlock_destroy(&THR_LOCK_servers); rwlock_destroy(&THR_LOCK_servers);
free_root(&mem,MYF(0)); free_root(&mem,MYF(0));
hash_free(&servers_cache); my_hash_free(&servers_cache);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1286,7 +1287,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
DBUG_PRINT("info", ("locking servers_cache")); DBUG_PRINT("info", ("locking servers_cache"));
rw_rdlock(&THR_LOCK_servers); rw_rdlock(&THR_LOCK_servers);
if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache, if (!(server= (FOREIGN_SERVER *) my_hash_search(&servers_cache,
(uchar*) server_name, (uchar*) server_name,
server_name_length))) server_name_length)))
{ {

View File

@ -3984,7 +3984,7 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
/* Wait for any database locks */ /* Wait for any database locks */
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);
while (!thd->killed && while (!thd->killed &&
hash_search(&lock_db_cache,(uchar*) db, strlen(db))) my_hash_search(&lock_db_cache,(uchar*) db, strlen(db)))
{ {
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);

View File

@ -85,7 +85,7 @@ void print_cached_tables(void)
for (idx=unused=0 ; idx < open_cache.records ; idx++) for (idx=unused=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *entry=(TABLE*) hash_element(&open_cache,idx); TABLE *entry=(TABLE*) my_hash_element(&open_cache,idx);
printf("%-14.14s %-32s%6ld%8ld%6d %s\n", printf("%-14.14s %-32s%6ld%8ld%6d %s\n",
entry->s->db.str, entry->s->table_name.str, entry->s->version, entry->s->db.str, entry->s->table_name.str, entry->s->version,
entry->in_use ? entry->in_use->thread_id : 0L, entry->in_use ? entry->in_use->thread_id : 0L,
@ -113,7 +113,7 @@ void print_cached_tables(void)
if (count != unused) if (count != unused)
printf("Unused_links (%d) doesn't match open_cache: %d\n", count,unused); printf("Unused_links (%d) doesn't match open_cache: %d\n", count,unused);
printf("\nCurrent refresh version: %ld\n",refresh_version); printf("\nCurrent refresh version: %ld\n",refresh_version);
if (hash_check(&open_cache)) if (my_hash_check(&open_cache))
printf("Error: File hash table is corrupted\n"); printf("Error: File hash table is corrupted\n");
fflush(stdout); fflush(stdout);
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));

View File

@ -124,10 +124,10 @@ void udf_init()
init_sql_alloc(&mem, UDF_ALLOC_BLOCK_SIZE, 0); init_sql_alloc(&mem, UDF_ALLOC_BLOCK_SIZE, 0);
THD *new_thd = new THD; THD *new_thd = new THD;
if (!new_thd || if (!new_thd ||
hash_init(&udf_hash,system_charset_info,32,0,0,get_hash_key, NULL, 0)) my_hash_init(&udf_hash,system_charset_info,32,0,0,get_hash_key, NULL, 0))
{ {
sql_print_error("Can't allocate memory for udf structures"); sql_print_error("Can't allocate memory for udf structures");
hash_free(&udf_hash); my_hash_free(&udf_hash);
free_root(&mem,MYF(0)); free_root(&mem,MYF(0));
delete new_thd; delete new_thd;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -239,20 +239,20 @@ void udf_free()
DBUG_ENTER("udf_free"); DBUG_ENTER("udf_free");
for (uint idx=0 ; idx < udf_hash.records ; idx++) for (uint idx=0 ; idx < udf_hash.records ; idx++)
{ {
udf_func *udf=(udf_func*) hash_element(&udf_hash,idx); udf_func *udf=(udf_func*) my_hash_element(&udf_hash,idx);
if (udf->dlhandle) // Not closed before if (udf->dlhandle) // Not closed before
{ {
/* Mark all versions using the same handler as closed */ /* Mark all versions using the same handler as closed */
for (uint j=idx+1 ; j < udf_hash.records ; j++) for (uint j=idx+1 ; j < udf_hash.records ; j++)
{ {
udf_func *tmp=(udf_func*) hash_element(&udf_hash,j); udf_func *tmp=(udf_func*) my_hash_element(&udf_hash,j);
if (udf->dlhandle == tmp->dlhandle) if (udf->dlhandle == tmp->dlhandle)
tmp->dlhandle=0; // Already closed tmp->dlhandle=0; // Already closed
} }
dlclose(udf->dlhandle); dlclose(udf->dlhandle);
} }
} }
hash_free(&udf_hash); my_hash_free(&udf_hash);
free_root(&mem,MYF(0)); free_root(&mem,MYF(0));
if (initialized) if (initialized)
{ {
@ -268,7 +268,7 @@ static void del_udf(udf_func *udf)
DBUG_ENTER("del_udf"); DBUG_ENTER("del_udf");
if (!--udf->usage_count) if (!--udf->usage_count)
{ {
hash_delete(&udf_hash,(uchar*) udf); my_hash_delete(&udf_hash,(uchar*) udf);
using_udf_functions=udf_hash.records != 0; using_udf_functions=udf_hash.records != 0;
} }
else else
@ -282,7 +282,7 @@ static void del_udf(udf_func *udf)
uint name_length=udf->name.length; uint name_length=udf->name.length;
udf->name.str=(char*) "*"; udf->name.str=(char*) "*";
udf->name.length=1; udf->name.length=1;
hash_update(&udf_hash,(uchar*) udf,(uchar*) name,name_length); my_hash_update(&udf_hash,(uchar*) udf,(uchar*) name,name_length);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -302,7 +302,7 @@ void free_udf(udf_func *udf)
We come here when someone has deleted the udf function We come here when someone has deleted the udf function
while another thread still was using the udf while another thread still was using the udf
*/ */
hash_delete(&udf_hash,(uchar*) udf); my_hash_delete(&udf_hash,(uchar*) udf);
using_udf_functions=udf_hash.records != 0; using_udf_functions=udf_hash.records != 0;
if (!find_udf_dl(udf->dl)) if (!find_udf_dl(udf->dl))
dlclose(udf->dlhandle); dlclose(udf->dlhandle);
@ -328,7 +328,7 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
else else
rw_rdlock(&THR_LOCK_udf); /* Called during parsing */ rw_rdlock(&THR_LOCK_udf); /* Called during parsing */
if ((udf=(udf_func*) hash_search(&udf_hash,(uchar*) name, if ((udf=(udf_func*) my_hash_search(&udf_hash,(uchar*) name,
length ? length : (uint) strlen(name)))) length ? length : (uint) strlen(name))))
{ {
if (!udf->dlhandle) if (!udf->dlhandle)
@ -351,7 +351,7 @@ static void *find_udf_dl(const char *dl)
*/ */
for (uint idx=0 ; idx < udf_hash.records ; idx++) for (uint idx=0 ; idx < udf_hash.records ; idx++)
{ {
udf_func *udf=(udf_func*) hash_element(&udf_hash,idx); udf_func *udf=(udf_func*) my_hash_element(&udf_hash,idx);
if (!strcmp(dl, udf->dl) && udf->dlhandle != NULL) if (!strcmp(dl, udf->dl) && udf->dlhandle != NULL)
DBUG_RETURN(udf->dlhandle); DBUG_RETURN(udf->dlhandle);
} }
@ -441,7 +441,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
thd->clear_current_stmt_binlog_row_based(); thd->clear_current_stmt_binlog_row_based();
rw_wrlock(&THR_LOCK_udf); rw_wrlock(&THR_LOCK_udf);
if ((hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length))) if ((my_hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length)))
{ {
my_error(ER_UDF_EXISTS, MYF(0), udf->name.str); my_error(ER_UDF_EXISTS, MYF(0), udf->name.str);
goto err; goto err;
@ -544,7 +544,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
thd->clear_current_stmt_binlog_row_based(); thd->clear_current_stmt_binlog_row_based();
rw_wrlock(&THR_LOCK_udf); rw_wrlock(&THR_LOCK_udf);
if (!(udf=(udf_func*) hash_search(&udf_hash,(uchar*) udf_name->str, if (!(udf=(udf_func*) my_hash_search(&udf_hash,(uchar*) udf_name->str,
(uint) udf_name->length))) (uint) udf_name->length)))
{ {
my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str); my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str);

View File

@ -423,7 +423,7 @@ void free_table_share(TABLE_SHARE *share)
pthread_mutex_destroy(&share->mutex); pthread_mutex_destroy(&share->mutex);
pthread_cond_destroy(&share->cond); pthread_cond_destroy(&share->cond);
} }
hash_free(&share->name_hash); my_hash_free(&share->name_hash);
plugin_unlock(NULL, share->db_plugin); plugin_unlock(NULL, share->db_plugin);
share->db_plugin= NULL; share->db_plugin= NULL;
@ -1147,10 +1147,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
use_hash= share->fields >= MAX_FIELDS_BEFORE_HASH; use_hash= share->fields >= MAX_FIELDS_BEFORE_HASH;
if (use_hash) if (use_hash)
use_hash= !hash_init(&share->name_hash, use_hash= !my_hash_init(&share->name_hash,
system_charset_info, system_charset_info,
share->fields,0,0, share->fields,0,0,
(hash_get_key) get_field_name,0,0); (my_hash_get_key) get_field_name,0,0);
for (i=0 ; i < share->fields; i++, strpos+=field_pack_length, field_ptr++) for (i=0 ; i < share->fields; i++, strpos+=field_pack_length, field_ptr++)
{ {
@ -1589,7 +1589,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
delete handler_file; delete handler_file;
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (use_hash) if (use_hash)
(void) hash_check(&share->name_hash); (void) my_hash_check(&share->name_hash);
#endif #endif
DBUG_RETURN (0); DBUG_RETURN (0);
@ -1600,7 +1600,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
x_free((uchar*) disk_buff); x_free((uchar*) disk_buff);
delete crypted; delete crypted;
delete handler_file; delete handler_file;
hash_free(&share->name_hash); my_hash_free(&share->name_hash);
open_table_error(share, error, share->open_errno, errarg); open_table_error(share, error, share->open_errno, errarg);
DBUG_RETURN(error); DBUG_RETURN(error);

View File

@ -1581,17 +1581,17 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
lex_start(thd); lex_start(thd);
/* Init all memory structures that require explicit destruction */ /* Init all memory structures that require explicit destruction */
if (hash_init(&tz_names, &my_charset_latin1, 20, if (my_hash_init(&tz_names, &my_charset_latin1, 20,
0, 0, (hash_get_key) my_tz_names_get_key, 0, 0)) 0, 0, (my_hash_get_key) my_tz_names_get_key, 0, 0))
{ {
sql_print_error("Fatal error: OOM while initializing time zones"); sql_print_error("Fatal error: OOM while initializing time zones");
goto end; goto end;
} }
if (hash_init(&offset_tzs, &my_charset_latin1, 26, 0, 0, if (my_hash_init(&offset_tzs, &my_charset_latin1, 26, 0, 0,
(hash_get_key)my_offset_tzs_get_key, 0, 0)) (my_hash_get_key)my_offset_tzs_get_key, 0, 0))
{ {
sql_print_error("Fatal error: OOM while initializing time zones"); sql_print_error("Fatal error: OOM while initializing time zones");
hash_free(&tz_names); my_hash_free(&tz_names);
goto end; goto end;
} }
init_alloc_root(&tz_storage, 32 * 1024, 0); init_alloc_root(&tz_storage, 32 * 1024, 0);
@ -1774,8 +1774,8 @@ void my_tz_free()
{ {
tz_inited= 0; tz_inited= 0;
VOID(pthread_mutex_destroy(&tz_LOCK)); VOID(pthread_mutex_destroy(&tz_LOCK));
hash_free(&offset_tzs); my_hash_free(&offset_tzs);
hash_free(&tz_names); my_hash_free(&tz_names);
free_root(&tz_storage, MYF(0)); free_root(&tz_storage, MYF(0));
} }
} }
@ -2267,7 +2267,7 @@ my_tz_find(THD *thd, const String *name)
if (!str_to_offset(name->ptr(), name->length(), &offset)) if (!str_to_offset(name->ptr(), name->length(), &offset))
{ {
if (!(result_tz= (Time_zone_offset *)hash_search(&offset_tzs, if (!(result_tz= (Time_zone_offset *)my_hash_search(&offset_tzs,
(const uchar *)&offset, (const uchar *)&offset,
sizeof(long)))) sizeof(long))))
{ {
@ -2285,8 +2285,9 @@ my_tz_find(THD *thd, const String *name)
else else
{ {
result_tz= 0; result_tz= 0;
if ((tmp_tzname= (Tz_names_entry *)hash_search(&tz_names, if ((tmp_tzname= (Tz_names_entry *)my_hash_search(&tz_names,
(const uchar *)name->ptr(), (const uchar *)
name->ptr(),
name->length()))) name->length())))
result_tz= tmp_tzname->tz; result_tz= tmp_tzname->tz;
else if (time_zone_tables_exist) else if (time_zone_tables_exist)

View File

@ -172,8 +172,8 @@ int archive_db_init(void *p)
if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)) if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (hash_init(&archive_open_tables, table_alias_charset, 32, 0, 0, if (my_hash_init(&archive_open_tables, table_alias_charset, 32, 0, 0,
(hash_get_key) archive_get_key, 0, 0)) (my_hash_get_key) archive_get_key, 0, 0))
{ {
VOID(pthread_mutex_destroy(&archive_mutex)); VOID(pthread_mutex_destroy(&archive_mutex));
} }
@ -198,7 +198,7 @@ error:
int archive_db_done(void *p) int archive_db_done(void *p)
{ {
hash_free(&archive_open_tables); my_hash_free(&archive_open_tables);
VOID(pthread_mutex_destroy(&archive_mutex)); VOID(pthread_mutex_destroy(&archive_mutex));
return 0; return 0;
@ -316,7 +316,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
pthread_mutex_lock(&archive_mutex); pthread_mutex_lock(&archive_mutex);
length=(uint) strlen(table_name); length=(uint) strlen(table_name);
if (!(share=(ARCHIVE_SHARE*) hash_search(&archive_open_tables, if (!(share=(ARCHIVE_SHARE*) my_hash_search(&archive_open_tables,
(uchar*) table_name, (uchar*) table_name,
length))) length)))
{ {
@ -394,7 +394,7 @@ int ha_archive::free_share()
pthread_mutex_lock(&archive_mutex); pthread_mutex_lock(&archive_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
hash_delete(&archive_open_tables, (uchar*) share); my_hash_delete(&archive_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
VOID(pthread_mutex_destroy(&share->mutex)); VOID(pthread_mutex_destroy(&share->mutex));
/* /*

View File

@ -319,7 +319,8 @@ static st_blackhole_share *get_share(const char *table_name)
length= (uint) strlen(table_name); length= (uint) strlen(table_name);
pthread_mutex_lock(&blackhole_mutex); pthread_mutex_lock(&blackhole_mutex);
if (!(share= (st_blackhole_share*) hash_search(&blackhole_open_tables, if (!(share= (st_blackhole_share*)
my_hash_search(&blackhole_open_tables,
(uchar*) table_name, length))) (uchar*) table_name, length)))
{ {
if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) + if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) +
@ -350,7 +351,7 @@ static void free_share(st_blackhole_share *share)
{ {
pthread_mutex_lock(&blackhole_mutex); pthread_mutex_lock(&blackhole_mutex);
if (!--share->use_count) if (!--share->use_count)
hash_delete(&blackhole_open_tables, (uchar*) share); my_hash_delete(&blackhole_open_tables, (uchar*) share);
pthread_mutex_unlock(&blackhole_mutex); pthread_mutex_unlock(&blackhole_mutex);
} }
@ -377,16 +378,16 @@ static int blackhole_init(void *p)
blackhole_hton->flags= HTON_CAN_RECREATE; blackhole_hton->flags= HTON_CAN_RECREATE;
VOID(pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST));
(void) hash_init(&blackhole_open_tables, system_charset_info,32,0,0, (void) my_hash_init(&blackhole_open_tables, system_charset_info,32,0,0,
(hash_get_key) blackhole_get_key, (my_hash_get_key) blackhole_get_key,
(hash_free_key) blackhole_free_key, 0); (my_hash_free_key) blackhole_free_key, 0);
return 0; return 0;
} }
static int blackhole_fini(void *p) static int blackhole_fini(void *p)
{ {
hash_free(&blackhole_open_tables); my_hash_free(&blackhole_open_tables);
pthread_mutex_destroy(&blackhole_mutex); pthread_mutex_destroy(&blackhole_mutex);
return 0; return 0;

View File

@ -111,8 +111,8 @@ static int tina_init_func(void *p)
tina_hton= (handlerton *)p; tina_hton= (handlerton *)p;
VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&tina_open_tables,system_charset_info,32,0,0, (void) my_hash_init(&tina_open_tables,system_charset_info,32,0,0,
(hash_get_key) tina_get_key,0,0); (my_hash_get_key) tina_get_key,0,0);
tina_hton->state= SHOW_OPTION_YES; tina_hton->state= SHOW_OPTION_YES;
tina_hton->db_type= DB_TYPE_CSV_DB; tina_hton->db_type= DB_TYPE_CSV_DB;
tina_hton->create= tina_create_handler; tina_hton->create= tina_create_handler;
@ -123,7 +123,7 @@ static int tina_init_func(void *p)
static int tina_done_func(void *p) static int tina_done_func(void *p)
{ {
hash_free(&tina_open_tables); my_hash_free(&tina_open_tables);
pthread_mutex_destroy(&tina_mutex); pthread_mutex_destroy(&tina_mutex);
return 0; return 0;
@ -148,7 +148,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
If share is not present in the hash, create a new share and If share is not present in the hash, create a new share and
initialize its members. initialize its members.
*/ */
if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables, if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables,
(uchar*) table_name, (uchar*) table_name,
length))) length)))
{ {
@ -377,7 +377,7 @@ static int free_share(TINA_SHARE *share)
share->tina_write_opened= FALSE; share->tina_write_opened= FALSE;
} }
hash_delete(&tina_open_tables, (uchar*) share); my_hash_delete(&tina_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); pthread_mutex_destroy(&share->mutex);
my_free((uchar*) share, MYF(0)); my_free((uchar*) share, MYF(0));

View File

@ -133,8 +133,8 @@ static int example_init_func(void *p)
example_hton= (handlerton *)p; example_hton= (handlerton *)p;
VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&example_open_tables,system_charset_info,32,0,0, (void) my_hash_init(&example_open_tables,system_charset_info,32,0,0,
(hash_get_key) example_get_key,0,0); (my_hash_get_key) example_get_key,0,0);
example_hton->state= SHOW_OPTION_YES; example_hton->state= SHOW_OPTION_YES;
example_hton->create= example_create_handler; example_hton->create= example_create_handler;
@ -151,7 +151,7 @@ static int example_done_func(void *p)
if (example_open_tables.records) if (example_open_tables.records)
error= 1; error= 1;
hash_free(&example_open_tables); my_hash_free(&example_open_tables);
pthread_mutex_destroy(&example_mutex); pthread_mutex_destroy(&example_mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
@ -175,7 +175,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
pthread_mutex_lock(&example_mutex); pthread_mutex_lock(&example_mutex);
length=(uint) strlen(table_name); length=(uint) strlen(table_name);
if (!(share=(EXAMPLE_SHARE*) hash_search(&example_open_tables, if (!(share=(EXAMPLE_SHARE*) my_hash_search(&example_open_tables,
(uchar*) table_name, (uchar*) table_name,
length))) length)))
{ {
@ -222,7 +222,7 @@ static int free_share(EXAMPLE_SHARE *share)
pthread_mutex_lock(&example_mutex); pthread_mutex_lock(&example_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
hash_delete(&example_open_tables, (uchar*) share); my_hash_delete(&example_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex); pthread_mutex_destroy(&share->mutex);
my_free(share, MYF(0)); my_free(share, MYF(0));

View File

@ -459,8 +459,8 @@ int federated_db_init(void *p)
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST)) if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (!hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0, if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0,
(hash_get_key) federated_get_key, 0, 0)) (my_hash_get_key) federated_get_key, 0, 0))
{ {
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
@ -483,7 +483,7 @@ error:
int federated_done(void *p) int federated_done(void *p)
{ {
hash_free(&federated_open_tables); my_hash_free(&federated_open_tables);
VOID(pthread_mutex_destroy(&federated_mutex)); VOID(pthread_mutex_destroy(&federated_mutex));
return 0; return 0;
@ -1495,7 +1495,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
goto error; goto error;
/* TODO: change tmp_share.scheme to LEX_STRING object */ /* TODO: change tmp_share.scheme to LEX_STRING object */
if (!(share= (FEDERATED_SHARE *) hash_search(&federated_open_tables, if (!(share= (FEDERATED_SHARE *) my_hash_search(&federated_open_tables,
(uchar*) tmp_share.share_key, (uchar*) tmp_share.share_key,
tmp_share. tmp_share.
share_key_length))) share_key_length)))
@ -1560,7 +1560,7 @@ static int free_share(FEDERATED_SHARE *share)
pthread_mutex_lock(&federated_mutex); pthread_mutex_lock(&federated_mutex);
if (!--share->use_count) if (!--share->use_count)
{ {
hash_delete(&federated_open_tables, (uchar*) share); my_hash_delete(&federated_open_tables, (uchar*) share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
VOID(pthread_mutex_destroy(&share->mutex)); VOID(pthread_mutex_destroy(&share->mutex));
free_root(&mem_root, MYF(0)); free_root(&mem_root, MYF(0));