summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.c3
-rw-r--r--include/hash.h6
-rw-r--r--mysys/hash.c30
-rw-r--r--sql/ha_berkeley.cc2
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/hash_filo.h4
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/repl_failsafe.cc2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_acl.cc11
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_cache.cc4
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_parse.cc3
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_udf.cc3
-rw-r--r--sql/table.cc1
-rw-r--r--tools/mysqlmanager.c6
18 files changed, 54 insertions, 38 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index dd71c3255a0..473205e608f 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2325,7 +2325,8 @@ static void var_from_env(const char* name, const char* def_val)
static void init_var_hash()
{
VAR* v;
- if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
+ if (hash_init(&var_hash, system_charset_info,
+ 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed");
var_from_env("MASTER_MYPORT", "9306");
var_from_env("SLAVE_MYPORT", "9307");
diff --git a/include/hash.h b/include/hash.h
index 8ca8d9fde02..49a75d98dcb 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -40,10 +40,12 @@ typedef struct st_hash {
DYNAMIC_ARRAY array; /* Place for hash_keys */
hash_get_key get_key;
void (*free)(void *);
- uint (*calc_hashnr)(const byte *key,uint length);
+ uint (*calc_hashnr)(CHARSET_INFO *cs, const byte *key,uint length);
+ CHARSET_INFO *charset;
} HASH;
-my_bool hash_init(HASH *hash,uint default_array_elements, uint key_offset,
+my_bool hash_init(HASH *hash,CHARSET_INFO *charset,
+ uint default_array_elements, uint key_offset,
uint key_length, hash_get_key get_key,
void (*free_element)(void*), uint flags);
void hash_free(HASH *tree);
diff --git a/mysys/hash.c b/mysys/hash.c
index f1ce5052e4f..41ebe59c2de 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -31,12 +31,13 @@
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
-static uint calc_hashnr(const byte *key,uint length);
-static uint calc_hashnr_caseup(const byte *key,uint length);
+static uint calc_hashnr(CHARSET_INFO *cs,const byte *key,uint length);
+static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length);
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length);
-my_bool hash_init(HASH *hash,uint size,uint key_offset,uint key_length,
+my_bool hash_init(HASH *hash,CHARSET_INFO *charset,
+ uint size,uint key_offset,uint key_length,
hash_get_key get_key,
void (*free_element)(void*),uint flags)
{
@@ -56,6 +57,7 @@ my_bool hash_init(HASH *hash,uint size,uint key_offset,uint key_length,
hash->get_key=get_key;
hash->free=free_element;
hash->flags=flags;
+ hash->charset=charset;
if (flags & HASH_CASE_INSENSITIVE)
hash->calc_hashnr=calc_hashnr_caseup;
else
@@ -104,14 +106,15 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
{
uint length;
byte *key=hash_key(hash,pos->data,&length,0);
- return hash_mask((*hash->calc_hashnr)(key,length),buffmax,maxlength);
+ return hash_mask((*hash->calc_hashnr)(hash->charset,key,length),
+ buffmax,maxlength);
}
#ifndef NEW_HASH_FUNCTION
/* Calc hashvalue for a key */
-static uint calc_hashnr(const byte *key,uint length)
+static uint calc_hashnr(CHARSET_INFO *cs, const byte *key,uint length)
{
register uint nr=1, nr2=4;
while (length--)
@@ -124,14 +127,13 @@ static uint calc_hashnr(const byte *key,uint length)
/* Calc hashvalue for a key, case indepenently */
-static uint calc_hashnr_caseup(const byte *key,uint length)
+static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length)
{
register uint nr=1, nr2=4;
while (length--)
{
- /* BAR TODO: remove default_charset_info */
nr^= (((nr & 63)+nr2)*
- ((uint) (uchar) my_toupper(default_charset_info, *key++)))+ (nr << 8);
+ ((uint) (uchar) my_toupper(cs, *key++)))+ (nr << 8);
nr2+=3;
}
return((uint) nr);
@@ -152,7 +154,7 @@ static uint calc_hashnr_caseup(const byte *key,uint length)
* This works well on both numbers and strings.
*/
-uint calc_hashnr(const byte *key, uint len)
+uint calc_hashnr(CHARSET_INFO *cs, const byte *key, uint len)
{
const byte *end=key+len;
uint hash;
@@ -164,14 +166,14 @@ uint calc_hashnr(const byte *key, uint len)
return (hash);
}
-uint calc_hashnr_caseup(const byte *key, uint len)
+uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key, uint len)
{
const byte *end=key+len;
uint hash;
for (hash = 0; key < end; key++)
{
hash *= 16777619;
- hash ^= (uint) (uchar) toupper(*key);
+ hash ^= (uint) (uchar) my_toupper(cs,*key);
}
return (hash);
}
@@ -186,7 +188,7 @@ uint rec_hashnr(HASH *hash,const byte *record)
{
uint length;
byte *key=hash_key(hash,record,&length,0);
- return (*hash->calc_hashnr)(key,length);
+ return (*hash->calc_hashnr)(hash->charset,key,length);
}
@@ -202,7 +204,7 @@ gptr hash_search(HASH *hash,const byte *key,uint length)
flag=1;
if (hash->records)
{
- idx=hash_mask((*hash->calc_hashnr)(key,length ? length :
+ idx=hash_mask((*hash->calc_hashnr)(hash->charset,key,length ? length :
hash->key_length),
hash->blength,hash->records);
do
@@ -516,7 +518,7 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length)
/* Search after record with key */
- idx=hash_mask((*hash->calc_hashnr)(old_key,(old_key_length ?
+ idx=hash_mask((*hash->calc_hashnr)(hash->charset, old_key,(old_key_length ?
old_key_length :
hash->key_length)),
blength,records);
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 614d1b5abf5..58a090a8aed 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -168,7 +168,7 @@ bool berkeley_init(void)
db_env=0; /* purecov: inspected */
}
- (void) hash_init(&bdb_open_tables,32,0,0,
+ (void) hash_init(&bdb_open_tables,system_charset_info,32,0,0,
(hash_get_key) bdb_get_key,0,0);
pthread_mutex_init(&bdb_mutex,MY_MUTEX_INIT_FAST);
DBUG_RETURN(db_env == 0);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index d53b027a415..fd2dcf4dfb6 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -666,7 +666,7 @@ innobase_init(void)
DBUG_RETURN(1);
}
- (void) hash_init(&innobase_open_tables,32,0,0,
+ (void) hash_init(&innobase_open_tables,system_charset_info,32,0,0,
(hash_get_key) innobase_get_key,0,0);
pthread_mutex_init(&innobase_mutex,MY_MUTEX_INIT_FAST);
DBUG_RETURN(0);
diff --git a/sql/hash_filo.h b/sql/hash_filo.h
index b8d45f0d3be..4d746d9b9bd 100644
--- a/sql/hash_filo.h
+++ b/sql/hash_filo.h
@@ -75,8 +75,8 @@ public:
if (!locked)
(void) pthread_mutex_lock(&lock);
(void) hash_free(&cache);
- (void) hash_init(&cache,size,key_offset, key_length, get_key, free_element,
- 0);
+ (void) hash_init(&cache,system_charset_info,size,key_offset,
+ key_length, get_key, free_element,0);
if (!locked)
(void) pthread_mutex_unlock(&lock);
first_link=last_link=0;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 587388d6159..e25f4c6e94a 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1421,7 +1421,8 @@ char *ull_get_key(const ULL *ull,uint *length,
void item_user_lock_init(void)
{
pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
- hash_init(&hash_user_locks,16,0,0,(hash_get_key) ull_get_key,NULL,0);
+ hash_init(&hash_user_locks,system_charset_info,
+ 16,0,0,(hash_get_key) ull_get_key,NULL,0);
}
void item_user_lock_free(void)
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 257418d1682..3f16880c18e 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -184,7 +184,7 @@ static void slave_info_free(void *s)
void init_slave_list()
{
- hash_init(&slave_list, SLAVE_LIST_CHUNK, 0, 0,
+ hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
(hash_get_key) slave_list_key, slave_info_free, 0);
pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST);
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 9630cf6aa0e..52f04ef8675 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -470,7 +470,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
void init_table_rule_hash(HASH* h, bool* h_inited)
{
- hash_init(h, TABLE_RULE_HASH_SIZE,0,0,
+ hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0,
(hash_get_key) get_table_key,
(void (*)(void*)) free_table_ent, 0);
*h_inited = 1;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 198569cec3c..32630a9537e 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -847,7 +847,7 @@ static void init_check_host(void)
DBUG_ENTER("init_check_host");
VOID(init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
acl_users.elements,1));
- VOID(hash_init(&acl_check_hosts,acl_users.elements,0,0,
+ VOID(hash_init(&acl_check_hosts,system_charset_info,acl_users.elements,0,0,
(hash_get_key) check_get_key,0,HASH_CASE_INSENSITIVE));
if (!allow_all_hosts)
{
@@ -1424,7 +1424,8 @@ public:
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length);
strmov(strmov(strmov(hash_key,user)+1,db)+1,tname);
- (void) hash_init(&hash_columns,0,0,0, (hash_get_key) get_key_column,0,
+ (void) hash_init(&hash_columns,system_charset_info,
+ 0,0,0, (hash_get_key) get_key_column,0,
HASH_CASE_INSENSITIVE);
}
@@ -1456,7 +1457,8 @@ public:
privs = fix_rights_for_table(privs);
cols = fix_rights_for_column(cols);
- (void) hash_init(&hash_columns,0,0,0, (hash_get_key) get_key_column,0,
+ (void) hash_init(&hash_columns,system_charset_info,
+ 0,0,0, (hash_get_key) get_key_column,0,
HASH_CASE_INSENSITIVE);
if (cols)
{
@@ -2143,7 +2145,8 @@ int grant_init (void)
DBUG_ENTER("grant_init");
grant_option = FALSE;
- (void) hash_init(&hash_tables,0,0,0, (hash_get_key) get_grant_table,
+ (void) hash_init(&hash_tables,system_charset_info,
+ 0,0,0, (hash_get_key) get_grant_table,
(hash_free_key) free_grant_table,0);
init_sql_alloc(&memex,1024,0);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index e73a0c63fa6..d2d38d9a7c4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -50,7 +50,7 @@ static byte *cache_key(const byte *record,uint *length,
void table_cache_init(void)
{
- VOID(hash_init(&open_cache,
+ VOID(hash_init(&open_cache,system_charset_info,
table_cache_size+16,0,0,cache_key,
(void (*)(void*)) free_cache_entry,0));
mysql_rm_tmp_tables();
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 72ac20d8818..78d82f9b420 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1330,9 +1330,9 @@ ulong Query_cache::init_cache()
DUMP(this);
- VOID(hash_init(&queries,def_query_hash_size, 0, 0,
+ VOID(hash_init(&queries,system_charset_info,def_query_hash_size, 0, 0,
query_cache_query_get_key, 0, 0));
- VOID(hash_init(&tables,def_table_hash_size, 0, 0,
+ VOID(hash_init(&tables,system_charset_info,def_table_hash_size, 0, 0,
query_cache_table_get_key, 0, 0));
queries_in_cache = 0;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f6f66b0b7da..d0caa4e7b8c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -137,7 +137,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
/* Initialize sub structures */
bzero((char*) &mem_root,sizeof(mem_root));
user_connect=(UC *)0;
- hash_init(&user_vars, USER_VARS_HASH_SIZE, 0, 0,
+ hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key,
(void (*)(void*)) free_var,0);
#ifdef USING_TRANSACTIONS
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c47d6ddd4bb..7fd3db1fe21 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -269,7 +269,8 @@ static void free_user(struct user_conn *uc)
void init_max_user_conn(void)
{
- (void) hash_init(&hash_user_connections,max_connections,0,0,
+ (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
+ 0,0,
(hash_get_key) get_key_conn, (void (*)(void*)) free_user,
0);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 14feb12c769..1ea85984bcc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5874,8 +5874,10 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
(uint) (field_count*sizeof(*field_lengths)),
NullS))
DBUG_RETURN(1);
- if (hash_init(&hash, (uint) file->records, 0, key_length,
- (hash_get_key) 0, 0, 0))
+
+ // BAR TODO: this must be fixed to use charset from "table" argument
+ if (hash_init(&hash, default_charset_info, (uint) file->records, 0,
+ key_length,(hash_get_key) 0, 0, 0))
{
my_free((char*) key_buffer,MYF(0));
DBUG_RETURN(1);
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 9493f969802..f44fa3b7321 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -127,7 +127,8 @@ void udf_init()
init_sql_alloc(&mem, 1024,0);
THD *new_thd = new THD;
if (!new_thd ||
- hash_init(&udf_hash,32,0,0,get_hash_key, NULL, HASH_CASE_INSENSITIVE))
+ hash_init(&udf_hash,system_charset_info,
+ 32,0,0,get_hash_key, NULL, HASH_CASE_INSENSITIVE))
{
sql_print_error("Can't allocate memory for udf structures");
hash_free(&udf_hash);
diff --git a/sql/table.cc b/sql/table.cc
index 2fa5d41f1ba..eeda172c65d 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -319,6 +319,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
use_hash= outparam->fields >= MAX_FIELDS_BEFORE_HASH;
if (use_hash)
use_hash= !hash_init(&outparam->name_hash,
+ system_charset_info,
outparam->fields,0,0,
(hash_get_key) get_field_name,0,
HASH_CASE_INSENSITIVE);
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index 9dbf433d8a1..536b76a1351 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -1655,7 +1655,8 @@ static void init_user_hash()
FILE* f;
char buf[80];
int line_num=1;
- if (hash_init(&user_hash,1024,0,0,get_user_key,manager_user_free,MYF(0)))
+ if (hash_init(&user_hash,system_charset_info,1024,0,0,
+ get_user_key,manager_user_free,MYF(0)))
die("Could not initialize user hash");
if (!(f=fopen(manager_pw_file,"r")))
die("Could not open password file '%s'", manager_pw_file);
@@ -1693,7 +1694,8 @@ static void init_pid_file()
static void init_globals()
{
pthread_attr_t thr_attr;
- if (hash_init(&exec_hash,1024,0,0,get_exec_key,manager_exec_free,MYF(0)))
+ if (hash_init(&exec_hash,system_charset_info,1024,0,0,
+ get_exec_key,manager_exec_free,MYF(0)))
die("Exec hash initialization failed");
if (!one_thread)
{