summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 897aa37ba11..6db97ab3c41 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -287,14 +287,13 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db,
int dblen;
TABLE **ptr;
- if (!db || ! *db)
- db= thd->db ? thd->db : "";
- dblen=strlen(db)+1;
+ DBUG_ASSERT(db);
+ dblen= *db ? strlen(db)+1 : 0;
ptr= &(thd->handler_tables);
for (TABLE *table= *ptr; table ; table= *ptr)
{
- if (!memcmp(table->table_cache_key, db, dblen) &&
+ if ((!dblen || !memcmp(table->table_cache_key, db, dblen)) &&
!my_strcasecmp(system_charset_info,
(is_alias ? table->table_name : table->real_name),
table_name))