diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index b847e8c36e42623ecf46e16c6b6e7991348d13cd..41dc3c419f0015f03bef49f2cd0c4ec9eadeec8b 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -525,13 +525,6 @@ else
   fi
 fi
 
-MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
-MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
-MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
-MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
-export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
-
-
 if [ -z "$MASTER_MYSQLD" ]
 then
 MASTER_MYSQLD=$MYSQLD
@@ -564,6 +557,12 @@ then
 fi
 
 
+MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
+MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
+MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
+MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
+export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
+
 MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
  --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
  --tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT $MYSQL_TEST_SSL_OPTS"
diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result
index f0cb4cc3ccffedf917945057bab7d622f2840bca..a30ec0f160cb356f7ee9addb1c9094819b0bdb86 100644
--- a/mysql-test/r/lowercase_table.result
+++ b/mysql-test/r/lowercase_table.result
@@ -1,4 +1,5 @@
 drop table if exists t1,t2,t3,t4;
+drop table if exists t0,t5,t6,t7,t8,t9;
 drop database if exists mysqltest;
 create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
 create table t4 (id int primary key, Word varchar(40) not null);
diff --git a/mysql-test/r/rename.result b/mysql-test/r/rename.result
index 9bcf1bc7f975d03747d252937407f921b446d093..ec36f01541207055688b0e10a3283a2e784352a8 100644
--- a/mysql-test/r/rename.result
+++ b/mysql-test/r/rename.result
@@ -1,4 +1,5 @@
 drop table if exists t0,t1,t2,t3,t4;
+drop table if exists t0,t5,t6,t7,t8,t9;
 create table t0 SELECT 1,"table 1";
 create table t2 SELECT 2,"table 2";
 create table t3 SELECT 3,"table 3";
diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test
index b36d63bfd72949b422d26c51f67d7ddcfceabe5f..a9c0c976afc1f12931ac9701ad1d6c6a3288b351 100644
--- a/mysql-test/t/lowercase_table.test
+++ b/mysql-test/t/lowercase_table.test
@@ -4,6 +4,8 @@
 
 --disable_warnings
 drop table if exists t1,t2,t3,t4;
+# Clear up from other tests (to ensure that SHOW TABLES below is right)
+drop table if exists t0,t5,t6,t7,t8,t9;
 drop database if exists mysqltest;
 --enable_warnings
 
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index bea0641ad2392b5dbd843af67ff64205ff717f46..e6dc6ce9456e9d09dcf64e51e8fa3820e11b84ca 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -4,6 +4,8 @@
 
 --disable_warnings
 drop table if exists t0,t1,t2,t3,t4;
+# Clear up from other tests (to ensure that SHOW TABLES below is right)
+drop table if exists t0,t5,t6,t7,t8,t9;
 --enable_warnings
 
 create table t0 SELECT 1,"table 1";
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 4ddb648399af95cf586c5924dc7c39586b399d01..f473d242b077854bc1f40df378315d5cce2c5a99 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2752,7 +2752,6 @@ longlong Item_cond_xor::val_int()
 
 Item *Item_func_not::neg_transformer(THD *thd)	/* NOT(x)  ->  x */
 {
-  // We should apply negation elimination to the argument of the NOT function
   return args[0];
 }
 
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 36b1b89f6bfe0024d9c25e588449eb07702e3fda..b103ee29095d3283251de63f1954fc69f97eb471 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -891,7 +891,8 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
   option|= MY_REPLACE_DIR;			// Force use of db directory
 #endif
 
-  strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "");
+  strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "",
+           NullS);
   (void) fn_format(path, exchange->file_name, path, "", option);
   if (!access(path, F_OK))
   {
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 1f4905837f03bdac5e8e5709bf5f45ab55995221..1ad9a6aa952a473f9873f63d7bb3d6dd0c7130f3 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -183,7 +183,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
 	strlen(ex->file_name)+strlen(mysql_real_data_home)+strlen(tdb)+3 <
 	FN_REFLEN)
     {
-      (void) sprintf(name,"%s/%s/%s",mysql_data_home,tdb,ex->file_name);
+      (void) sprintf(name,"%s%s/%s",mysql_real_data_home,tdb,ex->file_name);
       unpack_filename(name,name);		/* Convert to system format */
     }
     else
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 408f34083464424404af6ee08806153fdd11a49a..58e3bc1d9ac895b1a43b0863dfd3c57edf4b5462 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1579,7 +1579,7 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
 					reg_ext))
       DBUG_RETURN(-1); // protect buffer overflow
 
-    my_snprintf(dst_path, sizeof(dst_path), "%s/%s/%s",
+    my_snprintf(dst_path, sizeof(dst_path), "%s%s/%s",
 		mysql_real_data_home, db, table_name);
 
     if (lock_and_wait_for_table_name(thd,table))