summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-03-07 18:15:19 -0800
committerunknown <jimw@mysql.com>2005-03-07 18:15:19 -0800
commit8e24e6079f0a0e60dee696a9164bf4d8356c9630 (patch)
tree0dcef42e1652a287a31afeb7c904b298a5e66382
parenta93b0b59bd1d9e92819ba5eee4a66ee2d138605f (diff)
downloadmariadb-git-8e24e6079f0a0e60dee696a9164bf4d8356c9630.tar.gz
Flush entries from the query cache for tables used in
administrative statements that may alter the table, such as REPAIR TABLE. (Bug #8480) mysql-test/r/query_cache.result: Add new results mysql-test/t/query_cache.test: Add regression test sql/sql_table.cc: Make sure entries are flushed from the query cache for any administrative command run on a table that acquires a write lock on it (and thus might change it), like REPAIR TABLE.
-rw-r--r--mysql-test/r/query_cache.result20
-rw-r--r--mysql-test/t/query_cache.test12
-rw-r--r--sql/sql_table.cc4
3 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 85fe77b1f10..af86f67f8c3 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -717,4 +717,24 @@ select * from t1;
a
drop table t1;
drop table t1;
+set global query_cache_size=1024*1024;
+flush query cache;
+create table t1 ( a int );
+insert into t1 values (1);
+select a from t1;
+a
+1
+select a from t1;
+a
+1
+show status like 'qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 1
+repair table t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+show status like 'qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 0
+drop table t1;
set GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 61fbadde1e1..35eefececf3 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -533,4 +533,16 @@ select * from t1;
drop table t1;
drop table t1;
+# Bug #8480: REPAIR TABLE needs to flush the table from the query cache
+set global query_cache_size=1024*1024;
+flush query cache;
+create table t1 ( a int );
+insert into t1 values (1);
+select a from t1;
+select a from t1;
+show status like 'qcache_queries_in_cache';
+repair table t1;
+show status like 'qcache_queries_in_cache';
+drop table t1;
+
set GLOBAL query_cache_size=0;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 33bdd992efb..20d9b1dcb7d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1318,7 +1318,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->exit_cond(old_message);
if (thd->killed)
goto err;
- open_for_modify=0;
+ /* Flush entries in the query cache involving this table. */
+ query_cache_invalidate3(thd, table->table, 0);
+ open_for_modify= 0;
}
int result_code = (table->table->file->*operator_func)(thd, check_opt);