summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/query_cache.result11
-rw-r--r--mysql-test/t/query_cache.test14
-rw-r--r--sql/sql_table.cc2
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index a37313a150a..9d63050fc4e 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -542,3 +542,14 @@ select * from mysql.db;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
+create table t1(id int auto_increment primary key);
+insert into t1 values (NULL), (NULL), (NULL);
+select * from t1 where id=2;
+id
+2
+alter table t1 rename to t2;
+select * from t1 where id=2;
+Table 'test.t1' doesn't exist
+drop table t2;
+select * from t1 where id=2;
+Table 'test.t1' doesn't exist
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 6c3f3d6ac52..f77ea3c3b2a 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -383,3 +383,17 @@ disable_result_log;
select * from mysql.db;
enable_result_log;
show status like "Qcache_queries_in_cache";
+
+
+#
+# simple rename test
+#
+create table t1(id int auto_increment primary key);
+insert into t1 values (NULL), (NULL), (NULL);
+select * from t1 where id=2;
+alter table t1 rename to t2;
+-- error 1146
+select * from t1 where id=2;
+drop table t2;
+-- error 1146
+select * from t1 where id=2;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index c04b4871b4d..a763d6b6b91 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1432,6 +1432,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
send_ok(&thd->net);
}
+ table_list->table=0; // For query cache
+ query_cache_invalidate3(thd, table_list, 0);
DBUG_RETURN(error);
}