summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_rename.cc9
-rw-r--r--sql/sql_table.cc4
2 files changed, 4 insertions, 9 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 2c17898f07c..6496e1895fb 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -238,7 +238,6 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
{
int rc= 1;
handlerton *hton;
- bool new_exists, old_exists;
const char *new_alias, *old_alias;
DBUG_ENTER("do_rename");
@@ -254,17 +253,13 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
}
DBUG_ASSERT(new_alias);
- new_exists= ha_table_exists(thd, new_db, new_alias);
-
- if (new_exists)
+ if (ha_table_exists(thd, new_db, new_alias))
{
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
DBUG_RETURN(1); // This can't be skipped
}
- old_exists= ha_table_exists(thd, ren_table->db, old_alias, &hton);
-
- if (old_exists)
+ if (ha_table_exists(thd, ren_table->db, old_alias, &hton) && hton)
{
DBUG_ASSERT(!thd->locked_tables_mode);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 6ee0e9bc871..c31a6fd6474 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5149,6 +5149,7 @@ mysql_rename_table(handlerton *base, const char *old_db,
ulonglong save_bits= thd->variables.option_bits;
int length;
DBUG_ENTER("mysql_rename_table");
+ DBUG_ASSERT(base);
DBUG_PRINT("enter", ("old: '%s'.'%s' new: '%s'.'%s'",
old_db, old_name, new_db, new_name));
@@ -5156,8 +5157,7 @@ mysql_rename_table(handlerton *base, const char *old_db,
if (flags & NO_FK_CHECKS)
thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS;
- file= (base == NULL ? 0 :
- get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
+ file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base);
build_table_filename(from, sizeof(from) - 1, old_db, old_name, "",
flags & FN_FROM_IS_TMP);