Commit ed0bc17b authored by Monty's avatar Monty

Removed usage of my_hash_search() with uninitialized HASH.

- Not documented on intened usage
- Extra checking takes time for all HASH usage
parent e80ad58d
......@@ -246,13 +246,13 @@ uchar* my_hash_first(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
uchar *res;
if (my_hash_inited(hash))
res= my_hash_first_from_hash_value(hash,
hash->hash_function(hash->charset, key,
length ? length : hash->key_length),
key, length, current_record);
else
res= 0;
DBUG_ASSERT(my_hash_inited(hash));
res= my_hash_first_from_hash_value(hash,
hash->hash_function(hash->charset, key,
length ? length :
hash->key_length),
key, length, current_record);
return res;
}
......
......@@ -4302,7 +4302,8 @@ longlong Item_func_release_lock::val_int()
User_level_lock *ull;
if (!(ull=
if (!my_hash_inited(&thd->ull_hash) ||
!(ull=
(User_level_lock*) my_hash_search(&thd->ull_hash,
ull_key.ptr(), ull_key.length())))
{
......
......@@ -4365,6 +4365,8 @@ table_hash_search(const char *host, const char *ip, const char *db,
static GRANT_COLUMN *
column_hash_search(GRANT_TABLE *t, const char *cname, uint length)
{
if (!my_hash_inited(&t->hash_columns))
return (GRANT_COLUMN*) 0;
return (GRANT_COLUMN*) my_hash_search(&t->hash_columns,
(uchar*) cname, length);
}
......
......@@ -458,9 +458,10 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
DBUG_RETURN(TRUE);
}
if ((handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
(uchar*) tables->alias,
strlen(tables->alias) + 1)))
if ((my_hash_inited(&thd->handler_tables_hash)) &&
(handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
(uchar*) tables->alias,
strlen(tables->alias) + 1)))
{
mysql_ha_close_table(handler);
my_hash_delete(&thd->handler_tables_hash, (uchar*) handler);
......@@ -497,8 +498,10 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
SQL_HANDLER *mysql_ha_find_handler(THD *thd, const char *name)
{
SQL_HANDLER *handler;
if ((handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
(uchar*) name, strlen(name) + 1)))
if ((my_hash_inited(&thd->handler_tables_hash)) &&
(handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
(uchar*) name,
strlen(name) + 1)))
{
DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' table: %p",
handler->db.str,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment